all repos — fluxbox @ 3a5fd7342d6cfd00acafeec4c1f35948a550e4ab

custom fork of the fluxbox windowmanager

use function pointer for CommandParser::Command
Mark Tiefenbruck mark@fluxbox.org
commit

3a5fd7342d6cfd00acafeec4c1f35948a550e4ab

parent

c6099d777d844699fb8a4243921159898bc4f45c

2 files changed, 10 insertions(+), 10 deletions(-)

jump to
M src/CommandDialog.ccsrc/CommandDialog.cc

@@ -167,8 +167,8 @@ XBell(FbTk::App::instance()->display(), 0);

return; } - FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator *>::CreatorMap::const_iterator it = FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator *>::instance().creatorMap().begin(); - const FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator *>::CreatorMap::const_iterator it_end = FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator *>::instance().creatorMap().end(); + FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator>::CreatorMap::const_iterator it = FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator>::instance().creatorMap().begin(); + const FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator>::CreatorMap::const_iterator it_end = FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator>::instance().creatorMap().end(); vector<string> matches; for (; it != it_end; ++it) { if ((*it).first.find(prefix) == 0) {
M src/FbTk/CommandParser.hhsrc/FbTk/CommandParser.hh

@@ -32,7 +32,7 @@

// helper for registering a function to parse arguments #define REGISTER_COMMAND_PARSER(name, parser, type) \ namespace { \ - static const bool p_register_command_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, parser); \ + static const bool p_register_command_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &parser); \ } // include some basic Command<void> creators

@@ -44,7 +44,7 @@ }

#define REGISTER_COMMAND(name, classname, type) \ namespace { \ - static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, FbTk::CommandCreator<classname, type>); \ + static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::CommandCreator<classname, type>); \ } template <typename ClassName, typename Type>

@@ -55,7 +55,7 @@ }

#define REGISTER_COMMAND_WITH_ARGS(name, classname, type) \ namespace { \ - static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, FbTk::CommandCreatorWithArgs<classname, type>); \ + static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::CommandCreatorWithArgs<classname, type>); \ } template <typename ClassName, typename Type>

@@ -67,7 +67,7 @@ }

#define REGISTER_UNTRUSTED_COMMAND(name, classname, type) \ namespace { \ - static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, FbTk::UntrustedCommandCreator<classname, type>); \ + static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::UntrustedCommandCreator<classname, type>); \ } template <typename ClassName, typename Type>

@@ -79,13 +79,13 @@ }

#define REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(name, classname, type) \ namespace { \ - static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, FbTk::UntrustedCommandCreatorWithArgs<classname, type>); \ + static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::UntrustedCommandCreatorWithArgs<classname, type>); \ } template <typename Type> class CommandParser { public: - typedef Command<Type> *Creator(const string &, const string &, bool); + typedef Command<Type> *(*Creator)(const string &, const string &, bool); static CommandParser<Type> &instance() { static CommandParser<Type> s_instance;

@@ -95,7 +95,7 @@

Command<Type> *parse(const string &name, const string &args, bool trusted = true) const { string lc = StringUtil::toLower(name); - Creator *creator = ObjectRegistry<Creator *>::instance().lookup(lc); + Creator creator = ObjectRegistry<Creator>::instance().lookup(lc); if (creator) return creator(lc, args, trusted); return 0;

@@ -114,7 +114,7 @@ }

bool registerCommand(string name, Creator creator) { name = StringUtil::toLower(name); - return ObjectRegistry<Creator *>::instance().registerObject(name, + return ObjectRegistry<Creator>::instance().registerObject(name, creator); }