[vlc-commits] lua/libs/xml: add :node_empty to xml-reader

Filip Roséen git at videolan.org
Fri Jul 22 11:13:06 CEST 2016


vlc | branch: master | Filip Roséen <filip at videolabs.io> | Wed Jul 20 03:47:04 2016 +0200| [e5d4282307ac7e2aa43d28e9a78a5397b25ab05b] | committer: Jean-Baptiste Kempf

lua/libs/xml: add :node_empty to xml-reader

status, tagname = reader:next_node()
empty_state = reader:node_empty()

if     empty_state  < 0 then error()
elseif empty_state == 1 then signal_empty()
end

Close #17194

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/lua/libs/xml.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/modules/lua/libs/xml.c b/modules/lua/libs/xml.c
index 99bdd3b..fe88fff 100644
--- a/modules/lua/libs/xml.c
+++ b/modules/lua/libs/xml.c
@@ -68,10 +68,12 @@ static int vlclua_xml_create( lua_State *L )
  *****************************************************************************/
 static int vlclua_xml_reader_next_node( lua_State * );
 static int vlclua_xml_reader_next_attr( lua_State * );
+static int vlclua_xml_reader_node_empty( lua_State * );
 
 static const luaL_Reg vlclua_xml_reader_reg[] = {
     { "next_node", vlclua_xml_reader_next_node },
     { "next_attr", vlclua_xml_reader_next_attr },
+    { "node_empty", vlclua_xml_reader_node_empty },
     { NULL, NULL }
 };
 
@@ -136,6 +138,14 @@ static int vlclua_xml_reader_next_attr( lua_State *L )
     return 2;
 }
 
+static int vlclua_xml_reader_node_empty( lua_State* L )
+{
+    xml_reader_t *p_reader = *(xml_reader_t**)luaL_checkudata( L, 1, "xml_reader" );
+
+    lua_pushinteger( L, xml_ReaderIsEmptyElement( p_reader ) );
+    return 1;
+}
+
 void luaopen_xml( lua_State *L )
 {
     lua_pushcfunction( L, vlclua_xml_create );



More information about the vlc-commits mailing list