aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Luamm.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Luamm.cc')
-rw-r--r--src/FbTk/Luamm.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/FbTk/Luamm.cc b/src/FbTk/Luamm.cc
index 563be9c..1ef751f 100644
--- a/src/FbTk/Luamm.cc
+++ b/src/FbTk/Luamm.cc
@@ -59,6 +59,7 @@ namespace lua {
59 lua_rawset(l, index); 59 lua_rawset(l, index);
60 } 60 }
61 61
62 template<typename Functor>
62 int closure_trampoline(lua_State *l) 63 int closure_trampoline(lua_State *l)
63 { 64 {
64 lua_checkstack(l, 2); 65 lua_checkstack(l, 2);
@@ -68,7 +69,7 @@ namespace lua {
68 lua_pop(l, 1); 69 lua_pop(l, 1);
69 70
70 try { 71 try {
71 Slot *fn = static_cast<Slot *>( L->touserdata(lua_upvalueindex(1)) ); 72 Functor *fn = reinterpret_cast<Functor *>( L->touserdata(lua_upvalueindex(1)) );
72 assert(fn); 73 assert(fn);
73 return (*fn)(L); 74 return (*fn)(L);
74 } 75 }
@@ -390,7 +391,14 @@ namespace lua {
390 setmetatable(-2); 391 setmetatable(-2);
391 392
392 insert(-n-1); 393 insert(-n-1);
393 lua_pushcclosure(cobj, &closure_trampoline, n+1); 394 lua_pushcclosure(cobj, &closure_trampoline<Slot>, n+1);
395 }
396
397 void state::pushclosure(int (*fn)(state *), int n)
398 {
399 pushlightuserdata(reinterpret_cast<void *>(fn));
400 insert(-n-1);
401 lua_pushcclosure(cobj, &closure_trampoline<int (state *)>, n+1);
394 } 402 }
395 403
396 void state::rawgetfield(int index, const char *k) throw(std::bad_alloc) 404 void state::rawgetfield(int index, const char *k) throw(std::bad_alloc)