From e45194209f6fb9a71e44a976f7698af792968ae0 Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 14 Jun 2006 00:25:54 +0000 Subject: [PATCH] Macros for building protocol commands. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@665 38d2e660-2303-0410-9eaa-f027e97ec537 --- app/triface/cmd_ctor.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 app/triface/cmd_ctor.h diff --git a/app/triface/cmd_ctor.h b/app/triface/cmd_ctor.h new file mode 100755 index 00000000..bf4f3fb5 --- /dev/null +++ b/app/triface/cmd_ctor.h @@ -0,0 +1,36 @@ +/** + * \file + * + * + * \brief Macro for defining command for protocol. + * + * + * \version $Id$ + * + * \author Marco Benelli + */ +#ifndef CMD_CTOR_H +#define CMD_CTOR_H + +#include + +#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 -- 2.25.1