Commit 30aaaa4a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

LUA: store p_intf->p_sys separately

parent c1d3b260
......@@ -171,6 +171,7 @@ int Open_LuaIntf( vlc_object_t *p_this )
}
vlclua_set_this( L, p_intf );
vlclua_set_intf( L, p_sys );
luaL_openlibs( L );
......
......@@ -47,24 +47,44 @@
#include "../vlc.h"
#include "../libs.h"
#undef vlclua_set_this
/*****************************************************************************
* Internal lua<->vlc utils
*****************************************************************************/
void vlclua_set_this( lua_State *L, vlc_object_t *p_this )
static void vlclua_set_object( lua_State *L, void *id, void *value )
{
lua_pushlightuserdata( L, vlclua_set_this );
lua_pushlightuserdata( L, p_this );
lua_pushlightuserdata( L, id );
lua_pushlightuserdata( L, value );
lua_rawset( L, LUA_REGISTRYINDEX );
}
vlc_object_t * vlclua_get_this( lua_State *L )
static void *vlclua_get_object( lua_State *L, void *id )
{
lua_pushlightuserdata( L, vlclua_set_this );
lua_pushlightuserdata( L, id );
lua_rawget( L, LUA_REGISTRYINDEX );
vlc_object_t *p_this = (vlc_object_t*)lua_topointer( L, -1 );
const void *p = lua_topointer( L, -1 );
lua_pop( L, 1 );
return p_this;
return (void *)p;
}
#undef vlclua_set_this
void vlclua_set_this( lua_State *L, vlc_object_t *p_this )
{
vlclua_set_object( L, vlclua_set_this, p_this );
}
vlc_object_t * vlclua_get_this( lua_State *L )
{
return vlclua_get_object( L, vlclua_set_this );
}
void vlclua_set_intf( lua_State *L, intf_sys_t *p_intf )
{
vlclua_set_object( L, vlclua_set_intf, p_intf );
}
static intf_sys_t * vlclua_get_intf( lua_State *L )
{
return vlclua_get_object( L, vlclua_set_intf );
}
/*****************************************************************************
......
......@@ -95,6 +95,9 @@ void vlclua_set_this( lua_State *, vlc_object_t * );
#define vlclua_set_this(a, b) vlclua_set_this(a, VLC_OBJECT(b))
vlc_object_t * vlclua_get_this( lua_State * );
struct intf_sys_t;
void vlclua_set_intf( lua_State *, struct intf_sys_t * );
/*****************************************************************************
* Lua function bridge
*****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment