changeset 1:e12fbdb2eac2

modified readLuaScript.c requireLib.lua
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Fri, 01 Feb 2013 16:45:49 +0900
parents 73146cb10aa5
children 24fc70a8df95
files c/readLuaScript.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/c/readLuaScript.c	Fri Feb 01 03:07:15 2013 +0900
+++ b/c/readLuaScript.c	Fri Feb 01 16:45:49 2013 +0900
@@ -49,6 +49,7 @@
 
 int funcC(lua_State *L) 
 {
+	printf("call funcC\n");
 	return 0;
 }
 
@@ -77,15 +78,20 @@
 		return -1;
 	}
 	printStack(L);
-
 	/* get return value */
 	int add_res = (int)lua_tonumber(L, 1);
 	printf("add(2,3) = %d\n",add_res);
-
 	/* remove stack data */
 	int num = lua_gettop(L);
 	lua_pop(L, num);
+	printStack(L);
+	lua_getglobal(L,"callCFunction");
+	if (lua_pcall(L, 0, 0, 0)) {
+		printf("%s\n",lua_tostring(L, lua_gettop(L)));
+		lua_close(L);
+		return -1;
+	}
+	lua_pop(L, num);
 	lua_close(L);
-
 	return 0;
 }