Quellcode durchsuchen

inline vtable function definition

Julius Pfrommer vor 9 Jahren
Ursprung
Commit
ced1172586
2 geänderte Dateien mit 12 neuen und 19 gelöschten Zeilen
  1. 6 13
      src/ua_types.h
  2. 6 6
      tools/generate_namespace.py

+ 6 - 13
src/ua_types.h

@@ -395,23 +395,16 @@ void UA_Array_print(const void *p, UA_Int32 noElements, UA_VTable_Entry *vt, FIL
 /* VTable */
 /**********/
 
-/* @brief Returns the size of the encoded element.*/
-typedef UA_Int32 (*UA_calcSize)(const void *p);
-
-/* @brief The encoding function allocates the target bytestring. */
-typedef UA_Int32 (*UA_encode)(const void *src, UA_ByteString *dst, UA_UInt32 *offset);
-
-/* @brief The decoding function decodes a ByteString into an UA datatype. */
-typedef UA_Int32 (*UA_decode)(const UA_ByteString *src, UA_UInt32 *offset, void *dst);
-
 typedef struct UA_Encoding {
-	UA_calcSize calcSize;
-	UA_encode   encode;
-	UA_decode   decode;
+	/**  Returns the size of the encoded element.*/
+	UA_Int32 (*calcSize)(const void *p);
+	/** Encodes the type into the destination bytestring. */
+	UA_Int32 (*encode)(const void *src, UA_ByteString *dst, UA_UInt32 *offset);
+	/** Decodes a ByteString into an UA datatype. */
+	UA_Int32 (*decode)(const UA_ByteString *src, UA_UInt32 *offset, void *dst);
 } UA_Encoding;
 
 #define UA_ENCODING_BINARY 0 // Binary encoding is always available
-// #define UA_ENCODING_XML 1 // This is set by the build script.
 
 struct UA_VTable_Entry {
 	UA_NodeId  typeId;

+ 6 - 6
tools/generate_namespace.py

@@ -176,12 +176,12 @@ for row in rows:
           "\n#endif" + 
           "\n.memSize=" + ("sizeof(%(name)s)" if (name != "UA_InvalidType") else "0") +
           ",\n.dynMembers=" + ("UA_FALSE" if (name in fixed_size) else "UA_TRUE") +
-          ",\n.encodings={{.calcSize=(UA_calcSize)%(name)s_calcSizeBinary" +
-          ",\n.encode=(UA_encode)%(name)s_encodeBinary" +
-          ",\n.decode=(UA_decode)%(name)s_decodeBinary}" +
-           (",\n{.calcSize=(UA_calcSize)%(name)s_calcSizeXml" +
-            ",\n.encode=(UA_encode)%(name)s_encodeXml" +
-            ",\n.decode=(UA_decode)%(name)s_decodeXml}" if (args.with_xml) else "") +
+           ",\n.encodings={{.calcSize=(UA_Int32(*)(const void*))%(name)s_calcSizeBinary" +
+           ",\n.encode=(UA_Int32(*)(const void*,UA_ByteString*,UA_UInt32*))%(name)s_encodeBinary" +
+           ",\n.decode=(UA_Int32(*)(const UA_ByteString*,UA_UInt32*,void*))%(name)s_decodeBinary}" +
+           (",\n{.calcSize=(UA_Int32(*)(const void*))%(name)s_calcSizeXml" +
+            ",\n.encode=(UA_Int32(*)(const void*,UA_ByteString*,UA_UInt32*))%(name)s_encodeXml" +
+            ",\n.decode=(UA_Int32(*)(const UA_ByteString*,UA_UInt32*,void*))%(name)s_decodeXml}" if (args.with_xml) else "") +
           "}},")
 
 printc('''}};''')