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:
Azure.IoT.Build
Date:
Wed Dec 14 16:00:39 2016 -0800
Revision:
18:58b667752399
Parent:
17:fa1bba4c6053
Child:
21:6d3dea1abd9c
1.1.2

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