mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-02-04 09:40:27 +01:00
wplua: use the registry to store vtables & closures
This commit is contained in:
parent
70931969b4
commit
da375a7408
3 changed files with 10 additions and 5 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue