[vlc-commits] commit: lua_variables: allow the creation of a void variable. ( =?UTF-8?Q?R=C3=A9mi=20Duraffort=20?=)

git at videolan.org git at videolan.org
Fri Dec 3 11:03:23 CET 2010


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Dec  3 11:00:02 2010 +0100| [efa1666ad381c86feef6cf0d6b471d6c4fb6e0bb] | committer: Rémi Duraffort 

lua_variables: allow the creation of a void variable.

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

 modules/misc/lua/libs/variables.c |    8 ++++++++
 share/lua/README.txt              |    3 ++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/modules/misc/lua/libs/variables.c b/modules/misc/lua/libs/variables.c
index 15c393e..4784758 100644
--- a/modules/misc/lua/libs/variables.c
+++ b/modules/misc/lua/libs/variables.c
@@ -179,6 +179,9 @@ static int vlclua_var_create( lua_State *L )
         case LUA_TSTRING:
             i_type = VLC_VAR_STRING;
             break;
+        case LUA_TNIL:
+            i_type = VLC_VAR_VOID;
+            break;
         default:
             return 0;
     }
@@ -186,6 +189,11 @@ static int vlclua_var_create( lua_State *L )
     int i_ret = var_Create( *pp_obj, psz_var, i_type );
     if( i_ret != VLC_SUCCESS )
         return vlclua_push_ret( L, i_ret );
+
+    // Special case for void variables
+    if( i_type == VLC_VAR_VOID )
+        return 0;
+
     vlc_value_t val;
     vlclua_tovalue( L, i_type, &val );
     return vlclua_push_ret( L, var_Set( *pp_obj, psz_var, val ) );
diff --git a/share/lua/README.txt b/share/lua/README.txt
index d14efa0..0d72e87 100644
--- a/share/lua/README.txt
+++ b/share/lua/README.txt
@@ -388,7 +388,8 @@ var.get_list( object, name ): Get the object's variable "name"'s value list.
   1st return value is the value list, 2nd return value is the text list.
 var.set( object, name, value ): Set the object's variable "name" to "value".
 var.create( object, name, value ): Create and set the object's variable "name"
-  to "value". Created vars can be of type float, string or bool.
+  to "value". Created vars can be of type float, string, bool or void.
+  For a void variable the value has to be 'nil'.
 
 var.add_callback( object, name, function, data ): Add a callback to the
   object's "name" variable. Callback functions take 4 arguments: the



More information about the vlc-commits mailing list