aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Luamm.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-05-19 10:59:50 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 09:52:45 (GMT)
commit1f5591aae5b2ffbd4e1c96aa4ca9442857921264 (patch)
tree9c4453d79aa0d60d042519d48efb072920774f6b /src/FbTk/Luamm.cc
parent800a1a761d57919bb3556d5ce48380b6328b14ef (diff)
downloadfluxbox_pavel-1f5591aae5b2ffbd4e1c96aa4ca9442857921264.zip
fluxbox_pavel-1f5591aae5b2ffbd4e1c96aa4ca9442857921264.tar.bz2
c++ lua binding: replace std::function with FbTk::Slot
std::function is superior, but not supported on old compilers
Diffstat (limited to 'src/FbTk/Luamm.cc')
-rw-r--r--src/FbTk/Luamm.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/FbTk/Luamm.cc b/src/FbTk/Luamm.cc
index a4a6eca..81a8fb3 100644
--- a/src/FbTk/Luamm.cc
+++ b/src/FbTk/Luamm.cc
@@ -30,7 +30,7 @@ namespace lua {
30 const char cpp_exception_metatable[] = "lua::cpp_exception_metatable"; 30 const char cpp_exception_metatable[] = "lua::cpp_exception_metatable";
31 const char cpp_function_metatable [] = "lua::cpp_function_metatable"; 31 const char cpp_function_metatable [] = "lua::cpp_function_metatable";
32 const char lua_exception_namespace[] = "lua::lua_exception_namespace"; 32 const char lua_exception_namespace[] = "lua::lua_exception_namespace";
33 const char this_cpp_object [] = "lua::this_cpp_object"; 33 const char this_cpp_object [] = "lua::this_cpp_object";
34 34
35 // converts C++ exceptions to strings, so lua can do something with them 35 // converts C++ exceptions to strings, so lua can do something with them
36 int exception_to_string(lua_State *l) 36 int exception_to_string(lua_State *l)
@@ -245,7 +245,7 @@ namespace lua {
245 newmetatable(cpp_function_metatable); 245 newmetatable(cpp_function_metatable);
246 pushboolean(false); 246 pushboolean(false);
247 rawsetfield(-2, "__metatable"); 247 rawsetfield(-2, "__metatable");
248 pushdestructor<cpp_function>(); 248 pushdestructor<FbTk::Slot<int, state *> >();
249 rawsetfield(-2, "__gc"); 249 rawsetfield(-2, "__gc");
250 pop(); 250 pop();
251 251
@@ -399,16 +399,13 @@ namespace lua {
399 return r; 399 return r;
400 } 400 }
401 401
402 void state::pushclosure(const cpp_function &fn, int n) 402 void state::do_pushclosure(int n)
403 { 403 {
404 checkstack(2);
405
406 createuserdata<cpp_function>(fn);
407 rawgetfield(REGISTRYINDEX, cpp_function_metatable); 404 rawgetfield(REGISTRYINDEX, cpp_function_metatable);
408 setmetatable(-2); 405 setmetatable(-2);
409 406
410 insert(-n-1); 407 insert(-n-1);
411 lua_pushcclosure(cobj.get(), &closure_trampoline, n+1); 408 lua_pushcclosure(cobj, &closure_trampoline, n+1);
412 } 409 }
413 410
414 void state::rawgetfield(int index, const char *k) throw(std::bad_alloc) 411 void state::rawgetfield(int index, const char *k) throw(std::bad_alloc)