-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
50 #ifdef _CRTDBG_MAP_ALLOC
-
-
-
-
-
55 #include "macro_utils.h"
-
56 #include "iotdevice.h"
-
57 #include "crt_abstractions.h"
-
58 #include "iot_logging.h"
-
-
60 #include "codefirst.h"
-
61 #include "agenttypesystem.h"
-
-
-
-
-
-
-
-
-
70 #define IOT_AGENT_RESULT_ENUM_VALUES \
-
-
72 IOT_AGENT_AGENT_DATA_TYPES_ERROR, \
-
73 IOT_AGENT_COMMAND_EXECUTION_ERROR, \
-
-
75 IOT_AGENT_SERIALIZE_FAILED, \
-
-
-
78 DEFINE_ENUM(IOT_AGENT_RESULT, IOT_AGENT_RESULT_ENUM_VALUES);
-
-
-
-
-
-
91 #define BEGIN_NAMESPACE(schemaNamespace) \
-
-
-
99 #define END_NAMESPACE(schemaNamespace) \
-
100 REFLECTED_LIST_HEAD(schemaNamespace)
-
-
-
111 #define DECLARE_STRUCT(name, ...) \
-
-
113 typedef struct name##_TAG { \
-
114 FOR_EACH_2(INSERT_FIELD_INTO_STRUCT, __VA_ARGS__) \
-
-
-
117 REFLECTED_STRUCT(name) \
-
-
119 FOR_EACH_2_KEEP_1(REFLECTED_FIELD, name, __VA_ARGS__) \
-
120 TO_AGENT_DATA_TYPE(name, __VA_ARGS__) \
-
-
122 static AGENT_DATA_TYPES_RESULT FromAGENT_DATA_TYPE_##name(const AGENT_DATA_TYPE* source, name* destination) \
-
-
124 AGENT_DATA_TYPES_RESULT result; \
-
125 if(source->type != EDM_COMPLEX_TYPE_TYPE) \
-
-
127 result = AGENT_DATA_TYPES_INVALID_ARG; \
-
-
129 else if(DIV2(COUNT_ARG(__VA_ARGS__)) != source->value.edmComplexType.nMembers) \
-
-
-
132 result = AGENT_DATA_TYPES_INVALID_ARG; \
-
-
-
-
136 result = AGENT_DATA_TYPES_OK; \
-
137 FOR_EACH_2(BUILD_DESTINATION_FIELD, __VA_ARGS__); \
-
-
-
-
141 static void C2(destroyLocalParameter, name)(name * value) \
-
-
143 FOR_EACH_2_KEEP_1(UNBUILD_DESTINATION_FIELD, value, __VA_ARGS__); \
-
-
-
-
-
163 #define DECLARE_MODEL(name, ...) \
-
164 REFLECTED_MODEL(name) \
-
165 typedef struct name { int :1; FOR_EACH_1(BUILD_MODEL_STRUCT, __VA_ARGS__) } name; \
-
166 FOR_EACH_1_KEEP_1(CREATE_MODEL_ELEMENT, name, __VA_ARGS__) \
-
167 TO_AGENT_DATA_TYPE(name, DROP_FIRST_COMMA_FROM_ARGS(EXPAND_MODEL_ARGS(__VA_ARGS__)))
-
-
194 #define WITH_DATA(type, name) MODEL_PROPERTY(type, name)
-
-
-
206 #define WITH_ACTION(name, ...) MODEL_ACTION(name, __VA_ARGS__)
-
-
-
-
-
220 #define GET_MODEL_HANDLE(schemaNamespace, modelName) \
-
221 Schema_GetModelByName(CodeFirst_RegisterSchema(TOSTRING(schemaNamespace), &ALL_REFLECTED(schemaNamespace)), #modelName)
-
-
-
224 #define CREATE_DEVICE_WITH_INCLUDE_PROPERTY_PATH(schemaNamespace, modelName, serializerIncludePropertyPath) \
-
225 (modelName*)CodeFirst_CreateDevice(GET_MODEL_HANDLE(schemaNamespace, modelName), &ALL_REFLECTED(schemaNamespace), sizeof(modelName), serializerIncludePropertyPath)
-
-
-
228 #define CREATE_DEVICE_WITHOUT_INCLUDE_PROPERTY_PATH(schemaNamespace, modelName) \
-
229 (modelName*)CodeFirst_CreateDevice(GET_MODEL_HANDLE(schemaNamespace, modelName), &ALL_REFLECTED(schemaNamespace), sizeof(modelName), false)
-
-
-
-
-
-
235 #define CREATE_MODEL_INSTANCE(schemaNamespace, ...) \
-
236 IF(DIV2(COUNT_ARG(__VA_ARGS__)), CREATE_DEVICE_WITH_INCLUDE_PROPERTY_PATH, CREATE_DEVICE_WITHOUT_INCLUDE_PROPERTY_PATH) (schemaNamespace, __VA_ARGS__)
-
-
-
239 #define DESTROY_MODEL_INSTANCE(deviceData) \
-
240 CodeFirst_DestroyDevice(deviceData)
-
-
-
-
-
260 #define SERIALIZE(destination, destinationSize,...) ((CodeFirst_SendAsync(destination, destinationSize, COUNT_ARG(__VA_ARGS__) FOR_EACH_1(ADDRESS_MACRO, __VA_ARGS__)) == CODEFIRST_OK) ? IOT_AGENT_OK : IOT_AGENT_SERIALIZE_FAILED)
-
-
-
272 #define EXECUTE_COMMAND(device, command) (CodeFirst_ExecuteCommand(device, command))
-
-
-
-
-
-
-
-
280 #define DROP_FIRST_COMMA(N, x) \
-
-
-
283 #define DROP_IF_EMPTY(N, x) \
-
284 IF(COUNT_ARG(x),DROP_FIRST_COMMA(N,x),x)
-
-
286 #define DROP_FIRST_COMMA_FROM_ARGS(...) \
-
287 FOR_EACH_1_COUNTED(DROP_IF_EMPTY, C1(__VA_ARGS__))
-
-
-
-
291 #define DROP_FIRST_COMMA_0(N, x) \
-
-
-
294 #define DROP_FIRST_COMMA_1(N, x) \
-
-
-
297 #define DROP_FIRST_COMMA(empty, N, x) \
-
298 C2(DROP_FIRST_COMMA_,empty)(N,x)
-
-
300 #define DROP_IF_EMPTY(N, x) \
-
301 DROP_FIRST_COMMA(ISEMPTY(x),N,x)
-
-
303 #define DROP_FIRST_COMMA_FROM_ARGS(...) \
-
304 FOR_EACH_1_COUNTED(DROP_IF_EMPTY, __VA_ARGS__)
-
-
-
-
-
-
-
-
312 #define TO_AGENT_DT_EXPAND_MODEL_PROPERTY(x, y) ,x,y
-
313 #define TO_AGENT_DT_EXPAND_MODEL_ACTION(...)
-
-
315 #define TO_AGENT_DT_EXPAND_ELEMENT_ARGS(N, ...) TO_AGENT_DT_EXPAND_##__VA_ARGS__
-
-
317 #define EXPAND_MODEL_ARGS(...) \
-
318 FOR_EACH_1_COUNTED(TO_AGENT_DT_EXPAND_ELEMENT_ARGS, __VA_ARGS__)
-
-
320 #define TO_AGENT_DATA_TYPE(name, ...) \
-
321 static AGENT_DATA_TYPES_RESULT ToAGENT_DATA_TYPE_##name(AGENT_DATA_TYPE *destination, const name value) \
-
-
323 AGENT_DATA_TYPES_RESULT result = AGENT_DATA_TYPES_OK; \
-
324 size_t iMember = 0; \
-
325 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(phantomName, 1); \
-
326 const char* memberNames[IF(DIV2(C1(COUNT_ARG(__VA_ARGS__))), DIV2(C1(COUNT_ARG(__VA_ARGS__))), 1)] = { 0 }; \
-
327 size_t memberCount = sizeof(memberNames) / sizeof(memberNames[0]); \
-
-
329 if (memberCount == 0) \
-
-
331 result = AGENT_DATA_TYPES_OK; \
-
-
-
-
335 AGENT_DATA_TYPE members[sizeof(memberNames) / sizeof(memberNames[0])]; \
-
336 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(phantomName, 2); \
-
337 FOR_EACH_2(FIELD_AS_STRING, EXPAND_TWICE(__VA_ARGS__)) \
-
-
339 INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL; \
-
340 FOR_EACH_2(CREATE_AGENT_DATA_TYPE, EXPAND_TWICE(__VA_ARGS__)) \
-
341 INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL; \
-
342 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)) \
-
343 ? AGENT_DATA_TYPES_OK \
-
344 : AGENT_DATA_TYPES_ERROR; \
-
-
-
347 for (jMember = 0; jMember < iMember; jMember++) \
-
-
349 Destroy_AGENT_DATA_TYPE(&members[jMember]); \
-
-
-
-
-
-
-
356 #define FIELD_AS_STRING(x,y) memberNames[iMember++] = #y;
-
-
358 #define REFLECTED_LIST_HEAD(name) \
-
359 static const REFLECTED_DATA_FROM_DATAPROVIDER ALL_REFLECTED(name) = { &C2(REFLECTED_, C1(DEC(__COUNTER__))) };
-
360 #define REFLECTED_STRUCT(name) \
-
361 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_STRUCT_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {TOSTRING(name)}, {0}, {0}, {0}, {0}} };
-
362 #define REFLECTED_FIELD(XstructName, XfieldType, XfieldName) \
-
363 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_FIELD_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {TOSTRING(XfieldName), TOSTRING(XfieldType), TOSTRING(XstructName)}, {0}, {0}, {0} } };
-
364 #define REFLECTED_MODEL(name) \
-
365 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_MODEL_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {0}, {0}, {TOSTRING(name)} } };
-
366 #define REFLECTED_PROPERTY(type, name, modelName) \
-
367 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_PROPERTY_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {TOSTRING(name), TOSTRING(type), Create_AGENT_DATA_TYPE_From_Ptr_##name, offsetof(modelName, name), sizeof(type), TOSTRING(modelName)}, {0}, {0}} };
-
368 #define REFLECTED_ACTION(name, argc, argv, fn, modelName) \
-
369 static const REFLECTED_SOMETHING C2(REFLECTED_, C1(INC(__COUNTER__))) = { REFLECTION_ACTION_TYPE, &C2(REFLECTED_, C1(DEC(DEC(__COUNTER__)))), { {0}, {0}, {0}, {TOSTRING(name), (0 ? (uintptr_t)("", "") : argc), argv, fn, TOSTRING(modelName)}, {0}} };
-
370 #define REFLECTED_END_OF_LIST \
-
371 static const REFLECTED_SOMETHING C2(REFLECTED_, __COUNTER__) = { REFLECTION_NOTHING, NULL, { {0}, {0}, {0}, {0}, {0}} };
-
-
373 #define EXPAND_MODEL_PROPERTY(type, name) EXPAND_ARGS(MODEL_PROPERTY, type, name)
-
374 #define EXPAND_MODEL_ACTION(...) EXPAND_ARGS(MODEL_ACTION, __VA_ARGS__)
-
-
376 #define BUILD_MODEL_STRUCT(elem) INSERT_FIELD_FOR_##elem
-
-
378 #define CREATE_MODEL_ENTITY(modelName, callType, ...) EXPAND_ARGS(CREATE_##callType(modelName, __VA_ARGS__))
-
379 #define CREATE_SOMETHING(modelName, ...) EXPAND_ARGS(CREATE_MODEL_ENTITY(modelName, __VA_ARGS__))
-
380 #define CREATE_ELEMENT(modelName, elem) EXPAND_ARGS(CREATE_SOMETHING(modelName, EXPAND_ARGS(EXPAND_##elem)))
-
-
382 #define CREATE_MODEL_ELEMENT(modelName, elem) EXPAND_ARGS(CREATE_ELEMENT(modelName, elem))
-
-
384 #define INSERT_FIELD_INTO_STRUCT(x, y) x y;
-
385 #define INSERT_FIELD_FOR_MODEL_PROPERTY(type, name) INSERT_FIELD_INTO_STRUCT(type, name)
-
386 #define INSERT_FIELD_FOR_MODEL_ACTION(name, ...)
-
-
388 #define CREATE_MODEL_PROPERTY(modelName, type, name) \
-
389 IMPL_PROPERTY(type, name, modelName)
-
-
391 #define IMPL_PROPERTY(propertyType, propertyName, modelName) \
-
392 static int Create_AGENT_DATA_TYPE_From_Ptr_##propertyName(void* param, AGENT_DATA_TYPE* dest) \
-
-
394 return C1(ToAGENT_DATA_TYPE_##propertyType)(dest, *(propertyType*)param); \
-
-
396 REFLECTED_PROPERTY(propertyType, propertyName, modelName)
-
-
398 #define CREATE_MODEL_ACTION(modelName, actionName, ...) \
-
399 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(modelName##actionName, 1); \
-
400 EXECUTE_COMMAND_RESULT actionName (modelName* device FOR_EACH_2(DEFINE_FUNCTION_PARAMETER, __VA_ARGS__)); \
-
401 static EXECUTE_COMMAND_RESULT C2(actionName, WRAPPER)(void* device, size_t ParameterCount, const AGENT_DATA_TYPE* values); \
-
-
-
404 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 1); \
-
405 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} }; \
-
406 REFLECTED_ACTION(actionName, DIV2(COUNT_ARG(__VA_ARGS__)), C2(actionName, WRAPPERARGUMENTS), C2(actionName, WRAPPER), modelName) \
-
-
-
409 static EXECUTE_COMMAND_RESULT C2(actionName, WRAPPER)(void* device, size_t ParameterCount, const AGENT_DATA_TYPE* values) \
-
-
411 EXECUTE_COMMAND_RESULT result; \
-
412 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 2); \
-
-
414 if(ParameterCount != DIV2(COUNT_ARG(__VA_ARGS__))) \
-
-
416 result = EXECUTE_COMMAND_ERROR; \
-
-
-
-
-
421 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 3); \
-
422 IF(DIV2(COUNT_ARG(__VA_ARGS__)), size_t iParameter = 0;, ) \
-
423 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 4); \
-
-
425 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 5); \
-
426 FOR_EACH_2(DEFINE_LOCAL_PARAMETER, __VA_ARGS__) \
-
427 DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(actionName, 6); \
-
428 IF(DIV2(COUNT_ARG(__VA_ARGS__)), , (void)values;) \
-
429 INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL; \
-
430 FOR_EACH_2(START_BUILD_LOCAL_PARAMETER, __VA_ARGS__) \
-
431 INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL; \
-
432 result = actionName((modelName*)device FOR_EACH_2(PUSH_LOCAL_PARAMETER, __VA_ARGS__)); \
-
433 FOR_EACH_2(END_BUILD_LOCAL_PARAMETER, __VA_ARGS__) \
-
-
-
-
-
438 #define CREATE_AGENT_DATA_TYPE(type, name) \
-
439 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; \
-
440 iMember+= ((result==AGENT_DATA_TYPES_OK)?1:0);
-
-
442 #define BUILD_DESTINATION_FIELD(type, name) \
-
443 if(result == AGENT_DATA_TYPES_OK) \
-
-
-
446 bool wasFieldConverted = false; \
-
447 for (i = 0; i < source->value.edmComplexType.nMembers; i++) \
-
-
-
450 if (strcmp(source->value.edmComplexType.fields[i].fieldName, TOSTRING(name)) == 0) \
-
-
452 wasFieldConverted = (C2(FromAGENT_DATA_TYPE_, type)(source->value.edmComplexType.fields[i].value, &(destination->name)) == AGENT_DATA_TYPES_OK); \
-
-
-
-
456 result = (wasFieldConverted == true)? AGENT_DATA_TYPES_OK: AGENT_DATA_TYPES_INVALID_ARG; \
-
-
-
-
-
-
-
463 #define UNBUILD_DESTINATION_FIELD(value, type, name) \
-
464 C2(destroyLocalParameter, type)(&(value->name));
-
-
-
467 #define ADDRESS_MACRO(x) ,&x
-
-
469 #define KEEP_FIRST_(X, ...) X
-
-
471 #define KEEP_FIRST(X) KEEP_FIRST_ LPAREN X)
-
-
473 #define KEEP_FIRST(X) KEEP_FIRST_(X)
-
-
-
476 #define PROMOTIONMAP_float double, double
-
477 #define PROMOTIONMAP_int8_t int, int
-
478 #define PROMOTIONMAP_uint8_t int, int
-
479 #define PROMOTIONMAP_int16_t int, int
-
480 #define PROMOTIONMAP__Bool int, int
-
481 #define PROMOTIONMAP_bool int, int
-
-
483 #define CASTMAP_float (float), (float)
-
484 #define CASTMAP_int8_t (int8_t), (int8_t)
-
485 #define CASTMAP_uint8_t (uint8_t), (uint8_t)
-
486 #define CASTMAP_int16_t (int16_t), (int16_t)
-
487 #define CASTMAP__Bool 0!=, 0!=
-
488 #define CASTMAP_bool 0!=, 0!=
-
-
-
-
492 #define ANOTHERIF(x) C2(ANOTHERIF,x)
-
493 #define ANOTHERIF0(a,b) a
-
494 #define ANOTHERIF1(a,b) b
-
495 #define ANOTHERIF2(a,b) b
-
496 #define ANOTHERIF3(a,b) b
-
497 #define ANOTHERIF4(a,b) b
-
498 #define ANOTHERIF5(a,b) b
-
499 #define ANOTHERIF6(a,b) b
-
500 #define ANOTHERIF7(a,b) b
-
501 #define ANOTHERIF8(a,b) b
-
502 #define ANOTHERIF9(a,b) b
-
503 #define ANOTHERIF10(a,b) b
-
504 #define ANOTHERIF11(a,b) b
-
505 #define ANOTHERIF12(a,b) b
-
-
507 #define MAP_PROMOTED_TYPE(X) ANOTHERIF(DEC(COUNT_ARG(PROMOTIONMAP_##X))) (X, KEEP_FIRST(PROMOTIONMAP_##X))
-
508 #define MAP_CAST_TYPE(X) ANOTHERIF(DEC(COUNT_ARG(CASTMAP_##X))) (EMPTY_TOKEN, KEEP_FIRST(CASTMAP_##X) )
-
-
510 #define IFCOMMA(N) C2(IFCOMMA_, N)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
561 #define IFCOMMA_100 ,
-
562 #define IFCOMMA_102 ,
-
563 #define IFCOMMA_104 ,
-
564 #define IFCOMMA_106 ,
-
565 #define IFCOMMA_108 ,
-
566 #define IFCOMMA_110 ,
-
567 #define IFCOMMA_112 ,
-
568 #define IFCOMMA_114 ,
-
569 #define IFCOMMA_116 ,
-
570 #define IFCOMMA_118 ,
-
571 #define IFCOMMA_120 ,
-
572 #define IFCOMMA_122 ,
-
573 #define IFCOMMA_124 ,
-
574 #define IFCOMMA_126 ,
-
575 #define IFCOMMA_128 ,
-
-
577 #define DEFINE_LOCAL_PARAMETER(type, name) type C2(name,_local);
-
-
579 #define START_BUILD_LOCAL_PARAMETER(type, name) \
-
580 if (C2(FromAGENT_DATA_TYPE_, type)(&values[iParameter], &C2(name, _local)) != AGENT_DATA_TYPES_OK) \
-
-
-
583 result = EXECUTE_COMMAND_ERROR; \
-
-
-
-
-
-
589 #define END_BUILD_LOCAL_PARAMETER(type, name) \
-
590 (void)C2(destroyLocalParameter, type)(&C2(name, _local)); \
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
606 #define LOTS_OF_COMMA_TO_BE_EATEN \
-
607 "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
-
608 #define DEFINITION_THAT_CAN_SUSTAIN_A_COMMA_STEAL(name, instance) static const char* eatThese_COMMA_##name##instance[] = {LOTS_OF_COMMA_TO_BE_EATEN}
-
609 #define INSTRUCTION_THAT_CAN_SUSTAIN_A_COMMA_STEAL 0?LOTS_OF_COMMA_TO_BE_EATEN:LOTS_OF_COMMA_TO_BE_EATEN
-
-
611 #define PUSH_LOCAL_PARAMETER(type, name) , C2(name, _local)
-
612 #define DEFINE_FUNCTION_PARAMETER(type, name) , type name
-
613 #define MAKE_WRAPPER_ARGUMENT(N, type, name) {TOSTRING(type), TOSTRING(name)} IFCOMMA(N)
-
-
-
-
617 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_,
double)(AGENT_DATA_TYPE* dest,
double source)
-
-
619 return Create_AGENT_DATA_TYPE_from_DOUBLE(dest, source);
-
-
-
622 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_,
double)(
const AGENT_DATA_TYPE* agentData,
double* dest)
-
-
624 AGENT_DATA_TYPES_RESULT result;
-
625 if (agentData->type != EDM_DOUBLE_TYPE)
-
-
627 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
631 *dest = agentData->value.edmDouble.value;
-
632 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
639 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_,
float)(AGENT_DATA_TYPE* dest,
float source)
-
-
641 return Create_AGENT_DATA_TYPE_from_FLOAT(dest, source);
-
-
-
644 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_,
float)(
const AGENT_DATA_TYPE* agentData,
float* dest)
-
-
646 AGENT_DATA_TYPES_RESULT result;
-
647 if (agentData->type != EDM_SINGLE_TYPE)
-
-
649 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
653 *dest = agentData->value.edmSingle.value;
-
654 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
-
662 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_,
int)(AGENT_DATA_TYPE* dest,
int source)
-
-
664 return Create_AGENT_DATA_TYPE_from_SINT32(dest, source);
-
-
-
667 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_,
int)(
const AGENT_DATA_TYPE* agentData,
int* dest)
-
-
669 AGENT_DATA_TYPES_RESULT result;
-
670 if (agentData->type != EDM_INT32_TYPE)
-
-
672 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
676 *dest = agentData->value.edmInt32.value;
-
677 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
684 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_,
long)(AGENT_DATA_TYPE* dest,
long source)
-
-
686 return Create_AGENT_DATA_TYPE_from_SINT64(dest, source);
-
-
-
689 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_,
long)(
const AGENT_DATA_TYPE* agentData,
long* dest)
-
-
691 AGENT_DATA_TYPES_RESULT result;
-
692 if (agentData->type != EDM_INT64_TYPE)
-
-
694 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
698 *dest = (long)agentData->value.edmInt64.value;
-
699 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
706 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int8_t)(AGENT_DATA_TYPE* dest, int8_t source)
-
-
708 return Create_AGENT_DATA_TYPE_from_SINT8(dest, source);
-
-
-
711 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int8_t)(
const AGENT_DATA_TYPE* agentData, int8_t* dest)
-
-
713 AGENT_DATA_TYPES_RESULT result;
-
714 if (agentData->type != EDM_SBYTE_TYPE)
-
-
716 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
720 *dest = agentData->value.edmSbyte.value;
-
721 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
728 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, uint8_t)(AGENT_DATA_TYPE* dest, uint8_t source)
-
-
730 return Create_AGENT_DATA_TYPE_from_UINT8(dest, source);
-
-
-
733 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, uint8_t)(
const AGENT_DATA_TYPE* agentData, uint8_t* dest)
-
-
735 AGENT_DATA_TYPES_RESULT result;
-
736 if (agentData->type != EDM_BYTE_TYPE)
-
-
738 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
742 *dest = agentData->value.edmByte.value;
-
743 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
750 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int16_t)(AGENT_DATA_TYPE* dest, int16_t source)
-
-
752 return Create_AGENT_DATA_TYPE_from_SINT16(dest, source);
-
-
-
755 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int16_t)(
const AGENT_DATA_TYPE* agentData, int16_t* dest)
-
-
757 AGENT_DATA_TYPES_RESULT result;
-
758 if (agentData->type != EDM_INT16_TYPE)
-
-
760 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
764 *dest = agentData->value.edmInt16.value;
-
765 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
772 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int32_t)(AGENT_DATA_TYPE* dest, int32_t source)
-
-
774 return Create_AGENT_DATA_TYPE_from_SINT32(dest, source);
-
-
-
777 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int32_t)(
const AGENT_DATA_TYPE* agentData, int32_t* dest)
-
-
779 AGENT_DATA_TYPES_RESULT result;
-
780 if (agentData->type != EDM_INT32_TYPE)
-
-
782 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
786 *dest = agentData->value.edmInt32.value;
-
787 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
794 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, int64_t)(AGENT_DATA_TYPE* dest, int64_t source)
-
-
796 return Create_AGENT_DATA_TYPE_from_SINT64(dest, source);
-
-
-
799 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, int64_t)(
const AGENT_DATA_TYPE* agentData, int64_t* dest)
-
-
801 AGENT_DATA_TYPES_RESULT result;
-
802 if (agentData->type != EDM_INT64_TYPE)
-
-
804 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
808 *dest = agentData->value.edmInt64.value;
-
809 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
815 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_,
bool)(AGENT_DATA_TYPE* dest,
bool source)
-
-
817 return Create_EDM_BOOLEAN_from_int(dest, source ==
true);
-
-
-
820 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_,
bool)(
const AGENT_DATA_TYPE* agentData,
bool* dest)
-
-
822 AGENT_DATA_TYPES_RESULT result;
-
823 if (agentData->type != EDM_BOOLEAN_TYPE)
-
-
825 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
829 *dest = (agentData->value.edmBoolean.value == EDM_TRUE) ?
true :
false;
-
830 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
836 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, ascii_char_ptr)(AGENT_DATA_TYPE* dest, ascii_char_ptr source)
-
-
838 return Create_AGENT_DATA_TYPE_from_charz(dest, source);
-
-
-
841 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, ascii_char_ptr)(
const AGENT_DATA_TYPE* agentData, ascii_char_ptr* dest)
-
-
843 AGENT_DATA_TYPES_RESULT result;
-
844 if (agentData->type != EDM_STRING_TYPE)
-
-
846 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
850 *dest = agentData->value.edmString.chars;
-
851 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
856 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, ascii_char_ptr_no_quotes)(AGENT_DATA_TYPE* dest, ascii_char_ptr_no_quotes source)
-
-
858 return Create_AGENT_DATA_TYPE_from_charz_no_quotes(dest, source);
-
-
-
861 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)
-
-
863 AGENT_DATA_TYPES_RESULT result;
-
864 if (agentData->type != EDM_STRING_NO_QUOTES_TYPE)
-
-
866 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
870 *dest = agentData->value.edmStringNoQuotes.chars;
-
871 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
878 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, EDM_DATE_TIME_OFFSET)(AGENT_DATA_TYPE* dest, EDM_DATE_TIME_OFFSET source)
-
-
880 return Create_AGENT_DATA_TYPE_from_EDM_DATE_TIME_OFFSET(dest, source);
-
-
-
883 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, EDM_DATE_TIME_OFFSET)(
const AGENT_DATA_TYPE* agentData, EDM_DATE_TIME_OFFSET* dest)
-
-
885 AGENT_DATA_TYPES_RESULT result;
-
886 if (agentData->type != EDM_DATE_TIME_OFFSET_TYPE)
-
-
888 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
892 *dest = agentData->value.edmDateTimeOffset;
-
893 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
900 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, EDM_GUID)(AGENT_DATA_TYPE* dest, EDM_GUID guid)
-
-
902 return Create_AGENT_DATA_TYPE_from_EDM_GUID(dest, guid);
-
-
-
905 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, EDM_GUID)(
const AGENT_DATA_TYPE* agentData, EDM_GUID* dest)
-
-
907 AGENT_DATA_TYPES_RESULT result;
-
908 if (agentData->type != EDM_GUID_TYPE)
-
-
910 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
914 memcpy(dest->GUID, agentData->value.edmGuid.GUID, 16);
-
915 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
-
922 static AGENT_DATA_TYPES_RESULT C2(ToAGENT_DATA_TYPE_, EDM_BINARY)(AGENT_DATA_TYPE* dest, EDM_BINARY edmBinary)
-
-
924 return Create_AGENT_DATA_TYPE_from_EDM_BINARY(dest, edmBinary);
-
-
-
927 static AGENT_DATA_TYPES_RESULT C2(FromAGENT_DATA_TYPE_, EDM_BINARY)(
const AGENT_DATA_TYPE* agentData, EDM_BINARY* dest)
-
-
929 AGENT_DATA_TYPES_RESULT result;
-
930 if (agentData->type != EDM_BINARY_TYPE)
-
-
932 result = AGENT_DATA_TYPES_INVALID_ARG;
-
-
-
-
936 if ((dest->data = (
unsigned char *)malloc(agentData->value.edmBinary.size)) == NULL)
-
-
938 result = AGENT_DATA_TYPES_ERROR;
-
-
-
-
942 memcpy(dest->data, agentData->value.edmBinary.data, agentData->value.edmBinary.size);
-
943 dest->size = agentData->value.edmBinary.size;
-
944 result = AGENT_DATA_TYPES_OK;
-
-
-
-
-
-
950 static void C2(destroyLocalParameter, EDM_BINARY)(EDM_BINARY* value)
-
-
-
-
-
-
-
-
-
-
960 static void C2(destroyLocalParameter, EDM_BOOLEAN)(EDM_BOOLEAN* value)
-
-
-
-
-
965 static void C2(destroyLocalParameter, EDM_BYTE)(EDM_BYTE* value)
-
-
-
-
-
970 static void C2(destroyLocalParameter, EDM_DATE)(EDM_DATE* value)
-
-
-
-
-
975 static void C2(destroyLocalParameter, EDM_DATE_TIME_OFFSET)(EDM_DATE_TIME_OFFSET* value)
-
-
-
-
-
980 static void C2(destroyLocalParameter, EDM_DECIMAL)(EDM_DECIMAL* value)
-
-
-
-
984 STRING_delete(value->value);
-
-
-
-
-
989 static void C2(destroyLocalParameter, EDM_DOUBLE)(EDM_DOUBLE* value)
-
-
-
-
-
994 static void C2(destroyLocalParameter, EDM_DURATION)(EDM_DURATION* value)
-
-
-
-
-
999 value->digits = NULL;
-
-
-
-
-
1004 static void C2(destroyLocalParameter, EDM_GUID)(EDM_GUID* value)
-
-
-
-
-
1009 static void C2(destroyLocalParameter, EDM_INT16)(EDM_INT16* value)
-
-
-
-
-
1014 static void C2(destroyLocalParameter, EDM_INT32)(EDM_INT32* value)
-
-
-
-
-
1019 static void C2(destroyLocalParameter, EDM_INT64)(EDM_INT64* value)
-
-
-
-
-
1024 static void C2(destroyLocalParameter, EDM_SBYTE)(EDM_SBYTE* value)
-
-
-
-
-
1029 static void C2(destroyLocalParameter, EDM_SINGLE)(EDM_SINGLE* value)
-
-
-
-
-
1034 static void C2(destroyLocalParameter, EDM_STRING)(EDM_STRING* value)
-
-
-
-
-
-
1040 static void C2(destroyLocalParameter, EDM_TIME_OF_DAY)(EDM_TIME_OF_DAY* value)
-
-
-
-
-
1045 static void C2(destroyLocalParameter,
int)(
int* value)
-
-
-
-
-
1050 static void C2(destroyLocalParameter,
float)(
float* value)
-
-
-
-
-
1055 static void C2(destroyLocalParameter,
double)(
double* value)
-
-
-
-
-
1060 static void C2(destroyLocalParameter,
long)(
long* value)
-
-
-
-
-
1065 static void C2(destroyLocalParameter, int8_t)(int8_t* value)
-
-
-
-
-
1070 static void C2(destroyLocalParameter, uint8_t)(uint8_t* value)
-
-
-
-
-
1075 static void C2(destroyLocalParameter, int16_t)(int16_t* value)
-
-
-
-
-
1080 static void C2(destroyLocalParameter, int32_t)(int32_t* value)
-
-
-
-
-
1085 static void C2(destroyLocalParameter, int64_t)(int64_t* value)
-
-
-
-
-
1090 static void C2(destroyLocalParameter,
bool)(
bool* value)
-
-
-
-
-
1095 static void C2(destroyLocalParameter, ascii_char_ptr)(ascii_char_ptr* value)
-
-
-
-
-
1100 static void C2(destroyLocalParameter, ascii_char_ptr_no_quotes)(ascii_char_ptr_no_quotes* value)
-
-
-
-
-
-
-
-
-
-
-
-
The IoT Hub Serializer APIs allows developers to define models for their devices. ...
-