diff options
Diffstat (limited to 'src/FbTk/CommandParser.hh')
-rw-r--r-- | src/FbTk/CommandParser.hh | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/FbTk/CommandParser.hh b/src/FbTk/CommandParser.hh index 3e40ed6..030b6e0 100644 --- a/src/FbTk/CommandParser.hh +++ b/src/FbTk/CommandParser.hh | |||
@@ -33,9 +33,7 @@ namespace FbTk { | |||
33 | 33 | ||
34 | // helper for registering a function to parse arguments | 34 | // helper for registering a function to parse arguments |
35 | #define REGISTER_COMMAND_PARSER(name, parser, type) \ | 35 | #define REGISTER_COMMAND_PARSER(name, parser, type) \ |
36 | namespace { \ | 36 | static const bool p_register_command_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &parser) |
37 | static const bool p_register_command_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &parser); \ | ||
38 | } | ||
39 | 37 | ||
40 | // include some basic Command<void> creators | 38 | // include some basic Command<void> creators |
41 | template <typename ClassName, typename Type> | 39 | template <typename ClassName, typename Type> |
@@ -45,9 +43,7 @@ Command<Type> *CommandCreator(const string &name, const string &args, | |||
45 | } | 43 | } |
46 | 44 | ||
47 | #define REGISTER_COMMAND(name, classname, type) \ | 45 | #define REGISTER_COMMAND(name, classname, type) \ |
48 | namespace { \ | 46 | static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::CommandCreator<classname, type>) |
49 | static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::CommandCreator<classname, type>); \ | ||
50 | } | ||
51 | 47 | ||
52 | template <typename ClassName, typename Type> | 48 | template <typename ClassName, typename Type> |
53 | Command<Type> *CommandCreatorWithArgs(const string &name, const string &args, | 49 | Command<Type> *CommandCreatorWithArgs(const string &name, const string &args, |
@@ -56,9 +52,7 @@ Command<Type> *CommandCreatorWithArgs(const string &name, const string &args, | |||
56 | } | 52 | } |
57 | 53 | ||
58 | #define REGISTER_COMMAND_WITH_ARGS(name, classname, type) \ | 54 | #define REGISTER_COMMAND_WITH_ARGS(name, classname, type) \ |
59 | namespace { \ | 55 | static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::CommandCreatorWithArgs<classname, type>) |
60 | static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::CommandCreatorWithArgs<classname, type>); \ | ||
61 | } | ||
62 | 56 | ||
63 | template <typename ClassName, typename Type> | 57 | template <typename ClassName, typename Type> |
64 | Command<Type> *UntrustedCommandCreator(const string &name, const string &args, | 58 | Command<Type> *UntrustedCommandCreator(const string &name, const string &args, |
@@ -68,9 +62,7 @@ Command<Type> *UntrustedCommandCreator(const string &name, const string &args, | |||
68 | } | 62 | } |
69 | 63 | ||
70 | #define REGISTER_UNTRUSTED_COMMAND(name, classname, type) \ | 64 | #define REGISTER_UNTRUSTED_COMMAND(name, classname, type) \ |
71 | namespace { \ | 65 | static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::UntrustedCommandCreator<classname, type>) |
72 | static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::UntrustedCommandCreator<classname, type>); \ | ||
73 | } | ||
74 | 66 | ||
75 | template <typename ClassName, typename Type> | 67 | template <typename ClassName, typename Type> |
76 | Command<Type> *UntrustedCommandCreatorWithArgs(const string &name, | 68 | Command<Type> *UntrustedCommandCreatorWithArgs(const string &name, |
@@ -80,9 +72,7 @@ Command<Type> *UntrustedCommandCreatorWithArgs(const string &name, | |||
80 | } | 72 | } |
81 | 73 | ||
82 | #define REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(name, classname, type) \ | 74 | #define REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(name, classname, type) \ |
83 | namespace { \ | 75 | static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::UntrustedCommandCreatorWithArgs<classname, type>) |
84 | static const bool p_register_##type_##name = FbTk::CommandParser<type>::instance().registerCommand(#name, &FbTk::UntrustedCommandCreatorWithArgs<classname, type>); \ | ||
85 | } | ||
86 | 76 | ||
87 | template <typename Type> | 77 | template <typename Type> |
88 | class CommandParser { | 78 | class CommandParser { |