Beispiel #1
0
static int Ltimer_new(lua_State *L) {
    zn_State *S = (zn_State*)lbind_check(L, 1, &lbT_State);
    lzn_Timer *obj;
    luaL_checktype(L, 2, LUA_TFUNCTION);
    obj = (lzn_Timer*)lbind_new(L, sizeof(lzn_Timer), &lbT_Timer);
    obj->timer = zn_newtimer(S, lzn_ontimer, obj);
    obj->L = L;
    obj->ontimer_ref = LUA_NOREF;
    obj->ref = LUA_NOREF;
    if (obj->timer != NULL) {
        lzn_ref(L, 2, &obj->ontimer_ref);
        return 1;
    }
    return 0;
}
Beispiel #2
0
static struct vars *
newvarsobject(lua_State *L) {
	struct vars ** box = (struct vars **)lua_newuserdata(L, sizeof(*box));
	*box = NULL;
	struct vars * v = lbind_new();
	if (v == NULL) {
		return NULL;
	}
	*box = NULL;
	if (luaL_newmetatable(L, "luabindvars")) {
		lua_pushcfunction(L, ldelvars);
		lua_setfield(L, -2, "__gc");
	}
	lua_setmetatable(L, -2);

	*box = v;
	return v;
}