|
@@ -27,9 +27,9 @@ builtin_types = ["Boolean", "SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32
|
|
|
|
|
|
# If the type does not contain pointers, it can be copied with memcpy
|
|
|
# (internally, not into the protocol message). This dict contains the sizes of
|
|
|
-# fixed-size types. Parsed types are added if they apply.
|
|
|
-builtin_fixed_size = ["Boolean", "SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32",
|
|
|
- "Int64", "UInt64", "Float", "Double", "DateTime", "Guid", "StatusCode"]
|
|
|
+# pointer-free types. Parsed types are added if they apply.
|
|
|
+builtin_pointerfree = ["Boolean", "SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32",
|
|
|
+ "Int64", "UInt64", "Float", "Double", "DateTime", "Guid", "StatusCode"]
|
|
|
|
|
|
# Some types can be memcpy'd off the binary stream. That's especially important
|
|
|
# for arrays. But we need to check if they contain padding and whether the
|
|
@@ -62,7 +62,7 @@ class Type(object):
|
|
|
self.typeIndex = outname.upper() + "_" + self.name.upper()
|
|
|
self.outname = outname
|
|
|
self.description = ""
|
|
|
- self.fixed_size = "false"
|
|
|
+ self.pointerfree = "false"
|
|
|
self.overlayable = "false"
|
|
|
if self.name in builtin_types:
|
|
|
self.builtin = "true"
|
|
@@ -89,7 +89,7 @@ class Type(object):
|
|
|
",\n#ifdef UA_ENABLE_TYPENAMES\n .typeName = \"%s\",\n#endif\n" % self.name + \
|
|
|
" .memSize = sizeof(UA_" + self.name + ")" + \
|
|
|
",\n .builtin = " + self.builtin + \
|
|
|
- ",\n .fixedSize = " + self.fixed_size + \
|
|
|
+ ",\n .pointerFree = " + self.pointerfree + \
|
|
|
",\n .overlayable = " + self.overlayable + \
|
|
|
",\n .binaryEncodingId = " + binaryEncodingId + \
|
|
|
",\n .membersSize = " + str(len(self.members)) + \
|
|
@@ -129,7 +129,7 @@ class Type(object):
|
|
|
def functions_c(self):
|
|
|
funcs = "static UA_INLINE void\nUA_%s_init(UA_%s *p) {\n memset(p, 0, sizeof(UA_%s));\n}\n\n" % (self.name, self.name, self.name)
|
|
|
funcs += "static UA_INLINE UA_%s *\nUA_%s_new(void) {\n return (UA_%s*)UA_new(%s);\n}\n\n" % (self.name, self.name, self.name, self.datatype_ptr())
|
|
|
- if self.fixed_size == "true":
|
|
|
+ if self.pointerfree == "true":
|
|
|
funcs += "static UA_INLINE UA_StatusCode\nUA_%s_copy(const UA_%s *src, UA_%s *dst) {\n *dst = *src;\n return UA_STATUSCODE_GOOD;\n}\n\n" % (self.name, self.name, self.name)
|
|
|
funcs += "static UA_INLINE void\nUA_%s_deleteMembers(UA_%s *p) { }\n\n" % (self.name, self.name)
|
|
|
else:
|
|
@@ -140,7 +140,7 @@ class Type(object):
|
|
|
|
|
|
def encoding_h(self):
|
|
|
enc = "static UA_INLINE UA_StatusCode\nUA_%s_encodeBinary(const UA_%s *src, UA_ByteString *dst, size_t *offset) {\n return UA_encodeBinary(src, %s, NULL, NULL, dst, offset);\n}\n"
|
|
|
- enc += "static UA_INLINE UA_StatusCode\nUA_%s_decodeBinary(const UA_ByteString *src, size_t *offset, UA_%s *dst) {\n return UA_decodeBinary(src, offset, dst, %s);\n}"
|
|
|
+ enc += "static UA_INLINE UA_StatusCode\nUA_%s_decodeBinary(const UA_ByteString *src, size_t *offset, UA_%s *dst) {\n return UA_decodeBinary(src, offset, dst, %s, 0, NULL);\n}"
|
|
|
return enc % tuple(list(itertools.chain(*itertools.repeat([self.name, self.name, self.datatype_ptr()], 2))))
|
|
|
|
|
|
class BuiltinType(Type):
|
|
@@ -150,9 +150,9 @@ class BuiltinType(Type):
|
|
|
self.typeIndex = "UA_TYPES_" + self.name.upper()
|
|
|
self.outname = "ua_types"
|
|
|
self.description = ""
|
|
|
- self.fixed_size = "false"
|
|
|
- if self.name in builtin_fixed_size:
|
|
|
- self.fixed_size = "true"
|
|
|
+ self.pointerfree = "false"
|
|
|
+ if self.name in builtin_pointerfree:
|
|
|
+ self.pointerfree = "true"
|
|
|
self.overlayable = "false"
|
|
|
if name in builtin_overlayable:
|
|
|
self.overlayable = builtin_overlayable[name]
|
|
@@ -167,7 +167,7 @@ class BuiltinType(Type):
|
|
|
class EnumerationType(Type):
|
|
|
def __init__(self, outname, xml):
|
|
|
Type.__init__(self, outname, xml)
|
|
|
- self.fixed_size = "true"
|
|
|
+ self.pointerfree = "true"
|
|
|
self.overlayable = "UA_BINARY_OVERLAYABLE_INTEGER"
|
|
|
self.members = [StructMember("", types["Int32"], False)] # encoded as uint32
|
|
|
self.builtin = "true"
|
|
@@ -213,12 +213,12 @@ class StructType(Type):
|
|
|
isArray = True if child.get("LengthField") else False
|
|
|
self.members.append(StructMember(memberName, memberType, isArray))
|
|
|
|
|
|
- self.fixed_size = "true"
|
|
|
+ self.pointerfree = "true"
|
|
|
self.overlayable = "true"
|
|
|
before = None
|
|
|
for m in self.members:
|
|
|
- if m.isArray or m.memberType.fixed_size != "true":
|
|
|
- self.fixed_size = "false"
|
|
|
+ if m.isArray or m.memberType.pointerfree != "true":
|
|
|
+ self.pointerfree = "false"
|
|
|
self.overlayable = "false"
|
|
|
else:
|
|
|
self.overlayable += " && " + m.memberType.overlayable
|