[vlc-commits] LUA: limited and DEPRECATED comeback of vlc.misc.functions

Jean-Baptiste Kempf git at videolan.org
Fri Mar 16 16:30:07 CET 2012


vlc/vlc-2.0 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Mar 16 15:55:58 2012 +0100| [c8bc962e100356ca47ba2267e11768dc358eb43d] | committer: Jean-Baptiste Kempf

LUA: limited and DEPRECATED comeback of vlc.misc.functions

Only version, copyright, mdate (NO mwait) and *dir are present.
ALL of them are outputting warnings.

None of this is in master. This is for smooth transition ONLY.

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

 modules/lua/extension.c |    1 +
 modules/lua/libs.h      |    1 +
 modules/lua/libs/misc.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/modules/lua/extension.c b/modules/lua/extension.c
index 49fc511..2c4edc1 100644
--- a/modules/lua/extension.c
+++ b/modules/lua/extension.c
@@ -832,6 +832,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
             luaopen_osd( L );
             luaopen_playlist( L );
             luaopen_sd( L );
+            luaopen_misc_extensions( L );
             luaopen_stream( L );
             luaopen_strings( L );
             luaopen_variables( L );
diff --git a/modules/lua/libs.h b/modules/lua/libs.h
index d67a672..b5f31b1 100644
--- a/modules/lua/libs.h
+++ b/modules/lua/libs.h
@@ -31,6 +31,7 @@ void luaopen_httpd( lua_State * );
 void luaopen_input( lua_State * );
 void luaopen_msg( lua_State * );
 void luaopen_misc( lua_State * );
+void luaopen_misc_extensions( lua_State * );
 void luaopen_net( lua_State * );
 void luaopen_object( lua_State * );
 void luaopen_osd( lua_State * );
diff --git a/modules/lua/libs/misc.c b/modules/lua/libs/misc.c
index 6be9fe5..2d0fdd2 100644
--- a/modules/lua/libs/misc.c
+++ b/modules/lua/libs/misc.c
@@ -107,6 +107,13 @@ static int vlclua_version( lua_State *L )
     return 1;
 }
 
+static int vlclua_version_ext( lua_State *L )
+{
+    msg_Warn( vlclua_get_this( L ),
+            "This function misc.version() is DEPRECATED, please update your script" );
+    lua_pushstring( L, VERSION_MESSAGE );
+    return 1;
+}
 /*****************************************************************************
  * Get the VLC copyright
  *****************************************************************************/
@@ -115,6 +122,14 @@ static int vlclua_copyright( lua_State *L )
     lua_pushliteral( L, COPYRIGHT_MESSAGE );
     return 1;
 }
+static int vlclua_copyright_ext( lua_State *L )
+{
+    msg_Warn( vlclua_get_this( L ),
+            "This function misc.copyright() is DEPRECATED, please update your script" );
+
+    lua_pushliteral( L, COPYRIGHT_MESSAGE );
+    return 1;
+}
 
 /*****************************************************************************
  * Get the VLC license msg/disclaimer
@@ -228,6 +243,16 @@ static int vlclua_mdate( lua_State *L )
     return 1;
 }
 
+static int vlclua_mdate_ext( lua_State *L )
+{
+    msg_Warn( vlclua_get_this( L ),
+            "This function misc.mdate() is DEPRECATED, please update your script" );
+
+    lua_pushnumber( L, mdate() );
+    return 1;
+}
+
+
 static int vlclua_mwait( lua_State *L )
 {
     double f = luaL_checknumber( L, 1 );
@@ -355,6 +380,28 @@ static int vlclua_timer_create( lua_State *L )
 /*****************************************************************************
  *
  *****************************************************************************/
+static const luaL_Reg vlclua_misc_ext_reg[] = {
+    { "version", vlclua_version_ext },
+    { "copyright", vlclua_copyright_ext },
+
+    { "datadir", vlclua_datadir },
+    { "userdatadir", vlclua_userdatadir },
+    { "homedir", vlclua_homedir },
+    { "configdir", vlclua_configdir },
+    { "cachedir", vlclua_cachedir },
+
+    { "mdate", vlclua_mdate_ext },
+
+    { NULL, NULL }
+};
+
+void luaopen_misc_extensions( lua_State *L )
+{
+    lua_newtable( L );
+    luaL_register( L, NULL, vlclua_misc_ext_reg );
+    lua_setfield( L, -2, "misc" );
+}
+
 static const luaL_Reg vlclua_misc_reg[] = {
     { "version", vlclua_version },
     { "copyright", vlclua_copyright },



More information about the vlc-commits mailing list