summaryrefslogtreecommitdiff
path: root/lib/BLua.cc
diff options
context:
space:
mode:
authorpixel <pixel>2003-11-20 09:07:24 +0000
committerpixel <pixel>2003-11-20 09:07:24 +0000
commite995cb29c210d8d946c889a6a65dd0e90403e767 (patch)
tree29cace8a313c1e9d9968f54350ff810cb65da99f /lib/BLua.cc
parentebac9899fe2ef7a672d3728071b3a4179ec5a2df (diff)
Added LUA "compiler" to the code.
Diffstat (limited to 'lib/BLua.cc')
-rw-r--r--lib/BLua.cc28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/BLua.cc b/lib/BLua.cc
index 18789f7..c15e6d9 100644
--- a/lib/BLua.cc
+++ b/lib/BLua.cc
@@ -1,4 +1,5 @@
#include <lualib.h>
+
#include "BLua.h"
#ifndef BUFFERSIZE
@@ -10,6 +11,7 @@ typedef GeneralException LuaException;
class LuaStatics : public Base {
public:
static const char * getF(lua_State *, void *, size_t *);
+ static int putF(lua_State *, const void *, size_t, void *);
static int luapanic(lua_State *) throw(GeneralException);
static int destructor(lua_State *);
};
@@ -219,7 +221,18 @@ const char * LuaStatics::getF(lua_State * L, void * ud, size_t * size) {
return (*size > 0) ? lf->buff : NULL;
}
-void Lua::load(Handle * h) throw (GeneralException) {
+struct DumpF {
+ Handle * f;
+};
+
+int LuaStatics::putF(lua_State * L, const void * p, size_t size, void * ud) {
+ DumpF *lf = (DumpF *)ud;
+ (void)L;
+
+ return lf->f->write(p, size) == size;
+}
+
+void Lua::load(Handle * h, bool docall) throw (GeneralException) {
LoadF lf;
int status;
@@ -232,7 +245,18 @@ void Lua::load(Handle * h) throw (GeneralException) {
throw LuaException("Error loading lua chunk from Handle `" + h->GetName() + "'");
}
- call();
+ if (docall)
+ call();
+}
+
+extern "C" void luacmain(lua_State * L, int stripping, lua_Chunkwriter w, void * uD);
+
+void Lua::dump(Handle * h, bool strip) {
+ DumpF lf;
+
+ lf.f = h;
+
+ luacmain(L, strip, LuaStatics::putF, &lf);
}
Lua * Lua::thread() {