A modelling and serializer library for Microsoft Azure IoTHub client applications

Dependents:   sht15_remote_monitoring f767zi_mqtt remote_monitoring simplesample_amqp ... more

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

Committer:
AzureIoTClient
Date:
Tue Jan 24 15:24:19 2017 -0800
Revision:
21:6d3dea1abd9c
Parent:
18:58b667752399
Child:
22:422d94bd3c18
1.1.5

Who changed what in which revision?

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