Macros for building protocol commands.
authormarco <marco@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 14 Jun 2006 00:25:54 +0000 (00:25 +0000)
committermarco <marco@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 14 Jun 2006 00:25:54 +0000 (00:25 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@665 38d2e660-2303-0410-9eaa-f027e97ec537

app/triface/cmd_ctor.h [new file with mode: 0755]

diff --git a/app/triface/cmd_ctor.h b/app/triface/cmd_ctor.h
new file mode 100755 (executable)
index 0000000..bf4f3fb
--- /dev/null
@@ -0,0 +1,36 @@
+/**
+ * \file
+ * <!--
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * -->
+ *
+ * \brief Macro for defining command for protocol.
+ *
+ *
+ * \version $Id$
+ *
+ * \author Marco Benelli <marco@develer.com>
+ */
+#ifndef CMD_CTOR_H
+#define CMD_CTOR_H
+
+#include <mware/parser.h>
+
+#define REGISTER_FUNCTION parser_register_cmd
+
+#define REGISTER_CMD(NAME) REGISTER_FUNCTION(&cmd_ ## NAME ## _template)
+
+#define MAKE_TEMPLATE(NAME, ARGS, RES)                                 \
+const struct CmdTemplate cmd_ ## NAME ## _template =                   \
+{                                                                      \
+       #NAME, ARGS, RES, cmd_ ## NAME, 0                               \
+};
+
+#define MAKE_CMD(NAME, ARGS, RES, BODY)                                        \
+static ResultCode cmd_ ## NAME (parms *args)                           \
+{                                                                      \
+       return BODY;                                                    \
+}                                                                      \
+MAKE_TEMPLATE(NAME, ARGS, RES)
+
+#endif // CMD_CTOR_H