diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-05-19 10:59:50 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2013-02-16 23:19:15 (GMT) |
commit | cd602c9009ade65c87dd9dcee718c91622288a34 (patch) | |
tree | 8241dde2bb80520595016c2b58b38ca958bbd1ff /src/FbTk/Luamm.cc | |
parent | 1ce38476d96881221fb486a80f511feb80098416 (diff) | |
download | fluxbox_pavel-cd602c9009ade65c87dd9dcee718c91622288a34.zip fluxbox_pavel-cd602c9009ade65c87dd9dcee718c91622288a34.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.cc | 11 |
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) |