add more command_handler conversion macros
authorZachary T Welch <zw@superlucidity.net>
Sun, 15 Nov 2009 12:18:51 +0000 (04:18 -0800)
committerZachary T Welch <zw@superlucidity.net>
Tue, 17 Nov 2009 19:38:06 +0000 (11:38 -0800)
Add additional macros to allow command handling to be migrated easily:
CMD_CTX, CMD_ARGC, and CMD_ARGV.  Updates CMD_NAME to use CMD_ARGV.

In addition to making the remaining patches of this series cleaner,
this introduces easily sed-able symbols that could allow us to retire
these once the command handler infrastructure matures (i.e. pre-1.0).

src/helper/command.h

index 79e57f5ab1e6cd0214f93dc438937737be6dc84c..3e3662752a49975a829682f81bea1986f485e8ab 100644 (file)
@@ -121,11 +121,26 @@ struct command_context
  */
 #define COMMAND_HELPER(name, extra...) __COMMAND_HANDLER(name, extra)
 
+/**
+ * Use this macro to access the context of the command being handled,
+ * rather than accessing the variable directly.  It may be moved.
+ */
+#define CMD_CTX cmd_ctx
+/**
+ * Use this macro to access the number of arguments for the command being
+ * handled, rather than accessing the variable directly.  It may be moved.
+ */
+#define CMD_ARGC argc
+/**
+ * Use this macro to access the arguments for the command being handled,
+ * rather than accessing the variable directly.  It may be moved.
+ */
+#define CMD_ARGV args
 /**
  * Use this macro to access the name of the command being handled,
  * rather than accessing the variable directly.  It may be moved.
  */
-#define CMD_NAME args[-1]
+#define CMD_NAME CMD_ARGV[-1]
 
 
 /// The type signature for commands' handler functions.