summaryrefslogtreecommitdiff
path: root/src/BLua.cc
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-12 06:59:03 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-12 06:59:03 +0200
commit68e2e03838a475252e519a7a16a9bcb2e3e4dd62 (patch)
treec3f059fc59c4221fda81f006a578b5b4fe7643bb /src/BLua.cc
parent0d528cd7be88272ac9ce33641ab80a7fd0600f0a (diff)
Adding LuaBigInt and a few more things.
Diffstat (limited to 'src/BLua.cc')
-rw-r--r--src/BLua.cc25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/BLua.cc b/src/BLua.cc
index eee663b..886f92e 100644
--- a/src/BLua.cc
+++ b/src/BLua.cc
@@ -838,6 +838,29 @@ bool Balau::Lua::resume(int nargs) throw (GeneralException) {
}
}
+void Balau::Lua::pcall(int nargs) throw (GeneralException) {
+ int r = lua_pcall(L, nargs, LUA_MULTRET, 0);
+
+ if (r == 0)
+ return;
+
+ pushLuaContext();
+ showerror();
+
+ switch(r) {
+ case LUA_ERRRUN:
+ throw LuaException("Runtime error while running LUA code.");
+ case LUA_ERRMEM:
+ throw LuaException("Memory allocation error while running LUA code.");
+ case LUA_ERRERR:
+ throw LuaException("Error in Error function.");
+ case LUA_ERRSYNTAX:
+ throw LuaException("Syntax error in Lua code.");
+ default:
+ throw LuaException(String("Unknow error while running LUA code (err code: ") + String(r) + ")");
+ }
+}
+
bool Balau::Lua::resumeC(int & nargs) {
if (!yielded())
return false;
@@ -1016,7 +1039,7 @@ Balau::LuaObjectBase * Balau::LuaObjectFactory::getMeInternal(Lua & L, int i) {
if (L.istable(i)) {
L.push("__obj");
- L.gettable(i, true);
+ L.gettable(i < 0 ? i - 1 : i, true);
if (!(o = (LuaObjectBase *) L.touserdata()))
L.error("Table is not an object.");
L.pop();