From fbe83efc8183980109846bd884da28104ca1faa1 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周五, 16 10月 2015 06:48:56 +0800 Subject: [PATCH] Add USE_COMMAND_TAGS and USE_DEPRECATED_FUNCTIONS defines --- libscpi/inc/scpi/types.h | 2 ++ libscpi/src/parser.c | 2 ++ libscpi/inc/scpi/config.h | 8 ++++++++ libscpi/src/expression.c | 2 +- libscpi/inc/scpi/parser.h | 14 +++++++++----- examples/test-tcp-srq/main.c | 2 +- 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/examples/test-tcp-srq/main.c b/examples/test-tcp-srq/main.c index 5cd5074..b2f53d4 100644 --- a/examples/test-tcp-srq/main.c +++ b/examples/test-tcp-srq/main.c @@ -112,7 +112,7 @@ } scpi_result_t SCPI_SystemCommTcpipControlQ(scpi_t * context) { - SCPI_ResultInt(context, CONTROL_PORT); + SCPI_ResultInt32(context, CONTROL_PORT); return SCPI_RES_OK; } diff --git a/libscpi/inc/scpi/config.h b/libscpi/inc/scpi/config.h index c3f4e7e..b57d748 100644 --- a/libscpi/inc/scpi/config.h +++ b/libscpi/inc/scpi/config.h @@ -89,6 +89,14 @@ #define USE_USER_ERROR_LIST 0 #endif +#ifndef USE_COMMAND_TAGS +#define USE_COMMAND_TAGS 1 +#endif + +#ifndef USE_DEPRECATED_FUNCTIONS +#define USE_DEPRECATED_FUNCTIONS 1 +#endif + /* Compiler specific */ /* RealView/Keil ARM Compiler, e.g. Cortex-M CPUs */ #if defined(__CC_ARM) diff --git a/libscpi/inc/scpi/parser.h b/libscpi/inc/scpi/parser.h index 1e26a6b..b645dfe 100644 --- a/libscpi/inc/scpi/parser.h +++ b/libscpi/inc/scpi/parser.h @@ -2,7 +2,7 @@ * Copyright (c) 2012-2013 Jan Breuer, * * All Rights Reserved - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -11,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -28,10 +28,10 @@ /** * @file scpi_parser.h * @date Thu Nov 15 10:58:45 UTC 2012 - * + * * @brief SCPI parser implementation - * - * + * + * */ #ifndef SCPI_PARSER_H @@ -87,10 +87,13 @@ scpi_bool_t SCPI_ParamChoice(scpi_t * context, const scpi_choice_def_t * options, int32_t * value, scpi_bool_t mandatory); scpi_bool_t SCPI_IsCmd(scpi_t * context, const char * cmd); +#if USE_COMMAND_TAGS int32_t SCPI_CmdTag(scpi_t * context); +#endif /* USE_COMMAND_TAGS */ scpi_bool_t SCPI_Match(const char * pattern, const char * value, size_t len); scpi_bool_t SCPI_CommandNumbers(scpi_t * context, int32_t * numbers, size_t len, int32_t default_value); +#if USE_DEPRECATED_FUNCTIONS // deprecated finction, should be removed later #define SCPI_ResultIntBase(context, val, base) SCPI_ResultInt32Base ((context), (val), (base), TRUE) #define SCPI_ResultInt(context, val) SCPI_ResultInt32 ((context), (val)) @@ -98,6 +101,7 @@ #define SCPI_ParamToUnsignedInt(context, parameter, value) SCPI_ParamToUInt32((context), (parameter), (value)) #define SCPI_ParamInt(context, value, mandatory) SCPI_ParamInt32((context), (value), (mandatory)) #define SCPI_ParamUnsignedInt(context, value, mandatory) SCPI_ParamUInt32((context), (value), (mandatory)) +#endif /* USE_DEPRECATED_FUNCTIONS */ #ifdef __cplusplus } diff --git a/libscpi/inc/scpi/types.h b/libscpi/inc/scpi/types.h index fab9b37..38ee018 100644 --- a/libscpi/inc/scpi/types.h +++ b/libscpi/inc/scpi/types.h @@ -276,7 +276,9 @@ struct _scpi_command_t { const char * pattern; scpi_command_callback_t callback; +#if USE_COMMAND_TAGS int32_t tag; +#endif /* USE_COMMAND_TAGS */ }; struct _scpi_interface_t { diff --git a/libscpi/src/expression.c b/libscpi/src/expression.c index 1b8cb2e..010b40b 100644 --- a/libscpi/src/expression.c +++ b/libscpi/src/expression.c @@ -193,7 +193,7 @@ size_t i = 0; while (scpiLex_DecimalNumericProgramData(state, ¶m)) { if (i < length) { - SCPI_ParamToInt(context, ¶m, &values[i]); + SCPI_ParamToInt32(context, ¶m, &values[i]); } if (scpiLex_SpecificCharacter(state, ¶m, '!')) { diff --git a/libscpi/src/parser.c b/libscpi/src/parser.c index b040c5e..62dc151 100644 --- a/libscpi/src/parser.c +++ b/libscpi/src/parser.c @@ -1350,6 +1350,7 @@ return matchCommand(pattern, cmd, strlen(cmd), NULL, 0, 0); } +#if USE_COMMAND_TAGS /** * Return the .tag field of the matching scpi_command_t * @param context @@ -1362,6 +1363,7 @@ return 0; } } +#endif /* USE_COMMAND_TAGS */ scpi_bool_t SCPI_Match(const char * pattern, const char * value, size_t len) { return matchCommand(pattern, value, len, NULL, 0, 0); -- Gitblit v1.9.1