From 37c24268780d376cd72528c814260a192e61823e Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 23 Sep 2019 20:54:30 +0800 Subject: =?UTF-8?q?+=20misc=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/00-misc/main.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ src/00-misc/misc.lua | 3 +++ src/00-misc/vec.lua | 1 + src/02-enum/main.cpp | 1 + src/configure.h | 3 ++- 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/00-misc/main.cpp create mode 100644 src/00-misc/misc.lua create mode 100644 src/00-misc/vec.lua (limited to 'src') diff --git a/src/00-misc/main.cpp b/src/00-misc/main.cpp new file mode 100644 index 0000000..d55dac8 --- /dev/null +++ b/src/00-misc/main.cpp @@ -0,0 +1,43 @@ +#include "../configure.h" +#if BUILD_TEST == TEST_0 + +extern "C" { +#include "../lua51/lua.h" +#include "../lua51/lualib.h" +#include "../lua51/lauxlib.h" +} + +#include +#include +#include + +luaL_reg fns[] = { + { 0, 0 } +}; + +void openlibs(lua_State* L) +{ + luaL_openlibs(L); + //luaL_register(L, NULL, fns); + luaL_reg* fn; + int i = 0; + for (fn = &fns[0]; fn->name != 0; fn = &fns[++i]) + { + lua_pushcfunction(L, fn->func); + lua_setglobal(L, fn->name); + } +} + +int main(int args, char* argv[]) +{ + lua_State* L = luaL_newstate(); + openlibs(L); + + luaL_dofile(L, "00-misc/misc.lua"); + + lua_close(L); + getchar(); + return 0; +} + +#endif \ No newline at end of file diff --git a/src/00-misc/misc.lua b/src/00-misc/misc.lua new file mode 100644 index 0000000..e73d2e3 --- /dev/null +++ b/src/00-misc/misc.lua @@ -0,0 +1,3 @@ +package.preload["00-misc.vec"] = loadfile("00-misc/vec.lua") + +require("00-misc.vec") diff --git a/src/00-misc/vec.lua b/src/00-misc/vec.lua new file mode 100644 index 0000000..2862a16 --- /dev/null +++ b/src/00-misc/vec.lua @@ -0,0 +1 @@ +print("vec.lua") \ No newline at end of file diff --git a/src/02-enum/main.cpp b/src/02-enum/main.cpp index 172364b..c3914e7 100644 --- a/src/02-enum/main.cpp +++ b/src/02-enum/main.cpp @@ -36,6 +36,7 @@ int main(int args, char* argv[]) luaL_dofile(L, "02-enum/enum.lua"); lua_close(L); + getchar(); return 0; } diff --git a/src/configure.h b/src/configure.h index 6289d19..96e0142 100644 --- a/src/configure.h +++ b/src/configure.h @@ -1,6 +1,7 @@ #ifndef _CONFIGURE_H_ #define _CONFIGURE_H_ +#define TEST_0 0 #define TEST_1 1 #define TEST_2 2 #define TEST_3 3 @@ -13,7 +14,7 @@ #define TEST_10 10 -#define BUILD_TEST TEST_2 +#define BUILD_TEST TEST_0 //----------------------------------------------------------------------------------------------------- -- cgit v1.1-26-g67d0