Преглед изворни кода

Prepare python script for usage of define UA_INTERNAL_FUNC_ATTR_WARN_UNUSED_RESULT

Only the inserted dataTypes in list whitelistFuncAttrWarnUnusedResult will be generated with the define UA_INTERNAL_FUNC_ATTR_WARN_UNUSED_RESULT in front of the function declaration.
Martin Lang пре 5 година
родитељ
комит
df58cf8f36
1 измењених фајлова са 7 додато и 0 уклоњено
  1. 7 0
      tools/generate_datatypes.py

+ 7 - 0
tools/generate_datatypes.py

@@ -55,6 +55,8 @@ builtin_overlayable = {"Boolean": "true",
                        "offsetof(UA_Guid, data3) == (sizeof(UA_UInt16) + sizeof(UA_UInt32)) && " + \
                        "offsetof(UA_Guid, data4) == (2*sizeof(UA_UInt32)))"}
 
+whitelistFuncAttrWarnUnusedResult = [  ] # for instances [ "String", "ByteString", "LocalizedText" ]
+
 # Type aliases
 type_aliases = { "CharArray" : "String" }
 def getTypeName(xmlTypeName):
@@ -180,6 +182,11 @@ class Type(object):
             funcs += "static UA_INLINE void\nUA_%s_deleteMembers(UA_%s *p) {\n    memset(p, 0, sizeof(UA_%s));\n}\n\n" % (idName, idName, idName)
             funcs += "static UA_INLINE void\nUA_%s_clear(UA_%s *p) {\n    memset(p, 0, sizeof(UA_%s));\n}\n\n" % (idName, idName, idName)
         else:
+            for entry in whitelistFuncAttrWarnUnusedResult:
+                if idName == entry:
+                    funcs += "UA_INTERNAL_FUNC_ATTR_WARN_UNUSED_RESULT "
+                    break;
+            
             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" % (idName, idName, idName, self.datatype_ptr())
             funcs += "static UA_INLINE void\nUA_%s_deleteMembers(UA_%s *p) {\n    UA_clear(p, %s);\n}\n\n" % (idName, idName, self.datatype_ptr())
             funcs += "static UA_INLINE void\nUA_%s_clear(UA_%s *p) {\n    UA_clear(p, %s);\n}\n\n" % (idName, idName, self.datatype_ptr())