Skip to content
Snippets Groups Projects
Commit da375a74 authored by George Kiagiadakis's avatar George Kiagiadakis
Browse files

wplua: use the registry to store vtables & closures

parent 70931969
No related branches found
No related tags found
No related merge requests found
......@@ -117,7 +117,8 @@ wplua_function_to_closure (lua_State *L, int idx)
WpLuaClosure *wlc = (WpLuaClosure *) c;
GPtrArray *closures;
lua_getglobal (L, "__wplua_closures");
lua_pushliteral (L, "wplua_closures");
lua_gettable (L, LUA_REGISTRYINDEX);
closures = wplua_toboxed (L, -1);
lua_pop (L, 1);
......@@ -149,6 +150,7 @@ _wplua_init_closure (lua_State *L)
{
GPtrArray *a = g_ptr_array_new_with_free_func (
(GDestroyNotify) _wplua_closure_destroy);
lua_pushliteral (L, "wplua_closures");
wplua_pushboxed (L, G_TYPE_PTR_ARRAY, a);
lua_setglobal (L, "__wplua_closures");
lua_settable (L, LUA_REGISTRYINDEX);
}
......@@ -100,7 +100,8 @@ _wplua_gobject___index (lua_State *L)
lua_CFunction func = NULL;
GHashTable *vtables;
lua_getglobal (L, "__wplua_vtables");
lua_pushliteral (L, "wplua_vtables");
lua_gettable (L, LUA_REGISTRYINDEX);
vtables = wplua_toboxed (L, -1);
lua_pop (L, 1);
......
......@@ -62,8 +62,9 @@ wplua_new (void)
{
GHashTable *t = g_hash_table_new (g_direct_hash, g_direct_equal);
lua_pushliteral (L, "wplua_vtables");
wplua_pushboxed (L, G_TYPE_HASH_TABLE, t);
lua_setglobal (L, "__wplua_vtables");
lua_settable (L, LUA_REGISTRYINDEX);
}
return L;
......@@ -98,7 +99,8 @@ wplua_register_type_methods (lua_State * L, GType type,
if (methods) {
GHashTable *vtables;
lua_getglobal (L, "__wplua_vtables");
lua_pushliteral (L, "wplua_vtables");
lua_gettable (L, LUA_REGISTRYINDEX);
vtables = wplua_toboxed (L, -1);
lua_pop (L, 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment