Skip to content

Commit

Permalink
Added the LuaExpat module.
Browse files Browse the repository at this point in the history
  • Loading branch information
madmaxoft committed May 30, 2024
1 parent 91ab6c9 commit 6dd16a5
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@
[submodule "lib/LuaSha1"]
path = lib/LuaSha1
url = https://github.com/madmaxoft/LuaSha1
[submodule "lib/expat"]
path = lib/expat
url = https://github.com/madmaxoft/expat
[submodule "lib/luaexpat"]
path = lib/luaexpat
url = https://github.com/madmaxoft/luaexpat
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The package contains the following libraries:
- lzlib (+ zlib)
- lua-cjson
- LuaSimpleWinHttp
- [LuaExpat](https://lunarmodules.github.io/luaexpat/manual.html#parser)

# Installing
To install the interpreter, download the executable from the Releases, save it to a final destination and execute it once. It will register itself to handle .luna files automatically, and will add itself to the list of programs capable of handling .lua files. Next, you can run any .luna file by dbl-clicking it. For .lua files, you will need to manually set it as the default program, using built-in Windows functionality.
Expand Down
2 changes: 2 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ add_subdirectory(lua-cjson)
add_subdirectory(fmt)
add_subdirectory(LuaSimpleWinHttp)
add_subdirectory(LuaSha1)
add_subdirectory(expat)
add_subdirectory(luaexpat)
1 change: 1 addition & 0 deletions lib/expat
Submodule expat added at 0fc562
1 change: 1 addition & 0 deletions lib/luaexpat
Submodule luaexpat added at 631b26
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ target_link_libraries(LunaPaak
cjson-static
LuaSimpleWinHttp-static
LuaSha1-static
luaexpat-static
)


Expand All @@ -55,6 +56,7 @@ set(TESTS
Lfs
CJson
LuaSimpleWinHttp
LuaExpat
)


Expand Down
5 changes: 5 additions & 0 deletions src/LunaPaak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ extern "C"
// lua-cjson fwd:
extern int luaopen_cjson(lua_State *l);
extern int luaopen_cjson_safe(lua_State *l);

// luaexpat fwd:
extern int luaopen_lxp(lua_State * L);
}


Expand Down Expand Up @@ -250,6 +253,8 @@ int main(int argc, char * argv[])
luaopen_LuaSimpleWinHttp(L);
lua_pop(L, 1);
luaopen_LuaSha1(L);
lua_pop(L, 1);
luaL_requiref(L, "lxp", &luaopen_lxp, true);
lua_settop(L, 0); // Trim off all excess values left over by the reg functions

// Store the args to the script in a separate "arg" global:
Expand Down
17 changes: 17 additions & 0 deletions tests/LuaExpat.luna
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
print("LuaExpat test starting")

local lxp = require("lxp")

local callbacks =
{
StartElement = function(aParser, aElementName, aAttributes)
print("Start element: " .. aElementName)
end,
EndElement = function(aParser, aElementName)
print("End element: " .. aElementName)
end,
}
local parser = lxp.new(callbacks)
parser:parse("<a><b><c d=\"e\" /></b></a>")

print("LuaExpat test finished")

0 comments on commit 6dd16a5

Please sign in to comment.