Explorar el Código

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

Leon Urbas hace 11 años
padre
commit
9117602b87
Se han modificado 2 ficheros con 8 adiciones y 1 borrados
  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;
 }