summaryrefslogtreecommitdiff
path: root/src/01-coroutine/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/01-coroutine/main.cpp')
-rw-r--r--src/01-coroutine/main.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/01-coroutine/main.cpp b/src/01-coroutine/main.cpp
index 8187f6b..20bae2f 100644
--- a/src/01-coroutine/main.cpp
+++ b/src/01-coroutine/main.cpp
@@ -34,7 +34,24 @@ static int l_GetChar(lua_State* L)
return 1;
}
+static int __gc(lua_State* L)
+{
+ return 0;
+}
+
+static int l_createObj(lua_State* L)
+{
+ int* u = (int*)lua_newuserdata(L, sizeof(int));
+ lua_newtable(L);
+ lua_pushstring(L, "__gc");
+ lua_pushcfunction(L, __gc);
+ lua_rawset(L, -3);
+ lua_setmetatable(L, -2);
+ return 1;
+}
+
luaL_reg fns[] = {
+ { "createObj", l_createObj },
{"GetTime", l_GetTime } ,
{"Sleep", l_Sleep } ,
{"Kbhit", l_Kbhit },