瀏覽代碼

Added definitions that are lost or incomplete when encoding data in userspace.

ichrispa 8 年之前
父節點
當前提交
bf1e219e91
共有 1 個文件被更改,包括 18 次插入5 次删除
  1. 18 5
      tools/pyUANamespace/ua_namespace.py

+ 18 - 5
tools/pyUANamespace/ua_namespace.py

@@ -652,14 +652,27 @@ class opcua_namespace():
     header.append('  #include "ua_transport_generated_encoding_binary.h"')
     header.append('#else')
     header.append('  #include "open62541.h"')
-    header.append('  #ifndef NULL')
-    header.append('    #define NULL ((void *)0)')
-    header.append('  #endif')
     header.append('#endif')
+    header.append('')
+    header.append('/* Definition that (in userspace models) may be ')
+    header.append(' * - not included in the amalgamated header or')
+    header.append(' * - not part of public headers or')
+    header.append(' * - not exported in the shared object in combination with any of the above')
+    header.append(' * but are required for value encoding.')
+    header.append(' * NOTE: Userspace UA_(decode|encode)Binary /wo amalgamations requires UA_EXPORT to be appended to the appropriate definitions. */')
     header.append('#ifndef UA_ENCODINGOFFSET_BINARY')
-    header.append('#define UA_ENCODINGOFFSET_BINARY 2')
+    header.append('#  define UA_ENCODINGOFFSET_BINARY 2')
     header.append('#endif')
-
+    header.append('#ifndef NULL')
+    header.append('  #define NULL ((void *)0)')
+    header.append('#endif')
+    header.append('#ifndef UA_malloc')
+    header.append('  #define UA_malloc(_p_size) malloc(_p_size)')
+    header.append('#endif')
+    header.append('#ifndef UA_free')
+    header.append('  #define UA_free(_p_ptr) free(_p_ptr)')
+    header.append('#endif')
+    
     code.append('#include "'+outfilename+'.h"')
     code.append("UA_INLINE void "+outfilename+"(UA_Server *server) {")
     code.append('UA_StatusCode retval = UA_STATUSCODE_GOOD; ')