From 3a5fd7342d6cfd00acafeec4c1f35948a550e4ab Mon Sep 17 00:00:00 2001
From: Mark Tiefenbruck <mark@fluxbox.org>
Date: Thu, 17 Jan 2008 14:16:58 -0800
Subject: use function pointer for CommandParser::Command

---
 src/CommandDialog.cc      |  4 ++--
 src/FbTk/CommandParser.hh | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/CommandDialog.cc b/src/CommandDialog.cc
index 346a1a4..37e7bdd 100644
--- a/src/CommandDialog.cc
+++ b/src/CommandDialog.cc
@@ -167,8 +167,8 @@ void CommandDialog::tabComplete() {
             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) {
diff --git a/src/FbTk/CommandParser.hh b/src/FbTk/CommandParser.hh
index 89cac7d..006036d 100644
--- a/src/FbTk/CommandParser.hh
+++ b/src/FbTk/CommandParser.hh
@@ -32,7 +32,7 @@ namespace FbTk {
 // 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 @@ Command<Type> *CommandCreator(const string &name, const string &args,
 
 #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 @@ Command<Type> *CommandCreatorWithArgs(const string &name, const string &args,
 
 #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 @@ Command<Type> *UntrustedCommandCreator(const string &name, const string &args,
 
 #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 @@ Command<Type> *UntrustedCommandCreatorWithArgs(const string &name,
 
 #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 @@ public:
     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 @@ public:
 
     bool registerCommand(string name, Creator creator) {
         name = StringUtil::toLower(name);
-        return ObjectRegistry<Creator *>::instance().registerObject(name,
+        return ObjectRegistry<Creator>::instance().registerObject(name,
                                                                   creator);
     }
 
-- 
cgit v0.11.2