Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
LuaXML_lib.h File Reference
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

Go to the source code of this file.

Macros

#define LUAXML_DEBUG   0 /* set to 1 to enable debugging output */
 
#define _EXPORT
 

Functions

int _EXPORT luaopen_LuaXML_lib (lua_State *L)
 

Macro Definition Documentation

◆ _EXPORT

#define _EXPORT

Definition at line 20 of file LuaXML_lib.h.

◆ LUAXML_DEBUG

#define LUAXML_DEBUG   0 /* set to 1 to enable debugging output */

Definition at line 5 of file LuaXML_lib.h.

Function Documentation

◆ luaopen_LuaXML_lib()

int _EXPORT luaopen_LuaXML_lib ( lua_State * L)

Definition at line 1280 of file LuaXML_lib.c.

1281{
1282 static const struct luaL_Reg funcs[] = {{"append", Xml_append},
1283 {"decode", Xml_decode},
1284 {"encode", Xml_encode},
1285 {"eval", Xml_eval},
1286 {"find", Xml_find},
1287 {"iterate", Xml_iterate},
1288 {"load", Xml_load},
1289 {"match", Xml_match},
1290 {"new", Xml_new},
1291 {"registerCode", Xml_registerCode},
1292 {"str", Xml_str},
1293 {"tag", Xml_tag},
1294 {NULL, NULL}};
1295 luaL_newlib(L, funcs);
1296
1297 // create a metatable for LuaXML "objects"
1299 lua_pushliteral(L, "__index");
1300 lua_pushvalue(L, -3); // duplicate the module table
1301 lua_rawset(L, -3); // and set it as metaindex
1302 lua_pushliteral(L, "__tostring");
1304 lua_rawset(L, -3); // set metamethod
1305 lua_pop(L, 1); // drop value (metatable)
1306
1307 // expose API constants (via the module table)
1309 lua_setfield(L, -2, "WS_TRIM");
1311 lua_setfield(L, -2, "WS_NORMALIZE");
1313 lua_setfield(L, -2, "WS_PRESERVE");
1314
1315 // register default codes
1316 // Note: We'll always handle "&amp;" separately!
1317 lua_newtable(L);
1318 lua_pushliteral(L, "&lt;");
1319 lua_setfield(L, -2, "<");
1320 lua_pushliteral(L, "&gt;");
1321 lua_setfield(L, -2, ">");
1322 lua_pushliteral(L, "&quot;");
1323 lua_setfield(L, -2, "\"");
1324 lua_pushliteral(L, "&apos;");
1325 lua_setfield(L, -2, "'");
1326 sv_code_ref = luaL_ref(L, LUA_REGISTRYINDEX); // reference (and pop table)
1327
1328 return 1; // return module (table)
1329}
static int Xml_find(lua_State *L)
static int Xml_load(lua_State *L)
Definition LuaXML_lib.c:791
static int Xml_append(lua_State *L)
Definition LuaXML_lib.c:558
#define LUAXML_META
Definition LuaXML_lib.c:72
static int Xml_tag(lua_State *L)
Definition LuaXML_lib.c:483
#define luaL_newlib(L, funcs)
Definition LuaXML_lib.c:45
static int Xml_eval(lua_State *L)
Definition LuaXML_lib.c:692
static int Xml_iterate(lua_State *L)
@ WHITESPACE_NORMALIZE
Definition LuaXML_lib.c:224
@ WHITESPACE_PRESERVE
Definition LuaXML_lib.c:225
@ WHITESPACE_TRIM
Definition LuaXML_lib.c:223
static int Xml_str(lua_State *L)
Definition LuaXML_lib.c:912
static int Xml_match(lua_State *L)
static int Xml_encode(lua_State *L)
Definition LuaXML_lib.c:864
static int sv_code_ref
Definition LuaXML_lib.c:463
static int Xml_decode(lua_State *L)
Definition LuaXML_lib.c:884
static int Xml_new(lua_State *L)
Definition LuaXML_lib.c:528
static int Xml_registerCode(lua_State *L)
Definition LuaXML_lib.c:836
#define NULL
Definition gmacros.h:924
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
LUA_API void lua_rawset(lua_State *L, int idx)
LUALIB_API int luaL_ref(lua_State *L, int t)
LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname)
#define lua_pushcfunction(L, f)
#define LUA_REGISTRYINDEX
#define lua_pushliteral(L, s)
#define lua_newtable(L)
#define lua_pop(L, n)
static const luaL_Reg funcs[]

References funcs, lua_newtable, lua_pop, lua_pushcfunction, lua_pushinteger(), lua_pushliteral, lua_pushvalue(), lua_rawset(), LUA_REGISTRYINDEX, lua_setfield(), luaL_newlib, luaL_newmetatable(), luaL_ref(), LUAXML_META, NULL, sv_code_ref, WHITESPACE_NORMALIZE, WHITESPACE_PRESERVE, WHITESPACE_TRIM, Xml_append(), Xml_decode(), Xml_encode(), Xml_eval(), Xml_find(), Xml_iterate(), Xml_load(), Xml_match(), Xml_new(), Xml_registerCode(), Xml_str(), and Xml_tag().