diff options
-rw-r--r-- | src/FbCommands.cc | 19 | ||||
-rw-r--r-- | src/FbTk/LResource.cc | 47 | ||||
-rw-r--r-- | src/FbTk/LResource.hh | 11 | ||||
-rw-r--r-- | src/MenuCreator.cc | 1 | ||||
-rw-r--r-- | src/Screen.cc | 2 | ||||
-rw-r--r-- | src/fluxbox.cc | 3 | ||||
-rw-r--r-- | src/fluxbox.hh | 4 |
7 files changed, 42 insertions, 45 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 0d7c1df..c74cce6 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "MenuCreator.hh" | 31 | #include "MenuCreator.hh" |
32 | 32 | ||
33 | #include "FbTk/I18n.hh" | 33 | #include "FbTk/I18n.hh" |
34 | #include "FbTk/Luamm.hh" | 34 | #include "FbTk/LuaUtil.hh" |
35 | #include "FbTk/Theme.hh" | 35 | #include "FbTk/Theme.hh" |
36 | #include "FbTk/Menu.hh" | 36 | #include "FbTk/Menu.hh" |
37 | #include "FbTk/CommandParser.hh" | 37 | #include "FbTk/CommandParser.hh" |
@@ -547,6 +547,15 @@ REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(lua, LuaCmd, void); | |||
547 | 547 | ||
548 | namespace { | 548 | namespace { |
549 | const char LuaCmds[] = "FbCommands::LuaCmd"; | 549 | const char LuaCmds[] = "FbCommands::LuaCmd"; |
550 | |||
551 | void initLuaCmds(FbTk::Lua &l) { | ||
552 | l.checkstack(1); | ||
553 | |||
554 | l.newtable(); | ||
555 | l.rawsetfield(lua::REGISTRYINDEX, LuaCmds); | ||
556 | } | ||
557 | |||
558 | FbTk::Lua::RegisterInitFunction register_init_lua_cmds(&initLuaCmds); | ||
550 | } | 559 | } |
551 | 560 | ||
552 | LuaCmd::LuaCmd(const std::string &chunk) { | 561 | LuaCmd::LuaCmd(const std::string &chunk) { |
@@ -571,14 +580,6 @@ void LuaCmd::init(lua::state &l) { | |||
571 | l.checkstack(2); | 580 | l.checkstack(2); |
572 | 581 | ||
573 | l.rawgetfield(lua::REGISTRYINDEX, LuaCmds); { | 582 | l.rawgetfield(lua::REGISTRYINDEX, LuaCmds); { |
574 | if(l.isnil(-1)) { | ||
575 | l.pop(); | ||
576 | l.newtable(); | ||
577 | |||
578 | l.pushvalue(-1); | ||
579 | l.rawsetfield(lua::REGISTRYINDEX, LuaCmds); | ||
580 | } | ||
581 | |||
582 | l.pushvalue(-2); | 583 | l.pushvalue(-2); |
583 | m_ref = l.ref(-2); | 584 | m_ref = l.ref(-2); |
584 | } l.pop(); | 585 | } l.pop(); |
diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc index b91f0d8..6671b89 100644 --- a/src/FbTk/LResource.cc +++ b/src/FbTk/LResource.cc | |||
@@ -24,8 +24,8 @@ | |||
24 | 24 | ||
25 | #include "LResource.hh" | 25 | #include "LResource.hh" |
26 | 26 | ||
27 | #include "LuaUtil.hh" | ||
27 | #include "Resource.hh" | 28 | #include "Resource.hh" |
28 | #include "Luamm.hh" | ||
29 | 29 | ||
30 | extern const char LResourceHelper[]; | 30 | extern const char LResourceHelper[]; |
31 | extern const unsigned int LResourceHelper_size; | 31 | extern const unsigned int LResourceHelper_size; |
@@ -61,30 +61,32 @@ namespace { | |||
61 | 61 | ||
62 | return 0; | 62 | return 0; |
63 | } | 63 | } |
64 | } | ||
65 | 64 | ||
66 | void LResourceManager::initState(lua::state &l) { | 65 | void initState(Lua &l) { |
67 | l.checkstack(6); | 66 | l.checkstack(6); |
68 | lua::stack_sentry s(l); | 67 | lua::stack_sentry s(l); |
69 | 68 | ||
70 | l.loadstring(LResourceHelper, LResourceHelper_size); | 69 | l.loadstring(LResourceHelper, LResourceHelper_size); |
71 | l.pushfunction(&readResource); | 70 | l.pushfunction(&readResource); |
72 | l.pushfunction(&writeResource); | 71 | l.pushfunction(&writeResource); |
73 | l.newtable(); { | ||
74 | l.newtable(); { | 72 | l.newtable(); { |
75 | l.pushvalue(-2); | 73 | l.newtable(); { |
76 | l.setfield(-2, "__metatable"); | 74 | l.pushvalue(-2); |
77 | } l.setfield(lua::REGISTRYINDEX, resource_metatable); | 75 | l.setfield(-2, "__metatable"); |
76 | } l.setfield(lua::REGISTRYINDEX, resource_metatable); | ||
77 | } | ||
78 | l.call(3, 3); | ||
79 | l.setfield(lua::REGISTRYINDEX, dump_resources); | ||
80 | l.setfield(lua::REGISTRYINDEX, register_resource); | ||
81 | l.setfield(lua::REGISTRYINDEX, make_root); | ||
78 | } | 82 | } |
79 | l.call(3, 3); | 83 | |
80 | l.setfield(lua::REGISTRYINDEX, dump_resources); | 84 | Lua::RegisterInitFunction register_init_state(&initState); |
81 | l.setfield(lua::REGISTRYINDEX, register_resource); | 85 | |
82 | l.setfield(lua::REGISTRYINDEX, make_root); | 86 | } // anonymous namespace |
83 | } | ||
84 | 87 | ||
85 | void LResourceManager::convert(ResourceManager &old, const std::string &new_file) { | 88 | void LResourceManager::convert(ResourceManager &old, const std::string &new_file) { |
86 | lua::state l; | 89 | Lua l; |
87 | initState(l); | ||
88 | 90 | ||
89 | LResourceManager new_rm(old.root(), l); | 91 | LResourceManager new_rm(old.root(), l); |
90 | for(ResourceList::const_iterator i = old.begin(); i != old.end(); ++i) { | 92 | for(ResourceList::const_iterator i = old.begin(); i != old.end(); ++i) { |
@@ -98,17 +100,12 @@ void LResourceManager::convert(ResourceManager &old, const std::string &new_file | |||
98 | new_rm.save(new_file.c_str(), NULL); | 100 | new_rm.save(new_file.c_str(), NULL); |
99 | } | 101 | } |
100 | 102 | ||
101 | LResourceManager::LResourceManager(const std::string &root, lua::state &l) | 103 | LResourceManager::LResourceManager(const std::string &root, Lua &l) |
102 | : ResourceManager_base(root), m_l(&l) { | 104 | : ResourceManager_base(root), m_l(&l) { |
103 | l.checkstack(2); | 105 | l.checkstack(2); |
104 | lua::stack_sentry s(l); | 106 | lua::stack_sentry s(l); |
105 | 107 | ||
106 | l.getfield(lua::REGISTRYINDEX, make_root); | 108 | l.getfield(lua::REGISTRYINDEX, make_root); |
107 | if(l.isnil(-1)) { | ||
108 | l.pop(); | ||
109 | initState(l); | ||
110 | l.getfield(lua::REGISTRYINDEX, make_root); | ||
111 | } | ||
112 | l.pushstring(root); | 109 | l.pushstring(root); |
113 | l.call(1, 0); | 110 | l.call(1, 0); |
114 | } | 111 | } |
diff --git a/src/FbTk/LResource.hh b/src/FbTk/LResource.hh index 1125707..1567269 100644 --- a/src/FbTk/LResource.hh +++ b/src/FbTk/LResource.hh | |||
@@ -29,25 +29,22 @@ | |||
29 | 29 | ||
30 | #include "Resource.hh" | 30 | #include "Resource.hh" |
31 | 31 | ||
32 | namespace lua { | ||
33 | class state; | ||
34 | } | ||
35 | |||
36 | namespace FbTk { | 32 | namespace FbTk { |
37 | 33 | ||
34 | class Lua; | ||
35 | |||
38 | class LResourceManager: public ResourceManager_base { | 36 | class LResourceManager: public ResourceManager_base { |
39 | public: | 37 | public: |
40 | static void initState(lua::state &l); | ||
41 | static void convert(ResourceManager &old, const std::string &new_file); | 38 | static void convert(ResourceManager &old, const std::string &new_file); |
42 | 39 | ||
43 | LResourceManager(const std::string &root, lua::state &l); | 40 | LResourceManager(const std::string &root, Lua &l); |
44 | virtual bool save(const char *filename, const char *); | 41 | virtual bool save(const char *filename, const char *); |
45 | virtual void addResource(Resource_base &r); | 42 | virtual void addResource(Resource_base &r); |
46 | virtual void removeResource(Resource_base &r); | 43 | virtual void removeResource(Resource_base &r); |
47 | 44 | ||
48 | private: | 45 | private: |
49 | 46 | ||
50 | lua::state *m_l; | 47 | Lua *m_l; |
51 | }; | 48 | }; |
52 | 49 | ||
53 | } // end namespace FbTk | 50 | } // end namespace FbTk |
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index ea45487..406d9e5 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc | |||
@@ -43,6 +43,7 @@ | |||
43 | #include "RootCmdMenuItem.hh" | 43 | #include "RootCmdMenuItem.hh" |
44 | 44 | ||
45 | #include "FbTk/I18n.hh" | 45 | #include "FbTk/I18n.hh" |
46 | #include "FbTk/LuaUtil.hh" | ||
46 | #include "FbTk/MultiButtonMenuItem.hh" | 47 | #include "FbTk/MultiButtonMenuItem.hh" |
47 | #include "FbTk/BoolMenuItem.hh" | 48 | #include "FbTk/BoolMenuItem.hh" |
48 | #include "FbTk/RefCount.hh" | 49 | #include "FbTk/RefCount.hh" |
diff --git a/src/Screen.cc b/src/Screen.cc index f57c5ad..cb86c73 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -73,7 +73,7 @@ | |||
73 | #include "FbTk/STLUtil.hh" | 73 | #include "FbTk/STLUtil.hh" |
74 | #include "FbTk/KeyUtil.hh" | 74 | #include "FbTk/KeyUtil.hh" |
75 | #include "FbTk/Util.hh" | 75 | #include "FbTk/Util.hh" |
76 | #include "FbTk/Luamm.hh" | 76 | #include "FbTk/LuaUtil.hh" |
77 | 77 | ||
78 | //use GNU extensions | 78 | //use GNU extensions |
79 | #ifndef _GNU_SOURCE | 79 | #ifndef _GNU_SOURCE |
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 88038c9..7c2147c 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -43,6 +43,7 @@ | |||
43 | #include "FbTk/FileUtil.hh" | 43 | #include "FbTk/FileUtil.hh" |
44 | #include "FbTk/ImageControl.hh" | 44 | #include "FbTk/ImageControl.hh" |
45 | #include "FbTk/EventManager.hh" | 45 | #include "FbTk/EventManager.hh" |
46 | #include "FbTk/LuaUtil.hh" | ||
46 | #include "FbTk/StringUtil.hh" | 47 | #include "FbTk/StringUtil.hh" |
47 | #include "FbTk/Util.hh" | 48 | #include "FbTk/Util.hh" |
48 | #include "FbTk/LResource.hh" | 49 | #include "FbTk/LResource.hh" |
@@ -232,7 +233,7 @@ Fluxbox::Fluxbox(int argc, char **argv, | |||
232 | const std::string& dpy_name, | 233 | const std::string& dpy_name, |
233 | const std::string& rc_path, const std::string& rc_filename, bool xsync) | 234 | const std::string& rc_path, const std::string& rc_filename, bool xsync) |
234 | : FbTk::App(dpy_name.c_str()), | 235 | : FbTk::App(dpy_name.c_str()), |
235 | m_l(new lua::state()), | 236 | m_l(new Lua), |
236 | m_fbatoms(FbAtoms::instance()), | 237 | m_fbatoms(FbAtoms::instance()), |
237 | m_resourcemanager("session", *m_l), | 238 | m_resourcemanager("session", *m_l), |
238 | 239 | ||
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index e027660..c241fb7 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh | |||
@@ -173,7 +173,7 @@ public: | |||
173 | /// get screen from number | 173 | /// get screen from number |
174 | BScreen *findScreen(int num); | 174 | BScreen *findScreen(int num); |
175 | 175 | ||
176 | lua::state &lua() { return *m_l; } | 176 | FbTk::Lua& lua() { return *m_l; } |
177 | 177 | ||
178 | typedef std::list<BScreen *> ScreenList; | 178 | typedef std::list<BScreen *> ScreenList; |
179 | const ScreenList screenList() const { return m_screen_list; } | 179 | const ScreenList screenList() const { return m_screen_list; } |
@@ -226,7 +226,7 @@ private: | |||
226 | /// Called when a window layer changes | 226 | /// Called when a window layer changes |
227 | void windowLayerChanged(FluxboxWindow &win); | 227 | void windowLayerChanged(FluxboxWindow &win); |
228 | 228 | ||
229 | std::auto_ptr<lua::state> m_l; | 229 | std::auto_ptr<FbTk::Lua> m_l; |
230 | std::auto_ptr<FbAtoms> m_fbatoms; | 230 | std::auto_ptr<FbAtoms> m_fbatoms; |
231 | 231 | ||
232 | FbTk::LResourceManager m_resourcemanager; | 232 | FbTk::LResourceManager m_resourcemanager; |