From ee8ef0433e36bf354a717bd4af679a0a5af2e6be Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 20 Dec 2018 18:34:50 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin-lua/embed/embed.h | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/libjin-lua/embed/embed.h (limited to 'src/libjin-lua/embed/embed.h') diff --git a/src/libjin-lua/embed/embed.h b/src/libjin-lua/embed/embed.h new file mode 100644 index 0000000..1928dd5 --- /dev/null +++ b/src/libjin-lua/embed/embed.h @@ -0,0 +1,47 @@ +#ifndef __JIN_LUA_EMBED_H +#define __JIN_LUA_EMBED_H +#include + +namespace JinEngine +{ + namespace Embed + { + + // Embed structure. + struct jin_Embed + { + const char* file, *source; + }; + + // Embed scripts. + #include "scripts/graphics.lua.h" + #include "scripts/keyboard.lua.h" + #include "scripts/mouse.lua.h" + #include "scripts/boot.lua.h" + + // In order. + static const jin_Embed modules[] = { + { "graphics.lua", graphics_lua }, + { "keyboard.lua", keyboard_lua }, + { "mouse.lua", mouse_lua }, + { 0, 0 } + }; + + static const jin_Embed bootscript = { "boot.lua", boot_lua }; + + static void run(lua_State* L) + { + for (int i = 0; modules[i].file; ++i) + { + const char* file = modules[i].file, *source = modules[i].source; + if (luax_loadbuffer(L, source, strlen(source), file) == 0) + luax_call(L, 0, 0); + } + if (luax_loadbuffer(L, bootscript.source, strlen(bootscript.source), bootscript.file) == 0) + luax_call(L, 0, 0); + } + + } // namespace Embed +} // namespace JinEngine + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0