ua_types.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. #ifndef UA_TYPES_H_
  2. #define UA_TYPES_H_
  3. #include <stdio.h>
  4. #include <stdint.h>
  5. /**
  6. * @defgroup types Datatypes
  7. *
  8. * @brief This module describes the datatypes used in OPC UA. There is a
  9. * division into built-in datatypes (integers, strings, etc.) and more complex
  10. * datatypes that are comprise of built-in datatypes (structs defined in the OPC
  11. * UA standard).
  12. *
  13. * All datatypes follow the same schema in the naming of relevant functions.
  14. *
  15. * - <type>_init: Sets all values to a "safe" standard. For example, if the
  16. * datatype contains a string-element, its size will be set to zero.
  17. *
  18. * - <type>_new: Allocates the memory for the type and runs <type>_init on the
  19. * returned pointer.
  20. *
  21. * - <type>_copy: Copies a datatype. This performs a deep copy that iterates
  22. * over the members.
  23. *
  24. * - <type>_delete: Frees the memory where the datatype was stored.
  25. *
  26. * - <type>_deleteMembers: Frees the memory of dynamically sized members (e.g. a
  27. * string) of a datatype. This is useful when the datatype was allocated on
  28. * the stack, whereas the dynamically sized members is heap-allocated.
  29. *
  30. * @{
  31. */
  32. /* Function return values */
  33. #define UA_SUCCESS 0
  34. #define UA_NO_ERROR UA_SUCCESS
  35. #define UA_ERROR (0x01 << 31)
  36. #define UA_ERR_INCONSISTENT (UA_ERROR | (0x01 << 1))
  37. #define UA_ERR_INVALID_VALUE (UA_ERROR | (0x01 << 2))
  38. #define UA_ERR_NO_MEMORY (UA_ERROR | (0x01 << 3))
  39. #define UA_ERR_NOT_IMPLEMENTED (UA_ERROR | (0x01 << 4))
  40. /* Boolean values and null */
  41. #define UA_TRUE (42 == 42)
  42. #define TRUE UA_TRUE
  43. #define UA_FALSE (!UA_TRUE)
  44. #define FALSE UA_FALSE
  45. /* Compare values */
  46. #define UA_EQUAL 0
  47. #define UA_NOT_EQUAL (!UA_EQUAL)
  48. /** @brief A two-state logical value (true or false). */
  49. typedef _Bool UA_Boolean;
  50. /** @brief An integer value between −128 and 127. */
  51. typedef int8_t UA_SByte;
  52. /** @brief An integer value between 0 and 256. */
  53. typedef uint8_t UA_Byte;
  54. /** @brief An integer value between −32 768 and 32 767. */
  55. typedef int16_t UA_Int16;
  56. /** @brief An integer value between 0 and 65 535. */
  57. typedef uint16_t UA_UInt16;
  58. /** @brief An integer value between −2 147 483 648 and 2 147 483 647. */
  59. typedef int32_t UA_Int32;
  60. /** @brief An integer value between 0 and 429 4967 295. */
  61. typedef uint32_t UA_UInt32;
  62. /** @brief An integer value between −9 223 372 036 854 775 808 and 9 223 372 036 854 775 807 */
  63. typedef int64_t UA_Int64;
  64. /** @brief An integer value between 0 and 18 446 744 073 709 551 615. */
  65. typedef uint64_t UA_UInt64;
  66. /** @brief An IEEE single precision (32 bit) floating point value. */
  67. typedef float UA_Float;
  68. /** @brief An IEEE double precision (64 bit) floating point value. */
  69. typedef double UA_Double;
  70. /** @brief A sequence of Unicode characters. */
  71. typedef struct UA_String {
  72. UA_Int32 length;
  73. UA_Byte *data;
  74. } UA_String;
  75. /** @brief An instance in time. */
  76. typedef UA_Int64 UA_DateTime; //100 nanosecond resolution
  77. /** @brief A 16 byte value that can be used as a globally unique identifier. */
  78. typedef struct UA_Guid {
  79. UA_UInt32 data1;
  80. UA_UInt16 data2;
  81. UA_UInt16 data3;
  82. UA_Byte data4[8];
  83. } UA_Guid;
  84. /** @brief A sequence of octets. */
  85. typedef struct UA_String UA_ByteString;
  86. /** @brief An XML element. */
  87. typedef struct UA_String UA_XmlElement;
  88. /** @brief An identifier for a node in the address space of an OPC UA Server. */
  89. typedef struct UA_NodeId {
  90. UA_Byte encodingByte; //enum BID_NodeIdEncodingValuesType
  91. UA_UInt16 namespace;
  92. union {
  93. UA_UInt32 numeric;
  94. UA_String string;
  95. UA_Guid guid;
  96. UA_ByteString byteString;
  97. } identifier;
  98. } UA_NodeId;
  99. #define NS0NODEID(NUMERIC_ID) \
  100. (UA_NodeId){.encodingByte = 0 /*UA_NODEIDTYPE_TWOBYTE*/, .namespace = 0, .identifier.numeric = NUMERIC_ID}
  101. #define UA_NODEIDTYPE_NAMESPACE_URI_FLAG 0x80
  102. #define UA_NODEIDTYPE_SERVERINDEX_FLAG 0x40
  103. #define UA_NODEIDTYPE_MASK (~(UA_NODEIDTYPE_NAMESPACE_URI_FLAG | UA_NODEIDTYPE_SERVERINDEX_FLAG))
  104. /** @brief A NodeId that allows the namespace URI to be specified instead of an index. */
  105. typedef struct UA_ExpandedNodeId {
  106. UA_NodeId nodeId;
  107. UA_String namespaceUri;
  108. UA_UInt32 serverIndex;
  109. } UA_ExpandedNodeId;
  110. #define NS0EXPANDEDNODEID(NUMERIC_ID) \
  111. (UA_ExpandedNodeId){.nodeId = NS0NODEID(NUMERIC_ID), .namespaceUri = {-1, UA_NULL}, .serverIndex = 0}
  112. /** @brief A numeric identifier for a error or condition that is associated with a value or an operation. */
  113. typedef UA_UInt32 UA_StatusCode; // StatusCodes aren't an enum(=int) since 32 unsigned bits are needed. See also ua_statuscodes.h */
  114. /** @brief A name qualified by a namespace. */
  115. typedef struct UA_QualifiedName {
  116. UA_UInt16 namespaceIndex;
  117. UA_String name;
  118. } UA_QualifiedName;
  119. /** @brief Human readable text with an optional locale identifier. */
  120. typedef struct UA_LocalizedText {
  121. UA_String locale;
  122. UA_String text;
  123. } UA_LocalizedText;
  124. enum UA_LOCALIZEDTEXT_ENCODINGMASKTYPE_enum {
  125. UA_LOCALIZEDTEXT_ENCODINGMASKTYPE_LOCALE = 0x01,
  126. UA_LOCALIZEDTEXT_ENCODINGMASKTYPE_TEXT = 0x02
  127. };
  128. /** @brief A structure that contains an application specific data type that may
  129. not be recognized by the receiver. */
  130. typedef struct UA_ExtensionObject {
  131. UA_NodeId typeId;
  132. UA_Byte encoding; // Type of the enum UA_ExtensionObjectEncodingMaskType
  133. UA_ByteString body; // contains either the bytestring or a pointer to the memory-object
  134. } UA_ExtensionObject;
  135. enum UA_ExtensionObject_EncodingMaskType_enum {
  136. UA_EXTENSIONOBJECT_ENCODINGMASK_NOBODYISENCODED = 0x00,
  137. UA_EXTENSIONOBJECT_ENCODINGMASK_BODYISBYTESTRING = 0x01,
  138. UA_EXTENSIONOBJECT_ENCODINGMASK_BODYISXML = 0x02
  139. };
  140. struct UA_VTable_Entry; // forwards declaration
  141. typedef struct UA_VTable_Entry UA_VTable_Entry;
  142. /** @brief A union of all of the types specified above.
  143. *
  144. * Variants store (arrays of) built-in types. If you want to store a more
  145. * complex (or self-defined) type, you have to use an UA_ExtensionObject.*/
  146. typedef struct UA_Variant {
  147. UA_VTable_Entry *vt; // internal entry into vTable
  148. UA_Int32 arrayLength; // total number of elements
  149. void *data;
  150. UA_Int32 arrayDimensionsLength;
  151. UA_Int32 *arrayDimensions;
  152. } UA_Variant;
  153. /* VariantBinaryEncoding - Part: 6, Chapter: 5.2.2.16, Page: 22 */
  154. enum UA_VARIANT_ENCODINGMASKTYPE_enum {
  155. UA_VARIANT_ENCODINGMASKTYPE_TYPEID_MASK = 0x3F, // bits 0:5
  156. UA_VARIANT_ENCODINGMASKTYPE_DIMENSIONS = (0x01 << 6), // bit 6
  157. UA_VARIANT_ENCODINGMASKTYPE_ARRAY = (0x01 << 7) // bit 7
  158. };
  159. /** @brief A data value with an associated status code and timestamps. */
  160. typedef struct UA_DataValue {
  161. UA_Byte encodingMask;
  162. UA_Variant value;
  163. UA_StatusCode status;
  164. UA_DateTime sourceTimestamp;
  165. UA_Int16 sourcePicoseconds;
  166. UA_DateTime serverTimestamp;
  167. UA_Int16 serverPicoseconds;
  168. } UA_DataValue;
  169. enum UA_DATAVALUE_ENCODINGMASKTYPE_enum {
  170. UA_DATAVALUE_ENCODINGMASK_VARIANT = 0x01,
  171. UA_DATAVALUE_ENCODINGMASK_STATUSCODE = 0x02,
  172. UA_DATAVALUE_ENCODINGMASK_SOURCETIMESTAMP = 0x04,
  173. UA_DATAVALUE_ENCODINGMASK_SERVERTIMESTAMP = 0x08,
  174. UA_DATAVALUE_ENCODINGMASK_SOURCEPICOSECONDS = 0x10,
  175. UA_DATAVALUE_ENCODINGMASK_SERVERPICOSECONDS = 0x20
  176. };
  177. /** @brief A structure that contains detailed error and diagnostic information associated with a StatusCode. */
  178. typedef struct UA_DiagnosticInfo {
  179. UA_Byte encodingMask; // Type of the Enum UA_DIAGNOSTICINFO_ENCODINGMASKTYPE
  180. UA_Int32 symbolicId;
  181. UA_Int32 namespaceUri;
  182. UA_Int32 localizedText;
  183. UA_Int32 locale;
  184. UA_String additionalInfo;
  185. UA_StatusCode innerStatusCode;
  186. struct UA_DiagnosticInfo *innerDiagnosticInfo;
  187. } UA_DiagnosticInfo;
  188. enum UA_DIAGNOSTICINFO_ENCODINGMASKTYPE_enum {
  189. UA_DIAGNOSTICINFO_ENCODINGMASK_SYMBOLICID = 0x01,
  190. UA_DIAGNOSTICINFO_ENCODINGMASK_NAMESPACE = 0x02,
  191. UA_DIAGNOSTICINFO_ENCODINGMASK_LOCALIZEDTEXT = 0x04,
  192. UA_DIAGNOSTICINFO_ENCODINGMASK_LOCALE = 0x08,
  193. UA_DIAGNOSTICINFO_ENCODINGMASK_ADDITIONALINFO = 0x10,
  194. UA_DIAGNOSTICINFO_ENCODINGMASK_INNERSTATUSCODE = 0x20,
  195. UA_DIAGNOSTICINFO_ENCODINGMASK_INNERDIAGNOSTICINFO = 0x40
  196. };
  197. /** @brief Type use internally to denote an invalid datatype. */
  198. typedef void UA_InvalidType;
  199. /*************/
  200. /* Functions */
  201. /*************/
  202. #define UA_TYPE_PROTOTYPES(TYPE) \
  203. UA_Int32 TYPE##_new(TYPE **p); \
  204. UA_Int32 TYPE##_init(TYPE * p); \
  205. UA_Int32 TYPE##_delete(TYPE * p); \
  206. UA_Int32 TYPE##_deleteMembers(TYPE * p); \
  207. UA_Int32 TYPE##_copy(const TYPE *src, TYPE *dst); \
  208. void TYPE##_print(const TYPE *p, FILE *stream);
  209. /* Functions for all types */
  210. UA_TYPE_PROTOTYPES(UA_Boolean)
  211. UA_TYPE_PROTOTYPES(UA_SByte)
  212. UA_TYPE_PROTOTYPES(UA_Byte)
  213. UA_TYPE_PROTOTYPES(UA_Int16)
  214. UA_TYPE_PROTOTYPES(UA_UInt16)
  215. UA_TYPE_PROTOTYPES(UA_Int32)
  216. UA_TYPE_PROTOTYPES(UA_UInt32)
  217. UA_TYPE_PROTOTYPES(UA_Int64)
  218. UA_TYPE_PROTOTYPES(UA_UInt64)
  219. UA_TYPE_PROTOTYPES(UA_Float)
  220. UA_TYPE_PROTOTYPES(UA_Double)
  221. UA_TYPE_PROTOTYPES(UA_String)
  222. UA_TYPE_PROTOTYPES(UA_DateTime)
  223. UA_TYPE_PROTOTYPES(UA_Guid)
  224. UA_TYPE_PROTOTYPES(UA_ByteString)
  225. UA_TYPE_PROTOTYPES(UA_XmlElement)
  226. UA_TYPE_PROTOTYPES(UA_NodeId)
  227. UA_TYPE_PROTOTYPES(UA_ExpandedNodeId)
  228. UA_TYPE_PROTOTYPES(UA_StatusCode)
  229. UA_TYPE_PROTOTYPES(UA_QualifiedName)
  230. UA_TYPE_PROTOTYPES(UA_LocalizedText)
  231. UA_TYPE_PROTOTYPES(UA_ExtensionObject)
  232. UA_TYPE_PROTOTYPES(UA_DataValue)
  233. UA_TYPE_PROTOTYPES(UA_Variant)
  234. UA_TYPE_PROTOTYPES(UA_DiagnosticInfo)
  235. UA_TYPE_PROTOTYPES(UA_InvalidType)
  236. /* String */
  237. #define UA_STRING_NULL (UA_String){-1, UA_NULL}
  238. #define UA_STRING_STATIC(STRING) (UA_String){sizeof(STRING)-1, (UA_Byte*)STRING}
  239. UA_Int32 UA_String_copycstring(char const *src, UA_String *dst);
  240. UA_Int32 UA_String_copyprintf(char const *fmt, UA_String *dst, ...);
  241. UA_Int32 UA_String_equal(const UA_String *string1, const UA_String *string2);
  242. void UA_String_printf(char const *label, const UA_String *string);
  243. void UA_String_printx(char const *label, const UA_String *string);
  244. void UA_String_printx_hex(char const *label, const UA_String *string);
  245. /* DateTime */
  246. UA_DateTime UA_DateTime_now();
  247. typedef struct UA_DateTimeStruct {
  248. UA_Int16 nanoSec;
  249. UA_Int16 microSec;
  250. UA_Int16 milliSec;
  251. UA_Int16 sec;
  252. UA_Int16 min;
  253. UA_Int16 hour;
  254. UA_Int16 day;
  255. UA_Int16 mounth;
  256. UA_Int16 year;
  257. } UA_DateTimeStruct;
  258. UA_DateTimeStruct UA_DateTime_toStruct(UA_DateTime time);
  259. UA_Int32 UA_DateTime_toString(UA_DateTime time, UA_String *timeString);
  260. /* Guid */
  261. UA_Int32 UA_Guid_equal(const UA_Guid *g1, const UA_Guid *g2);
  262. /* ByteString */
  263. UA_Int32 UA_ByteString_equal(const UA_ByteString *string1, const UA_ByteString *string2);
  264. UA_Int32 UA_ByteString_newMembers(UA_ByteString *p, UA_Int32 length);
  265. void UA_ByteString_printf(char *label, const UA_ByteString *string);
  266. void UA_ByteString_printx(char *label, const UA_ByteString *string);
  267. void UA_ByteString_printx_hex(char *label, const UA_ByteString *string);
  268. /* NodeId */
  269. UA_Int32 UA_NodeId_equal(const UA_NodeId *n1, const UA_NodeId *n2);
  270. void UA_NodeId_printf(char *label, const UA_NodeId *node);
  271. UA_Boolean UA_NodeId_isNull(const UA_NodeId *p);
  272. UA_Int16 UA_NodeId_getNamespace(UA_NodeId const *id);
  273. UA_Int16 UA_NodeId_getIdentifier(UA_NodeId const *id);
  274. UA_Boolean UA_NodeId_isBasicType(UA_NodeId const *id);
  275. /* ExpandedNodeId */
  276. UA_Boolean UA_ExpandedNodeId_isNull(const UA_ExpandedNodeId *p);
  277. /* QualifiedName */
  278. #define UA_QUALIFIEDNAME_STATIC(STRING) \
  279. (UA_QualifiedName){0, {sizeof(STRING)-1, (UA_Byte*)STRING}}
  280. void UA_QualifiedName_printf(char const *label, const UA_QualifiedName *qn);
  281. /* LocalizedText */
  282. #define UA_LOCALIZEDTEXT_STATIC(STRING) (UA_LocalizedText){{2, (UA_Byte*)"en"}, UA_STRING_STATIC(STRING)}
  283. UA_Int32 UA_LocalizedText_copycstring(char const *src, UA_LocalizedText *dst);
  284. /* Variant */
  285. UA_Int32 UA_Variant_copySetValue(UA_Variant *v, UA_VTable_Entry *vt, const void *value);
  286. UA_Int32 UA_Variant_copySetArray(UA_Variant *v, UA_VTable_Entry *vt, UA_Int32 arrayLength, const void *array);
  287. /** @brief Functions UA_Variant_borrowSetValue and ..Array allow to define
  288. variants whose payload will not be deleted. This is achieved by a second
  289. vtable. The functionality can be used e.g. when UA_VariableNodes point into a
  290. "father" structured object that is stored in an UA_VariableNode itself. */
  291. UA_Int32 UA_Variant_borrowSetValue(UA_Variant *v, UA_VTable_Entry *vt, const void *value);
  292. UA_Int32 UA_Variant_borrowSetArray(UA_Variant *v, UA_VTable_Entry *vt, UA_Int32 arrayLength,
  293. const void *array);
  294. /* Array operations */
  295. UA_Int32 UA_Array_new(void **p, UA_Int32 noElements, UA_VTable_Entry *vt);
  296. UA_Int32 UA_Array_init(void *p, UA_Int32 noElements, UA_VTable_Entry *vt);
  297. UA_Int32 UA_Array_delete(void *p, UA_Int32 noElements, UA_VTable_Entry *vt);
  298. /* @brief The destination array is allocated according to noElements. */
  299. UA_Int32 UA_Array_copy(const void *src, UA_Int32 noElements, UA_VTable_Entry *vt, void **dst);
  300. void UA_Array_print(const void *p, UA_Int32 noElements, UA_VTable_Entry *vt, FILE *stream);
  301. /**********/
  302. /* VTable */
  303. /**********/
  304. /* @brief Returns the size of the encoded element.*/
  305. typedef UA_Int32 (*UA_calcSize)(const void *p);
  306. /* @brief The encoding function allocates the target bytestring. */
  307. typedef UA_Int32 (*UA_encode)(const void *src, UA_ByteString *dst, UA_UInt32 *offset);
  308. /* @brief The decoding function decodes a ByteString into an UA datatype. */
  309. typedef UA_Int32 (*UA_decode)(const UA_ByteString *src, UA_UInt32 *offset, void *dst);
  310. typedef struct UA_Encoding {
  311. UA_calcSize calcSize;
  312. UA_encode encode;
  313. UA_decode decode;
  314. } UA_Encoding;
  315. #define UA_ENCODING_BINARY 0
  316. #define UA_ENCODING_XML 1
  317. struct UA_VTable_Entry {
  318. UA_NodeId typeId;
  319. UA_Byte *name;
  320. UA_Int32 (*new)(void **p);
  321. UA_Int32 (*init)(void *p);
  322. UA_Int32 (*copy)(void const *src, void *dst);
  323. UA_Int32 (*delete)(void *p);
  324. UA_Int32 (*deleteMembers)(void *p);
  325. void (*print)(const void *p, FILE *stream);
  326. UA_UInt32 memSize; // size of the struct only in memory (no dynamic components)
  327. UA_Boolean dynMembers; // does the type contain members that are dynamically
  328. // allocated (strings, ..)? Otherwise, the size on
  329. // the wire == size in memory.
  330. UA_Encoding encodings[2]; // binary, xml, ...
  331. };
  332. typedef UA_Int32 (*UA_nodeIdToVTableIndex)(const UA_NodeId *id);
  333. typedef struct UA_VTable {
  334. UA_nodeIdToVTableIndex getTypeIndex;
  335. UA_VTable_Entry *types;
  336. } UA_VTable;
  337. /***********************************/
  338. /* Macros for type implementations */
  339. /***********************************/
  340. #define UA_TYPE_DEFAULT(TYPE) \
  341. UA_TYPE_DELETE_DEFAULT(TYPE) \
  342. UA_TYPE_DELETEMEMBERS_NOACTION(TYPE) \
  343. UA_TYPE_INIT_DEFAULT(TYPE) \
  344. UA_TYPE_NEW_DEFAULT(TYPE) \
  345. UA_TYPE_COPY_DEFAULT(TYPE) \
  346. #define UA_TYPE_NEW_DEFAULT(TYPE) \
  347. UA_Int32 TYPE##_new(TYPE **p) { \
  348. UA_Int32 retval = UA_SUCCESS; \
  349. retval |= UA_alloc((void **)p, sizeof(TYPE)); \
  350. retval |= TYPE##_init(*p); \
  351. return retval; \
  352. }
  353. #define UA_TYPE_INIT_DEFAULT(TYPE) \
  354. UA_Int32 TYPE##_init(TYPE * p) { \
  355. if(p == UA_NULL) return UA_ERROR; \
  356. *p = (TYPE)0; \
  357. return UA_SUCCESS; \
  358. }
  359. #define UA_TYPE_INIT_AS(TYPE, TYPE_AS) \
  360. UA_Int32 TYPE##_init(TYPE * p) { \
  361. return TYPE_AS##_init((TYPE_AS *)p); \
  362. }
  363. #define UA_TYPE_DELETE_DEFAULT(TYPE) \
  364. UA_Int32 TYPE##_delete(TYPE *p) { \
  365. UA_Int32 retval = UA_SUCCESS; \
  366. retval |= TYPE##_deleteMembers(p); \
  367. retval |= UA_free(p); \
  368. return retval; \
  369. }
  370. #define UA_TYPE_DELETE_AS(TYPE, TYPE_AS) \
  371. UA_Int32 TYPE##_delete(TYPE * p) { return TYPE_AS##_delete((TYPE_AS *)p); }
  372. #define UA_TYPE_DELETEMEMBERS_NOACTION(TYPE) \
  373. UA_Int32 TYPE##_deleteMembers(TYPE * p) { return UA_SUCCESS; }
  374. #define UA_TYPE_DELETEMEMBERS_AS(TYPE, TYPE_AS) \
  375. UA_Int32 TYPE##_deleteMembers(TYPE * p) { return TYPE_AS##_deleteMembers((TYPE_AS *)p); }
  376. /* Use only when the type has no arrays. Otherwise, implement deep copy */
  377. #define UA_TYPE_COPY_DEFAULT(TYPE) \
  378. UA_Int32 TYPE##_copy(TYPE const *src, TYPE *dst) { \
  379. if(src == UA_NULL || dst == UA_NULL) return UA_ERROR; \
  380. UA_Int32 retval = UA_SUCCESS; \
  381. retval |= UA_memcpy(dst, src, sizeof(TYPE)); \
  382. return retval; \
  383. }
  384. #define UA_TYPE_COPY_AS(TYPE, TYPE_AS) \
  385. UA_Int32 TYPE##_copy(TYPE const *src, TYPE *dst) { \
  386. return TYPE_AS##_copy((TYPE_AS *)src, (TYPE_AS *)dst); \
  387. }
  388. #define UA_TYPE_PRINT_AS(TYPE, TYPE_AS) \
  389. void TYPE##_print(TYPE const *p, FILE *stream) { \
  390. TYPE_AS##_print((TYPE_AS *)p, stream); \
  391. }
  392. #define UA_TYPE_AS(TYPE, TYPE_AS) \
  393. UA_TYPE_NEW_DEFAULT(TYPE) \
  394. UA_TYPE_INIT_AS(TYPE, TYPE_AS) \
  395. UA_TYPE_DELETE_AS(TYPE, TYPE_AS) \
  396. UA_TYPE_DELETEMEMBERS_AS(TYPE, TYPE_AS) \
  397. UA_TYPE_COPY_AS(TYPE, TYPE_AS) \
  398. UA_TYPE_PRINT_AS(TYPE, TYPE_AS)
  399. /// @} /* end of group */
  400. #endif /* UA_TYPES_H_ */