return 1;
}
+static int vlclua_mwait( lua_State *L )
+{
+ double f = luaL_checknumber( L, 1 );
+ mwait( (int64_t)f );
+ return 0;
+}
+
static int vlclua_intf_should_die( lua_State *L )
{
intf_thread_t *p_intf = (intf_thread_t*)vlclua_get_this( L );
{ "datadir_list", vlclua_datadir_list },
{ "mdate", vlclua_mdate },
+ { "mwait", vlclua_mwait },
{ "lock_and_wait", vlclua_lock_and_wait },
{ "signal", vlclua_signal },
return i_top;
}
+static int vlclua_encode_uri_component( lua_State *L )
+{
+ int i_top = lua_gettop( L );
+ int i;
+ for( i = 1; i <= i_top; i++ )
+ {
+ const char *psz_cstring = luaL_checkstring( L, 1 );
+ char *psz_string = encode_URI_component( psz_cstring );
+ lua_remove( L,1 );
+ lua_pushstring( L, psz_string );
+ free( psz_string );
+ }
+ return i_top;
+}
+
static int vlclua_resolve_xml_special_chars( lua_State *L )
{
int i_top = lua_gettop( L );
*****************************************************************************/
static const luaL_Reg vlclua_strings_reg[] = {
{ "decode_uri", vlclua_decode_uri },
+ { "encode_uri_component", vlclua_encode_uri_component },
{ "resolve_xml_special_chars", vlclua_resolve_xml_special_chars },
{ "convert_xml_special_chars", vlclua_convert_xml_special_chars },
{ NULL, NULL }
vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
const char *psz_var = luaL_checkstring( L, 2 );
i_type = var_Type( *pp_obj, psz_var );
- var_Get( *pp_obj, psz_var, &val );
+ if( var_Get( *pp_obj, psz_var, &val ) != VLC_SUCCESS )
+ return 0;
lua_pop( L, 2 );
return vlclua_pushvalue( L, i_type, val );
}
return vlclua_push_ret( L, i_ret );
}
+static int vlclua_var_create( lua_State *L )
+{
+ vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
+ const char *psz_var = luaL_checkstring( L, 2 );
+ int i_type;
+ switch( lua_type( L, 3 ) )
+ {
+ case LUA_TNUMBER:
+ i_type = VLC_VAR_FLOAT;
+ break;
+ case LUA_TBOOLEAN:
+ i_type = VLC_VAR_BOOL;
+ break;
+ case LUA_TSTRING:
+ i_type = VLC_VAR_STRING;
+ break;
+ default:
+ return 0;
+ }
+
+ int i_ret = var_Create( *pp_obj, psz_var, i_type );
+ if( i_ret != VLC_SUCCESS )
+ return vlclua_push_ret( L, i_ret );
+ vlc_value_t val;
+ vlclua_tovalue( L, i_type, &val );
+ return vlclua_push_ret( L, var_Set( *pp_obj, psz_var, val ) );
+}
+
static int vlclua_var_get_list( lua_State *L )
{
vlc_value_t val;
psz_cmd = luaL_checkstring( L, 1 );
val_arg.psz_string = strdup( luaL_optstring( L, 2, "" ) );
lua_pop( L, 2 );
- if( !var_Type( p_this->p_libvlc, psz_cmd ) & VLC_VAR_ISCOMMAND )
+ int i_type = var_Type( p_this->p_libvlc, psz_cmd );
+ if( ! i_type & VLC_VAR_ISCOMMAND )
{
free( val_arg.psz_string );
return luaL_error( L, "libvlc's \"%s\" is not a command",
{ "get", vlclua_var_get },
{ "get_list", vlclua_var_get_list },
{ "set", vlclua_var_set },
+ { "create", vlclua_var_create },
{ "add_callback", vlclua_add_callback },
{ "del_callback", vlclua_del_callback },
{ "command", vlclua_command },
luaopen_msg( L );
luaopen_stream( L );
luaopen_strings( L );
+ luaopen_variables( L );
+ luaopen_object( L );
+ luaopen_misc( L );
lua_pushlightuserdata( L, p_this );
lua_setfield( L, -2, "private" );
misc.datadir_list( name ): FIXME: write description ... or ditch function if it isn't usefull anymore, we have datadir and userdatadir :)
misc.mdate(): Get the current date (in milliseconds).
+misc.mwait(): Wait for the given date (in milliseconds).
misc.lock_and_wait(): Lock our object thread and wait for a wake up signal.
misc.signal(): Wake up our object thread.
-------
strings.decode_uri( [uri1, [uri2, [...]]] ): Decode a list of URIs. This
function returns as many variables as it had arguments.
+strings.encode_uri_component( [uri1, [uri2, [...]]] ): Encode a list of URI
+ components. This function returns as many variables as it had arguments.
strings.resolve_xml_special_chars( [str1, [str2, [...]]] ): Resolve XML
special characters in a list of strings. This function returns as many
variables as it had arguments.
var.set( object, name, value ): Set the object's variable "name" to "value".
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.create( object, name, value ): Create and set the object's variable "name"
+ to "value". Created vars can be of type float, string or bool.
var.add_callback( object, name, function, data ): Add a callback to the
object's "name" variable. Callback functions take 4 arguments: the
VLC Lua meta modules should define one of the following functions:
* fetch_art(): returns a path to an artwork for the given item
-Available VLC specific Lua modules: msg, stream and strings. See lua/README.txt
+Available VLC specific Lua modules: msg, stream, strings, variables,
+objects and misc. See lua/README.txt