diff options
Diffstat (limited to 'src/FbTk/LuaUtil.hh')
-rw-r--r-- | src/FbTk/LuaUtil.hh | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/FbTk/LuaUtil.hh b/src/FbTk/LuaUtil.hh index d013ed9..12a687e 100644 --- a/src/FbTk/LuaUtil.hh +++ b/src/FbTk/LuaUtil.hh | |||
@@ -53,9 +53,11 @@ public: | |||
53 | */ | 53 | */ |
54 | void readOnlySet(int index); | 54 | void readOnlySet(int index); |
55 | 55 | ||
56 | typedef Slot<void, Lua &> InitFunction; | ||
57 | |||
56 | template<typename Functor> | 58 | template<typename Functor> |
57 | static void registerInitFunction(const Functor &fn) { | 59 | static void registerInitFunction(const Functor &fn) { |
58 | s_init_functions.push_back(new SlotImpl<Functor, void, Lua &>(fn)); | 60 | doRegisterInitFunction(std::auto_ptr<InitFunction>(new SlotImpl<Functor, void, Lua &>(fn))); |
59 | } | 61 | } |
60 | 62 | ||
61 | class RegisterInitFunction { | 63 | class RegisterInitFunction { |
@@ -67,16 +69,7 @@ public: | |||
67 | }; | 69 | }; |
68 | 70 | ||
69 | private: | 71 | private: |
70 | typedef Slot<void, Lua &> InitFunction; | 72 | static void doRegisterInitFunction(std::auto_ptr<InitFunction> fn); |
71 | struct AutoVector: public std::vector<InitFunction *> { | ||
72 | ~AutoVector() { | ||
73 | for(iterator it = begin(); it != end(); ++it) | ||
74 | delete *it; | ||
75 | } | ||
76 | }; | ||
77 | typedef AutoVector InitFunctions; | ||
78 | |||
79 | static InitFunctions s_init_functions; | ||
80 | }; | 73 | }; |
81 | 74 | ||
82 | } // namespace FbTk | 75 | } // namespace FbTk |