[vlc-commits] commit: lua: implement var_ToggleBool and var_CountChoices. ( Rémi Duraffort )

git at videolan.org git at videolan.org
Tue Nov 2 17:44:59 CET 2010


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue Nov  2 17:30:21 2010 +0100| [89e6bf1e9ef34ffbe3ca5964b4d83b0fb1281124] | committer: Rémi Duraffort 

lua: implement var_ToggleBool and var_CountChoices.

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

 modules/misc/lua/libs/variables.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/modules/misc/lua/libs/variables.c b/modules/misc/lua/libs/variables.c
index b2bfb07..9f47568 100644
--- a/modules/misc/lua/libs/variables.c
+++ b/modules/misc/lua/libs/variables.c
@@ -561,6 +561,26 @@ static int vlclua_dec_integer( lua_State *L )
     return 1;
 }
 
+static int vlclua_countchoices( lua_State *L )
+{
+    vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
+    const char *psz_var = luaL_checkstring( L, 2 );
+    int i_count = var_CountChoices( *pp_obj, psz_var );
+
+    lua_pushinteger( L, i_count );
+    return 1;
+}
+
+static int vlclua_togglebool( lua_State *L )
+{
+    vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
+    const char *psz_var = luaL_checkstring( L, 2 );
+    bool b_val = var_ToggleBool( *pp_obj, psz_var );
+
+    lua_pushboolean( L, b_val );
+    return 1;
+}
+
 /*****************************************************************************
  *
  *****************************************************************************/
@@ -576,6 +596,8 @@ static const luaL_Reg vlclua_var_reg[] = {
     { "libvlc_command", vlclua_libvlc_command },
     { "inc_integer", vlclua_inc_integer },
     { "dec_integer", vlclua_dec_integer },
+    { "count_choices", vlclua_countchoices },
+    { "toggle_bool", vlclua_togglebool },
     { NULL, NULL }
 };
 



More information about the vlc-commits mailing list