static int rpm_register(lua_State *L) { if (!lua_isstring(L, 1)) { (void) luaL_argerror(L, 1, "hook name expected"); } else if (!lua_isfunction(L, 2)) { (void) luaL_argerror(L, 2, "function expected"); } else { rpmluaHookData hookdata = lua_newuserdata(L, sizeof(struct rpmluaHookData_s)); lua_pushvalue(L, -1); hookdata->dataRef = luaL_ref(L, LUA_REGISTRYINDEX); lua_pushvalue(L, 2); hookdata->funcRef = luaL_ref(L, LUA_REGISTRYINDEX); hookdata->L = L; rpmhookRegister(lua_tostring(L, 1), rpmluaHookWrapper, hookdata); return 1; } return 0; }
static int rpm_register(lua_State *L) /*@globals internalState @*/ /*@modifies L, internalState @*/ { if (!lua_isstring(L, 1)) { (void) luaL_argerror(L, 1, "hook name expected"); } else if (!lua_isfunction(L, 2)) { (void) luaL_argerror(L, 2, "function expected"); } else { rpmluaHookData hookdata = (rpmluaHookData) lua_newuserdata(L, sizeof(struct rpmluaHookData_s)); lua_pushvalue(L, -1); hookdata->dataRef = luaL_ref(L, LUA_REGISTRYINDEX); lua_pushvalue(L, 2); hookdata->funcRef = luaL_ref(L, LUA_REGISTRYINDEX); /*@-temptrans@*/ hookdata->L = L; /*@=temptrans@*/ rpmhookRegister(lua_tostring(L, 1), rpmluaHookWrapper, hookdata); return 1; } return 0; }