Browse Source

add size of the structs to vtable

This can be used to find the correct pointer offsets to members.
But I still need to know the structure.
Julius Pfrommer 10 years ago
parent
commit
98acf92cd0
2 changed files with 3 additions and 0 deletions
  1. 1 0
      include/ua_basictypes.h
  2. 2 0
      tools/generate_namespace.py

+ 1 - 0
include/ua_basictypes.h

@@ -205,6 +205,7 @@ typedef struct UA_VTable {
 	UA_Int32 (*new)(void ** p);
 	UA_Int32 (*copy)(void const *src,void *dst);
 	UA_Int32 (*delete)(void * p);
+	UA_UInt32 memSize; // size of the struct only in memory (no dynamic components)
 	UA_Byte* name;
 } UA_VTable;
 

+ 2 - 0
tools/generate_namespace.py

@@ -113,6 +113,7 @@ for row in rows:
           ",(UA_Int32(*)(void **))"+name+"_new"+
 	  ",(UA_Int32(*)(void const * ,void*))"+name+"_copy"+
           ",(UA_Int32(*)(void *))"+name+"_delete"+
+          (",sizeof("+name+")" if (name != "UA_InvalidType") else ",0") +
           ',(UA_Byte*)"'+name+'"},',end='\n',file=fc) 
 
 print("};\n\nUA_VTable UA_noDelete_[] = {", end='\n', file=fc)
@@ -135,6 +136,7 @@ for row in rows:
           ",(UA_Int32(*)(void **))"+name+"_new"+
 	  ",(UA_Int32(*)(void const * ,void*))"+name+"_copy"+
           ",(UA_Int32(*)(void *))phantom_delete"+
+          (",sizeof("+name+")" if (name != "UA_InvalidType") else ",0") +
           ',(UA_Byte*)"'+name+'"},',end='\n',file=fc)
 print("};", end='\n', file=fc)