generate_datatypes.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. from __future__ import print_function
  2. import sys
  3. import time
  4. import platform
  5. import getpass
  6. from collections import OrderedDict
  7. import re
  8. import xml.etree.ElementTree as etree
  9. import itertools
  10. import argparse
  11. types = OrderedDict() # contains types that were already parsed
  12. typedescriptions = {} # contains type nodeids
  13. excluded_types = ["NodeIdType", "InstanceNode", "TypeNode", "Node", "ObjectNode",
  14. "ObjectTypeNode", "VariableNode", "VariableTypeNode", "ReferenceTypeNode",
  15. "MethodNode", "ViewNode", "DataTypeNode",
  16. "UA_ServerDiagnosticsSummaryDataType", "UA_SamplingIntervalDiagnosticsDataType",
  17. "UA_SessionSecurityDiagnosticsDataType", "UA_SubscriptionDiagnosticsDataType",
  18. "UA_SessionDiagnosticsDataType"]
  19. builtin_types = ["Boolean", "SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32",
  20. "Int64", "UInt64", "Float", "Double", "String", "DateTime", "Guid",
  21. "ByteString", "XmlElement", "NodeId", "ExpandedNodeId", "StatusCode",
  22. "QualifiedName", "LocalizedText", "ExtensionObject", "DataValue",
  23. "Variant", "DiagnosticInfo"]
  24. # If the type does not contain pointers, it can be copied with memcpy
  25. # (internally, not into the protocol message). This dict contains the sizes of
  26. # fixed-size types. Parsed types are added if they apply.
  27. builtin_fixed_size = ["Boolean", "SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32",
  28. "Int64", "UInt64", "Float", "Double", "DateTime", "Guid", "StatusCode"]
  29. # Some types can be memcpy'd off the binary stream. That's especially important
  30. # for arrays. But we need to check if they contain padding and whether the
  31. # endianness is correct. This dict gives the C-statement that must be true for the
  32. # type to be overlayable. Parsed types are added if they apply.
  33. builtin_overlayable = {"Boolean": "true", "SByte": "true", "Byte": "true",
  34. "Int16": "UA_BINARY_OVERLAYABLE_INTEGER", "UInt16": "UA_BINARY_OVERLAYABLE_INTEGER",
  35. "Int32": "UA_BINARY_OVERLAYABLE_INTEGER", "UInt32": "UA_BINARY_OVERLAYABLE_INTEGER",
  36. "Int64": "UA_BINARY_OVERLAYABLE_INTEGER", "UInt64": "UA_BINARY_OVERLAYABLE_INTEGER",
  37. "Float": "UA_BINARY_OVERLAYABLE_FLOAT", "Double": "UA_BINARY_OVERLAYABLE_FLOAT",
  38. "DateTime": "UA_BINARY_OVERLAYABLE_INTEGER", "StatusCode": "UA_BINARY_OVERLAYABLE_INTEGER",
  39. "Guid": "(UA_BINARY_OVERLAYABLE_INTEGER && offsetof(UA_Guid, data2) == sizeof(UA_UInt32) && " + \
  40. "offsetof(UA_Guid, data3) == (sizeof(UA_UInt16) + sizeof(UA_UInt32)) && " + \
  41. "offsetof(UA_Guid, data4) == (2*sizeof(UA_UInt32)))"}
  42. ################
  43. # Type Classes #
  44. ################
  45. class StructMember(object):
  46. def __init__(self, name, memberType, isArray):
  47. self.name = name
  48. self.memberType = memberType
  49. self.isArray = isArray
  50. class Type(object):
  51. def __init__(self, outname, xml):
  52. self.name = xml.get("Name")
  53. self.ns0 = ("true" if outname == "ua_types" else "false")
  54. self.typeIndex = outname.upper() + "_" + self.name.upper()
  55. self.outname = outname
  56. self.description = ""
  57. self.fixed_size = "false"
  58. self.overlayable = "false"
  59. if self.name in builtin_types:
  60. self.builtin = "true"
  61. else:
  62. self.builtin = "false"
  63. self.members = [StructMember("", self, False)] # Returns one member: itself. Overwritten by some types.
  64. for child in xml:
  65. if child.tag == "{http://opcfoundation.org/BinarySchema/}Documentation":
  66. self.description = child.text
  67. break
  68. def datatype_c(self):
  69. xmlEncodingId = "0"
  70. binaryEncodingId = "0"
  71. if self.name in typedescriptions:
  72. description = typedescriptions[self.name]
  73. typeid = "{.namespaceIndex = %s, .identifierType = UA_NODEIDTYPE_NUMERIC, .identifier.numeric = %s}" % (description.namespaceid, description.nodeid)
  74. xmlEncodingId = description.xmlEncodingId
  75. binaryEncodingId = description.binaryEncodingId
  76. else:
  77. typeid = "{.namespaceIndex = 0, .identifierType = UA_NODEIDTYPE_NUMERIC, .identifier.numeric = 0}"
  78. return "{ .typeId = " + typeid + \
  79. ",\n .typeIndex = " + self.typeIndex + \
  80. ",\n#ifdef UA_ENABLE_TYPENAMES\n .typeName = \"%s\",\n#endif\n" % self.name + \
  81. " .memSize = sizeof(UA_" + self.name + ")" + \
  82. ",\n .builtin = " + self.builtin + \
  83. ",\n .fixedSize = " + self.fixed_size + \
  84. ",\n .overlayable = " + self.overlayable + \
  85. ",\n .binaryEncodingId = " + binaryEncodingId + \
  86. ",\n .membersSize = " + str(len(self.members)) + \
  87. ",\n .members = %s_members" % self.name + " }"
  88. #",\n .xmlEncodingId = " + xmlEncodingId + \ Not used for now
  89. def members_c(self):
  90. members = "static UA_DataTypeMember %s_members[%s] = {" % (self.name, len(self.members))
  91. before = None
  92. for index, member in enumerate(self.members):
  93. m = "\n { .memberTypeIndex = %s_%s,\n" % (member.memberType.outname.upper(), member.memberType.name.upper())
  94. m += "#ifdef UA_ENABLE_TYPENAMES\n .memberName = \"%s\",\n#endif\n" % member.name
  95. m += " .namespaceZero = %s,\n" % member.memberType.ns0
  96. m += " .padding = "
  97. if not before:
  98. m += "0,\n"
  99. else:
  100. if member.isArray:
  101. m += "offsetof(UA_%s, %sSize)" % (self.name, member.name)
  102. else:
  103. m += "offsetof(UA_%s, %s)" % (self.name, member.name)
  104. m += " - offsetof(UA_%s, %s)" % (self.name, before.name)
  105. if before.isArray:
  106. m += " - sizeof(void*),\n"
  107. else:
  108. m += " - sizeof(UA_%s),\n" % before.memberType.name
  109. m += " .isArray = " + ("true" if member.isArray else "false")
  110. members += m + "\n },"
  111. before = member
  112. return members + "};"
  113. def datatype_ptr(self):
  114. return "&" + self.outname.upper() + "[" + self.outname.upper() + "_" + self.name.upper() + "]"
  115. def functions_c(self):
  116. 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)
  117. 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())
  118. if self.fixed_size == "true":
  119. 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)
  120. funcs += "static UA_INLINE void\nUA_%s_deleteMembers(UA_%s *p) { }\n\n" % (self.name, self.name)
  121. else:
  122. funcs += "static UA_INLINE UA_StatusCode\nUA_%s_copy(const UA_%s *src, UA_%s *dst) {\n return UA_copy(src, dst, %s);\n}\n\n" % (self.name, self.name, self.name, self.datatype_ptr())
  123. funcs += "static UA_INLINE void\nUA_%s_deleteMembers(UA_%s *p) {\n UA_deleteMembers(p, %s);\n}\n\n" % (self.name, self.name, self.datatype_ptr())
  124. funcs += "static UA_INLINE void\nUA_%s_delete(UA_%s *p) {\n UA_delete(p, %s);\n}" % (self.name, self.name, self.datatype_ptr())
  125. return funcs
  126. def encoding_h(self):
  127. 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"
  128. 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}"
  129. return enc % tuple(list(itertools.chain(*itertools.repeat([self.name, self.name, self.datatype_ptr()], 2))))
  130. class BuiltinType(Type):
  131. def __init__(self, name):
  132. self.name = name
  133. self.ns0 = "true"
  134. self.typeIndex = "UA_TYPES_" + self.name.upper()
  135. self.outname = "ua_types"
  136. self.description = ""
  137. self.fixed_size = "false"
  138. if self.name in builtin_fixed_size:
  139. self.fixed_size = "true"
  140. self.overlayable = "false"
  141. if name in builtin_overlayable:
  142. self.overlayable = builtin_overlayable[name]
  143. self.builtin = "true"
  144. if self.name == "QualifiedName":
  145. self.members = [StructMember("namespaceIndex", types["Int16"], False), StructMember("name", types["String"], False)]
  146. elif self.name in ["String", "ByteString", "XmlElement"]:
  147. self.members = [StructMember("", types["Byte"], True)]
  148. else:
  149. self.members = [StructMember("", self, False)]
  150. class EnumerationType(Type):
  151. def __init__(self, outname, xml):
  152. Type.__init__(self, outname, xml)
  153. self.fixed_size = "true"
  154. self.overlayable = "UA_BINARY_OVERLAYABLE_INTEGER"
  155. self.members = [StructMember("", types["Int32"], False)] # encoded as uint32
  156. self.builtin = "true"
  157. self.typeIndex = "UA_TYPES_INT32"
  158. self.elements = OrderedDict()
  159. for child in xml:
  160. if child.tag == "{http://opcfoundation.org/BinarySchema/}EnumeratedValue":
  161. self.elements[child.get("Name")] = child.get("Value")
  162. def typedef_h(self):
  163. if sys.version_info[0] < 3:
  164. values = self.elements.iteritems()
  165. else:
  166. values = self.elements.items()
  167. return "typedef enum {\n " + ",\n ".join(map(lambda kv : "UA_" + self.name.upper() + "_" + kv[0].upper() + \
  168. " = " + kv[1], values)) + "\n} UA_%s;" % self.name
  169. class OpaqueType(Type):
  170. def __init__(self, outname, xml):
  171. Type.__init__(self, outname, xml)
  172. self.members = [StructMember("", types["ByteString"], False)] # encoded as string
  173. def typedef_h(self):
  174. return "typedef UA_ByteString UA_%s;" % self.name
  175. class StructType(Type):
  176. def __init__(self, outname, xml):
  177. Type.__init__(self, outname, xml)
  178. self.members = []
  179. lengthfields = [] # lengthfields of arrays are not included as members
  180. for child in xml:
  181. if child.get("LengthField"):
  182. lengthfields.append(child.get("LengthField"))
  183. for child in xml:
  184. if not child.tag == "{http://opcfoundation.org/BinarySchema/}Field":
  185. continue
  186. if child.get("Name") in lengthfields:
  187. continue
  188. memberName = child.get("Name")
  189. memberName = memberName[:1].lower() + memberName[1:]
  190. memberTypeName = child.get("TypeName")
  191. memberType = types[memberTypeName[memberTypeName.find(":")+1:]]
  192. isArray = True if child.get("LengthField") else False
  193. self.members.append(StructMember(memberName, memberType, isArray))
  194. self.fixed_size = "true"
  195. self.overlayable = "true"
  196. before = None
  197. for m in self.members:
  198. if m.isArray or m.memberType.fixed_size != "true":
  199. self.fixed_size = "false"
  200. self.overlayable = "false"
  201. else:
  202. self.overlayable += " && " + m.memberType.overlayable
  203. if before:
  204. self.overlayable += " && offsetof(UA_%s, %s) == (offsetof(UA_%s, %s) + sizeof(UA_%s))" % \
  205. (self.name, m.name, self.name, before.name, before.memberType.name)
  206. if "false" in self.overlayable:
  207. self.overlayable = "false"
  208. before = m
  209. def typedef_h(self):
  210. if len(self.members) == 0:
  211. return "typedef void * UA_%s;" % self.name
  212. returnstr = "typedef struct {\n"
  213. for member in self.members:
  214. if member.isArray:
  215. returnstr += " size_t %sSize;\n" % member.name
  216. returnstr += " UA_%s *%s;\n" % (member.memberType.name, member.name)
  217. else:
  218. returnstr += " UA_%s %s;\n" % (member.memberType.name, member.name)
  219. return returnstr + "} UA_%s;" % self.name
  220. #########################
  221. # Parse Typedefinitions #
  222. #########################
  223. def parseTypeDefinitions(outname, xmlDescription):
  224. def typeReady(element):
  225. "Are all member types defined?"
  226. for child in element:
  227. if child.tag == "{http://opcfoundation.org/BinarySchema/}Field":
  228. childname = child.get("TypeName")
  229. if childname[childname.find(":")+1:] not in types:
  230. return False
  231. return True
  232. def skipType(name):
  233. if name in excluded_types:
  234. return True
  235. if "Test" in name: # skip all test types
  236. return True
  237. if re.search("NodeId$", name) != None:
  238. return True
  239. return False
  240. snippets = {}
  241. for typeXml in etree.parse(xmlDescription).getroot():
  242. if not typeXml.get("Name"):
  243. continue
  244. name = typeXml.get("Name")
  245. snippets[name] = typeXml
  246. while(len(snippets) > 0):
  247. for name, typeXml in list(snippets.items()):
  248. if name in types or skipType(name):
  249. del snippets[name]
  250. continue
  251. if not typeReady(typeXml):
  252. continue
  253. if name in builtin_types:
  254. types[name] = BuiltinType(name)
  255. elif typeXml.tag == "{http://opcfoundation.org/BinarySchema/}EnumeratedType":
  256. types[name] = EnumerationType(outname, typeXml)
  257. elif typeXml.tag == "{http://opcfoundation.org/BinarySchema/}OpaqueType":
  258. types[name] = OpaqueType(outname, typeXml)
  259. elif typeXml.tag == "{http://opcfoundation.org/BinarySchema/}StructuredType":
  260. types[name] = StructType(outname, typeXml)
  261. else:
  262. raise Exception("Type not known")
  263. del snippets[name]
  264. ##########################
  265. # Parse TypeDescriptions #
  266. ##########################
  267. class TypeDescription(object):
  268. def __init__(self, name, nodeid, namespaceid):
  269. self.name = name
  270. self.nodeid = nodeid
  271. self.namespaceid = namespaceid
  272. self.xmlEncodingId = "0"
  273. self.binaryEncodingId = "0"
  274. def parseTypeDescriptions(filename, namespaceid):
  275. definitions = {}
  276. with open(filename) as f:
  277. input_str = f.read()
  278. input_str = input_str.replace('\r','')
  279. rows = map(lambda x:tuple(x.split(',')), input_str.split('\n'))
  280. for index, row in enumerate(rows):
  281. if len(row) < 3:
  282. continue
  283. if row[2] == "Object":
  284. # Check if node name ends with _Encoding_(DefaultXml|DefaultBinary) and store the node id in the corresponding DataType
  285. m = re.match('(.*?)_Encoding_Default(Xml|Binary)$',row[0])
  286. if (m):
  287. baseType = m.group(1)
  288. if baseType not in types:
  289. continue
  290. if m.group(2) == "Xml":
  291. definitions[baseType].xmlEncodingId = row[1]
  292. else:
  293. definitions[baseType].binaryEncodingId = row[1]
  294. continue
  295. if row[2] != "DataType":
  296. continue
  297. if row[0] == "BaseDataType":
  298. definitions["Variant"] = TypeDescription(row[0], row[1], namespaceid)
  299. elif row[0] == "Structure":
  300. definitions["ExtensionObject"] = TypeDescription(row[0], row[1], namespaceid)
  301. elif row[0] not in types:
  302. continue
  303. elif type(types[row[0]]) == EnumerationType:
  304. definitions[row[0]] = TypeDescription(row[0], "6", namespaceid) # enumerations look like int32 on the wire
  305. else:
  306. definitions[row[0]] = TypeDescription(row[0], row[1], namespaceid)
  307. return definitions
  308. ###############################
  309. # Parse the Command Line Input#
  310. ###############################
  311. parser = argparse.ArgumentParser()
  312. parser.add_argument('--typedescriptions', help='csv file with type descriptions')
  313. parser.add_argument('--namespace', type=int, default=0, help='namespace id of the generated type nodeids (defaults to 0)')
  314. parser.add_argument('--selected_types', help='file with list of types (among those parsed) to be generated')
  315. parser.add_argument('typexml_ns0', help='path/to/Opc.Ua.Types.bsd ...')
  316. parser.add_argument('typexml_additional', nargs='*', help='path/to/Opc.Ua.Types.bsd ...')
  317. parser.add_argument('outfile', help='output file w/o extension')
  318. args = parser.parse_args()
  319. outname = args.outfile.split("/")[-1]
  320. inname = ', '.join([args.typexml_ns0.split("/")[-1]] + list(map(lambda x:x.split("/")[-1], args.typexml_additional)))
  321. ################
  322. # Create Types #
  323. ################
  324. for builtin in builtin_types:
  325. types[builtin] = BuiltinType(builtin)
  326. with open(args.typexml_ns0) as f:
  327. parseTypeDefinitions("ua_types", f)
  328. for typexml in args.typexml_additional:
  329. with open(typexml) as f:
  330. parseTypeDefinitions(outname, f)
  331. typedescriptions = {}
  332. if args.typedescriptions:
  333. typedescriptions = parseTypeDescriptions(args.typedescriptions, args.namespace)
  334. selected_types = types.keys()
  335. if args.selected_types:
  336. with open(args.selected_types) as f:
  337. selected_types = list(filter(len, [line.strip() for line in f]))
  338. #############################
  339. # Write out the Definitions #
  340. #############################
  341. fh = open(args.outfile + "_generated.h",'w')
  342. ff = open(args.outfile + "_generated_handling.h",'w')
  343. fe = open(args.outfile + "_generated_encoding_binary.h",'w')
  344. fc = open(args.outfile + "_generated.c",'w')
  345. def printh(string):
  346. print(string, end='\n', file=fh)
  347. def printf(string):
  348. print(string, end='\n', file=ff)
  349. def printe(string):
  350. print(string, end='\n', file=fe)
  351. def printc(string):
  352. print(string, end='\n', file=fc)
  353. def iter_types(v):
  354. l = None
  355. if sys.version_info[0] < 3:
  356. l = list(v.itervalues())
  357. else:
  358. l = list(v.values())
  359. return filter(lambda t: t.name in selected_types, l)
  360. ################
  361. # Print Header #
  362. ################
  363. printh('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
  364. * on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + \
  365. ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + ''' */
  366. #ifndef ''' + outname.upper() + '''_GENERATED_H_
  367. #define ''' + outname.upper() + '''_GENERATED_H_
  368. #ifdef __cplusplus
  369. extern "C" {
  370. #endif
  371. #include "ua_types.h"
  372. ''' + ('\n#include "ua_types_generated.h"\n' if outname != "ua_types" else ''))
  373. printh('''/**
  374. * Every type is assigned an index in an array containing the type descriptions.
  375. * These descriptions are used during type handling (copying, deletion,
  376. * binary encoding, ...). */''')
  377. printh("#define " + outname.upper() + "_COUNT %s" % (str(len(selected_types))))
  378. printh("extern UA_EXPORT const UA_DataType " + outname.upper() + "[" + outname.upper() + "_COUNT];")
  379. i = 0
  380. for t in iter_types(types):
  381. printh("\n/**\n * " + t.name)
  382. printh(" * " + "^" * len(t.name))
  383. if t.description == "":
  384. printh(" */")
  385. else:
  386. printh(" * " + t.description + " */")
  387. if type(t) != BuiltinType:
  388. printh(t.typedef_h() + "\n")
  389. printh("#define " + outname.upper() + "_" + t.name.upper() + " " + str(i))
  390. i += 1
  391. printh('''
  392. #ifdef __cplusplus
  393. } // extern "C"
  394. #endif\n
  395. #endif /* %s_GENERATED_H_ */''' % outname.upper())
  396. ##################
  397. # Print Handling #
  398. ##################
  399. printf('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
  400. * on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + \
  401. ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + ''' */
  402. #ifndef ''' + outname.upper() + '''_GENERATED_HANDLING_H_
  403. #define ''' + outname.upper() + '''_GENERATED_HANDLING_H_
  404. #ifdef __cplusplus
  405. extern "C" {
  406. #endif
  407. #include "''' + outname + '''_generated.h"
  408. #if defined(__GNUC__) && __GNUC__ <= 4
  409. # pragma GCC diagnostic push
  410. # pragma GCC diagnostic ignored "-Wmissing-field-initializers"
  411. # pragma GCC diagnostic ignored "-Wmissing-braces"
  412. #endif
  413. ''')
  414. for t in iter_types(types):
  415. printf("\n/* " + t.name + " */")
  416. printf(t.functions_c())
  417. printf('''
  418. #if defined(__GNUC__) && __GNUC__ <= 4
  419. # pragma GCC diagnostic pop
  420. #endif
  421. #ifdef __cplusplus
  422. } // extern "C"
  423. #endif\n
  424. #endif /* %s_GENERATED_HANDLING_H_ */''' % outname.upper())
  425. ###########################
  426. # Print Description Array #
  427. ###########################
  428. printc('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
  429. * on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + \
  430. ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + ''' */
  431. #include "stddef.h"
  432. #include "ua_types.h"
  433. #include "''' + outname + '''_generated.h"''')
  434. for t in iter_types(types):
  435. printc("")
  436. printc("/* " + t.name + " */")
  437. printc(t.members_c())
  438. printc("const UA_DataType %s[%s_COUNT] = {" % (outname.upper(), outname.upper()))
  439. for t in iter_types(types):
  440. printc("")
  441. printc("/* " + t.name + " */")
  442. printc(t.datatype_c() + ",")
  443. printc("};\n")
  444. ##################
  445. # Print Encoding #
  446. ##################
  447. printe('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
  448. * on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + \
  449. ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + ''' */
  450. #include "ua_types_encoding_binary.h"
  451. #include "''' + outname + '''_generated.h"''')
  452. for t in iter_types(types):
  453. printe("\n/* " + t.name + " */")
  454. printe(t.encoding_h())
  455. fh.close()
  456. ff.close()
  457. fc.close()
  458. fe.close()