Browse Source

added camlCase2CCase to have the generated
naming of the struct members conforming to the projects coding
conventions

Leon Urbas 11 years ago
parent
commit
9117602b87
2 changed files with 8 additions and 1 deletions
  1. 6 1
      tool/generate_builtin.py
  2. 2 0
      tool/opcua_basictypes.c

+ 6 - 1
tool/generate_builtin.py

@@ -51,6 +51,11 @@ def stripTypename(tn):
 def camlCase2AdaCase(item):
     (newitem, n) = re.subn("(?<!^)(?<![A-Z])([A-Z])", "_\\1", item)
     return newitem
+    
+def camlCase2CCase(item):
+    if item in ["Float","Double"]:
+        return "my" + item
+    return item[:1].lower() + item[1:] if item else ''
 
 # are the prerequisites in place? if not, postpone.
 def printableStructuredType(element):
@@ -102,7 +107,7 @@ def createStructured(element):
         elif child.tag == "{http://opcfoundation.org/BinarySchema/}Field":
             if child.get("Name") in lengthfields:
                 continue
-            childname = camlCase2AdaCase(child.get("Name"))
+            childname = camlCase2CCase(child.get("Name"))
             if childname in printed_types:
                 childname = childname + "_Value" # attributes may not have the name of a type
             typename = stripTypename(child.get("TypeName"))

+ 2 - 0
tool/opcua_basictypes.c

@@ -36,12 +36,14 @@ Int32 UA_Array_decode(char const * src, Int32 noElements, Int32 type, Int32* pos
 }
 
 Int32 UA_free(void * ptr){
+	printf("UA_free - ptr=%p\n",ptr);
 	free(ptr);
 	return UA_SUCCESS;
 }
 
 Int32 UA_alloc(void ** ptr, int size){
 	*ptr = malloc(size);
+	printf("UA_alloc - ptr=%p, size=%d\n",ptr,size);
 	if(*ptr == UA_NULL) return UA_ERR_NO_MEMORY;
 	return UA_SUCCESS;
 }