Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
8f5a86b3
Commit
8f5a86b3
authored
Dec 02, 2010
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua_variables: add the possibility to attach a callback to a void variable.
parent
df4237b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
modules/misc/lua/libs/variables.c
modules/misc/lua/libs/variables.c
+10
-7
modules/misc/lua/libs/variables.h
modules/misc/lua/libs/variables.h
+0
-2
No files found.
modules/misc/lua/libs/variables.c
View file @
8f5a86b3
...
...
@@ -46,12 +46,15 @@
/*****************************************************************************
* Variables handling
*****************************************************************************/
int
vlclua_pushvalue
(
lua_State
*
L
,
int
i_type
,
vlc_value_t
val
)
static
int
vlclua_pushvalue
(
lua_State
*
L
,
int
i_type
,
vlc_value_t
val
,
bool
b_error_void
)
{
switch
(
i_type
&
VLC_VAR_CLASS
)
{
case
VLC_VAR_VOID
:
vlclua_error
(
L
);
if
(
b_error_void
)
vlclua_error
(
L
);
else
lua_pushnil
(
L
);
break
;
case
VLC_VAR_BOOL
:
lua_pushboolean
(
L
,
val
.
b_bool
);
...
...
@@ -90,7 +93,7 @@ static int vlclua_pushlist( lua_State *L, vlc_list_t *p_list )
{
lua_pushinteger
(
L
,
i
+
1
);
if
(
!
vlclua_pushvalue
(
L
,
p_list
->
pi_types
[
i
],
p_list
->
p_values
[
i
]
)
)
p_list
->
p_values
[
i
]
,
true
)
)
lua_pushnil
(
L
);
lua_settable
(
L
,
-
3
);
}
...
...
@@ -143,7 +146,7 @@ static int vlclua_var_get( lua_State *L )
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_pushvalue
(
L
,
i_type
,
val
,
true
);
}
static
int
vlclua_var_set
(
lua_State
*
L
)
...
...
@@ -304,9 +307,9 @@ static int vlclua_callback( vlc_object_t *p_this, char const *psz_var,
/* callbacks[index] callback */
lua_pushstring
(
L
,
psz_var
);
/* callbacks[index] callback var */
vlclua_pushvalue
(
L
,
p_callback
->
i_type
,
oldval
);
vlclua_pushvalue
(
L
,
p_callback
->
i_type
,
oldval
,
false
);
/* callbacks[index] callback var oldval */
vlclua_pushvalue
(
L
,
p_callback
->
i_type
,
newval
);
vlclua_pushvalue
(
L
,
p_callback
->
i_type
,
newval
,
false
);
/* callbacks[index] callback var oldval newval */
lua_getfield
(
L
,
-
5
,
"data"
);
/* callbacks[index] callback var oldval newval data */
...
...
@@ -348,6 +351,7 @@ static int vlclua_add_callback( lua_State *L )
/* Check variable type, in order to avoid PANIC */
switch
(
i_type
&
VLC_VAR_CLASS
)
{
case
VLC_VAR_VOID
:
case
VLC_VAR_BOOL
:
case
VLC_VAR_INTEGER
:
case
VLC_VAR_STRING
:
...
...
@@ -355,7 +359,6 @@ static int vlclua_add_callback( lua_State *L )
case
VLC_VAR_TIME
:
break
;
case
VLC_VAR_ADDRESS
:
case
VLC_VAR_VOID
:
case
VLC_VAR_MUTEX
:
default:
return
vlclua_error
(
L
);
...
...
modules/misc/lua/libs/variables.h
View file @
8f5a86b3
...
...
@@ -25,8 +25,6 @@
#ifndef VLC_LUA_VARIABLES_H
#define VLC_LUA_VARIABLES_H
int
vlclua_pushvalue
(
lua_State
*
L
,
int
i_type
,
vlc_value_t
val
);
/* internal use only */
#define vlclua_var_toggle_or_set(a,b,c) \
__vlclua_var_toggle_or_set(a,VLC_OBJECT(b),c)
int
__vlclua_var_toggle_or_set
(
lua_State
*
,
vlc_object_t
*
,
const
char
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment