[vlc-commits] lua: separate generic and interface-specific net functions

Rémi Denis-Courmont git at videolan.org
Mon Oct 28 18:11:47 CET 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Oct 28 19:03:04 2013 +0200| [11ffab8a5938a74646053149b104e70cdbfe42a9] | committer: Rémi Denis-Courmont

lua: separate generic and interface-specific net functions

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=11ffab8a5938a74646053149b104e70cdbfe42a9
---

 modules/lua/extension.c |    2 +-
 modules/lua/intf.c      |    2 +-
 modules/lua/libs.h      |    3 ++-
 modules/lua/libs/net.c  |   24 ++++++++++++++++++++----
 4 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/modules/lua/extension.c b/modules/lua/extension.c
index 3bf5a17..d6015ba 100644
--- a/modules/lua/extension.c
+++ b/modules/lua/extension.c
@@ -821,7 +821,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
             luaopen_dialog( L, p_ext );
             luaopen_input( L );
             luaopen_msg( L );
-            luaopen_net( L );
+            luaopen_net_generic( L );
             luaopen_object( L );
             luaopen_osd( L );
             luaopen_playlist( L );
diff --git a/modules/lua/intf.c b/modules/lua/intf.c
index a865972..fa086d8 100644
--- a/modules/lua/intf.c
+++ b/modules/lua/intf.c
@@ -255,7 +255,7 @@ static int Start_LuaIntf( vlc_object_t *p_this, const char *name )
     luaopen_input( L );
     luaopen_msg( L );
     luaopen_misc( L );
-    luaopen_net( L );
+    luaopen_net_intf( L );
     luaopen_object( L );
     luaopen_osd( L );
     luaopen_playlist( L );
diff --git a/modules/lua/libs.h b/modules/lua/libs.h
index a86a7a0..7e62f18 100644
--- a/modules/lua/libs.h
+++ b/modules/lua/libs.h
@@ -30,7 +30,8 @@ void luaopen_httpd( lua_State * );
 void luaopen_input( lua_State * );
 void luaopen_msg( lua_State * );
 void luaopen_misc( lua_State * );
-void luaopen_net( lua_State * );
+void luaopen_net_generic( lua_State * );
+void luaopen_net_intf( lua_State * );
 void luaopen_object( lua_State * );
 void luaopen_osd( lua_State * );
 void luaopen_playlist( lua_State * );
diff --git a/modules/lua/libs/net.c b/modules/lua/libs/net.c
index acdaeae..b74174e 100644
--- a/modules/lua/libs/net.c
+++ b/modules/lua/libs/net.c
@@ -491,8 +491,7 @@ static int vlclua_opendir( lua_State *L )
 /*****************************************************************************
  *
  *****************************************************************************/
-static const luaL_Reg vlclua_net_reg[] = {
-    { "url_parse", vlclua_url_parse },
+static const luaL_Reg vlclua_net_intf_reg[] = {
     { "listen_tcp", vlclua_net_listen_tcp },
     { "connect_tcp", vlclua_net_connect_tcp },
     { "close", vlclua_net_close },
@@ -503,15 +502,18 @@ static const luaL_Reg vlclua_net_reg[] = {
     { "read", vlclua_fd_read },
     { "write", vlclua_fd_write },
 #endif
+    /* The following functions do not depend on intf_thread_t and do not really
+     * belong in net.* but are left here for backward compatibility: */
+    { "url_parse", vlclua_url_parse },
     { "stat", vlclua_stat }, /* Not really "net" */
     { "opendir", vlclua_opendir }, /* Not really "net" */
     { NULL, NULL }
 };
 
-void luaopen_net( lua_State *L )
+void luaopen_net_intf( lua_State *L )
 {
     lua_newtable( L );
-    luaL_register( L, NULL, vlclua_net_reg );
+    luaL_register( L, NULL, vlclua_net_intf_reg );
 #define ADD_CONSTANT( name, value )    \
     lua_pushinteger( L, value ); \
     lua_setfield( L, -2, name );
@@ -523,3 +525,17 @@ void luaopen_net( lua_State *L )
     ADD_CONSTANT( "POLLNVAL", POLLNVAL )
     lua_setfield( L, -2, "net" );
 }
+
+static const luaL_Reg vlclua_net_generic_reg[] = {
+    { "url_parse", vlclua_url_parse },
+    { "stat", vlclua_stat }, /* Not really "net" */
+    { "opendir", vlclua_opendir }, /* Not really "net" */
+    { NULL, NULL }
+};
+
+void luaopen_net_generic( lua_State *L )
+{
+    lua_newtable( L );
+    luaL_register( L, NULL, vlclua_net_generic_reg );
+    lua_setfield( L, -2, "net" );
+}



More information about the vlc-commits mailing list