Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
2c244563
Commit
2c244563
authored
Feb 26, 2010
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not store p_this in a table value visible from lua code.
parent
5a60c559
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
19 deletions
+21
-19
modules/misc/lua/demux.c
modules/misc/lua/demux.c
+1
-2
modules/misc/lua/extension.c
modules/misc/lua/extension.c
+2
-3
modules/misc/lua/intf.c
modules/misc/lua/intf.c
+2
-4
modules/misc/lua/libs/misc.c
modules/misc/lua/libs/misc.c
+11
-5
modules/misc/lua/meta.c
modules/misc/lua/meta.c
+2
-3
modules/misc/lua/services_discovery.c
modules/misc/lua/services_discovery.c
+1
-2
modules/misc/lua/vlc.h
modules/misc/lua/vlc.h
+2
-0
No files found.
modules/misc/lua/demux.c
View file @
2c244563
...
@@ -135,14 +135,13 @@ static int probe_luascript( vlc_object_t *p_this, const char * psz_filename,
...
@@ -135,14 +135,13 @@ static int probe_luascript( vlc_object_t *p_this, const char * psz_filename,
/* Load Lua libraries */
/* Load Lua libraries */
luaL_openlibs
(
L
);
/* FIXME: Don't open all the libs? */
luaL_openlibs
(
L
);
/* FIXME: Don't open all the libs? */
vlclua_set_this
(
L
,
p_demux
);
luaL_register
(
L
,
"vlc"
,
p_reg
);
luaL_register
(
L
,
"vlc"
,
p_reg
);
luaopen_msg
(
L
);
luaopen_msg
(
L
);
luaopen_strings
(
L
);
luaopen_strings
(
L
);
luaopen_stream
(
L
);
luaopen_stream
(
L
);
luaopen_xml
(
L
);
luaopen_xml
(
L
);
luaopen_md5
(
L
);
luaopen_md5
(
L
);
lua_pushlightuserdata
(
L
,
p_demux
);
lua_setfield
(
L
,
-
2
,
"private"
);
lua_pushstring
(
L
,
p_demux
->
psz_path
);
lua_pushstring
(
L
,
p_demux
->
psz_path
);
lua_setfield
(
L
,
-
2
,
"path"
);
lua_setfield
(
L
,
-
2
,
"path"
);
lua_pushstring
(
L
,
p_demux
->
psz_access
);
lua_pushstring
(
L
,
p_demux
->
psz_access
);
...
...
modules/misc/lua/extension.c
View file @
2c244563
...
@@ -719,13 +719,12 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
...
@@ -719,13 +719,12 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
msg_Err
(
p_mgr
,
"Could not create new Lua State"
);
msg_Err
(
p_mgr
,
"Could not create new Lua State"
);
return
NULL
;
return
NULL
;
}
}
vlclua_set_this
(
L
,
p_mgr
);
luaL_openlibs
(
L
);
luaL_openlibs
(
L
);
luaL_register
(
L
,
"vlc"
,
p_reg
);
luaL_register
(
L
,
"vlc"
,
p_reg
);
luaopen_msg
(
L
);
luaopen_msg
(
L
);
lua_pushlightuserdata
(
L
,
p_mgr
);
lua_setfield
(
L
,
-
2
,
"private"
);
lua_pushlightuserdata
(
L
,
p_ext
);
lua_pushlightuserdata
(
L
,
p_ext
);
lua_setfield
(
L
,
-
2
,
"extension"
);
lua_setfield
(
L
,
-
2
,
"extension"
);
...
...
modules/misc/lua/intf.c
View file @
2c244563
...
@@ -168,15 +168,13 @@ int Open_LuaIntf( vlc_object_t *p_this )
...
@@ -168,15 +168,13 @@ int Open_LuaIntf( vlc_object_t *p_this )
goto
error
;
goto
error
;
}
}
vlclua_set_this
(
L
,
p_intf
);
luaL_openlibs
(
L
);
luaL_openlibs
(
L
);
/* register our functions */
/* register our functions */
luaL_register
(
L
,
"vlc"
,
p_reg
);
luaL_register
(
L
,
"vlc"
,
p_reg
);
/* store a pointer to p_intf (FIXME: user could overwrite this) */
lua_pushlightuserdata
(
L
,
p_intf
);
lua_setfield
(
L
,
-
2
,
"private"
);
/* register submodules */
/* register submodules */
luaopen_acl
(
L
);
luaopen_acl
(
L
);
luaopen_config
(
L
);
luaopen_config
(
L
);
...
...
modules/misc/lua/libs/misc.c
View file @
2c244563
...
@@ -50,13 +50,19 @@
...
@@ -50,13 +50,19 @@
/*****************************************************************************
/*****************************************************************************
* Internal lua<->vlc utils
* Internal lua<->vlc utils
*****************************************************************************/
*****************************************************************************/
void
__vlclua_set_this
(
lua_State
*
L
,
vlc_object_t
*
p_this
)
{
lua_pushlightuserdata
(
L
,
__vlclua_set_this
);
lua_pushlightuserdata
(
L
,
p_this
);
lua_rawset
(
L
,
LUA_REGISTRYINDEX
);
}
vlc_object_t
*
vlclua_get_this
(
lua_State
*
L
)
vlc_object_t
*
vlclua_get_this
(
lua_State
*
L
)
{
{
vlc_object_t
*
p_this
;
lua_pushlightuserdata
(
L
,
__vlclua_set_this
);
lua_getglobal
(
L
,
"vlc"
);
lua_rawget
(
L
,
LUA_REGISTRYINDEX
);
lua_getfield
(
L
,
-
1
,
"private"
);
vlc_object_t
*
p_this
=
(
vlc_object_t
*
)
lua_topointer
(
L
,
-
1
);
p_this
=
(
vlc_object_t
*
)
lua_topointer
(
L
,
lua_gettop
(
L
)
);
lua_pop
(
L
,
1
);
lua_pop
(
L
,
2
);
return
p_this
;
return
p_this
;
}
}
...
...
modules/misc/lua/meta.c
View file @
2c244563
...
@@ -60,6 +60,8 @@ static lua_State * init( vlc_object_t *p_this, input_item_t * p_item, const char
...
@@ -60,6 +60,8 @@ static lua_State * init( vlc_object_t *p_this, input_item_t * p_item, const char
return
NULL
;
return
NULL
;
}
}
vlclua_set_this
(
L
,
p_this
);
/* Load Lua libraries */
/* Load Lua libraries */
luaL_openlibs
(
L
);
/* XXX: Don't open all the libs? */
luaL_openlibs
(
L
);
/* XXX: Don't open all the libs? */
...
@@ -75,9 +77,6 @@ static lua_State * init( vlc_object_t *p_this, input_item_t * p_item, const char
...
@@ -75,9 +77,6 @@ static lua_State * init( vlc_object_t *p_this, input_item_t * p_item, const char
luaopen_md5
(
L
);
luaopen_md5
(
L
);
luaopen_input_item
(
L
,
p_item
);
luaopen_input_item
(
L
,
p_item
);
lua_pushlightuserdata
(
L
,
p_this
);
lua_setfield
(
L
,
-
2
,
"private"
);
if
(
vlclua_add_modules_path
(
p_this
,
L
,
psz_filename
)
)
if
(
vlclua_add_modules_path
(
p_this
,
L
,
psz_filename
)
)
{
{
msg_Warn
(
p_this
,
"Error while setting the module search path for %s"
,
msg_Warn
(
p_this
,
"Error while setting the module search path for %s"
,
...
...
modules/misc/lua/services_discovery.c
View file @
2c244563
...
@@ -94,10 +94,9 @@ int Open_LuaSD( vlc_object_t *p_this )
...
@@ -94,10 +94,9 @@ int Open_LuaSD( vlc_object_t *p_this )
msg_Err
(
p_sd
,
"Could not create new Lua State"
);
msg_Err
(
p_sd
,
"Could not create new Lua State"
);
goto
error
;
goto
error
;
}
}
vlclua_set_this
(
L
,
p_sd
);
luaL_openlibs
(
L
);
luaL_openlibs
(
L
);
luaL_register
(
L
,
"vlc"
,
p_reg
);
luaL_register
(
L
,
"vlc"
,
p_reg
);
lua_pushlightuserdata
(
L
,
p_sd
);
lua_setfield
(
L
,
-
2
,
"private"
);
luaopen_input
(
L
);
luaopen_input
(
L
);
luaopen_msg
(
L
);
luaopen_msg
(
L
);
luaopen_misc
(
L
);
luaopen_misc
(
L
);
...
...
modules/misc/lua/vlc.h
View file @
2c244563
...
@@ -91,6 +91,8 @@ static inline const char *luaL_nilorcheckstring( lua_State *L, int narg )
...
@@ -91,6 +91,8 @@ static inline const char *luaL_nilorcheckstring( lua_State *L, int narg )
return
luaL_checkstring
(
L
,
narg
);
return
luaL_checkstring
(
L
,
narg
);
}
}
#define vlclua_set_this(a, b) __vlclua_set_this(a, VLC_OBJECT(b))
void
__vlclua_set_this
(
lua_State
*
,
vlc_object_t
*
);
vlc_object_t
*
vlclua_get_this
(
lua_State
*
);
vlc_object_t
*
vlclua_get_this
(
lua_State
*
);
/*****************************************************************************
/*****************************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment