A modelling and serializer library for Microsoft Azure IoTHub client applications

Dependents:   sht15_remote_monitoring f767zi_mqtt remote_monitoring simplesample_amqp ... more

This library implements a serializer library to be used in projects involving Microsoft Azure IoT Hub connectivity. The code is replicated from https://github.com/Azure/azure-iot-sdks

Committer:
AzureIoTClient
Date:
Tue Mar 20 10:30:45 2018 -0700
Revision:
32:4de3e6f83424
Parent:
26:7c0e6f86d034
Child:
36:7d12a5386197
1.2.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzureIoTClient 4:233dd7616d73 1 // Copyright (c) Microsoft. All rights reserved.
AzureIoTClient 4:233dd7616d73 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
AzureIoTClient 4:233dd7616d73 3
AzureIoTClient 4:233dd7616d73 4 /** @file serializer.h
AzureIoTClient 4:233dd7616d73 5 * @brief The IoT Hub Serializer APIs allows developers to define models for
AzureIoTClient 4:233dd7616d73 6 * their devices
AzureIoTClient 4:233dd7616d73 7 *
AzureIoTClient 4:233dd7616d73 8 * @details The IoT Hub Serializer APIs allows developers to quickly and easily define
AzureIoTClient 4:233dd7616d73 9 * models for their devices directly as code, while supporting the required
AzureIoTClient 4:233dd7616d73 10 * features for modeling devices (including multiple models and multiple
AzureIoTClient 4:233dd7616d73 11 * devices within the same application). For example:
AzureIoTClient 4:233dd7616d73 12 *
AzureIoTClient 4:233dd7616d73 13 * <pre>
AzureIoTClient 4:233dd7616d73 14 * BEGIN_NAMESPACE(Contoso);
AzureIoTClient 4:233dd7616d73 15 *
AzureIoTClient 4:233dd7616d73 16 * DECLARE_STRUCT(SystemProperties,
AzureIoTClient 4:233dd7616d73 17 * ascii_char_ptr, DeviceID,
AzureIoTClient 4:233dd7616d73 18 * _Bool, Enabled
AzureIoTClient 4:233dd7616d73 19 * );
AzureIoTClient 4:233dd7616d73 20 *
AzureIoTClient 4:233dd7616d73 21 * DECLARE_MODEL(VendingMachine,
AzureIoTClient 4:233dd7616d73 22 *
AzureIoTClient 4:233dd7616d73 23 * WITH_DATA(int, SensorValue),
AzureIoTClient 4:233dd7616d73 24 *
AzureIoTClient 4:233dd7616d73 25 * WITH_DATA(ascii_char_ptr, ObjectName),
AzureIoTClient 4:233dd7616d73 26 * WITH_DATA(ascii_char_ptr, ObjectType),
AzureIoTClient 4:233dd7616d73 27 * WITH_DATA(ascii_char_ptr, Version),
AzureIoTClient 4:233dd7616d73 28 * WITH_DATA(SystemProperties, SystemProperties),
AzureIoTClient 4:233dd7616d73 29 * WITH_DATA(ascii_char_ptr_no_quotes, Commands),
AzureIoTClient 4:233dd7616d73 30 *
AzureIoTClient 4:233dd7616d73 31 * WITH_ACTION(SetItemPrice, ascii_char_ptr, itemId, ascii_char_ptr, price)
AzureIoTClient 4:233dd7616d73 32 * );
AzureIoTClient 4:233dd7616d73 33 *
AzureIoTClient 4:233dd7616d73 34 * END_NAMESPACE(Contoso);
AzureIoTClient 4:233dd7616d73 35 * </pre>
AzureIoTClient 4:233dd7616d73 36 */
AzureIoTClient 4:233dd7616d73 37
AzureIoTClient 4:233dd7616d73 38 #ifndef SERIALIZER_H
AzureIoTClient 4:233dd7616d73 39 #define SERIALIZER_H
AzureIoTClient 4:233dd7616d73 40
AzureIoTClient 4:233dd7616d73 41 #ifdef __cplusplus
AzureIoTClient 4:233dd7616d73 42 #include <cstdlib>
AzureIoTClient 4:233dd7616d73 43 #include <cstdarg>
AzureIoTClient 4:233dd7616d73 44
AzureIoTClient 4:233dd7616d73 45 #else
AzureIoTClient 4:233dd7616d73 46 #include <stdlib.h>
AzureIoTClient 4:233dd7616d73 47 #include <stdarg.h>
AzureIoTClient 4:233dd7616d73 48 #endif
AzureIoTClient 4:233dd7616d73 49
Azure.IoT Build 10:c2aee3965a83 50 #include "azure_c_shared_utility/gballoc.h"
Azure.IoT Build 10:c2aee3965a83 51 #include "azure_c_shared_utility/macro_utils.h"
AzureIoTClient 4:233dd7616d73 52 #include "iotdevice.h"
Azure.IoT Build 10:c2aee3965a83 53 #include "azure_c_shared_utility/crt_abstractions.h"
Azure.IoT Build 13:16e88f0cfa5f 54 #include "azure_c_shared_utility/xlogging.h"
Azure.IoT.Build 18:58b667752399 55 #include "methodreturn.h"
AzureIoTClient 4:233dd7616d73 56 #include "schemalib.h"
AzureIoTClient 4:233dd7616d73 57 #include "codefirst.h"
AzureIoTClient 4:233dd7616d73 58 #include "agenttypesystem.h"
AzureIoTClient 4:233dd7616d73 59 #include "schema.h"
AzureIoTClient 4:233dd7616d73 60
AzureIoTClient 4:233dd7616d73 61
Azure.IoT.Build 18:58b667752399 62
AzureIoTClient 4:233dd7616d73 63 #ifdef __cplusplus
AzureIoTClient 4:233dd7616d73 64 extern "C"
AzureIoTClient 4:233dd7616d73 65 {
AzureIoTClient 4:233dd7616d73 66 #endif
AzureIoTClient 4:233dd7616d73 67
AzureIoTClient 17:fa1bba4c6053 68 /* IOT Agent Macros */
AzureIoTClient 4:233dd7616d73 69
AzureIoTClient 17:fa1bba4c6053 70 /**
AzureIoTClient 17:fa1bba4c6053 71 * @def BEGIN_NAMESPACE(schemaNamespace)
AzureIoTClient 17:fa1bba4c6053 72 * This macro marks the start of a section that declares IOT model
AzureIoTClient 17:fa1bba4c6053 73 * elements (like complex types, etc.). Declarations are typically
AzureIoTClient 17:fa1bba4c6053 74 * placed in header files, so that they can be shared between
AzureIoTClient 17:fa1bba4c6053 75 * translation units.
AzureIoTClient 17:fa1bba4c6053 76 */
AzureIoTClient 17:fa1bba4c6053 77 /* Codes_SRS_SERIALIZER_99_001:[For each completed schema declaration block, a unique storage container for schema metadata shall be available in the translation unit at runtime.] */
AzureIoTClient 4:233dd7616d73 78 #define BEGIN_NAMESPACE(schemaNamespace) \
AzureIoTClient 4:233dd7616d73 79 REFLECTED_END_OF_LIST
AzureIoTClient 4:233dd7616d73 80
AzureIoTClient 4:233dd7616d73 81 /**
AzureIoTClient 4:233dd7616d73 82 * @def END_NAMESPACE(schemaNamespace)
AzureIoTClient 4:233dd7616d73 83 * This macro marks the end of a section that declares IOT model
AzureIoTClient 4:233dd7616d73 84 * elements.
AzureIoTClient 4:233dd7616d73 85 */
AzureIoTClient 4:233dd7616d73 86 #define END_NAMESPACE(schemaNamespace) \
AzureIoTClient 4:233dd7616d73 87 REFLECTED_LIST_HEAD(schemaNamespace)
AzureIoTClient 4:233dd7616d73 88
AzureIoTClient 17:fa1bba4c6053 89 #define GLOBAL_INITIALIZE_STRUCT_FIELD(structType, destination, type, name) GlobalInitialize_##type((char*)destination+offsetof(structType, name));
AzureIoTClient 17:fa1bba4c6053 90 #define GLOBAL_DEINITIALIZE_STRUCT_FIELD(structType, destination, type, name) GlobalDeinitialize_##type((char*)destination+offsetof(structType, name));
AzureIoTClient 4:233dd7616d73 91 /**
AzureIoTClient 4:233dd7616d73 92 * @def DECLARE_STRUCT(name, ...)
AzureIoTClient 4:233dd7616d73 93 * This macro allows the definition of a struct type that can then be used as
AzureIoTClient 4:233dd7616d73 94 * part of a model definition.
AzureIoTClient 17:fa1bba4c6053 95 *
AzureIoTClient 4:233dd7616d73 96 * @param name Name of the struct
AzureIoTClient 4:233dd7616d73 97 * @param element1, element2... Specifies a list of struct members
AzureIoTClient 4:233dd7616d73 98 */
AzureIoTClient 4:233dd7616d73 99 /* Codes_SRS_SERIALIZER_99_080:[ The DECLARE_STRUCT declaration shall insert metadata describing a complex data type.] */
AzureIoTClient 4:233dd7616d73 100 #define DECLARE_STRUCT(name, ...) \
AzureIoTClient 4:233dd7616d73 101 /* Codes_SRS_SERIALIZER_99_096:[ DECLARE_STRUCT shall declare a matching C struct data type named name, which can be referenced from any code that can access the declaration.] */ \
AzureIoTClient 4:233dd7616d73 102 typedef struct name##_TAG { \
AzureIoTClient 4:233dd7616d73 103 FOR_EACH_2(INSERT_FIELD_INTO_STRUCT, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 104 } name; \
AzureIoTClient 4:233dd7616d73 105 /* Codes_SRS_SERIALIZER_99_081:[ DECLARE_STRUCT's name argument shall uniquely identify the struct within the schema.] */ \
AzureIoTClient 4:233dd7616d73 106 REFLECTED_STRUCT(name) \
AzureIoTClient 4:233dd7616d73 107 /* Codes_SRS_SERIALIZER_99_082:[ DECLARE_STRUCT's field<n>Name argument shall uniquely name a field within the struct.] */ \
AzureIoTClient 4:233dd7616d73 108 FOR_EACH_2_KEEP_1(REFLECTED_FIELD, name, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 109 TO_AGENT_DATA_TYPE(name, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 110 /*Codes_SRS_SERIALIZER_99_042:[ The parameter types are either predefined parameter types (specs SRS_SERIALIZER_99_004-SRS_SERIALIZER_99_014) or a type introduced by DECLARE_STRUCT.]*/ \
AzureIoTClient 4:233dd7616d73 111 static AGENT_DATA_TYPES_RESULT FromAGENT_DATA_TYPE_##name(const AGENT_DATA_TYPE* source, name* destination) \
AzureIoTClient 4:233dd7616d73 112 { \
AzureIoTClient 4:233dd7616d73 113 AGENT_DATA_TYPES_RESULT result; \
AzureIoTClient 4:233dd7616d73 114 if(source->type != EDM_COMPLEX_TYPE_TYPE) \
AzureIoTClient 4:233dd7616d73 115 { \
AzureIoTClient 4:233dd7616d73 116 result = AGENT_DATA_TYPES_INVALID_ARG; \
AzureIoTClient 4:233dd7616d73 117 } \
AzureIoTClient 4:233dd7616d73 118 else if(DIV2(COUNT_ARG(__VA_ARGS__)) != source->value.edmComplexType.nMembers) \
AzureIoTClient 4:233dd7616d73 119 { \
AzureIoTClient 4:233dd7616d73 120 /*too many or too few fields*/ \
AzureIoTClient 4:233dd7616d73 121 result = AGENT_DATA_TYPES_INVALID_ARG; \
AzureIoTClient 4:233dd7616d73 122 } \
AzureIoTClient 4:233dd7616d73 123 else \
AzureIoTClient 4:233dd7616d73 124 { \
AzureIoTClient 4:233dd7616d73 125 result = AGENT_DATA_TYPES_OK; \
AzureIoTClient 4:233dd7616d73 126 FOR_EACH_2(BUILD_DESTINATION_FIELD, __VA_ARGS__); \
AzureIoTClient 4:233dd7616d73 127 } \
AzureIoTClient 4:233dd7616d73 128 return result; \
AzureIoTClient 4:233dd7616d73 129 } \
AzureIoTClient 4:233dd7616d73 130 static void C2(destroyLocalParameter, name)(name * value) \
AzureIoTClient 4:233dd7616d73 131 { \
AzureIoTClient 4:233dd7616d73 132 FOR_EACH_2_KEEP_1(UNBUILD_DESTINATION_FIELD, value, __VA_ARGS__); \
AzureIoTClient 17:fa1bba4c6053 133 } \
AzureIoTClient 17:fa1bba4c6053 134 static void C2(GlobalInitialize_, name)(void* destination) \
AzureIoTClient 17:fa1bba4c6053 135 { \
AzureIoTClient 17:fa1bba4c6053 136 FOR_EACH_2_KEEP_2(GLOBAL_INITIALIZE_STRUCT_FIELD, name, destination, __VA_ARGS__); \
AzureIoTClient 17:fa1bba4c6053 137 } \
AzureIoTClient 17:fa1bba4c6053 138 static void C2(GlobalDeinitialize_, name)(void* destination) \
AzureIoTClient 17:fa1bba4c6053 139 { \
AzureIoTClient 17:fa1bba4c6053 140 FOR_EACH_2_KEEP_2(GLOBAL_DEINITIALIZE_STRUCT_FIELD, name, destination, __VA_ARGS__); \
AzureIoTClient 17:fa1bba4c6053 141 } \
AzureIoTClient 17:fa1bba4c6053 142
AzureIoTClient 4:233dd7616d73 143
AzureIoTClient 4:233dd7616d73 144 /**
AzureIoTClient 4:233dd7616d73 145 * @def DECLARE_MODEL(name, ...)
AzureIoTClient 4:233dd7616d73 146 * This macro allows declaring a model that can be later used to instantiate
AzureIoTClient 4:233dd7616d73 147 * a device.
AzureIoTClient 17:fa1bba4c6053 148 *
AzureIoTClient 4:233dd7616d73 149 * @param name Specifies the model name
AzureIoTClient 4:233dd7616d73 150 * @param element1, element2... Specifies a model element which can be
AzureIoTClient 4:233dd7616d73 151 * a property or an action.
AzureIoTClient 17:fa1bba4c6053 152 * - A property is described in a
AzureIoTClient 4:233dd7616d73 153 * model by using the WITH_DATA
AzureIoTClient 17:fa1bba4c6053 154 * - An action is described in a
AzureIoTClient 4:233dd7616d73 155 * model by using the ::WITH_ACTION
AzureIoTClient 4:233dd7616d73 156 * macro.
AzureIoTClient 4:233dd7616d73 157 *
AzureIoTClient 4:233dd7616d73 158 */
AzureIoTClient 17:fa1bba4c6053 159 /* WITH_DATA's name argument shall be one of the following data types: */
AzureIoTClient 17:fa1bba4c6053 160 /* Codes_SRS_SERIALIZER_99_133:[a model type introduced previously by DECLARE_MODEL] */
AzureIoTClient 17:fa1bba4c6053 161
AzureIoTClient 17:fa1bba4c6053 162 #define CREATE_DESIRED_PROPERTY_CALLBACK_MODEL_ACTION(...)
Azure.IoT.Build 18:58b667752399 163 #define CREATE_DESIRED_PROPERTY_CALLBACK_MODEL_METHOD(...)
AzureIoTClient 17:fa1bba4c6053 164 #define CREATE_DESIRED_PROPERTY_CALLBACK_MODEL_DESIRED_PROPERTY(type, name, ...) IF(COUNT_ARG(__VA_ARGS__), void __VA_ARGS__ (void*);, )
AzureIoTClient 17:fa1bba4c6053 165 #define CREATE_DESIRED_PROPERTY_CALLBACK_MODEL_PROPERTY(...)
AzureIoTClient 17:fa1bba4c6053 166 #define CREATE_DESIRED_PROPERTY_CALLBACK_MODEL_REPORTED_PROPERTY(...)
AzureIoTClient 17:fa1bba4c6053 167
AzureIoTClient 17:fa1bba4c6053 168 #define CREATE_DESIRED_PROPERTY_CALLBACK(...) CREATE_DESIRED_PROPERTY_CALLBACK_##__VA_ARGS__
AzureIoTClient 17:fa1bba4c6053 169
AzureIoTClient 17:fa1bba4c6053 170 #define SERIALIZER_REGISTER_NAMESPACE(NAMESPACE) CodeFirst_RegisterSchema(#NAMESPACE, & ALL_REFLECTED(NAMESPACE))
AzureIoTClient 17:fa1bba4c6053 171
AzureIoTClient 17:fa1bba4c6053 172 #define DECLARE_MODEL(name, ...) \
AzureIoTClient 17:fa1bba4c6053 173 REFLECTED_MODEL(name) \
AzureIoTClient 17:fa1bba4c6053 174 FOR_EACH_1(CREATE_DESIRED_PROPERTY_CALLBACK, __VA_ARGS__) \
AzureIoTClient 17:fa1bba4c6053 175 typedef struct name { int :1; FOR_EACH_1(BUILD_MODEL_STRUCT, __VA_ARGS__) } name; \
AzureIoTClient 17:fa1bba4c6053 176 FOR_EACH_1_KEEP_1(CREATE_MODEL_ELEMENT, name, __VA_ARGS__) \
AzureIoTClient 17:fa1bba4c6053 177 TO_AGENT_DATA_TYPE(name, DROP_FIRST_COMMA_FROM_ARGS(EXPAND_MODEL_ARGS(__VA_ARGS__))) \
AzureIoTClient 17:fa1bba4c6053 178 int FromAGENT_DATA_TYPE_##name(const AGENT_DATA_TYPE* source, void* destination) \
AzureIoTClient 17:fa1bba4c6053 179 { \
AzureIoTClient 22:422d94bd3c18 180 (void)source; \
AzureIoTClient 22:422d94bd3c18 181 (void)destination; \
AzureIoTClient 17:fa1bba4c6053 182 LogError("SHOULD NOT GET CALLED... EVER"); \
AzureIoTClient 17:fa1bba4c6053 183 return 0; \
AzureIoTClient 17:fa1bba4c6053 184 } \
AzureIoTClient 17:fa1bba4c6053 185 static void C2(GlobalInitialize_, name)(void* destination) \
AzureIoTClient 17:fa1bba4c6053 186 { \
AzureIoTClient 17:fa1bba4c6053 187 (void)destination; \
AzureIoTClient 17:fa1bba4c6053 188 FOR_EACH_1_KEEP_1(CREATE_MODEL_ELEMENT_GLOBAL_INITIALIZE, name, __VA_ARGS__) \
AzureIoTClient 17:fa1bba4c6053 189 } \
AzureIoTClient 17:fa1bba4c6053 190 static void C2(GlobalDeinitialize_, name)(void* destination) \
AzureIoTClient 17:fa1bba4c6053 191 { \
AzureIoTClient 17:fa1bba4c6053 192 (void)destination; \
AzureIoTClient 17:fa1bba4c6053 193 FOR_EACH_1_KEEP_1(CREATE_MODEL_ELEMENT_GLOBAL_DEINITIALIZE, name, __VA_ARGS__) \
AzureIoTClient 17:fa1bba4c6053 194 } \
AzureIoTClient 17:fa1bba4c6053 195
AzureIoTClient 17:fa1bba4c6053 196
AzureIoTClient 4:233dd7616d73 197
AzureIoTClient 4:233dd7616d73 198 /**
AzureIoTClient 4:233dd7616d73 199 * @def WITH_DATA(type, name)
AzureIoTClient 4:233dd7616d73 200 * The ::WITH_DATA macro allows declaring a model property in a model. A
AzureIoTClient 4:233dd7616d73 201 * property can be published by using the ::SERIALIZE macro.
AzureIoTClient 4:233dd7616d73 202 *
AzureIoTClient 4:233dd7616d73 203 * @param type Specifies the property type. Can be any of the following
AzureIoTClient 4:233dd7616d73 204 * types:
AzureIoTClient 4:233dd7616d73 205 * - int
AzureIoTClient 4:233dd7616d73 206 * - double
AzureIoTClient 4:233dd7616d73 207 * - float
AzureIoTClient 4:233dd7616d73 208 * - long
AzureIoTClient 4:233dd7616d73 209 * - int8_t
AzureIoTClient 4:233dd7616d73 210 * - uint8_t
AzureIoTClient 4:233dd7616d73 211 * - int16_t
AzureIoTClient 4:233dd7616d73 212 * - int32_t
AzureIoTClient 4:233dd7616d73 213 * - int64_t
AzureIoTClient 4:233dd7616d73 214 * - bool
AzureIoTClient 4:233dd7616d73 215 * - ascii_char_ptr
AzureIoTClient 4:233dd7616d73 216 * - EDM_DATE_TIME_OFFSET
AzureIoTClient 4:233dd7616d73 217 * - EDM_GUID
AzureIoTClient 4:233dd7616d73 218 * - EDM_BINARY
AzureIoTClient 4:233dd7616d73 219 * - Any struct type previously introduced by another ::DECLARE_STRUCT.
AzureIoTClient 4:233dd7616d73 220 *
AzureIoTClient 4:233dd7616d73 221 * @param name Specifies the property name
AzureIoTClient 4:233dd7616d73 222 */
AzureIoTClient 4:233dd7616d73 223 #define WITH_DATA(type, name) MODEL_PROPERTY(type, name)
AzureIoTClient 4:233dd7616d73 224
AzureIoTClient 17:fa1bba4c6053 225
AzureIoTClient 17:fa1bba4c6053 226 #define WITH_REPORTED_PROPERTY(type, name) MODEL_REPORTED_PROPERTY(type, name)
AzureIoTClient 17:fa1bba4c6053 227
AzureIoTClient 17:fa1bba4c6053 228 #define WITH_DESIRED_PROPERTY(type, name, ...) MODEL_DESIRED_PROPERTY(type, name, __VA_ARGS__)
AzureIoTClient 17:fa1bba4c6053 229
AzureIoTClient 4:233dd7616d73 230 /**
AzureIoTClient 4:233dd7616d73 231 * @def WITH_ACTION(name, ...)
AzureIoTClient 4:233dd7616d73 232 * The ::WITH_ACTION macro allows declaring a model action.
AzureIoTClient 4:233dd7616d73 233 *
AzureIoTClient 4:233dd7616d73 234 * @param name Specifies the action name.
AzureIoTClient 4:233dd7616d73 235 * @param argXtype, argXName... Defines the type and name for the X<sup>th</sup>
AzureIoTClient 4:233dd7616d73 236 * argument of the action. The type can be any of
AzureIoTClient 4:233dd7616d73 237 * the primitive types or a struct type.
AzureIoTClient 4:233dd7616d73 238 */
AzureIoTClient 4:233dd7616d73 239 /*Codes_SRS_SERIALIZER_99_039:[WITH_ACTION shall declare an action of the current data provider called as the first macro parameter(name) and having the first parameter called parameter1Name of type parameter1Type, the second parameter named parameter2Name having the type parameter2Type and so on.]*/
AzureIoTClient 4:233dd7616d73 240 #define WITH_ACTION(name, ...) MODEL_ACTION(name, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 241
AzureIoTClient 17:fa1bba4c6053 242
AzureIoTClient 4:233dd7616d73 243 /**
Azure.IoT.Build 18:58b667752399 244 * @def WITH_METHOD(name, ...)
Azure.IoT.Build 18:58b667752399 245 * The ::WITH_METHOD macro allows declaring a model method.
Azure.IoT.Build 18:58b667752399 246 *
Azure.IoT.Build 18:58b667752399 247 * @param name Specifies the method name.
Azure.IoT.Build 18:58b667752399 248 * @param argXtype, argXName... Defines the type and name for the X<sup>th</sup>
Azure.IoT.Build 18:58b667752399 249 * argument of the method. The type can be any of
Azure.IoT.Build 18:58b667752399 250 * the primitive types or a struct type.
Azure.IoT.Build 18:58b667752399 251 */
Azure.IoT.Build 18:58b667752399 252 /*Codes_SRS_SERIALIZER_H_02_029: [ WITH_METHOD shall declare a function with the signature 'METHODRETURN_HANDLE name(param1Type param1Name, ...)', which the developer can define to receive corresponding commands from the IoT service. ]*/
Azure.IoT.Build 18:58b667752399 253 #define WITH_METHOD(name, ...) MODEL_METHOD(name, __VA_ARGS__)
Azure.IoT.Build 18:58b667752399 254
Azure.IoT.Build 18:58b667752399 255
Azure.IoT.Build 18:58b667752399 256 /**
AzureIoTClient 4:233dd7616d73 257 * @def GET_MODEL_HANDLE(schemaNamespace, modelName)
AzureIoTClient 4:233dd7616d73 258 * The ::GET_MODEL_HANDLE macro returns a model handle that can be used in
AzureIoTClient 4:233dd7616d73 259 * subsequent operations like generating the CSDL schema for the model,
AzureIoTClient 4:233dd7616d73 260 * uploading the schema, creating a device, etc.
AzureIoTClient 4:233dd7616d73 261 *
AzureIoTClient 4:233dd7616d73 262 * @param schemaNamespace The namespace to which the model belongs.
AzureIoTClient 4:233dd7616d73 263 * @param modelName The name of the model.
AzureIoTClient 4:233dd7616d73 264 */
AzureIoTClient 4:233dd7616d73 265 /* Codes_SRS_SERIALIZER_99_110:[ The GET_MODEL_HANDLE function macro shall first register the schema by calling CodeFirst_RegisterSchema, passing schemaNamespace and a pointer to the metadata generated in the schema declaration block.] */
AzureIoTClient 4:233dd7616d73 266 /* Codes_SRS_SERIALIZER_99_094:[ GET_MODEL_HANDLE shall then call Schema_GetModelByName, passing the schemaHandle obtained from CodeFirst_RegisterSchema and modelName arguments, to retrieve the SCHEMA_MODEL_TYPE_HANDLE corresponding to the modelName argument.] */
AzureIoTClient 4:233dd7616d73 267 /* Codes_SRS_SERIALIZER_99_112:[ GET_MODEL_HANDLE will return the handle for the named model.] */
AzureIoTClient 4:233dd7616d73 268 #define GET_MODEL_HANDLE(schemaNamespace, modelName) \
AzureIoTClient 4:233dd7616d73 269 Schema_GetModelByName(CodeFirst_RegisterSchema(TOSTRING(schemaNamespace), &ALL_REFLECTED(schemaNamespace)), #modelName)
AzureIoTClient 4:233dd7616d73 270
AzureIoTClient 4:233dd7616d73 271 /* Codes_SRS_SERIALIZER_01_002: [If the argument serializerIncludePropertyPath is specified, its value shall be passed to CodeFirst_Create.] */
AzureIoTClient 4:233dd7616d73 272 #define CREATE_DEVICE_WITH_INCLUDE_PROPERTY_PATH(schemaNamespace, modelName, serializerIncludePropertyPath) \
AzureIoTClient 4:233dd7616d73 273 (modelName*)CodeFirst_CreateDevice(GET_MODEL_HANDLE(schemaNamespace, modelName), &ALL_REFLECTED(schemaNamespace), sizeof(modelName), serializerIncludePropertyPath)
AzureIoTClient 4:233dd7616d73 274
AzureIoTClient 4:233dd7616d73 275 /* Codes_SRS_SERIALIZER_01_003: [If the argument serializerIncludePropertyPath is not specified, CREATE_MODEL_INSTANCE shall pass false to CodeFirst_Create.] */
AzureIoTClient 4:233dd7616d73 276 #define CREATE_DEVICE_WITHOUT_INCLUDE_PROPERTY_PATH(schemaNamespace, modelName) \
AzureIoTClient 4:233dd7616d73 277 (modelName*)CodeFirst_CreateDevice(GET_MODEL_HANDLE(schemaNamespace, modelName), &ALL_REFLECTED(schemaNamespace), sizeof(modelName), false)
AzureIoTClient 4:233dd7616d73 278
AzureIoTClient 4:233dd7616d73 279 /* Codes_SRS_SERIALIZER_99_104:[ CREATE_MODEL_INSTANCE shall call GET_MODEL_HANDLE, passing schemaNamespace and modelName, to get a model handle representing the model defined in the corresponding schema declaration block.] */
AzureIoTClient 4:233dd7616d73 280 /* Codes_SRS_SERIALIZER_99_106:[ CREATE_MODEL_INSTANCE shall call CodeFirst_CreateDevice, passing the model handle (SCHEMA_MODEL_TYPE_HANDLE]*/
AzureIoTClient 4:233dd7616d73 281 /* Codes_SRS_SERIALIZER_99_107:[ If CodeFirst_CreateDevice fails, CREATE_MODEL_INSTANCE shall return NULL.] */
AzureIoTClient 4:233dd7616d73 282 /* Codes_SRS_SERIALIZER_99_108:[ If CodeFirst_CreateDevice succeeds, CREATE_MODEL_INSTANCE shall return a pointer to an instance of the C struct representing the model for the device.] */
AzureIoTClient 4:233dd7616d73 283 #define CREATE_MODEL_INSTANCE(schemaNamespace, ...) \
AzureIoTClient 4:233dd7616d73 284 IF(DIV2(COUNT_ARG(__VA_ARGS__)), CREATE_DEVICE_WITH_INCLUDE_PROPERTY_PATH, CREATE_DEVICE_WITHOUT_INCLUDE_PROPERTY_PATH) (schemaNamespace, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 285
AzureIoTClient 4:233dd7616d73 286 /* Codes_SRS_SERIALIZER_99_109:[ DESTROY_MODEL_INSTANCE shall call CodeFirst_DestroyDevice, passing the pointer returned from CREATE_MODEL_INSTANCE, to release all resources associated with the device.] */
AzureIoTClient 4:233dd7616d73 287 #define DESTROY_MODEL_INSTANCE(deviceData) \
AzureIoTClient 4:233dd7616d73 288 CodeFirst_DestroyDevice(deviceData)
AzureIoTClient 4:233dd7616d73 289
AzureIoTClient 4:233dd7616d73 290 /**
AzureIoTClient 4:233dd7616d73 291 * @def SERIALIZE(destination, destinationSize,...)
AzureIoTClient 4:233dd7616d73 292 * This macro produces JSON serialized representation of the properties.
AzureIoTClient 4:233dd7616d73 293 *
AzureIoTClient 4:233dd7616d73 294 * @param destination Pointer to an @c unsigned @c char* that
AzureIoTClient 4:233dd7616d73 295 * will receive the serialized data.
AzureIoTClient 4:233dd7616d73 296 * @param destinationSize Pointer to a @c size_t that gets
AzureIoTClient 4:233dd7616d73 297 * written with the size in bytes of the
AzureIoTClient 4:233dd7616d73 298 * serialized data
AzureIoTClient 4:233dd7616d73 299 * @param property1, property2... A list of property values to send. The
AzureIoTClient 4:233dd7616d73 300 * order in which the properties appear in
AzureIoTClient 4:233dd7616d73 301 * the list does not matter, all values
AzureIoTClient 4:233dd7616d73 302 * will be sent together.
AzureIoTClient 4:233dd7616d73 303 *
AzureIoTClient 4:233dd7616d73 304 */
AzureIoTClient 4:233dd7616d73 305 /*Codes_SRS_SERIALIZER_99_113:[ SERIALIZE shall call CodeFirst_SendAsync, passing a destination, destinationSize, the number of properties to publish, and pointers to the values for each property.] */
AzureIoTClient 4:233dd7616d73 306 /*Codes_SRS_SERIALIZER_99_117:[ If CodeFirst_SendAsync succeeds, SEND will return IOT_AGENT_OK.] */
AzureIoTClient 4:233dd7616d73 307 /*Codes_SRS_SERIALIZER_99_114:[ If CodeFirst_SendAsync fails, SEND shall return IOT_AGENT_SERIALIZE_FAILED.] */
AzureIoTClient 17:fa1bba4c6053 308 #define SERIALIZE(destination, destinationSize,...) CodeFirst_SendAsync(destination, destinationSize, COUNT_ARG(__VA_ARGS__) FOR_EACH_1(ADDRESS_MACRO, __VA_ARGS__))
AzureIoTClient 17:fa1bba4c6053 309
AzureIoTClient 17:fa1bba4c6053 310 #define SERIALIZE_REPORTED_PROPERTIES(destination, destinationSize,...) CodeFirst_SendAsyncReported(destination, destinationSize, COUNT_ARG(__VA_ARGS__) FOR_EACH_1(ADDRESS_MACRO, __VA_ARGS__))
AzureIoTClient 4:233dd7616d73 311
Azure.IoT.Build 18:58b667752399 312
Azure.IoT.Build 18:58b667752399 313 #define IDENTITY_MACRO(x) ,x
Azure.IoT.Build 18:58b667752399 314 #define SERIALIZE_REPORTED_PROPERTIES_FROM_POINTERS(destination, destinationSize, ...) CodeFirst_SendAsyncReported(destination, destinationSize, COUNT_ARG(__VA_ARGS__) FOR_EACH_1(IDENTITY_MACRO, __VA_ARGS__))
Azure.IoT.Build 18:58b667752399 315
AzureIoTClient 4:233dd7616d73 316 /**
AzureIoTClient 4:233dd7616d73 317 * @def EXECUTE_COMMAND(device, command)
AzureIoTClient 4:233dd7616d73 318 * Any action that is declared in a model must also have an implementation as
AzureIoTClient 4:233dd7616d73 319 * a C function.
AzureIoTClient 4:233dd7616d73 320 *
AzureIoTClient 4:233dd7616d73 321 * @param device Pointer to device data.
AzureIoTClient 4:233dd7616d73 322 * @param command Values that match the arguments declared in the model
AzureIoTClient 4:233dd7616d73 323 * action.
AzureIoTClient 4:233dd7616d73 324 */
AzureIoTClient 4:233dd7616d73 325 /*Codes_SRS_SERIALIZER_02_018: [EXECUTE_COMMAND macro shall call CodeFirst_ExecuteCommand passing device, commandBuffer and commandBufferSize.]*/
AzureIoTClient 4:233dd7616d73 326 #define EXECUTE_COMMAND(device, command) (CodeFirst_ExecuteCommand(device, command))
AzureIoTClient 4:233dd7616d73 327
AzureIoTClient 17:fa1bba4c6053 328 /**
Azure.IoT.Build 18:58b667752399 329 * @def EXECUTE_METHOD(device, methodName, methodPayload)
Azure.IoT.Build 18:58b667752399 330 * Any method that is declared in a model must also have an implementation as
Azure.IoT.Build 18:58b667752399 331 * a C function.
Azure.IoT.Build 18:58b667752399 332 *
Azure.IoT.Build 18:58b667752399 333 * @param device Pointer to device data.
Azure.IoT.Build 18:58b667752399 334 * @param methodName The method name.
Azure.IoT.Build 18:58b667752399 335 * @param methodPayload The method payload.
Azure.IoT.Build 18:58b667752399 336 */
Azure.IoT.Build 18:58b667752399 337 #define EXECUTE_METHOD(device, methodName, methodPayload) CodeFirst_ExecuteMethod(device, methodName, methodPayload)
Azure.IoT.Build 18:58b667752399 338
Azure.IoT.Build 18:58b667752399 339 /**
AzureIoTClient 17:fa1bba4c6053 340 * @def INGEST_DESIRED_PROPERTIES(device, desiredProperties)
AzureIoTClient 17:fa1bba4c6053 341 *
AzureIoTClient 17:fa1bba4c6053 342 * @param device return of CodeFirst_CreateDevice.
AzureIoTClient 17:fa1bba4c6053 343 * @param desiredProperties a null terminated string containing in JSON format the desired properties
AzureIoTClient 17:fa1bba4c6053 344 */
AzureIoTClient 26:7c0e6f86d034 345 #define INGEST_DESIRED_PROPERTIES(device, jsonPayload, parseDesiredNode) (CodeFirst_IngestDesiredProperties(device, jsonPayload, parseDesiredNode))
AzureIoTClient 17:fa1bba4c6053 346
AzureIoTClient 4:233dd7616d73 347 /* Helper macros */
AzureIoTClient 4:233dd7616d73 348
AzureIoTClient 4:233dd7616d73 349 /* These macros remove a useless comma from the beginning of an argument list that looks like:
AzureIoTClient 4:233dd7616d73 350 ,x1,y1,x2,y2 */
AzureIoTClient 4:233dd7616d73 351 #ifdef _MSC_VER
AzureIoTClient 4:233dd7616d73 352
AzureIoTClient 4:233dd7616d73 353 #define DROP_FIRST_COMMA(N, x) \
AzureIoTClient 4:233dd7616d73 354 x IFCOMMA_NOFIRST(N)
AzureIoTClient 4:233dd7616d73 355
AzureIoTClient 4:233dd7616d73 356 #define DROP_IF_EMPTY(N, x) \
AzureIoTClient 4:233dd7616d73 357 IF(COUNT_ARG(x),DROP_FIRST_COMMA(N,x),x)
AzureIoTClient 4:233dd7616d73 358
AzureIoTClient 4:233dd7616d73 359 #define DROP_FIRST_COMMA_FROM_ARGS(...) \
AzureIoTClient 4:233dd7616d73 360 FOR_EACH_1_COUNTED(DROP_IF_EMPTY, C1(__VA_ARGS__))
AzureIoTClient 4:233dd7616d73 361
AzureIoTClient 4:233dd7616d73 362 #else
AzureIoTClient 4:233dd7616d73 363
AzureIoTClient 4:233dd7616d73 364 #define DROP_FIRST_COMMA_0(N, x) \
AzureIoTClient 4:233dd7616d73 365 x IFCOMMA_NOFIRST(N)
AzureIoTClient 4:233dd7616d73 366
AzureIoTClient 4:233dd7616d73 367 #define DROP_FIRST_COMMA_1(N, x) \
AzureIoTClient 4:233dd7616d73 368 x
AzureIoTClient 4:233dd7616d73 369
AzureIoTClient 4:233dd7616d73 370 #define DROP_FIRST_COMMA(empty, N, x) \
AzureIoTClient 4:233dd7616d73 371 C2(DROP_FIRST_COMMA_,empty)(N,x)
AzureIoTClient 4:233dd7616d73 372
AzureIoTClient 4:233dd7616d73 373 #define DROP_IF_EMPTY(N, x) \
AzureIoTClient 4:233dd7616d73 374 DROP_FIRST_COMMA(ISEMPTY(x),N,x)
AzureIoTClient 4:233dd7616d73 375
AzureIoTClient 4:233dd7616d73 376 #define DROP_FIRST_COMMA_FROM_ARGS(...) \
AzureIoTClient 4:233dd7616d73 377 FOR_EACH_1_COUNTED(DROP_IF_EMPTY, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 378
AzureIoTClient 4:233dd7616d73 379 #endif
AzureIoTClient 4:233dd7616d73 380
AzureIoTClient 4:233dd7616d73 381 /* These macros expand a sequence of arguments for DECLARE_MODEL that looks like
AzureIoTClient 4:233dd7616d73 382 WITH_DATA(x, y), WITH_DATA(x2, y2) to a list of arguments consumed by the macro that marshalls a struct, like:
AzureIoTClient 4:233dd7616d73 383 x, y, x2, y2
AzureIoTClient 4:233dd7616d73 384 Actions are discarded, since no marshalling will be done for those when sending state data */
AzureIoTClient 4:233dd7616d73 385 #define TO_AGENT_DT_EXPAND_MODEL_PROPERTY(x, y) ,x,y
AzureIoTClient 17:fa1bba4c6053 386
AzureIoTClient 17:fa1bba4c6053 387 #define TO_AGENT_DT_EXPAND_MODEL_REPORTED_PROPERTY(x, y) ,x,y
AzureIoTClient 17:fa1bba4c6053 388
AzureIoTClient 17:fa1bba4c6053 389 #define TO_AGENT_DT_EXPAND_MODEL_DESIRED_PROPERTY(x, y, ...) ,x,y
AzureIoTClient 17:fa1bba4c6053 390
AzureIoTClient 4:233dd7616d73 391 #define TO_AGENT_DT_EXPAND_MODEL_ACTION(...)
AzureIoTClient 4:233dd7616d73 392
Azure.IoT.Build 18:58b667752399 393 #define TO_AGENT_DT_EXPAND_MODEL_METHOD(...)
Azure.IoT.Build 18:58b667752399 394
AzureIoTClient 4:233dd7616d73 395 #define TO_AGENT_DT_EXPAND_ELEMENT_ARGS(N, ...) TO_AGENT_DT_EXPAND_##__VA_ARGS__
AzureIoTClient 4:233dd7616d73 396
AzureIoTClient 4:233dd7616d73 397 #define EXPAND_MODEL_ARGS(...) \
AzureIoTClient 4:233dd7616d73 398 FOR_EACH_1_COUNTED(TO_AGENT_DT_EXPAND_ELEMENT_ARGS, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 399
AzureIoTClient 4:233dd7616d73 400 #define TO_AGENT_DATA_TYPE(name, ...) \
AzureIoTClient 4:233dd7616d73 401 static AGENT_DATA_TYPES_RESULT ToAGENT_DATA_TYPE_##name(AGENT_DATA_TYPE *destination, const name value) \
AzureIoTClient 4:233dd7616d73 402 { \
AzureIoTClient 4:233dd7616d73 403 AGENT_DATA_TYPES_RESULT result = AGENT_DATA_TYPES_OK; \
AzureIoTClient 4:233dd7616d73 404 size_t iMember = 0; \
AzureIoTClient 4:233dd7616d73 405 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(phantomName, 1); \
AzureIoTClient 4:233dd7616d73 406 const char* memberNames[IF(DIV2(C1(COUNT_ARG(__VA_ARGS__))), DIV2(C1(COUNT_ARG(__VA_ARGS__))), 1)] = { 0 }; \
AzureIoTClient 4:233dd7616d73 407 size_t memberCount = sizeof(memberNames) / sizeof(memberNames[0]); \
AzureIoTClient 4:233dd7616d73 408 (void)value; \
AzureIoTClient 4:233dd7616d73 409 if (memberCount == 0) \
AzureIoTClient 17:fa1bba4c6053 410 { \
AzureIoTClient 4:233dd7616d73 411 result = AGENT_DATA_TYPES_OK; \
AzureIoTClient 17:fa1bba4c6053 412 } \
AzureIoTClient 17:fa1bba4c6053 413 else \
AzureIoTClient 4:233dd7616d73 414 { \
AzureIoTClient 4:233dd7616d73 415 AGENT_DATA_TYPE members[sizeof(memberNames) / sizeof(memberNames[0])]; \
AzureIoTClient 4:233dd7616d73 416 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(phantomName, 2); \
AzureIoTClient 4:233dd7616d73 417 FOR_EACH_2(FIELD_AS_STRING, EXPAND_TWICE(__VA_ARGS__)) \
AzureIoTClient 4:233dd7616d73 418 iMember = 0; \
AzureIoTClient 4:233dd7616d73 419 { \
AzureIoTClient 22:422d94bd3c18 420 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(phantomName, 3); \
AzureIoTClient 22:422d94bd3c18 421 FOR_EACH_2(CREATE_AGENT_DATA_TYPE, EXPAND_TWICE(__VA_ARGS__)) \
AzureIoTClient 22:422d94bd3c18 422 {DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(phantomName, 4); } \
AzureIoTClient 22:422d94bd3c18 423 result = ((result == AGENT_DATA_TYPES_OK) && (Create_AGENT_DATA_TYPE_from_Members(destination, #name, sizeof(memberNames) / sizeof(memberNames[0]), memberNames, members) == AGENT_DATA_TYPES_OK)) \
AzureIoTClient 22:422d94bd3c18 424 ? AGENT_DATA_TYPES_OK \
AzureIoTClient 22:422d94bd3c18 425 : AGENT_DATA_TYPES_ERROR; \
AzureIoTClient 4:233dd7616d73 426 { \
AzureIoTClient 22:422d94bd3c18 427 size_t jMember; \
AzureIoTClient 22:422d94bd3c18 428 for (jMember = 0; jMember < iMember; jMember++) \
AzureIoTClient 22:422d94bd3c18 429 { \
AzureIoTClient 22:422d94bd3c18 430 Destroy_AGENT_DATA_TYPE(&members[jMember]); \
AzureIoTClient 22:422d94bd3c18 431 } \
AzureIoTClient 4:233dd7616d73 432 } \
AzureIoTClient 4:233dd7616d73 433 } \
AzureIoTClient 4:233dd7616d73 434 } \
AzureIoTClient 4:233dd7616d73 435 return result; \
AzureIoTClient 4:233dd7616d73 436 }
AzureIoTClient 4:233dd7616d73 437
AzureIoTClient 4:233dd7616d73 438 #define FIELD_AS_STRING(x,y) memberNames[iMember++] = #y;
AzureIoTClient 4:233dd7616d73 439
AzureIoTClient 4:233dd7616d73 440 #define REFLECTED_LIST_HEAD(name) \
AzureIoTClient 4:233dd7616d73 441 static const REFLECTED_DATA_FROM_DATAPROVIDER ALL_REFLECTED(name) = { &C2(REFLECTED_, C1(DEC(__COUNTER__))) };
AzureIoTClient 4:233dd7616d73 442 #define REFLECTED_STRUCT(name) \
Azure.IoT.Build 18:58b667752399 443 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_STRUCT_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {0}, {TOSTRING(name)}, {0}, {0}, {0}, {0}} };
AzureIoTClient 4:233dd7616d73 444 #define REFLECTED_FIELD(XstructName, XfieldType, XfieldName) \
Azure.IoT.Build 18:58b667752399 445 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_FIELD_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {0}, {0}, {TOSTRING(XfieldName), TOSTRING(XfieldType), TOSTRING(XstructName)}, {0}, {0}, {0} } };
AzureIoTClient 4:233dd7616d73 446 #define REFLECTED_MODEL(name) \
Azure.IoT.Build 18:58b667752399 447 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_MODEL_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {0}, {0}, {0}, {0}, {0}, {TOSTRING(name)} } };
AzureIoTClient 4:233dd7616d73 448 #define REFLECTED_PROPERTY(type, name, modelName) \
Azure.IoT.Build 18:58b667752399 449 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_PROPERTY_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {0}, {0}, {0}, {TOSTRING(name), TOSTRING(type), Create_AGENT_DATA_TYPE_From_Ptr_##modelName##name, offsetof(modelName, name), sizeof(type), TOSTRING(modelName)}, {0}, {0} } };
AzureIoTClient 17:fa1bba4c6053 450 #define REFLECTED_REPORTED_PROPERTY(type, name, modelName) \
Azure.IoT.Build 18:58b667752399 451 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_REPORTED_PROPERTY_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {TOSTRING(name), TOSTRING(type), Create_AGENT_DATA_TYPE_From_Ptr_##modelName##name, offsetof(modelName, name), sizeof(type), TOSTRING(modelName)}, {0}, {0}, {0}, {0}, {0} } };
AzureIoTClient 17:fa1bba4c6053 452
AzureIoTClient 17:fa1bba4c6053 453
AzureIoTClient 17:fa1bba4c6053 454 #define REFLECTED_DESIRED_PROPERTY_WITH_ON_DESIRED_PROPERTY_CHANGE(type, name, modelName, COUNTER, onDesiredPropertyChange) \
Azure.IoT.Build 18:58b667752399 455 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(COUNTER))) = { REFLECTION_DESIRED_PROPERTY_TYPE, &C2(REFLECTED_, C1(DEC(COUNTER))), { {0}, {onDesiredPropertyChange, DesiredPropertyInitialize_##modelName##name, DesiredPropertyDeinitialize_##modelName##name, TOSTRING(name), TOSTRING(type), (int(*)(const AGENT_DATA_TYPE*, void*))FromAGENT_DATA_TYPE_##type, offsetof(modelName, name), sizeof(type), TOSTRING(modelName)}, {0}, {0}, {0}, {0}, {0}, {0}} };
AzureIoTClient 17:fa1bba4c6053 456
AzureIoTClient 17:fa1bba4c6053 457 #define REFLECTED_DESIRED_PROPERTY(type, name, modelName, ...) \
AzureIoTClient 17:fa1bba4c6053 458 IF(COUNT_ARG(__VA_ARGS__), \
AzureIoTClient 32:4de3e6f83424 459 MACRO_UTILS_DELAY(REFLECTED_DESIRED_PROPERTY_WITH_ON_DESIRED_PROPERTY_CHANGE)(type, name, modelName,__COUNTER__, __VA_ARGS__), \
AzureIoTClient 32:4de3e6f83424 460 MACRO_UTILS_DELAY(REFLECTED_DESIRED_PROPERTY_WITH_ON_DESIRED_PROPERTY_CHANGE)(type, name, modelName,DEC(__COUNTER__), NULL) \
AzureIoTClient 17:fa1bba4c6053 461 ) \
AzureIoTClient 17:fa1bba4c6053 462
AzureIoTClient 4:233dd7616d73 463 #define REFLECTED_ACTION(name, argc, argv, fn, modelName) \
AzureIoTClient 22:422d94bd3c18 464 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_ACTION_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {0}, {0}, {0}, {0}, {TOSTRING(name), argc, argv, fn, TOSTRING(modelName)}, {0}} };
Azure.IoT.Build 18:58b667752399 465
Azure.IoT.Build 18:58b667752399 466 #define REFLECTED_METHOD(name, argc, argv, fn, modelName) \
AzureIoTClient 22:422d94bd3c18 467 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_METHOD_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {TOSTRING(name), argc, argv, fn, TOSTRING(modelName)}, {0}, {0}, {0}, {0}, {0}, {0}, {0}} };
Azure.IoT.Build 18:58b667752399 468
Azure.IoT.Build 18:58b667752399 469
AzureIoTClient 4:233dd7616d73 470 #define REFLECTED_END_OF_LIST \
Azure.IoT.Build 18:58b667752399 471 static const REFLECTED_SOMETHING C2(REFLECTED_, __COUNTER__) = { REFLECTION_NOTHING, NULL, { {0},{0}, {0}, {0}, {0}, {0}, {0}, {0}} };
AzureIoTClient 4:233dd7616d73 472
AzureIoTClient 4:233dd7616d73 473 #define EXPAND_MODEL_PROPERTY(type, name) EXPAND_ARGS(MODEL_PROPERTY, type, name)
AzureIoTClient 17:fa1bba4c6053 474
AzureIoTClient 17:fa1bba4c6053 475 #define EXPAND_MODEL_REPORTED_PROPERTY(type, name) EXPAND_ARGS(MODEL_REPORTED_PROPERTY, type, name)
AzureIoTClient 17:fa1bba4c6053 476
AzureIoTClient 17:fa1bba4c6053 477 #define EXPAND_MODEL_DESIRED_PROPERTY(type, name, ...) EXPAND_ARGS(MODEL_DESIRED_PROPERTY, type, name, __VA_ARGS__)
AzureIoTClient 17:fa1bba4c6053 478
AzureIoTClient 4:233dd7616d73 479 #define EXPAND_MODEL_ACTION(...) EXPAND_ARGS(MODEL_ACTION, __VA_ARGS__)
AzureIoTClient 4:233dd7616d73 480
Azure.IoT.Build 18:58b667752399 481 #define EXPAND_MODEL_METHOD(...) EXPAND_ARGS(MODEL_METHOD, __VA_ARGS__)
Azure.IoT.Build 18:58b667752399 482
AzureIoTClient 4:233dd7616d73 483 #define BUILD_MODEL_STRUCT(elem) INSERT_FIELD_FOR_##elem
AzureIoTClient 4:233dd7616d73 484
AzureIoTClient 4:233dd7616d73 485 #define CREATE_MODEL_ENTITY(modelName, callType, ...) EXPAND_ARGS(CREATE_##callType(modelName, __VA_ARGS__))
AzureIoTClient 4:233dd7616d73 486 #define CREATE_SOMETHING(modelName, ...) EXPAND_ARGS(CREATE_MODEL_ENTITY(modelName, __VA_ARGS__))
AzureIoTClient 4:233dd7616d73 487 #define CREATE_ELEMENT(modelName, elem) EXPAND_ARGS(CREATE_SOMETHING(modelName, EXPAND_ARGS(EXPAND_##elem)))
AzureIoTClient 4:233dd7616d73 488
AzureIoTClient 4:233dd7616d73 489 #define CREATE_MODEL_ELEMENT(modelName, elem) EXPAND_ARGS(CREATE_ELEMENT(modelName, elem))
AzureIoTClient 4:233dd7616d73 490
AzureIoTClient 17:fa1bba4c6053 491
AzureIoTClient 17:fa1bba4c6053 492 #define CREATE_MODEL_ENTITY_GLOBAL_INITIALIZATION(modelName, callType, ...) EXPAND_ARGS(CREATE_GLOBAL_INITIALIZE_##callType(modelName, __VA_ARGS__))
AzureIoTClient 17:fa1bba4c6053 493 #define CREATE_SOMETHING_GLOBAL_INITIALIZATION(modelName, ...) EXPAND_ARGS(CREATE_MODEL_ENTITY_GLOBAL_INITIALIZATION(modelName, __VA_ARGS__))
AzureIoTClient 17:fa1bba4c6053 494 #define CREATE_ELEMENT_GLOBAL_INITIALIZATION(modelName, elem) EXPAND_ARGS(CREATE_SOMETHING_GLOBAL_INITIALIZATION(modelName, EXPAND_ARGS(EXPAND_##elem)))
AzureIoTClient 17:fa1bba4c6053 495 #define CREATE_MODEL_ELEMENT_GLOBAL_INITIALIZE(modelName, elem) EXPAND_ARGS(CREATE_ELEMENT_GLOBAL_INITIALIZATION(modelName, elem))
AzureIoTClient 17:fa1bba4c6053 496
AzureIoTClient 17:fa1bba4c6053 497 #define CREATE_MODEL_ENTITY_GLOBAL_DEINITIALIZATION(modelName, callType, ...) EXPAND_ARGS(CREATE_GLOBAL_DEINITIALIZE_##callType(modelName, __VA_ARGS__))
AzureIoTClient 17:fa1bba4c6053 498 #define CREATE_SOMETHING_GLOBAL_DEINITIALIZATION(modelName, ...) EXPAND_ARGS(CREATE_MODEL_ENTITY_GLOBAL_DEINITIALIZATION(modelName, __VA_ARGS__))
AzureIoTClient 17:fa1bba4c6053 499 #define CREATE_ELEMENT_GLOBAL_DEINITIALIZATION(modelName, elem) EXPAND_ARGS(CREATE_SOMETHING_GLOBAL_DEINITIALIZATION(modelName, EXPAND_ARGS(EXPAND_##elem)))
AzureIoTClient 17:fa1bba4c6053 500 #define CREATE_MODEL_ELEMENT_GLOBAL_DEINITIALIZE(modelName, elem) EXPAND_ARGS(CREATE_ELEMENT_GLOBAL_DEINITIALIZATION(modelName, elem))
AzureIoTClient 17:fa1bba4c6053 501
AzureIoTClient 4:233dd7616d73 502 #define INSERT_FIELD_INTO_STRUCT(x, y) x y;
AzureIoTClient 17:fa1bba4c6053 503
AzureIoTClient 17:fa1bba4c6053 504
AzureIoTClient 4:233dd7616d73 505 #define INSERT_FIELD_FOR_MODEL_PROPERTY(type, name) INSERT_FIELD_INTO_STRUCT(type, name)
AzureIoTClient 17:fa1bba4c6053 506 #define CREATE_GLOBAL_INITIALIZE_MODEL_PROPERTY(modelName, type, name) /*do nothing, this is written by user*/
AzureIoTClient 17:fa1bba4c6053 507 #define CREATE_GLOBAL_DEINITIALIZE_MODEL_PROPERTY(modelName, type, name) /*do nothing, this is user's stuff*/
AzureIoTClient 17:fa1bba4c6053 508
AzureIoTClient 17:fa1bba4c6053 509 /*REPORTED_PROPERTY is not different than regular WITH_DATA*/
AzureIoTClient 17:fa1bba4c6053 510 #define INSERT_FIELD_FOR_MODEL_REPORTED_PROPERTY(type, name) INSERT_FIELD_INTO_STRUCT(type, name)
AzureIoTClient 17:fa1bba4c6053 511 #define CREATE_GLOBAL_INITIALIZE_MODEL_REPORTED_PROPERTY(modelName, type,name) GlobalInitialize_##type((char*)destination+offsetof(modelName, name));
AzureIoTClient 17:fa1bba4c6053 512 #define CREATE_GLOBAL_DEINITIALIZE_MODEL_REPORTED_PROPERTY(modelName, type,name) GlobalDeinitialize_##type((char*)destination+offsetof(modelName, name));
AzureIoTClient 17:fa1bba4c6053 513
AzureIoTClient 17:fa1bba4c6053 514 /*DESIRED_PROPERTY is not different than regular WITH_DATA*/
AzureIoTClient 17:fa1bba4c6053 515 #define INSERT_FIELD_FOR_MODEL_DESIRED_PROPERTY(type, name, ...) INSERT_FIELD_INTO_STRUCT(type, name)
AzureIoTClient 17:fa1bba4c6053 516 #define CREATE_GLOBAL_INITIALIZE_MODEL_DESIRED_PROPERTY(modelName, type, name, ...) /*do nothing*/
AzureIoTClient 17:fa1bba4c6053 517 #define CREATE_GLOBAL_DEINITIALIZE_MODEL_DESIRED_PROPERTY(modelName, type, name, ...) /*do nothing*/
AzureIoTClient 17:fa1bba4c6053 518
AzureIoTClient 4:233dd7616d73 519 #define INSERT_FIELD_FOR_MODEL_ACTION(name, ...) /* action isn't a part of the model struct */
Azure.IoT.Build 18:58b667752399 520 #define INSERT_FIELD_FOR_MODEL_METHOD(name, ...) /* method isn't a part of the model struct */
Azure.IoT.Build 18:58b667752399 521
AzureIoTClient 17:fa1bba4c6053 522 #define CREATE_GLOBAL_INITIALIZE_MODEL_ACTION(...) /*do nothing*/
AzureIoTClient 17:fa1bba4c6053 523 #define CREATE_GLOBAL_DEINITIALIZE_MODEL_ACTION(...) /*do nothing*/
AzureIoTClient 4:233dd7616d73 524
Azure.IoT.Build 18:58b667752399 525 #define CREATE_GLOBAL_INITIALIZE_MODEL_METHOD(...) /*do nothing*/
Azure.IoT.Build 18:58b667752399 526 #define CREATE_GLOBAL_DEINITIALIZE_MODEL_METHOD(...) /*do nothing*/
Azure.IoT.Build 18:58b667752399 527
AzureIoTClient 4:233dd7616d73 528 #define CREATE_MODEL_PROPERTY(modelName, type, name) \
AzureIoTClient 4:233dd7616d73 529 IMPL_PROPERTY(type, name, modelName)
AzureIoTClient 4:233dd7616d73 530
AzureIoTClient 17:fa1bba4c6053 531 #define CREATE_MODEL_REPORTED_PROPERTY(modelName, type, name) \
AzureIoTClient 17:fa1bba4c6053 532 IMPL_REPORTED_PROPERTY(type, name, modelName)
AzureIoTClient 17:fa1bba4c6053 533
AzureIoTClient 17:fa1bba4c6053 534 #define CREATE_MODEL_DESIRED_PROPERTY(modelName, type, name, ...) \
AzureIoTClient 17:fa1bba4c6053 535 IMPL_DESIRED_PROPERTY(type, name, modelName, __VA_ARGS__)
AzureIoTClient 17:fa1bba4c6053 536
AzureIoTClient 4:233dd7616d73 537 #define IMPL_PROPERTY(propertyType, propertyName, modelName) \
AzureIoTClient 17:fa1bba4c6053 538 static int Create_AGENT_DATA_TYPE_From_Ptr_##modelName##propertyName(void* param, AGENT_DATA_TYPE* dest) \
AzureIoTClient 4:233dd7616d73 539 { \
AzureIoTClient 4:233dd7616d73 540 return C1(ToAGENT_DATA_TYPE_##propertyType)(dest, *(propertyType*)param); \
AzureIoTClient 4:233dd7616d73 541 } \
AzureIoTClient 4:233dd7616d73 542 REFLECTED_PROPERTY(propertyType, propertyName, modelName)
AzureIoTClient 4:233dd7616d73 543
AzureIoTClient 17:fa1bba4c6053 544 #define IMPL_REPORTED_PROPERTY(propertyType, propertyName, modelName) \
AzureIoTClient 17:fa1bba4c6053 545 static int Create_AGENT_DATA_TYPE_From_Ptr_##modelName##propertyName(void* param, AGENT_DATA_TYPE* dest) \
AzureIoTClient 17:fa1bba4c6053 546 { \
AzureIoTClient 17:fa1bba4c6053 547 return C1(ToAGENT_DATA_TYPE_##propertyType)(dest, *(propertyType*)param); \
AzureIoTClient 17:fa1bba4c6053 548 } \
AzureIoTClient 17:fa1bba4c6053 549 REFLECTED_REPORTED_PROPERTY(propertyType, propertyName, modelName)
AzureIoTClient 17:fa1bba4c6053 550
AzureIoTClient 17:fa1bba4c6053 551 #define IMPL_DESIRED_PROPERTY(propertyType, propertyName, modelName, ...) \
AzureIoTClient 17:fa1bba4c6053 552 static void DesiredPropertyInitialize_##modelName##propertyName(void* destination) \
AzureIoTClient 17:fa1bba4c6053 553 { \
AzureIoTClient 17:fa1bba4c6053 554 GlobalInitialize_##propertyType(destination); \
AzureIoTClient 17:fa1bba4c6053 555 } \
AzureIoTClient 17:fa1bba4c6053 556 static void DesiredPropertyDeinitialize_##modelName##propertyName(void* destination) \
AzureIoTClient 17:fa1bba4c6053 557 { \
AzureIoTClient 17:fa1bba4c6053 558 GlobalDeinitialize_##propertyType(destination); \
AzureIoTClient 17:fa1bba4c6053 559 } \
AzureIoTClient 17:fa1bba4c6053 560 REFLECTED_DESIRED_PROPERTY(propertyType, propertyName, modelName, __VA_ARGS__) \
AzureIoTClient 17:fa1bba4c6053 561
AzureIoTClient 4:233dd7616d73 562 #define CREATE_MODEL_ACTION(modelName, actionName, ...) \
AzureIoTClient 4:233dd7616d73 563 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(modelName##actionName, 1); \
AzureIoTClient 4:233dd7616d73 564 EXECUTE_COMMAND_RESULT actionName (modelName* device FOR_EACH_2(DEFINE_FUNCTION_PARAMETER, __VA_ARGS__)); \
AzureIoTClient 4:233dd7616d73 565 static EXECUTE_COMMAND_RESULT C2(actionName, WRAPPER)(void* device, size_t ParameterCount, const AGENT_DATA_TYPE* values); \
AzureIoTClient 4:233dd7616d73 566 /*for macro purposes, this array always has at least 1 element*/ \
AzureIoTClient 4:233dd7616d73 567 /*Codes_SRS_SERIALIZER_99_043:[ It is valid for a method not to have any parameters.]*/ \
AzureIoTClient 4:233dd7616d73 568 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 1); \
AzureIoTClient 4:233dd7616d73 569 static const WRAPPER_ARGUMENT C2(actionName, WRAPPERARGUMENTS)[DIV2(INC(INC(COUNT_ARG(__VA_ARGS__))))] = { FOR_EACH_2_COUNTED(MAKE_WRAPPER_ARGUMENT, __VA_ARGS__) IFCOMMA(INC(INC(COUNT_ARG(__VA_ARGS__)))) {0} }; \
AzureIoTClient 4:233dd7616d73 570 REFLECTED_ACTION(actionName, DIV2(COUNT_ARG(__VA_ARGS__)), C2(actionName, WRAPPERARGUMENTS), C2(actionName, WRAPPER), modelName) \
AzureIoTClient 4:233dd7616d73 571 /*Codes_SRS_SERIALIZER_99_040:[ In addition to declaring the function, DECLARE_IOT_METHOD shall provide a definition for a wrapper that takes as parameters a size_t parameterCount and const AGENT_DATA_TYPE*.] */ \
AzureIoTClient 4:233dd7616d73 572 /*Codes_SRS_SERIALIZER_99_041:[ This wrapper shall convert all the arguments to predefined types and then call the function written by the data provider developer.]*/ \
AzureIoTClient 4:233dd7616d73 573 static EXECUTE_COMMAND_RESULT C2(actionName, WRAPPER)(void* device, size_t ParameterCount, const AGENT_DATA_TYPE* values) \
AzureIoTClient 4:233dd7616d73 574 { \
AzureIoTClient 4:233dd7616d73 575 EXECUTE_COMMAND_RESULT result; \
AzureIoTClient 4:233dd7616d73 576 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 2); \
AzureIoTClient 4:233dd7616d73 577 /*Codes_SRS_SERIALIZER_99_045:[ If the number of passed parameters doesn't match the number of declared parameters, wrapper execution shall fail and return DATA_PROVIDER_INVALID_ARG;]*/ \
AzureIoTClient 4:233dd7616d73 578 if(ParameterCount != DIV2(COUNT_ARG(__VA_ARGS__))) \
AzureIoTClient 4:233dd7616d73 579 { \
AzureIoTClient 4:233dd7616d73 580 result = EXECUTE_COMMAND_ERROR; \
AzureIoTClient 4:233dd7616d73 581 } \
AzureIoTClient 4:233dd7616d73 582 else \
AzureIoTClient 4:233dd7616d73 583 { \
AzureIoTClient 4:233dd7616d73 584 /*the below line takes care of initialized but not referenced parameter warning*/ \
AzureIoTClient 4:233dd7616d73 585 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 3); \
AzureIoTClient 4:233dd7616d73 586 IF(DIV2(COUNT_ARG(__VA_ARGS__)), size_t iParameter = 0;, ) \
AzureIoTClient 4:233dd7616d73 587 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 4); \
AzureIoTClient 4:233dd7616d73 588 /*the below line takes care of an unused parameter when values is really never questioned*/ \
AzureIoTClient 4:233dd7616d73 589 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 5); \
AzureIoTClient 4:233dd7616d73 590 FOR_EACH_2(DEFINE_LOCAL_PARAMETER, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 591 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 6); \
AzureIoTClient 4:233dd7616d73 592 IF(DIV2(COUNT_ARG(__VA_ARGS__)), , (void)values;) \
AzureIoTClient 22:422d94bd3c18 593 { \
AzureIoTClient 22:422d94bd3c18 594 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 7); \
AzureIoTClient 22:422d94bd3c18 595 } \
Azure.IoT.Build 18:58b667752399 596 FOR_EACH_2_KEEP_1(START_BUILD_LOCAL_PARAMETER, EXECUTE_COMMAND_ERROR, __VA_ARGS__) \
AzureIoTClient 22:422d94bd3c18 597 { \
AzureIoTClient 22:422d94bd3c18 598 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 8); \
AzureIoTClient 22:422d94bd3c18 599 } \
AzureIoTClient 4:233dd7616d73 600 result = actionName((modelName*)device FOR_EACH_2(PUSH_LOCAL_PARAMETER, __VA_ARGS__)); \
AzureIoTClient 17:fa1bba4c6053 601 FOR_EACH_2_REVERSE(END_BUILD_LOCAL_PARAMETER, __VA_ARGS__) \
AzureIoTClient 4:233dd7616d73 602 } \
AzureIoTClient 4:233dd7616d73 603 return result; \
AzureIoTClient 4:233dd7616d73 604 }
AzureIoTClient 4:233dd7616d73 605
Azure.IoT.Build 18:58b667752399 606 #define CREATE_MODEL_METHOD(modelName, methodName, ...) \
Azure.IoT.Build 18:58b667752399 607 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(modelName##methodName, 1); \
Azure.IoT.Build 18:58b667752399 608 METHODRETURN_HANDLE methodName (modelName* device FOR_EACH_2(DEFINE_FUNCTION_PARAMETER, __VA_ARGS__)); \
Azure.IoT.Build 18:58b667752399 609 static METHODRETURN_HANDLE C2(methodName, WRAPPER)(void* device, size_t ParameterCount, const AGENT_DATA_TYPE* values); \
Azure.IoT.Build 18:58b667752399 610 /*for macro purposes, this array always has at least 1 element*/ \
Azure.IoT.Build 18:58b667752399 611 /*Codes_SRS_SERIALIZER_H_02_030: [ It is valid for a method function not to have any parameters. ]*/ \
Azure.IoT.Build 18:58b667752399 612 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(methodName, 1); \
Azure.IoT.Build 18:58b667752399 613 static const WRAPPER_ARGUMENT C2(methodName, WRAPPERARGUMENTS)[DIV2(INC(INC(COUNT_ARG(__VA_ARGS__))))] = { FOR_EACH_2_COUNTED(MAKE_WRAPPER_ARGUMENT, __VA_ARGS__) IFCOMMA(INC(INC(COUNT_ARG(__VA_ARGS__)))) {0} }; \
Azure.IoT.Build 18:58b667752399 614 REFLECTED_METHOD(methodName, DIV2(COUNT_ARG(__VA_ARGS__)), C2(methodName, WRAPPERARGUMENTS), C2(methodName, WRAPPER), modelName) \
Azure.IoT.Build 18:58b667752399 615 /*Codes_SRS_SERIALIZER_H_02_034: [ WITH_METHOD shall result in the declaration of a conversion function with the prototype METHODRETURN_HANDLE nameWRAPPER(size_t ParameterCount, const AGENT_DATA_TYPE* values)' ]*/ \
Azure.IoT.Build 18:58b667752399 616 /*Codes_SRS_SERIALIZER_H_02_031: [ The function shall convert the input arguments to the types declared in the method parameter list and then call the user-defined method function. ]*/ \
Azure.IoT.Build 18:58b667752399 617 static METHODRETURN_HANDLE C2(methodName, WRAPPER)(void* device, size_t ParameterCount, const AGENT_DATA_TYPE* values) \
Azure.IoT.Build 18:58b667752399 618 { \
Azure.IoT.Build 18:58b667752399 619 METHODRETURN_HANDLE result; \
Azure.IoT.Build 18:58b667752399 620 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(methodName, 2); \
Azure.IoT.Build 18:58b667752399 621 /*Codes_SRS_SERIALIZER_H_02_032: [ If the number of arguments passed to the conversion function does not match the expected count, the function shall return DATAPROVIDER_INVALID_ARG. ]*/ \
Azure.IoT.Build 18:58b667752399 622 if(ParameterCount != DIV2(COUNT_ARG(__VA_ARGS__))) \
Azure.IoT.Build 18:58b667752399 623 { \
Azure.IoT.Build 18:58b667752399 624 LogError("expected parameter count (%zu) does not match the actual parameter count (%zu)", ParameterCount, COUNT_ARG(__VA_ARGS__)); \
Azure.IoT.Build 18:58b667752399 625 result = NULL; \
Azure.IoT.Build 18:58b667752399 626 } \
Azure.IoT.Build 18:58b667752399 627 else \
Azure.IoT.Build 18:58b667752399 628 { \
Azure.IoT.Build 18:58b667752399 629 /*the below line takes care of initialized but not referenced parameter warning*/ \
Azure.IoT.Build 18:58b667752399 630 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(methodName, 3); \
Azure.IoT.Build 18:58b667752399 631 IF(DIV2(COUNT_ARG(__VA_ARGS__)), size_t iParameter = 0;, ) \
Azure.IoT.Build 18:58b667752399 632 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(methodName, 4); \
Azure.IoT.Build 18:58b667752399 633 /*the below line takes care of an unused parameter when values is really never questioned*/ \
Azure.IoT.Build 18:58b667752399 634 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(methodName, 5); \
Azure.IoT.Build 18:58b667752399 635 FOR_EACH_2(DEFINE_LOCAL_PARAMETER, __VA_ARGS__) \
Azure.IoT.Build 18:58b667752399 636 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(methodName, 6); \
Azure.IoT.Build 18:58b667752399 637 IF(DIV2(COUNT_ARG(__VA_ARGS__)), , (void)values;) \
AzureIoTClient 22:422d94bd3c18 638 { \
AzureIoTClient 22:422d94bd3c18 639 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 7); \
AzureIoTClient 22:422d94bd3c18 640 } \
Azure.IoT.Build 18:58b667752399 641 FOR_EACH_2_KEEP_1(START_BUILD_LOCAL_PARAMETER, NULL,__VA_ARGS__) \
AzureIoTClient 22:422d94bd3c18 642 { \
AzureIoTClient 22:422d94bd3c18 643 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 8); \
AzureIoTClient 22:422d94bd3c18 644 } \
Azure.IoT.Build 18:58b667752399 645 result = methodName((modelName*)device FOR_EACH_2(PUSH_LOCAL_PARAMETER, __VA_ARGS__)); \
Azure.IoT.Build 18:58b667752399 646 FOR_EACH_2_REVERSE(END_BUILD_LOCAL_PARAMETER, __VA_ARGS__) \
Azure.IoT.Build 18:58b667752399 647 } \
Azure.IoT.Build 18:58b667752399 648 return result; \
Azure.IoT.Build 18:58b667752399 649 }
Azure.IoT.Build 18:58b667752399 650
AzureIoTClient 4:233dd7616d73 651 #define CREATE_AGENT_DATA_TYPE(type, name) \
AzureIoTClient 4:233dd7616d73 652 result = (( result==AGENT_DATA_TYPES_OK) && (ToAGENT_DATA_TYPE_##type( &(members[iMember]), value.name) == AGENT_DATA_TYPES_OK))?AGENT_DATA_TYPES_OK:AGENT_DATA_TYPES_ERROR; \
AzureIoTClient 4:233dd7616d73 653 iMember+= ((result==AGENT_DATA_TYPES_OK)?1:0);
AzureIoTClient 4:233dd7616d73 654
AzureIoTClient 4:233dd7616d73 655 #define BUILD_DESTINATION_FIELD(type, name) \
AzureIoTClient 4:233dd7616d73 656 if(result == AGENT_DATA_TYPES_OK) \
AzureIoTClient 4:233dd7616d73 657 { \
AzureIoTClient 4:233dd7616d73 658 size_t i; \
AzureIoTClient 4:233dd7616d73 659 bool wasFieldConverted = false; \
AzureIoTClient 4:233dd7616d73 660 for (i = 0; i < source->value.edmComplexType.nMembers; i++) \
AzureIoTClient 4:233dd7616d73 661 { \
AzureIoTClient 4:233dd7616d73 662 /*the name of the field of the complex type must match the name of the field of the structure (parameter name here)*/ \
AzureIoTClient 4:233dd7616d73 663 if (strcmp(source->value.edmComplexType.fields[i].fieldName, TOSTRING(name)) == 0) \
AzureIoTClient 4:233dd7616d73 664 { /*Codes_SRS_SERIALIZER_99_017:[ These types can either be one of the types mentioned in WITH_DATA or it can be a type introduced by a previous DECLARE_STRUCT.]*/ \
AzureIoTClient 4:233dd7616d73 665 wasFieldConverted = (C2(FromAGENT_DATA_TYPE_, type)(source->value.edmComplexType.fields[i].value, &(destination->name)) == AGENT_DATA_TYPES_OK); \
AzureIoTClient 4:233dd7616d73 666 break; \
AzureIoTClient 4:233dd7616d73 667 } \
AzureIoTClient 4:233dd7616d73 668 } \
AzureIoTClient 4:233dd7616d73 669 result = (wasFieldConverted == true)? AGENT_DATA_TYPES_OK: AGENT_DATA_TYPES_INVALID_ARG; \
AzureIoTClient 4:233dd7616d73 670 } \
AzureIoTClient 4:233dd7616d73 671 else \
AzureIoTClient 4:233dd7616d73 672 { \
AzureIoTClient 4:233dd7616d73 673 /*fallthrough*/ \
AzureIoTClient 4:233dd7616d73 674 }
AzureIoTClient 4:233dd7616d73 675
AzureIoTClient 4:233dd7616d73 676 #define UNBUILD_DESTINATION_FIELD(value, type, name) \
AzureIoTClient 4:233dd7616d73 677 C2(destroyLocalParameter, type)(&(value->name));
AzureIoTClient 4:233dd7616d73 678
AzureIoTClient 4:233dd7616d73 679
AzureIoTClient 4:233dd7616d73 680 #define ADDRESS_MACRO(x) ,&x
AzureIoTClient 4:233dd7616d73 681
AzureIoTClient 4:233dd7616d73 682 #define KEEP_FIRST_(X, ...) X
AzureIoTClient 4:233dd7616d73 683 #ifdef _MSC_VER
AzureIoTClient 4:233dd7616d73 684 #define KEEP_FIRST(X) KEEP_FIRST_ LPAREN X)
AzureIoTClient 4:233dd7616d73 685 #else
AzureIoTClient 4:233dd7616d73 686 #define KEEP_FIRST(X) KEEP_FIRST_(X)
AzureIoTClient 4:233dd7616d73 687 #endif
AzureIoTClient 4:233dd7616d73 688
AzureIoTClient 4:233dd7616d73 689 #define PROMOTIONMAP_float double, double
AzureIoTClient 4:233dd7616d73 690 #define PROMOTIONMAP_int8_t int, int
AzureIoTClient 4:233dd7616d73 691 #define PROMOTIONMAP_uint8_t int, int
AzureIoTClient 4:233dd7616d73 692 #define PROMOTIONMAP_int16_t int, int
AzureIoTClient 4:233dd7616d73 693 #define PROMOTIONMAP__Bool int, int
AzureIoTClient 4:233dd7616d73 694 #define PROMOTIONMAP_bool int, int
AzureIoTClient 4:233dd7616d73 695
AzureIoTClient 4:233dd7616d73 696 #define CASTMAP_float (float), (float)
AzureIoTClient 4:233dd7616d73 697 #define CASTMAP_int8_t (int8_t), (int8_t)
AzureIoTClient 4:233dd7616d73 698 #define CASTMAP_uint8_t (uint8_t), (uint8_t)
AzureIoTClient 4:233dd7616d73 699 #define CASTMAP_int16_t (int16_t), (int16_t)
AzureIoTClient 4:233dd7616d73 700 #define CASTMAP__Bool 0!=, 0!=
AzureIoTClient 4:233dd7616d73 701 #define CASTMAP_bool 0!=, 0!=
AzureIoTClient 4:233dd7616d73 702
AzureIoTClient 4:233dd7616d73 703 #define EMPTY_TOKEN
AzureIoTClient 4:233dd7616d73 704
AzureIoTClient 4:233dd7616d73 705 #define ANOTHERIF(x) C2(ANOTHERIF,x)
AzureIoTClient 4:233dd7616d73 706 #define ANOTHERIF0(a,b) a
AzureIoTClient 4:233dd7616d73 707 #define ANOTHERIF1(a,b) b
AzureIoTClient 4:233dd7616d73 708 #define ANOTHERIF2(a,b) b
AzureIoTClient 4:233dd7616d73 709 #define ANOTHERIF3(a,b) b
AzureIoTClient 4:233dd7616d73 710 #define ANOTHERIF4(a,b) b
AzureIoTClient 4:233dd7616d73 711 #define ANOTHERIF5(a,b) b
AzureIoTClient 4:233dd7616d73 712 #define ANOTHERIF6(a,b) b
AzureIoTClient 4:233dd7616d73 713 #define ANOTHERIF7(a,b) b
AzureIoTClient 4:233dd7616d73 714 #define ANOTHERIF8(a,b) b
AzureIoTClient 4:233dd7616d73 715 #define ANOTHERIF9(a,b) b
AzureIoTClient 4:233dd7616d73 716 #define ANOTHERIF10(a,b) b
AzureIoTClient 4:233dd7616d73 717 #define ANOTHERIF11(a,b) b
AzureIoTClient 4:233dd7616d73 718 #define ANOTHERIF12(a,b) b
AzureIoTClient 4:233dd7616d73 719
AzureIoTClient 4:233dd7616d73 720 #define MAP_PROMOTED_TYPE(X) ANOTHERIF(DEC(COUNT_ARG(PROMOTIONMAP_##X))) (X, KEEP_FIRST(PROMOTIONMAP_##X))
AzureIoTClient 4:233dd7616d73 721 #define MAP_CAST_TYPE(X) ANOTHERIF(DEC(COUNT_ARG(CASTMAP_##X))) (EMPTY_TOKEN, KEEP_FIRST(CASTMAP_##X) )
AzureIoTClient 4:233dd7616d73 722
AzureIoTClient 4:233dd7616d73 723 #define IFCOMMA(N) C2(IFCOMMA_, N)
AzureIoTClient 4:233dd7616d73 724 #define IFCOMMA_0
AzureIoTClient 4:233dd7616d73 725 #define IFCOMMA_2
AzureIoTClient 4:233dd7616d73 726 #define IFCOMMA_4 ,
AzureIoTClient 4:233dd7616d73 727 #define IFCOMMA_6 ,
AzureIoTClient 4:233dd7616d73 728 #define IFCOMMA_8 ,
AzureIoTClient 4:233dd7616d73 729 #define IFCOMMA_10 ,
AzureIoTClient 4:233dd7616d73 730 #define IFCOMMA_12 ,
AzureIoTClient 4:233dd7616d73 731 #define IFCOMMA_14 ,
AzureIoTClient 4:233dd7616d73 732 #define IFCOMMA_16 ,
AzureIoTClient 4:233dd7616d73 733 #define IFCOMMA_18 ,
AzureIoTClient 4:233dd7616d73 734 #define IFCOMMA_20 ,
AzureIoTClient 4:233dd7616d73 735 #define IFCOMMA_22 ,
AzureIoTClient 4:233dd7616d73 736 #define IFCOMMA_24 ,
AzureIoTClient 4:233dd7616d73 737 #define IFCOMMA_26 ,
AzureIoTClient 4:233dd7616d73 738 #define IFCOMMA_28 ,
AzureIoTClient 4:233dd7616d73 739 #define IFCOMMA_30 ,
AzureIoTClient 4:233dd7616d73 740 #define IFCOMMA_32 ,
AzureIoTClient 4:233dd7616d73 741 #define IFCOMMA_34 ,
AzureIoTClient 4:233dd7616d73 742 #define IFCOMMA_36 ,
AzureIoTClient 4:233dd7616d73 743 #define IFCOMMA_38 ,
AzureIoTClient 4:233dd7616d73 744 #define IFCOMMA_40 ,
AzureIoTClient 4:233dd7616d73 745 #define IFCOMMA_42 ,
AzureIoTClient 4:233dd7616d73 746 #define IFCOMMA_44 ,
AzureIoTClient 4:233dd7616d73 747 #define IFCOMMA_46 ,
AzureIoTClient 4:233dd7616d73 748 #define IFCOMMA_48 ,
AzureIoTClient 4:233dd7616d73 749 #define IFCOMMA_50 ,
AzureIoTClient 4:233dd7616d73 750 #define IFCOMMA_52 ,
AzureIoTClient 4:233dd7616d73 751 #define IFCOMMA_54 ,
AzureIoTClient 4:233dd7616d73 752 #define IFCOMMA_56 ,
AzureIoTClient 4:233dd7616d73 753 #define IFCOMMA_58 ,
AzureIoTClient 4:233dd7616d73 754 #define IFCOMMA_60 ,
AzureIoTClient 4:233dd7616d73 755 #define IFCOMMA_62 ,
AzureIoTClient 4:233dd7616d73 756 #define IFCOMMA_64 ,
AzureIoTClient 4:233dd7616d73 757 #define IFCOMMA_66 ,
AzureIoTClient 4:233dd7616d73 758 #define IFCOMMA_68 ,
AzureIoTClient 4:233dd7616d73 759 #define IFCOMMA_70 ,
AzureIoTClient 4:233dd7616d73 760 #define IFCOMMA_72 ,
AzureIoTClient 4:233dd7616d73 761 #define IFCOMMA_74 ,
AzureIoTClient 4:233dd7616d73 762 #define IFCOMMA_76 ,
AzureIoTClient 4:233dd7616d73 763 #define IFCOMMA_78 ,
AzureIoTClient 4:233dd7616d73 764 #define IFCOMMA_80 ,
AzureIoTClient 4:233dd7616d73 765 #define IFCOMMA_82 ,
AzureIoTClient 4:233dd7616d73 766 #define IFCOMMA_84 ,
AzureIoTClient 4:233dd7616d73 767 #define IFCOMMA_86 ,
AzureIoTClient 4:233dd7616d73 768 #define IFCOMMA_88 ,
AzureIoTClient 4:233dd7616d73 769 #define IFCOMMA_90 ,
AzureIoTClient 4:233dd7616d73 770 #define IFCOMMA_92 ,
AzureIoTClient 4:233dd7616d73 771 #define IFCOMMA_94 ,
AzureIoTClient 4:233dd7616d73 772 #define IFCOMMA_96 ,
AzureIoTClient 4:233dd7616d73 773 #define IFCOMMA_98 ,
AzureIoTClient 4:233dd7616d73 774 #define IFCOMMA_100 ,
AzureIoTClient 4:233dd7616d73 775 #define IFCOMMA_102 ,
AzureIoTClient 4:233dd7616d73 776 #define IFCOMMA_104 ,
AzureIoTClient 4:233dd7616d73 777 #define IFCOMMA_106 ,
AzureIoTClient 4:233dd7616d73 778 #define IFCOMMA_108 ,
AzureIoTClient 4:233dd7616d73 779 #define IFCOMMA_110 ,
AzureIoTClient 4:233dd7616d73 780 #define IFCOMMA_112 ,
AzureIoTClient 4:233dd7616d73 781 #define IFCOMMA_114 ,
AzureIoTClient 4:233dd7616d73 782 #define IFCOMMA_116 ,
AzureIoTClient 4:233dd7616d73 783 #define IFCOMMA_118 ,
AzureIoTClient 4:233dd7616d73 784 #define IFCOMMA_120 ,
AzureIoTClient 4:233dd7616d73 785 #define IFCOMMA_122 ,
AzureIoTClient 4:233dd7616d73 786 #define IFCOMMA_124 ,
AzureIoTClient 4:233dd7616d73 787 #define IFCOMMA_126 ,
AzureIoTClient 4:233dd7616d73 788 #define IFCOMMA_128 ,
AzureIoTClient 4:233dd7616d73 789
AzureIoTClient 17:fa1bba4c6053 790 #define DEFINE_LOCAL_PARAMETER(type, name) type C2(name,_local); GlobalInitialize_##type(& C2(name, _local));
AzureIoTClient 4:233dd7616d73 791
Azure.IoT.Build 18:58b667752399 792 #define START_BUILD_LOCAL_PARAMETER(errorWhenItFails, type, name) \
AzureIoTClient 4:233dd7616d73 793 if (C2(FromAGENT_DATA_TYPE_, type)(&values[iParameter], &C2(name, _local)) != AGENT_DATA_TYPES_OK) \
AzureIoTClient 4:233dd7616d73 794 { \
AzureIoTClient 4:233dd7616d73 795 /*Codes_SRS_SERIALIZER_99_046:[ If the types of the parameters do not match the declared types, DATAPROVIDER_INVALID_ARG shall be returned.]*/ \
Azure.IoT.Build 18:58b667752399 796 result = errorWhenItFails; \
AzureIoTClient 4:233dd7616d73 797 }\
AzureIoTClient 4:233dd7616d73 798 else \
AzureIoTClient 4:233dd7616d73 799 { \
AzureIoTClient 4:233dd7616d73 800 iParameter++;
AzureIoTClient 4:233dd7616d73 801
AzureIoTClient 4:233dd7616d73 802 #define END_BUILD_LOCAL_PARAMETER(type, name) \
AzureIoTClient 4:233dd7616d73 803 (void)C2(destroyLocalParameter, type)(&C2(name, _local)); \
AzureIoTClient 4:233dd7616d73 804 }
AzureIoTClient 4:233dd7616d73 805
AzureIoTClient 4:233dd7616d73 806 /*The following constructs have been devised to work around the precompiler bug of Visual Studio 2005, version 14.00.50727.42*/
AzureIoTClient 4:233dd7616d73 807 /* The bug is explained in https://connect.microsoft.com/VisualStudio/feedback/details/278752/comma-missing-when-using-va-args */
AzureIoTClient 22:422d94bd3c18 808 /*A short description is: preprocessor is mysteriously eating commas ','.
AzureIoTClient 4:233dd7616d73 809 In order to feed the appetite of the preprocessor, several constructs have
AzureIoTClient 4:233dd7616d73 810 been devised that can sustain a missing ',' while still compiling and while still doing nothing
AzureIoTClient 4:233dd7616d73 811 and while hopefully being eliminated from the code based on "doesn't do anything" so no code size penalty
AzureIoTClient 4:233dd7616d73 812 */
AzureIoTClient 4:233dd7616d73 813
AzureIoTClient 4:233dd7616d73 814 /*the reason why all these constructs work is:
AzureIoTClient 4:233dd7616d73 815 if two strings separated by a comma will lose the comma (myteriously) then they will become just one string:
AzureIoTClient 4:233dd7616d73 816 "a", "b" ------Preprocessor------> "a" "b" -----Compiler----> "ab"
AzureIoTClient 4:233dd7616d73 817 */
AzureIoTClient 4:233dd7616d73 818
AzureIoTClient 4:233dd7616d73 819 #define LOTS_OF_COMMA_TO_BE_EATEN /*there were witnesses where as many as THREE commas have been eaten!*/ \
AzureIoTClient 22:422d94bd3c18 820 "0" "1", "2", "3", "4", "5", "6", "7", "8", "9"
AzureIoTClient 4:233dd7616d73 821 #define DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(name, instance) static const char* eatThese_COMMA_##name##instance[] = {LOTS_OF_COMMA_TO_BE_EATEN}
AzureIoTClient 4:233dd7616d73 822
AzureIoTClient 4:233dd7616d73 823 #define PUSH_LOCAL_PARAMETER(type, name) , C2(name, _local)
AzureIoTClient 4:233dd7616d73 824 #define DEFINE_FUNCTION_PARAMETER(type, name) , type name
AzureIoTClient 4:233dd7616d73 825 #define MAKE_WRAPPER_ARGUMENT(N, type, name) {TOSTRING(type), TOSTRING(name)} IFCOMMA(N)
AzureIoTClient 4:233dd7616d73 826
AzureIoTClient 4:233dd7616d73 827 /*Codes_SRS_SERIALIZER_99_019:[ Create_AGENT_DATA_TYPE_from_DOUBLE]*/
AzureIoTClient 4:233dd7616d73 828 /*Codes_SRS_SERIALIZER_99_004:[ The propertyType can be any of the following data types: double]*/
AzureIoTClient 4:233dd7616d73 829 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, double)(AGENT_DATA_TYPE* dest, double source)
AzureIoTClient 4:233dd7616d73 830 {
AzureIoTClient 4:233dd7616d73 831 return Create_AGENT_DATA_TYPE_from_DOUBLE(dest, source);
AzureIoTClient 4:233dd7616d73 832 }
AzureIoTClient 4:233dd7616d73 833
AzureIoTClient 4:233dd7616d73 834 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, double)(const AGENT_DATA_TYPE* agentData, double* dest)
AzureIoTClient 4:233dd7616d73 835 {
AzureIoTClient 4:233dd7616d73 836 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 837 if (agentData->type != EDM_DOUBLE_TYPE)
AzureIoTClient 4:233dd7616d73 838 {
AzureIoTClient 4:233dd7616d73 839 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 840 }
AzureIoTClient 4:233dd7616d73 841 else
AzureIoTClient 4:233dd7616d73 842 {
AzureIoTClient 4:233dd7616d73 843 *dest = agentData->value.edmDouble.value;
AzureIoTClient 4:233dd7616d73 844 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 845 }
AzureIoTClient 4:233dd7616d73 846 return result;
AzureIoTClient 4:233dd7616d73 847 }
AzureIoTClient 4:233dd7616d73 848
AzureIoTClient 17:fa1bba4c6053 849 static void C2(GlobalInitialize_, double)(void* dest)
AzureIoTClient 17:fa1bba4c6053 850 {
AzureIoTClient 17:fa1bba4c6053 851 *(double*)dest = 0.0;
AzureIoTClient 17:fa1bba4c6053 852 }
AzureIoTClient 17:fa1bba4c6053 853
AzureIoTClient 17:fa1bba4c6053 854 static void C2(GlobalDeinitialize_, double)(void* dest)
AzureIoTClient 17:fa1bba4c6053 855 {
AzureIoTClient 17:fa1bba4c6053 856 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 857 }
AzureIoTClient 17:fa1bba4c6053 858
AzureIoTClient 4:233dd7616d73 859 /*Codes_SRS_SERIALIZER_99_021:[ Create_AGENT_DATA_TYPE_from_FLOAT]*/
AzureIoTClient 4:233dd7616d73 860 /*Codes_SRS_SERIALIZER_99_006:[ float]*/
AzureIoTClient 4:233dd7616d73 861 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, float)(AGENT_DATA_TYPE* dest, float source)
AzureIoTClient 4:233dd7616d73 862 {
AzureIoTClient 4:233dd7616d73 863 return Create_AGENT_DATA_TYPE_from_FLOAT(dest, source);
AzureIoTClient 4:233dd7616d73 864 }
AzureIoTClient 4:233dd7616d73 865
AzureIoTClient 4:233dd7616d73 866 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, float)(const AGENT_DATA_TYPE* agentData, float* dest)
AzureIoTClient 4:233dd7616d73 867 {
AzureIoTClient 4:233dd7616d73 868 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 869 if (agentData->type != EDM_SINGLE_TYPE)
AzureIoTClient 4:233dd7616d73 870 {
AzureIoTClient 4:233dd7616d73 871 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 872 }
AzureIoTClient 4:233dd7616d73 873 else
AzureIoTClient 4:233dd7616d73 874 {
AzureIoTClient 4:233dd7616d73 875 *dest = agentData->value.edmSingle.value;
AzureIoTClient 4:233dd7616d73 876 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 877 }
AzureIoTClient 4:233dd7616d73 878 return result;
AzureIoTClient 4:233dd7616d73 879 }
AzureIoTClient 4:233dd7616d73 880
AzureIoTClient 17:fa1bba4c6053 881 static void C2(GlobalInitialize_, float)(void* dest)
AzureIoTClient 17:fa1bba4c6053 882 {
AzureIoTClient 17:fa1bba4c6053 883 *(float*)dest = 0.0f;
AzureIoTClient 17:fa1bba4c6053 884 }
AzureIoTClient 17:fa1bba4c6053 885
AzureIoTClient 17:fa1bba4c6053 886 static void C2(GlobalDeinitialize_, float)(void* dest)
AzureIoTClient 17:fa1bba4c6053 887 {
AzureIoTClient 17:fa1bba4c6053 888 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 889 }
AzureIoTClient 17:fa1bba4c6053 890
AzureIoTClient 4:233dd7616d73 891
AzureIoTClient 4:233dd7616d73 892 /*Codes_SRS_SERIALIZER_99_020:[ Create_AGENT_DATA_TYPE_from_SINT32]*/
AzureIoTClient 4:233dd7616d73 893 /*Codes_SRS_SERIALIZER_99_005:[ int], */
AzureIoTClient 4:233dd7616d73 894 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int)(AGENT_DATA_TYPE* dest, int source)
AzureIoTClient 4:233dd7616d73 895 {
AzureIoTClient 4:233dd7616d73 896 return Create_AGENT_DATA_TYPE_from_SINT32(dest, source);
AzureIoTClient 4:233dd7616d73 897 }
AzureIoTClient 4:233dd7616d73 898
AzureIoTClient 4:233dd7616d73 899 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int)(const AGENT_DATA_TYPE* agentData, int* dest)
AzureIoTClient 4:233dd7616d73 900 {
AzureIoTClient 4:233dd7616d73 901 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 902 if (agentData->type != EDM_INT32_TYPE)
AzureIoTClient 4:233dd7616d73 903 {
AzureIoTClient 4:233dd7616d73 904 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 905 }
AzureIoTClient 4:233dd7616d73 906 else
AzureIoTClient 4:233dd7616d73 907 {
AzureIoTClient 4:233dd7616d73 908 *dest = agentData->value.edmInt32.value;
AzureIoTClient 4:233dd7616d73 909 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 910 }
AzureIoTClient 4:233dd7616d73 911 return result;
AzureIoTClient 4:233dd7616d73 912 }
AzureIoTClient 4:233dd7616d73 913
AzureIoTClient 17:fa1bba4c6053 914 static void C2(GlobalInitialize_, int)(void* dest)
AzureIoTClient 17:fa1bba4c6053 915 {
AzureIoTClient 17:fa1bba4c6053 916 *(int*)dest = 0;
AzureIoTClient 17:fa1bba4c6053 917 }
AzureIoTClient 17:fa1bba4c6053 918
AzureIoTClient 17:fa1bba4c6053 919 static void C2(GlobalDeinitialize_, int)(void* dest)
AzureIoTClient 17:fa1bba4c6053 920 {
AzureIoTClient 17:fa1bba4c6053 921 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 922 }
AzureIoTClient 17:fa1bba4c6053 923
AzureIoTClient 4:233dd7616d73 924 /*Codes_SRS_SERIALIZER_99_022:[ Create_AGENT_DATA_TYPE_from_SINT64]*/
AzureIoTClient 4:233dd7616d73 925 /*Codes_SRS_SERIALIZER_99_007:[ long]*/
AzureIoTClient 4:233dd7616d73 926 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, long)(AGENT_DATA_TYPE* dest, long source)
AzureIoTClient 4:233dd7616d73 927 {
AzureIoTClient 4:233dd7616d73 928 return Create_AGENT_DATA_TYPE_from_SINT64(dest, source);
AzureIoTClient 4:233dd7616d73 929 }
AzureIoTClient 4:233dd7616d73 930
AzureIoTClient 4:233dd7616d73 931 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, long)(const AGENT_DATA_TYPE* agentData, long* dest)
AzureIoTClient 4:233dd7616d73 932 {
AzureIoTClient 4:233dd7616d73 933 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 934 if (agentData->type != EDM_INT64_TYPE)
AzureIoTClient 4:233dd7616d73 935 {
AzureIoTClient 4:233dd7616d73 936 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 937 }
AzureIoTClient 4:233dd7616d73 938 else
AzureIoTClient 4:233dd7616d73 939 {
AzureIoTClient 4:233dd7616d73 940 *dest = (long)agentData->value.edmInt64.value;
AzureIoTClient 4:233dd7616d73 941 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 942 }
AzureIoTClient 4:233dd7616d73 943 return result;
AzureIoTClient 4:233dd7616d73 944 }
AzureIoTClient 4:233dd7616d73 945
AzureIoTClient 17:fa1bba4c6053 946 static void C2(GlobalInitialize_, long)(void* dest)
AzureIoTClient 17:fa1bba4c6053 947 {
AzureIoTClient 17:fa1bba4c6053 948 *(long*)dest = 0;
AzureIoTClient 17:fa1bba4c6053 949 }
AzureIoTClient 17:fa1bba4c6053 950
AzureIoTClient 17:fa1bba4c6053 951 static void C2(GlobalDeinitialize_, long)(void* dest)
AzureIoTClient 17:fa1bba4c6053 952 {
AzureIoTClient 17:fa1bba4c6053 953 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 954 }
AzureIoTClient 17:fa1bba4c6053 955
AzureIoTClient 17:fa1bba4c6053 956
AzureIoTClient 4:233dd7616d73 957 /*Codes_SRS_SERIALIZER_99_023:[ Create_AGENT_DATA_TYPE_from_SINT8]*/
AzureIoTClient 4:233dd7616d73 958 /*Codes_SRS_SERIALIZER_99_008:[ int8_t]*/
AzureIoTClient 4:233dd7616d73 959 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int8_t)(AGENT_DATA_TYPE* dest, int8_t source)
AzureIoTClient 4:233dd7616d73 960 {
AzureIoTClient 4:233dd7616d73 961 return Create_AGENT_DATA_TYPE_from_SINT8(dest, source);
AzureIoTClient 4:233dd7616d73 962 }
AzureIoTClient 4:233dd7616d73 963
AzureIoTClient 4:233dd7616d73 964 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int8_t)(const AGENT_DATA_TYPE* agentData, int8_t* dest)
AzureIoTClient 4:233dd7616d73 965 {
AzureIoTClient 4:233dd7616d73 966 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 967 if (agentData->type != EDM_SBYTE_TYPE)
AzureIoTClient 4:233dd7616d73 968 {
AzureIoTClient 4:233dd7616d73 969 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 970 }
AzureIoTClient 4:233dd7616d73 971 else
AzureIoTClient 4:233dd7616d73 972 {
AzureIoTClient 4:233dd7616d73 973 *dest = agentData->value.edmSbyte.value;
AzureIoTClient 4:233dd7616d73 974 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 975 }
AzureIoTClient 4:233dd7616d73 976 return result;
AzureIoTClient 4:233dd7616d73 977 }
AzureIoTClient 4:233dd7616d73 978
AzureIoTClient 17:fa1bba4c6053 979 static void C2(GlobalInitialize_, int8_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 980 {
AzureIoTClient 17:fa1bba4c6053 981 *(int8_t*)dest = 0;
AzureIoTClient 17:fa1bba4c6053 982 }
AzureIoTClient 17:fa1bba4c6053 983
AzureIoTClient 17:fa1bba4c6053 984 static void C2(GlobalDeinitialize_, int8_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 985 {
AzureIoTClient 17:fa1bba4c6053 986 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 987 }
AzureIoTClient 17:fa1bba4c6053 988
AzureIoTClient 4:233dd7616d73 989 /*Codes_SRS_SERIALIZER_99_024:[ Create_AGENT_DATA_TYPE_from_UINT8]*/
AzureIoTClient 4:233dd7616d73 990 /*Codes_SRS_SERIALIZER_99_009:[ uint8_t]*/
AzureIoTClient 4:233dd7616d73 991 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, uint8_t)(AGENT_DATA_TYPE* dest, uint8_t source)
AzureIoTClient 4:233dd7616d73 992 {
AzureIoTClient 4:233dd7616d73 993 return Create_AGENT_DATA_TYPE_from_UINT8(dest, source);
AzureIoTClient 4:233dd7616d73 994 }
AzureIoTClient 4:233dd7616d73 995
AzureIoTClient 4:233dd7616d73 996 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, uint8_t)(const AGENT_DATA_TYPE* agentData, uint8_t* dest)
AzureIoTClient 4:233dd7616d73 997 {
AzureIoTClient 4:233dd7616d73 998 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 999 if (agentData->type != EDM_BYTE_TYPE)
AzureIoTClient 4:233dd7616d73 1000 {
AzureIoTClient 4:233dd7616d73 1001 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1002 }
AzureIoTClient 4:233dd7616d73 1003 else
AzureIoTClient 4:233dd7616d73 1004 {
AzureIoTClient 4:233dd7616d73 1005 *dest = agentData->value.edmByte.value;
AzureIoTClient 4:233dd7616d73 1006 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 1007 }
AzureIoTClient 4:233dd7616d73 1008 return result;
AzureIoTClient 4:233dd7616d73 1009 }
AzureIoTClient 4:233dd7616d73 1010
AzureIoTClient 17:fa1bba4c6053 1011 static void C2(GlobalInitialize_, uint8_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1012 {
AzureIoTClient 17:fa1bba4c6053 1013 *(uint8_t*)dest = 0;
AzureIoTClient 17:fa1bba4c6053 1014 }
AzureIoTClient 17:fa1bba4c6053 1015
AzureIoTClient 17:fa1bba4c6053 1016 static void C2(GlobalDeinitialize_, uint8_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1017 {
AzureIoTClient 17:fa1bba4c6053 1018 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 1019 }
AzureIoTClient 17:fa1bba4c6053 1020
AzureIoTClient 17:fa1bba4c6053 1021
AzureIoTClient 4:233dd7616d73 1022 /*Codes_SRS_SERIALIZER_99_025:[ Create_AGENT_DATA_TYPE_from_SINT16]*/
AzureIoTClient 4:233dd7616d73 1023 /*Codes_SRS_SERIALIZER_99_010:[ int16_t]*/
AzureIoTClient 4:233dd7616d73 1024 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int16_t)(AGENT_DATA_TYPE* dest, int16_t source)
AzureIoTClient 4:233dd7616d73 1025 {
AzureIoTClient 4:233dd7616d73 1026 return Create_AGENT_DATA_TYPE_from_SINT16(dest, source);
AzureIoTClient 4:233dd7616d73 1027 }
AzureIoTClient 4:233dd7616d73 1028
AzureIoTClient 4:233dd7616d73 1029 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int16_t)(const AGENT_DATA_TYPE* agentData, int16_t* dest)
AzureIoTClient 4:233dd7616d73 1030 {
AzureIoTClient 4:233dd7616d73 1031 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 1032 if (agentData->type != EDM_INT16_TYPE)
AzureIoTClient 4:233dd7616d73 1033 {
AzureIoTClient 4:233dd7616d73 1034 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1035 }
AzureIoTClient 4:233dd7616d73 1036 else
AzureIoTClient 4:233dd7616d73 1037 {
AzureIoTClient 4:233dd7616d73 1038 *dest = agentData->value.edmInt16.value;
AzureIoTClient 4:233dd7616d73 1039 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 1040 }
AzureIoTClient 4:233dd7616d73 1041 return result;
AzureIoTClient 4:233dd7616d73 1042 }
AzureIoTClient 4:233dd7616d73 1043
AzureIoTClient 17:fa1bba4c6053 1044 static void C2(GlobalInitialize_, int16_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1045 {
AzureIoTClient 17:fa1bba4c6053 1046 *(int16_t*)dest = 0;
AzureIoTClient 17:fa1bba4c6053 1047 }
AzureIoTClient 17:fa1bba4c6053 1048
AzureIoTClient 17:fa1bba4c6053 1049 static void C2(GlobalDeinitialize_, int16_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1050 {
AzureIoTClient 17:fa1bba4c6053 1051 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 1052 }
AzureIoTClient 17:fa1bba4c6053 1053
AzureIoTClient 4:233dd7616d73 1054 /*Codes_SRS_SERIALIZER_99_026:[ Create_AGENT_DATA_TYPE_from_SINT32]*/
AzureIoTClient 4:233dd7616d73 1055 /*Codes_SRS_SERIALIZER_99_011:[ int32_t]*/
AzureIoTClient 4:233dd7616d73 1056 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int32_t)(AGENT_DATA_TYPE* dest, int32_t source)
AzureIoTClient 4:233dd7616d73 1057 {
AzureIoTClient 4:233dd7616d73 1058 return Create_AGENT_DATA_TYPE_from_SINT32(dest, source);
AzureIoTClient 4:233dd7616d73 1059 }
AzureIoTClient 4:233dd7616d73 1060
AzureIoTClient 4:233dd7616d73 1061 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int32_t)(const AGENT_DATA_TYPE* agentData, int32_t* dest)
AzureIoTClient 4:233dd7616d73 1062 {
AzureIoTClient 4:233dd7616d73 1063 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 1064 if (agentData->type != EDM_INT32_TYPE)
AzureIoTClient 4:233dd7616d73 1065 {
AzureIoTClient 4:233dd7616d73 1066 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1067 }
AzureIoTClient 4:233dd7616d73 1068 else
AzureIoTClient 4:233dd7616d73 1069 {
AzureIoTClient 4:233dd7616d73 1070 *dest = agentData->value.edmInt32.value;
AzureIoTClient 4:233dd7616d73 1071 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 1072 }
AzureIoTClient 4:233dd7616d73 1073 return result;
AzureIoTClient 4:233dd7616d73 1074 }
AzureIoTClient 4:233dd7616d73 1075
AzureIoTClient 17:fa1bba4c6053 1076 static void C2(GlobalInitialize_, int32_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1077 {
AzureIoTClient 17:fa1bba4c6053 1078 *(int32_t*)dest = 0;
AzureIoTClient 17:fa1bba4c6053 1079 }
AzureIoTClient 17:fa1bba4c6053 1080
AzureIoTClient 17:fa1bba4c6053 1081 static void C2(GlobalDeinitialize_, int32_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1082 {
AzureIoTClient 17:fa1bba4c6053 1083 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 1084 }
AzureIoTClient 17:fa1bba4c6053 1085
AzureIoTClient 4:233dd7616d73 1086 /*Codes_SRS_SERIALIZER_99_027:[ Create_AGENT_DATA_TYPE_from_SINT64]*/
AzureIoTClient 4:233dd7616d73 1087 /*Codes_SRS_SERIALIZER_99_012:[ int64_t]*/
AzureIoTClient 4:233dd7616d73 1088 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int64_t)(AGENT_DATA_TYPE* dest, int64_t source)
AzureIoTClient 4:233dd7616d73 1089 {
AzureIoTClient 4:233dd7616d73 1090 return Create_AGENT_DATA_TYPE_from_SINT64(dest, source);
AzureIoTClient 4:233dd7616d73 1091 }
AzureIoTClient 4:233dd7616d73 1092
AzureIoTClient 4:233dd7616d73 1093 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int64_t)(const AGENT_DATA_TYPE* agentData, int64_t* dest)
AzureIoTClient 4:233dd7616d73 1094 {
AzureIoTClient 4:233dd7616d73 1095 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 1096 if (agentData->type != EDM_INT64_TYPE)
AzureIoTClient 4:233dd7616d73 1097 {
AzureIoTClient 4:233dd7616d73 1098 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1099 }
AzureIoTClient 4:233dd7616d73 1100 else
AzureIoTClient 4:233dd7616d73 1101 {
AzureIoTClient 4:233dd7616d73 1102 *dest = agentData->value.edmInt64.value;
AzureIoTClient 4:233dd7616d73 1103 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 1104 }
AzureIoTClient 4:233dd7616d73 1105 return result;
AzureIoTClient 4:233dd7616d73 1106 }
AzureIoTClient 4:233dd7616d73 1107
AzureIoTClient 17:fa1bba4c6053 1108 static void C2(GlobalInitialize_, int64_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1109 {
AzureIoTClient 17:fa1bba4c6053 1110 *(int64_t*)dest = 0;
AzureIoTClient 17:fa1bba4c6053 1111 }
AzureIoTClient 17:fa1bba4c6053 1112
AzureIoTClient 17:fa1bba4c6053 1113 static void C2(GlobalDeinitialize_, int64_t)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1114 {
AzureIoTClient 17:fa1bba4c6053 1115 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 1116 }
AzureIoTClient 17:fa1bba4c6053 1117
AzureIoTClient 4:233dd7616d73 1118 /*Codes_SRS_SERIALIZER_99_013:[ bool]*/
AzureIoTClient 4:233dd7616d73 1119 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, bool)(AGENT_DATA_TYPE* dest, bool source)
AzureIoTClient 4:233dd7616d73 1120 {
AzureIoTClient 4:233dd7616d73 1121 return Create_EDM_BOOLEAN_from_int(dest, source == true);
AzureIoTClient 4:233dd7616d73 1122 }
AzureIoTClient 4:233dd7616d73 1123
AzureIoTClient 4:233dd7616d73 1124 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, bool)(const AGENT_DATA_TYPE* agentData, bool* dest)
AzureIoTClient 4:233dd7616d73 1125 {
AzureIoTClient 4:233dd7616d73 1126 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 1127 if (agentData->type != EDM_BOOLEAN_TYPE)
AzureIoTClient 4:233dd7616d73 1128 {
AzureIoTClient 4:233dd7616d73 1129 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1130 }
AzureIoTClient 4:233dd7616d73 1131 else
AzureIoTClient 4:233dd7616d73 1132 {
AzureIoTClient 4:233dd7616d73 1133 *dest = (agentData->value.edmBoolean.value == EDM_TRUE) ? true : false;
AzureIoTClient 4:233dd7616d73 1134 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 1135 }
AzureIoTClient 4:233dd7616d73 1136 return result;
AzureIoTClient 4:233dd7616d73 1137 }
AzureIoTClient 4:233dd7616d73 1138
AzureIoTClient 17:fa1bba4c6053 1139 static void C2(GlobalInitialize_, bool)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1140 {
AzureIoTClient 17:fa1bba4c6053 1141 *(bool*)dest = false;
AzureIoTClient 17:fa1bba4c6053 1142 }
AzureIoTClient 17:fa1bba4c6053 1143
AzureIoTClient 17:fa1bba4c6053 1144 static void C2(GlobalDeinitialize_, bool)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1145 {
AzureIoTClient 17:fa1bba4c6053 1146 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 1147 }
AzureIoTClient 17:fa1bba4c6053 1148
AzureIoTClient 4:233dd7616d73 1149 /*Codes_SRS_SERIALIZER_99_014:[ ascii_char_ptr]*/
AzureIoTClient 4:233dd7616d73 1150 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, ascii_char_ptr)(AGENT_DATA_TYPE* dest, ascii_char_ptr source)
AzureIoTClient 4:233dd7616d73 1151 {
AzureIoTClient 4:233dd7616d73 1152 return Create_AGENT_DATA_TYPE_from_charz(dest, source);
AzureIoTClient 4:233dd7616d73 1153 }
AzureIoTClient 4:233dd7616d73 1154
AzureIoTClient 4:233dd7616d73 1155 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, ascii_char_ptr)(const AGENT_DATA_TYPE* agentData, ascii_char_ptr* dest)
AzureIoTClient 4:233dd7616d73 1156 {
AzureIoTClient 4:233dd7616d73 1157 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 1158 if (agentData->type != EDM_STRING_TYPE)
AzureIoTClient 4:233dd7616d73 1159 {
AzureIoTClient 4:233dd7616d73 1160 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1161 }
AzureIoTClient 4:233dd7616d73 1162 else
AzureIoTClient 4:233dd7616d73 1163 {
AzureIoTClient 17:fa1bba4c6053 1164 if (*dest != NULL)
AzureIoTClient 17:fa1bba4c6053 1165 {
AzureIoTClient 17:fa1bba4c6053 1166 free(*dest);
AzureIoTClient 17:fa1bba4c6053 1167 *dest = NULL;
AzureIoTClient 17:fa1bba4c6053 1168 }
AzureIoTClient 17:fa1bba4c6053 1169
AzureIoTClient 17:fa1bba4c6053 1170 if (mallocAndStrcpy_s(dest, agentData->value.edmString.chars) != 0)
AzureIoTClient 17:fa1bba4c6053 1171 {
AzureIoTClient 17:fa1bba4c6053 1172 LogError("failure in mallocAndStrcpy_s");
AzureIoTClient 17:fa1bba4c6053 1173 result = AGENT_DATA_TYPES_ERROR;
AzureIoTClient 17:fa1bba4c6053 1174 }
AzureIoTClient 17:fa1bba4c6053 1175 else
AzureIoTClient 17:fa1bba4c6053 1176 {
AzureIoTClient 17:fa1bba4c6053 1177 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 17:fa1bba4c6053 1178 }
AzureIoTClient 17:fa1bba4c6053 1179
AzureIoTClient 4:233dd7616d73 1180 }
AzureIoTClient 4:233dd7616d73 1181 return result;
AzureIoTClient 4:233dd7616d73 1182 }
AzureIoTClient 4:233dd7616d73 1183
AzureIoTClient 17:fa1bba4c6053 1184 static void C2(GlobalInitialize_, ascii_char_ptr)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1185 {
AzureIoTClient 17:fa1bba4c6053 1186 *(ascii_char_ptr*)dest = NULL;
AzureIoTClient 17:fa1bba4c6053 1187 }
AzureIoTClient 17:fa1bba4c6053 1188
AzureIoTClient 17:fa1bba4c6053 1189 static void C2(GlobalDeinitialize_, ascii_char_ptr)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1190 {
AzureIoTClient 17:fa1bba4c6053 1191 if (*(ascii_char_ptr*)dest != NULL)
AzureIoTClient 17:fa1bba4c6053 1192 {
AzureIoTClient 17:fa1bba4c6053 1193 free(*(ascii_char_ptr*)dest);
AzureIoTClient 17:fa1bba4c6053 1194 }
AzureIoTClient 17:fa1bba4c6053 1195 }
AzureIoTClient 17:fa1bba4c6053 1196
AzureIoTClient 4:233dd7616d73 1197 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, ascii_char_ptr_no_quotes)(AGENT_DATA_TYPE* dest, ascii_char_ptr_no_quotes source)
AzureIoTClient 4:233dd7616d73 1198 {
AzureIoTClient 4:233dd7616d73 1199 return Create_AGENT_DATA_TYPE_from_charz_no_quotes(dest, source);
AzureIoTClient 4:233dd7616d73 1200 }
AzureIoTClient 4:233dd7616d73 1201
AzureIoTClient 4:233dd7616d73 1202 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, ascii_char_ptr_no_quotes)(const AGENT_DATA_TYPE* agentData, ascii_char_ptr_no_quotes* dest)
AzureIoTClient 4:233dd7616d73 1203 {
AzureIoTClient 4:233dd7616d73 1204 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 1205 if (agentData->type != EDM_STRING_NO_QUOTES_TYPE)
AzureIoTClient 4:233dd7616d73 1206 {
AzureIoTClient 4:233dd7616d73 1207 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1208 }
AzureIoTClient 4:233dd7616d73 1209 else
AzureIoTClient 4:233dd7616d73 1210 {
AzureIoTClient 17:fa1bba4c6053 1211 if (*dest != NULL)
AzureIoTClient 17:fa1bba4c6053 1212 {
AzureIoTClient 17:fa1bba4c6053 1213 free(*dest);
AzureIoTClient 17:fa1bba4c6053 1214 *dest = NULL;
AzureIoTClient 17:fa1bba4c6053 1215 }
AzureIoTClient 17:fa1bba4c6053 1216
AzureIoTClient 17:fa1bba4c6053 1217 if (mallocAndStrcpy_s(dest, agentData->value.edmStringNoQuotes.chars) != 0)
AzureIoTClient 17:fa1bba4c6053 1218 {
AzureIoTClient 17:fa1bba4c6053 1219 LogError("failure in mallocAndStrcpy_s");
AzureIoTClient 17:fa1bba4c6053 1220 result = AGENT_DATA_TYPES_ERROR;
AzureIoTClient 17:fa1bba4c6053 1221 }
AzureIoTClient 17:fa1bba4c6053 1222 else
AzureIoTClient 17:fa1bba4c6053 1223 {
AzureIoTClient 17:fa1bba4c6053 1224 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 17:fa1bba4c6053 1225 }
AzureIoTClient 4:233dd7616d73 1226 }
AzureIoTClient 4:233dd7616d73 1227 return result;
AzureIoTClient 4:233dd7616d73 1228 }
AzureIoTClient 4:233dd7616d73 1229
AzureIoTClient 17:fa1bba4c6053 1230 static void C2(GlobalInitialize_, ascii_char_ptr_no_quotes)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1231 {
AzureIoTClient 17:fa1bba4c6053 1232 *(ascii_char_ptr_no_quotes*)dest = NULL;
AzureIoTClient 17:fa1bba4c6053 1233 }
AzureIoTClient 17:fa1bba4c6053 1234
AzureIoTClient 17:fa1bba4c6053 1235 static void C2(GlobalDeinitialize_, ascii_char_ptr_no_quotes)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1236 {
AzureIoTClient 17:fa1bba4c6053 1237 if (*(ascii_char_ptr_no_quotes*)dest != NULL)
AzureIoTClient 17:fa1bba4c6053 1238 {
AzureIoTClient 17:fa1bba4c6053 1239 free(*(ascii_char_ptr_no_quotes*)dest);
AzureIoTClient 17:fa1bba4c6053 1240 }
AzureIoTClient 17:fa1bba4c6053 1241 }
AzureIoTClient 17:fa1bba4c6053 1242
AzureIoTClient 4:233dd7616d73 1243 /*Codes_SRS_SERIALIZER_99_051:[ EDM_DATE_TIME_OFFSET*/
AzureIoTClient 4:233dd7616d73 1244 /*Codes_SRS_SERIALIZER_99_053:[Create_AGENT_DATA_TYPE_from_EDM_DATE_TIME_OFFSET]*/
AzureIoTClient 4:233dd7616d73 1245 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, EDM_DATE_TIME_OFFSET)(AGENT_DATA_TYPE* dest, EDM_DATE_TIME_OFFSET source)
AzureIoTClient 4:233dd7616d73 1246 {
AzureIoTClient 4:233dd7616d73 1247 return Create_AGENT_DATA_TYPE_from_EDM_DATE_TIME_OFFSET(dest, source);
AzureIoTClient 4:233dd7616d73 1248 }
AzureIoTClient 4:233dd7616d73 1249
AzureIoTClient 4:233dd7616d73 1250 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, EDM_DATE_TIME_OFFSET)(const AGENT_DATA_TYPE* agentData, EDM_DATE_TIME_OFFSET* dest)
AzureIoTClient 4:233dd7616d73 1251 {
AzureIoTClient 4:233dd7616d73 1252 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 1253 if (agentData->type != EDM_DATE_TIME_OFFSET_TYPE)
AzureIoTClient 4:233dd7616d73 1254 {
AzureIoTClient 4:233dd7616d73 1255 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1256 }
AzureIoTClient 4:233dd7616d73 1257 else
AzureIoTClient 4:233dd7616d73 1258 {
AzureIoTClient 4:233dd7616d73 1259 *dest = agentData->value.edmDateTimeOffset;
AzureIoTClient 4:233dd7616d73 1260 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 1261 }
AzureIoTClient 4:233dd7616d73 1262 return result;
AzureIoTClient 4:233dd7616d73 1263 }
AzureIoTClient 4:233dd7616d73 1264
AzureIoTClient 17:fa1bba4c6053 1265 static void C2(GlobalInitialize_, EDM_DATE_TIME_OFFSET)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1266 {
AzureIoTClient 17:fa1bba4c6053 1267 memset(dest, 0, sizeof(EDM_DATE_TIME_OFFSET));
AzureIoTClient 17:fa1bba4c6053 1268 }
AzureIoTClient 17:fa1bba4c6053 1269
AzureIoTClient 17:fa1bba4c6053 1270 static void C2(GlobalDeinitialize_, EDM_DATE_TIME_OFFSET)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1271 {
AzureIoTClient 17:fa1bba4c6053 1272 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 1273 }
AzureIoTClient 17:fa1bba4c6053 1274
AzureIoTClient 4:233dd7616d73 1275 /*Codes_SRS_SERIALIZER_99_072:[ EDM_GUID]*/
AzureIoTClient 4:233dd7616d73 1276 /*Codes_SRS_SERIALIZER_99_073:[ Create_AGENT_DATA_TYPE_from_EDM_GUID]*/
AzureIoTClient 4:233dd7616d73 1277 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, EDM_GUID)(AGENT_DATA_TYPE* dest, EDM_GUID guid)
AzureIoTClient 4:233dd7616d73 1278 {
AzureIoTClient 4:233dd7616d73 1279 return Create_AGENT_DATA_TYPE_from_EDM_GUID(dest, guid);
AzureIoTClient 4:233dd7616d73 1280 }
AzureIoTClient 4:233dd7616d73 1281
AzureIoTClient 4:233dd7616d73 1282 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, EDM_GUID)(const AGENT_DATA_TYPE* agentData, EDM_GUID* dest)
AzureIoTClient 4:233dd7616d73 1283 {
AzureIoTClient 4:233dd7616d73 1284 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 1285 if (agentData->type != EDM_GUID_TYPE)
AzureIoTClient 4:233dd7616d73 1286 {
AzureIoTClient 4:233dd7616d73 1287 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1288 }
AzureIoTClient 4:233dd7616d73 1289 else
AzureIoTClient 4:233dd7616d73 1290 {
AzureIoTClient 22:422d94bd3c18 1291 (void)memcpy(dest->GUID, agentData->value.edmGuid.GUID, 16);
AzureIoTClient 4:233dd7616d73 1292 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 1293 }
AzureIoTClient 4:233dd7616d73 1294 return result;
AzureIoTClient 4:233dd7616d73 1295 }
AzureIoTClient 4:233dd7616d73 1296
AzureIoTClient 17:fa1bba4c6053 1297 static void C2(GlobalInitialize_, EDM_GUID)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1298 {
AzureIoTClient 17:fa1bba4c6053 1299 memset(dest, 0, sizeof(EDM_GUID));
AzureIoTClient 17:fa1bba4c6053 1300 }
AzureIoTClient 17:fa1bba4c6053 1301
AzureIoTClient 17:fa1bba4c6053 1302 static void C2(GlobalDeinitialize_, EDM_GUID)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1303 {
AzureIoTClient 17:fa1bba4c6053 1304 (void)(dest);
AzureIoTClient 17:fa1bba4c6053 1305 }
AzureIoTClient 17:fa1bba4c6053 1306
AzureIoTClient 17:fa1bba4c6053 1307
AzureIoTClient 4:233dd7616d73 1308 /*Codes_SRS_SERIALIZER_99_074:[ EDM_BINARY]*/
AzureIoTClient 4:233dd7616d73 1309 /*Codes_SRS_SERIALIZER_99_075:[ Create_AGENT_DATA_TYPE_from_EDM_BINARY]*/
AzureIoTClient 4:233dd7616d73 1310 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, EDM_BINARY)(AGENT_DATA_TYPE* dest, EDM_BINARY edmBinary)
AzureIoTClient 4:233dd7616d73 1311 {
AzureIoTClient 4:233dd7616d73 1312 return Create_AGENT_DATA_TYPE_from_EDM_BINARY(dest, edmBinary);
AzureIoTClient 4:233dd7616d73 1313 }
AzureIoTClient 4:233dd7616d73 1314
AzureIoTClient 4:233dd7616d73 1315 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, EDM_BINARY)(const AGENT_DATA_TYPE* agentData, EDM_BINARY* dest)
AzureIoTClient 4:233dd7616d73 1316 {
AzureIoTClient 4:233dd7616d73 1317 AGENT_DATA_TYPES_RESULT result;
AzureIoTClient 4:233dd7616d73 1318 if (agentData->type != EDM_BINARY_TYPE)
AzureIoTClient 4:233dd7616d73 1319 {
AzureIoTClient 4:233dd7616d73 1320 result = AGENT_DATA_TYPES_INVALID_ARG;
AzureIoTClient 4:233dd7616d73 1321 }
AzureIoTClient 4:233dd7616d73 1322 else
AzureIoTClient 4:233dd7616d73 1323 {
AzureIoTClient 4:233dd7616d73 1324 if ((dest->data = (unsigned char *)malloc(agentData->value.edmBinary.size)) == NULL) /*cast because this get included in a C++ file.*/
AzureIoTClient 4:233dd7616d73 1325 {
AzureIoTClient 4:233dd7616d73 1326 result = AGENT_DATA_TYPES_ERROR;
AzureIoTClient 4:233dd7616d73 1327 }
AzureIoTClient 4:233dd7616d73 1328 else
AzureIoTClient 4:233dd7616d73 1329 {
AzureIoTClient 22:422d94bd3c18 1330 (void)memcpy(dest->data, agentData->value.edmBinary.data, agentData->value.edmBinary.size);
AzureIoTClient 4:233dd7616d73 1331 dest->size = agentData->value.edmBinary.size;
AzureIoTClient 4:233dd7616d73 1332 result = AGENT_DATA_TYPES_OK;
AzureIoTClient 4:233dd7616d73 1333 }
AzureIoTClient 4:233dd7616d73 1334 }
AzureIoTClient 4:233dd7616d73 1335 return result;
AzureIoTClient 4:233dd7616d73 1336 }
AzureIoTClient 4:233dd7616d73 1337
AzureIoTClient 17:fa1bba4c6053 1338 static void C2(GlobalInitialize_, EDM_BINARY)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1339 {
AzureIoTClient 17:fa1bba4c6053 1340 ((EDM_BINARY*)dest)->data = NULL;
AzureIoTClient 17:fa1bba4c6053 1341 ((EDM_BINARY*)dest)->size = 0;
AzureIoTClient 17:fa1bba4c6053 1342 }
AzureIoTClient 17:fa1bba4c6053 1343
AzureIoTClient 17:fa1bba4c6053 1344 static void C2(GlobalDeinitialize_, EDM_BINARY)(void* dest)
AzureIoTClient 17:fa1bba4c6053 1345 {
AzureIoTClient 17:fa1bba4c6053 1346 if ((((EDM_BINARY*)dest)->data) != NULL)
AzureIoTClient 17:fa1bba4c6053 1347 {
AzureIoTClient 17:fa1bba4c6053 1348 free(((EDM_BINARY*)dest)->data);
AzureIoTClient 17:fa1bba4c6053 1349 }
AzureIoTClient 17:fa1bba4c6053 1350 }
AzureIoTClient 17:fa1bba4c6053 1351
AzureIoTClient 4:233dd7616d73 1352 static void C2(destroyLocalParameter, EDM_BINARY)(EDM_BINARY* value)
AzureIoTClient 4:233dd7616d73 1353 {
AzureIoTClient 4:233dd7616d73 1354 if (value != NULL)
AzureIoTClient 4:233dd7616d73 1355 {
AzureIoTClient 4:233dd7616d73 1356 free(value->data);
AzureIoTClient 4:233dd7616d73 1357 value->data = NULL;
AzureIoTClient 4:233dd7616d73 1358 value->size = 0;
AzureIoTClient 4:233dd7616d73 1359 }
AzureIoTClient 4:233dd7616d73 1360 }
AzureIoTClient 4:233dd7616d73 1361
AzureIoTClient 4:233dd7616d73 1362 static void C2(destroyLocalParameter, EDM_BOOLEAN)(EDM_BOOLEAN* value)
AzureIoTClient 4:233dd7616d73 1363 {
AzureIoTClient 4:233dd7616d73 1364 (void)value;
AzureIoTClient 4:233dd7616d73 1365 }
AzureIoTClient 4:233dd7616d73 1366
AzureIoTClient 4:233dd7616d73 1367 static void C2(destroyLocalParameter, EDM_BYTE)(EDM_BYTE* value)
AzureIoTClient 4:233dd7616d73 1368 {
AzureIoTClient 4:233dd7616d73 1369 (void)value;
AzureIoTClient 4:233dd7616d73 1370 }
AzureIoTClient 4:233dd7616d73 1371
AzureIoTClient 4:233dd7616d73 1372 static void C2(destroyLocalParameter, EDM_DATE)(EDM_DATE* value)
AzureIoTClient 4:233dd7616d73 1373 {
AzureIoTClient 4:233dd7616d73 1374 (void)value;
AzureIoTClient 4:233dd7616d73 1375 }
AzureIoTClient 4:233dd7616d73 1376
AzureIoTClient 4:233dd7616d73 1377 static void C2(destroyLocalParameter, EDM_DATE_TIME_OFFSET)(EDM_DATE_TIME_OFFSET* value)
AzureIoTClient 4:233dd7616d73 1378 {
AzureIoTClient 4:233dd7616d73 1379 (void)value;
AzureIoTClient 4:233dd7616d73 1380 }
AzureIoTClient 4:233dd7616d73 1381
AzureIoTClient 4:233dd7616d73 1382 static void C2(destroyLocalParameter, EDM_DECIMAL)(EDM_DECIMAL* value)
AzureIoTClient 4:233dd7616d73 1383 {
AzureIoTClient 4:233dd7616d73 1384 if (value != NULL)
AzureIoTClient 4:233dd7616d73 1385 {
AzureIoTClient 4:233dd7616d73 1386 STRING_delete(value->value);
AzureIoTClient 4:233dd7616d73 1387 value->value = NULL;
AzureIoTClient 4:233dd7616d73 1388 }
AzureIoTClient 4:233dd7616d73 1389 }
AzureIoTClient 4:233dd7616d73 1390
AzureIoTClient 4:233dd7616d73 1391 static void C2(destroyLocalParameter, EDM_DOUBLE)(EDM_DOUBLE* value)
AzureIoTClient 4:233dd7616d73 1392 {
AzureIoTClient 4:233dd7616d73 1393 (void)value;
AzureIoTClient 4:233dd7616d73 1394 }
AzureIoTClient 4:233dd7616d73 1395
AzureIoTClient 4:233dd7616d73 1396 static void C2(destroyLocalParameter, EDM_DURATION)(EDM_DURATION* value)
AzureIoTClient 4:233dd7616d73 1397 {
AzureIoTClient 4:233dd7616d73 1398 if (value != NULL)
AzureIoTClient 4:233dd7616d73 1399 {
AzureIoTClient 4:233dd7616d73 1400 free(value->digits);
AzureIoTClient 4:233dd7616d73 1401 value->digits = NULL;
AzureIoTClient 4:233dd7616d73 1402 value->nDigits = 0;
AzureIoTClient 4:233dd7616d73 1403 }
AzureIoTClient 4:233dd7616d73 1404 }
AzureIoTClient 4:233dd7616d73 1405
AzureIoTClient 4:233dd7616d73 1406 static void C2(destroyLocalParameter, EDM_GUID)(EDM_GUID* value)
AzureIoTClient 4:233dd7616d73 1407 {
AzureIoTClient 4:233dd7616d73 1408 (void)value;
AzureIoTClient 4:233dd7616d73 1409 }
AzureIoTClient 4:233dd7616d73 1410
AzureIoTClient 4:233dd7616d73 1411 static void C2(destroyLocalParameter, EDM_INT16)(EDM_INT16* value)
AzureIoTClient 4:233dd7616d73 1412 {
AzureIoTClient 4:233dd7616d73 1413 (void)value;
AzureIoTClient 4:233dd7616d73 1414 }
AzureIoTClient 4:233dd7616d73 1415
AzureIoTClient 4:233dd7616d73 1416 static void C2(destroyLocalParameter, EDM_INT32)(EDM_INT32* value)
AzureIoTClient 4:233dd7616d73 1417 {
AzureIoTClient 4:233dd7616d73 1418 (void)value;
AzureIoTClient 4:233dd7616d73 1419 }
AzureIoTClient 4:233dd7616d73 1420
AzureIoTClient 4:233dd7616d73 1421 static void C2(destroyLocalParameter, EDM_INT64)(EDM_INT64* value)
AzureIoTClient 4:233dd7616d73 1422 {
AzureIoTClient 4:233dd7616d73 1423 (void)value;
AzureIoTClient 4:233dd7616d73 1424 }
AzureIoTClient 4:233dd7616d73 1425
AzureIoTClient 4:233dd7616d73 1426 static void C2(destroyLocalParameter, EDM_SBYTE)(EDM_SBYTE* value)
AzureIoTClient 4:233dd7616d73 1427 {
AzureIoTClient 4:233dd7616d73 1428 (void)value;
AzureIoTClient 4:233dd7616d73 1429 }
AzureIoTClient 4:233dd7616d73 1430
AzureIoTClient 4:233dd7616d73 1431 static void C2(destroyLocalParameter, EDM_SINGLE)(EDM_SINGLE* value)
AzureIoTClient 4:233dd7616d73 1432 {
AzureIoTClient 4:233dd7616d73 1433 (void)value;
AzureIoTClient 4:233dd7616d73 1434 }
AzureIoTClient 4:233dd7616d73 1435
AzureIoTClient 4:233dd7616d73 1436 static void C2(destroyLocalParameter, EDM_STRING)(EDM_STRING* value)
AzureIoTClient 4:233dd7616d73 1437 {
AzureIoTClient 4:233dd7616d73 1438 (void)value;
AzureIoTClient 4:233dd7616d73 1439 }
AzureIoTClient 4:233dd7616d73 1440
AzureIoTClient 4:233dd7616d73 1441
AzureIoTClient 4:233dd7616d73 1442 static void C2(destroyLocalParameter, EDM_TIME_OF_DAY)(EDM_TIME_OF_DAY* value)
AzureIoTClient 4:233dd7616d73 1443 {
AzureIoTClient 4:233dd7616d73 1444 (void)value;
AzureIoTClient 4:233dd7616d73 1445 }
AzureIoTClient 4:233dd7616d73 1446
AzureIoTClient 4:233dd7616d73 1447 static void C2(destroyLocalParameter, int)(int* value)
AzureIoTClient 4:233dd7616d73 1448 {
AzureIoTClient 4:233dd7616d73 1449 (void)value;
AzureIoTClient 4:233dd7616d73 1450 }
AzureIoTClient 4:233dd7616d73 1451
AzureIoTClient 4:233dd7616d73 1452 static void C2(destroyLocalParameter, float)(float* value)
AzureIoTClient 4:233dd7616d73 1453 {
AzureIoTClient 4:233dd7616d73 1454 (void)value;
AzureIoTClient 4:233dd7616d73 1455 }
AzureIoTClient 4:233dd7616d73 1456
AzureIoTClient 4:233dd7616d73 1457 static void C2(destroyLocalParameter, double)(double* value)
AzureIoTClient 4:233dd7616d73 1458 {
AzureIoTClient 4:233dd7616d73 1459 (void)value;
AzureIoTClient 4:233dd7616d73 1460 }
AzureIoTClient 4:233dd7616d73 1461
AzureIoTClient 4:233dd7616d73 1462 static void C2(destroyLocalParameter, long)(long* value)
AzureIoTClient 4:233dd7616d73 1463 {
AzureIoTClient 4:233dd7616d73 1464 (void)value;
AzureIoTClient 4:233dd7616d73 1465 }
AzureIoTClient 4:233dd7616d73 1466
AzureIoTClient 4:233dd7616d73 1467 static void C2(destroyLocalParameter, int8_t)(int8_t* value)
AzureIoTClient 4:233dd7616d73 1468 {
AzureIoTClient 4:233dd7616d73 1469 (void)value;
AzureIoTClient 4:233dd7616d73 1470 }
AzureIoTClient 4:233dd7616d73 1471
AzureIoTClient 4:233dd7616d73 1472 static void C2(destroyLocalParameter, uint8_t)(uint8_t* value)
AzureIoTClient 4:233dd7616d73 1473 {
AzureIoTClient 4:233dd7616d73 1474 (void)value;
AzureIoTClient 4:233dd7616d73 1475 }
AzureIoTClient 4:233dd7616d73 1476
AzureIoTClient 4:233dd7616d73 1477 static void C2(destroyLocalParameter, int16_t)(int16_t* value)
AzureIoTClient 4:233dd7616d73 1478 {
AzureIoTClient 4:233dd7616d73 1479 (void)value;
AzureIoTClient 4:233dd7616d73 1480 }
AzureIoTClient 4:233dd7616d73 1481
AzureIoTClient 4:233dd7616d73 1482 static void C2(destroyLocalParameter, int32_t)(int32_t* value)
AzureIoTClient 4:233dd7616d73 1483 {
AzureIoTClient 4:233dd7616d73 1484 (void)value;
AzureIoTClient 4:233dd7616d73 1485 }
AzureIoTClient 4:233dd7616d73 1486
AzureIoTClient 4:233dd7616d73 1487 static void C2(destroyLocalParameter, int64_t)(int64_t* value)
AzureIoTClient 4:233dd7616d73 1488 {
AzureIoTClient 4:233dd7616d73 1489 (void)value;
AzureIoTClient 4:233dd7616d73 1490 }
AzureIoTClient 4:233dd7616d73 1491
AzureIoTClient 4:233dd7616d73 1492 static void C2(destroyLocalParameter, bool)(bool* value)
AzureIoTClient 4:233dd7616d73 1493 {
AzureIoTClient 4:233dd7616d73 1494 (void)value;
AzureIoTClient 4:233dd7616d73 1495 }
AzureIoTClient 4:233dd7616d73 1496
AzureIoTClient 4:233dd7616d73 1497 static void C2(destroyLocalParameter, ascii_char_ptr)(ascii_char_ptr* value)
AzureIoTClient 4:233dd7616d73 1498 {
AzureIoTClient 17:fa1bba4c6053 1499 if (value != NULL)
AzureIoTClient 17:fa1bba4c6053 1500 {
AzureIoTClient 17:fa1bba4c6053 1501 free(*value);
AzureIoTClient 17:fa1bba4c6053 1502 }
AzureIoTClient 17:fa1bba4c6053 1503
AzureIoTClient 4:233dd7616d73 1504 }
AzureIoTClient 4:233dd7616d73 1505
AzureIoTClient 4:233dd7616d73 1506 static void C2(destroyLocalParameter, ascii_char_ptr_no_quotes)(ascii_char_ptr_no_quotes* value)
AzureIoTClient 4:233dd7616d73 1507 {
AzureIoTClient 17:fa1bba4c6053 1508 if (value != NULL)
AzureIoTClient 17:fa1bba4c6053 1509 {
AzureIoTClient 17:fa1bba4c6053 1510 free(*value);
AzureIoTClient 17:fa1bba4c6053 1511 }
AzureIoTClient 4:233dd7616d73 1512 }
AzureIoTClient 4:233dd7616d73 1513
AzureIoTClient 4:233dd7616d73 1514 #ifdef __cplusplus
AzureIoTClient 4:233dd7616d73 1515 }
AzureIoTClient 4:233dd7616d73 1516 #endif
AzureIoTClient 4:233dd7616d73 1517
AzureIoTClient 4:233dd7616d73 1518 #endif /*SERIALIZER_H*/
AzureIoTClient 4:233dd7616d73 1519
AzureIoTClient 4:233dd7616d73 1520