aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CommandDialog.cc4
-rw-r--r--src/FbTk/CommandParser.hh16
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() {
167 return; 167 return;
168 } 168 }
169 169
170 FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator *>::CreatorMap::const_iterator it = FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator *>::instance().creatorMap().begin(); 170 FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator>::CreatorMap::const_iterator it = FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator>::instance().creatorMap().begin();
171 const FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator *>::CreatorMap::const_iterator it_end = FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator *>::instance().creatorMap().end(); 171 const FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator>::CreatorMap::const_iterator it_end = FbTk::ObjectRegistry<FbTk::CommandParser<void>::Creator>::instance().creatorMap().end();
172 vector<string> matches; 172 vector<string> matches;
173 for (; it != it_end; ++it) { 173 for (; it != it_end; ++it) {
174 if ((*it).first.find(prefix) == 0) { 174 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 {
32// helper for registering a function to parse arguments 32// helper for registering a function to parse arguments
33#define REGISTER_COMMAND_PARSER(name, parser, type) \ 33#define REGISTER_COMMAND_PARSER(name, parser, type) \
34 namespace { \ 34 namespace { \
35 static const bool p_register_command_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, parser); \ 35 static const bool p_register_command_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &parser); \
36 } 36 }
37 37
38// include some basic Command<void> creators 38// include some basic Command<void> creators
@@ -44,7 +44,7 @@ Command<Type> *CommandCreator(const string &name, const string &args,
44 44
45#define REGISTER_COMMAND(name, classname, type) \ 45#define REGISTER_COMMAND(name, classname, type) \
46 namespace { \ 46 namespace { \
47 static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, FbTk::CommandCreator<classname, type>); \ 47 static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::CommandCreator<classname, type>); \
48 } 48 }
49 49
50template <typename ClassName, typename Type> 50template <typename ClassName, typename Type>
@@ -55,7 +55,7 @@ Command<Type> *CommandCreatorWithArgs(const string &name, const string &args,
55 55
56#define REGISTER_COMMAND_WITH_ARGS(name, classname, type) \ 56#define REGISTER_COMMAND_WITH_ARGS(name, classname, type) \
57 namespace { \ 57 namespace { \
58 static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, FbTk::CommandCreatorWithArgs<classname, type>); \ 58 static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::CommandCreatorWithArgs<classname, type>); \
59 } 59 }
60 60
61template <typename ClassName, typename Type> 61template <typename ClassName, typename Type>
@@ -67,7 +67,7 @@ Command<Type> *UntrustedCommandCreator(const string &name, const string &args,
67 67
68#define REGISTER_UNTRUSTED_COMMAND(name, classname, type) \ 68#define REGISTER_UNTRUSTED_COMMAND(name, classname, type) \
69 namespace { \ 69 namespace { \
70 static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, FbTk::UntrustedCommandCreator<classname, type>); \ 70 static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::UntrustedCommandCreator<classname, type>); \
71 } 71 }
72 72
73template <typename ClassName, typename Type> 73template <typename ClassName, typename Type>
@@ -79,13 +79,13 @@ Command<Type> *UntrustedCommandCreatorWithArgs(const string &name,
79 79
80#define REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(name, classname, type) \ 80#define REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(name, classname, type) \
81 namespace { \ 81 namespace { \
82 static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, FbTk::UntrustedCommandCreatorWithArgs<classname, type>); \ 82 static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::UntrustedCommandCreatorWithArgs<classname, type>); \
83 } 83 }
84 84
85template <typename Type> 85template <typename Type>
86class CommandParser { 86class CommandParser {
87public: 87public:
88 typedef Command<Type> *Creator(const string &, const string &, bool); 88 typedef Command<Type> *(*Creator)(const string &, const string &, bool);
89 89
90 static CommandParser<Type> &instance() { 90 static CommandParser<Type> &instance() {
91 static CommandParser<Type> s_instance; 91 static CommandParser<Type> s_instance;
@@ -95,7 +95,7 @@ public:
95 Command<Type> *parse(const string &name, const string &args, 95 Command<Type> *parse(const string &name, const string &args,
96 bool trusted = true) const { 96 bool trusted = true) const {
97 string lc = StringUtil::toLower(name); 97 string lc = StringUtil::toLower(name);
98 Creator *creator = ObjectRegistry<Creator *>::instance().lookup(lc); 98 Creator creator = ObjectRegistry<Creator>::instance().lookup(lc);
99 if (creator) 99 if (creator)
100 return creator(lc, args, trusted); 100 return creator(lc, args, trusted);
101 return 0; 101 return 0;
@@ -114,7 +114,7 @@ public:
114 114
115 bool registerCommand(string name, Creator creator) { 115 bool registerCommand(string name, Creator creator) {
116 name = StringUtil::toLower(name); 116 name = StringUtil::toLower(name);
117 return ObjectRegistry<Creator *>::instance().registerObject(name, 117 return ObjectRegistry<Creator>::instance().registerObject(name,
118 creator); 118 creator);
119 } 119 }
120 120