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
bddd76b0
Commit
bddd76b0
authored
Nov 04, 2007
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some more simplification of the luaplaylist/luameta code.
Fix a few FIXMEs.
parent
1b653546
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
71 deletions
+56
-71
modules/misc/lua/playlist.c
modules/misc/lua/playlist.c
+6
-16
modules/misc/lua/vlc.c
modules/misc/lua/vlc.c
+50
-55
No files found.
modules/misc/lua/playlist.c
View file @
bddd76b0
...
...
@@ -60,14 +60,9 @@ struct demux_sys_t
static
int
vlclua_demux_peek
(
lua_State
*
L
)
{
demux_t
*
p_demux
=
(
demux_t
*
)
vlclua_get_this
(
L
);
int
i
=
lua_gettop
(
L
);
int
n
;
int
n
=
luaL_checkint
(
L
,
1
);
const
uint8_t
*
p_peek
;
int
i_peek
;
if
(
!
i
)
return
0
;
n
=
lua_tonumber
(
L
,
1
);
lua_pop
(
L
,
i
);
i_peek
=
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
n
);
int
i_peek
=
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
n
);
lua_pushlstring
(
L
,
(
const
char
*
)
p_peek
,
i_peek
);
return
1
;
}
...
...
@@ -75,14 +70,9 @@ static int vlclua_demux_peek( lua_State *L )
static
int
vlclua_demux_read
(
lua_State
*
L
)
{
demux_t
*
p_demux
=
(
demux_t
*
)
vlclua_get_this
(
L
);
int
i
=
lua_gettop
(
L
);
int
n
;
byte_t
*
p_read
;
int
i_read
;
if
(
!
i
)
return
0
;
n
=
lua_tonumber
(
L
,
1
);
lua_pop
(
L
,
i
);
i_read
=
stream_Read
(
p_demux
->
s
,
&
p_read
,
n
);
int
n
=
luaL_checkint
(
L
,
1
);
int
i_read
=
stream_Read
(
p_demux
->
s
,
&
p_read
,
n
);
lua_pushlstring
(
L
,
(
const
char
*
)
p_read
,
i_read
);
return
1
;
}
...
...
@@ -153,7 +143,7 @@ static int probe_luascript( vlc_object_t *p_this, const char * psz_filename,
lua_getglobal
(
L
,
"probe"
);
if
(
!
lua_isfunction
(
L
,
lua_gettop
(
L
)
)
)
if
(
!
lua_isfunction
(
L
,
-
1
)
)
{
msg_Warn
(
p_demux
,
"Error while runing script %s, "
"function probe() not found"
,
psz_filename
);
...
...
@@ -259,7 +249,7 @@ static int Demux( demux_t *p_demux )
lua_getglobal
(
L
,
"parse"
);
if
(
!
lua_isfunction
(
L
,
lua_gettop
(
L
)
)
)
if
(
!
lua_isfunction
(
L
,
-
1
)
)
{
msg_Warn
(
p_demux
,
"Error while runing script %s, "
"function parse() not found"
,
psz_filename
);
...
...
modules/misc/lua/vlc.c
View file @
bddd76b0
...
...
@@ -136,7 +136,7 @@ int vlclua_quit( lua_State *L )
int
vlclua_volume_set
(
lua_State
*
L
)
{
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
int
i_volume
=
luaL_checkint
(
L
,
-
1
);
int
i_volume
=
luaL_checkint
(
L
,
1
);
/* Do we need to check that i_volume is in the AOUT_VOLUME_MIN->MAX range?*/
return
vlclua_push_ret
(
L
,
aout_VolumeSet
(
p_this
,
i_volume
)
);
}
...
...
@@ -184,7 +184,6 @@ int vlclua_stream_new( lua_State *L )
p_stream
=
stream_UrlNew
(
p_this
,
psz_url
);
if
(
!
p_stream
)
return
luaL_error
(
L
,
"Error when opening url: `%s'"
,
psz_url
);
lua_pop
(
L
,
1
);
lua_pushlightuserdata
(
L
,
p_stream
);
return
1
;
}
...
...
@@ -195,10 +194,8 @@ int vlclua_stream_read( lua_State *L )
int
n
;
byte_t
*
p_read
;
int
i_read
;
if
(
lua_gettop
(
L
)
!=
2
)
return
vlclua_error
(
L
);
p_stream
=
(
stream_t
*
)
luaL_checklightuserdata
(
L
,
-
2
);
n
=
luaL_checkint
(
L
,
-
1
);
lua_pop
(
L
,
2
);
p_stream
=
(
stream_t
*
)
luaL_checklightuserdata
(
L
,
1
);
n
=
luaL_checkint
(
L
,
2
);
p_read
=
malloc
(
n
);
if
(
!
p_read
)
return
vlclua_error
(
L
);
i_read
=
stream_Read
(
p_stream
,
p_read
,
n
);
...
...
@@ -210,9 +207,7 @@ int vlclua_stream_read( lua_State *L )
int
vlclua_stream_readline
(
lua_State
*
L
)
{
stream_t
*
p_stream
;
if
(
lua_gettop
(
L
)
!=
1
)
return
vlclua_error
(
L
);
p_stream
=
(
stream_t
*
)
luaL_checklightuserdata
(
L
,
-
1
);
lua_pop
(
L
,
1
);
p_stream
=
(
stream_t
*
)
luaL_checklightuserdata
(
L
,
1
);
char
*
psz_line
=
stream_ReadLine
(
p_stream
);
if
(
psz_line
)
{
...
...
@@ -220,94 +215,94 @@ int vlclua_stream_readline( lua_State *L )
free
(
psz_line
);
}
else
{
lua_pushnil
(
L
);
}
return
1
;
}
int
vlclua_stream_delete
(
lua_State
*
L
)
{
stream_t
*
p_stream
;
if
(
lua_gettop
(
L
)
!=
1
)
return
vlclua_error
(
L
);
p_stream
=
(
stream_t
*
)
luaL_checklightuserdata
(
L
,
-
1
);
lua_pop
(
L
,
1
);
p_stream
=
(
stream_t
*
)
luaL_checklightuserdata
(
L
,
1
);
stream_Delete
(
p_stream
);
return
1
;
return
0
;
}
/*****************************************************************************
* String transformations
*****************************************************************************/
/* TODO: make it work for any number of arguments */
int
vlclua_decode_uri
(
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
!=
1
)
return
vlclua_error
(
L
);
const
char
*
psz_cstring
=
luaL_checkstring
(
L
,
1
);
if
(
!
psz_cstring
)
return
vlclua_error
(
L
);
char
*
psz_string
=
strdup
(
psz_cstring
);
lua_pop
(
L
,
1
);
decode_URI
(
psz_string
);
lua_pushstring
(
L
,
psz_string
);
free
(
psz_string
);
return
1
;
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
=
strdup
(
psz_cstring
);
lua_remove
(
L
,
1
);
/* remove elements to prevent being limited by
* the stack's size (this function will work with
* up to (stack size - 1) arguments */
decode_URI
(
psz_string
);
lua_pushstring
(
L
,
psz_string
);
free
(
psz_string
);
}
return
i_top
;
}
/* TODO: make it work for any number of arguments */
int
vlclua_resolve_xml_special_chars
(
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
!=
1
)
return
vlclua_error
(
L
);
const
char
*
psz_cstring
=
luaL_checkstring
(
L
,
1
);
if
(
!
psz_cstring
)
return
vlclua_error
(
L
);
char
*
psz_string
=
strdup
(
psz_cstring
);
lua_pop
(
L
,
1
);
resolve_xml_special_chars
(
psz_string
);
lua_pushstring
(
L
,
psz_string
);
free
(
psz_string
);
return
1
;
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
=
strdup
(
psz_cstring
);
lua_remove
(
L
,
1
);
/* remove elements to prevent being limited by
* the stack's size (this function will work with
* up to (stack size - 1) arguments */
resolve_xml_special_chars
(
psz_string
);
lua_pushstring
(
L
,
psz_string
);
free
(
psz_string
);
}
return
i_top
;
}
/*****************************************************************************
* Messaging facilities
*****************************************************************************/
/* TODO: make it work for any number of arguments */
int
vlclua_msg_dbg
(
lua_State
*
L
)
{
int
i_top
=
lua_gettop
(
L
);
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
if
(
lua_gettop
(
L
)
!=
1
)
return
vlclua_error
(
L
);
const
char
*
psz_cstring
=
luaL_checkstring
(
L
,
1
);
if
(
!
psz_cstring
)
return
vlclua_error
(
L
);
msg_Dbg
(
p_this
,
"%s"
,
psz_cstring
);
int
i
;
for
(
i
=
1
;
i
<=
i_top
;
i
++
)
msg_Dbg
(
p_this
,
"%s"
,
luaL_checkstring
(
L
,
1
)
);
return
0
;
}
/* TODO: make it work for any number of arguments */
int
vlclua_msg_warn
(
lua_State
*
L
)
{
int
i_top
=
lua_gettop
(
L
);
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
if
(
lua_gettop
(
L
)
!=
1
)
return
vlclua_error
(
L
);
const
char
*
psz_cstring
=
luaL_checkstring
(
L
,
1
);
if
(
!
psz_cstring
)
return
vlclua_error
(
L
);
msg_Warn
(
p_this
,
"%s"
,
psz_cstring
);
int
i
;
for
(
i
=
1
;
i
<=
i_top
;
i
++
)
msg_Warn
(
p_this
,
"%s"
,
luaL_checkstring
(
L
,
i
)
);
return
0
;
}
/* TODO: make it work for any number of arguments */
int
vlclua_msg_err
(
lua_State
*
L
)
{
int
i_top
=
lua_gettop
(
L
);
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
if
(
lua_gettop
(
L
)
!=
1
)
return
vlclua_error
(
L
);
const
char
*
psz_cstring
=
luaL_checkstring
(
L
,
1
);
if
(
!
psz_cstring
)
return
vlclua_error
(
L
);
msg_Err
(
p_this
,
"%s"
,
psz_cstring
);
int
i
;
for
(
i
=
1
;
i
<=
i_top
;
i
++
)
msg_Err
(
p_this
,
"%s"
,
luaL_checkstring
(
L
,
i
)
);
return
0
;
}
/* TODO: make it work for any number of arguments */
int
vlclua_msg_info
(
lua_State
*
L
)
{
int
i_top
=
lua_gettop
(
L
);
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
if
(
lua_gettop
(
L
)
!=
1
)
return
vlclua_error
(
L
);
const
char
*
psz_cstring
=
luaL_checkstring
(
L
,
1
);
if
(
!
psz_cstring
)
return
vlclua_error
(
L
);
msg_Info
(
p_this
,
"%s"
,
psz_cstring
);
int
i
;
for
(
i
=
1
;
i
<=
i_top
;
i
++
)
msg_Info
(
p_this
,
"%s"
,
luaL_checkstring
(
L
,
i
)
);
return
0
;
}
...
...
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