diff options
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/SConscript | 22 | ||||
-rw-r--r-- | scripting/test.cpp | 11 | ||||
-rw-r--r-- | scripting/test.h | 8 |
3 files changed, 41 insertions, 0 deletions
diff --git a/scripting/SConscript b/scripting/SConscript new file mode 100644 index 0000000..eaf9f21 --- /dev/null +++ b/scripting/SConscript @@ -0,0 +1,22 @@ +Import('env') + +def tolua_generator(source, target, env, for_signature): + name = str(source[0]).rsplit('/', 1)[-1].rsplit('.' , 1)[0] + return 'tolua++ -o %s -H %s -n %s %s' % (target[1], target[2], name, source[0]) + +def tolua_emitter(target, source, env): + target.append('tolua_%s.cpp' % target[0]) + target.append('tolua_%s.h' % target[0]) + return target, source + +tolua_bld = Builder( + generator = tolua_generator, + emitter = tolua_emitter, + src_suffix = '.pkg', +) + +env.Append(BUILDERS = {'tolua': tolua_bld}) + +env.tolua('test') + +# vim: syn=python diff --git a/scripting/test.cpp b/scripting/test.cpp new file mode 100644 index 0000000..1a378b7 --- /dev/null +++ b/scripting/test.cpp @@ -0,0 +1,11 @@ +#include "scripting/test.h" +#include "scripting.h" + +#include <iostream> + +void print(lua_State *L, const char *s) { + lua_getglobal(L, "lua_instance"); + Lua *lua = static_cast<Lua*>(lua_touserdata(L, -1)); + lua_pop(L, 1); + lua->print(s); +} diff --git a/scripting/test.h b/scripting/test.h new file mode 100644 index 0000000..48f560e --- /dev/null +++ b/scripting/test.h @@ -0,0 +1,8 @@ +#ifndef TEST_H +#define TEST_H + +#include <lua.hpp> + +void print(lua_State *L, const char *s); + +#endif |