From 6dd16a5548d2f008f05932d18587fa4e316262e9 Mon Sep 17 00:00:00 2001 From: Matyas Dolak Date: Thu, 30 May 2024 17:51:24 +0200 Subject: [PATCH] Added the LuaExpat module. --- .gitmodules | 6 ++++++ README.md | 1 + lib/CMakeLists.txt | 2 ++ lib/expat | 1 + lib/luaexpat | 1 + src/CMakeLists.txt | 2 ++ src/LunaPaak.cpp | 5 +++++ tests/LuaExpat.luna | 17 +++++++++++++++++ 8 files changed, 35 insertions(+) create mode 160000 lib/expat create mode 160000 lib/luaexpat create mode 100644 tests/LuaExpat.luna diff --git a/.gitmodules b/.gitmodules index 1a1c5c9..8613865 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/README.md b/README.md index 61ca3c9..e37fa1b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 7175a72..515f158 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -14,3 +14,5 @@ add_subdirectory(lua-cjson) add_subdirectory(fmt) add_subdirectory(LuaSimpleWinHttp) add_subdirectory(LuaSha1) +add_subdirectory(expat) +add_subdirectory(luaexpat) diff --git a/lib/expat b/lib/expat new file mode 160000 index 0000000..0fc5626 --- /dev/null +++ b/lib/expat @@ -0,0 +1 @@ +Subproject commit 0fc562607c4b457954839dbfb1f47fe1567d8c7f diff --git a/lib/luaexpat b/lib/luaexpat new file mode 160000 index 0000000..631b26d --- /dev/null +++ b/lib/luaexpat @@ -0,0 +1 @@ +Subproject commit 631b26d9eb2e42a226ad344924bd0518fdc62e2d diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b04c313..df26829 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,6 +46,7 @@ target_link_libraries(LunaPaak cjson-static LuaSimpleWinHttp-static LuaSha1-static + luaexpat-static ) @@ -55,6 +56,7 @@ set(TESTS Lfs CJson LuaSimpleWinHttp + LuaExpat ) diff --git a/src/LunaPaak.cpp b/src/LunaPaak.cpp index 5756986..89801b9 100644 --- a/src/LunaPaak.cpp +++ b/src/LunaPaak.cpp @@ -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); } @@ -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: diff --git a/tests/LuaExpat.luna b/tests/LuaExpat.luna new file mode 100644 index 0000000..763b5db --- /dev/null +++ b/tests/LuaExpat.luna @@ -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("") + +print("LuaExpat test finished")