Sfoglia il codice sorgente

adapted to return type changes, refixed sign warnings

Leon Urbas 11 anni fa
parent
commit
f8f0221b80
3 ha cambiato i file con 18 aggiunte e 29 eliminazioni
  1. 3 3
      tool/generate_builtin.py
  2. 1 0
      tool/opcua_basictypes.c
  3. 14 26
      tool/opcua_basictypes.h

+ 3 - 3
tool/generate_builtin.py

@@ -149,10 +149,10 @@ def createStructured(element):
     elif "Request" in name[len(name)-9:]:
 		#Sten: dito
         #print("UA_Int32 "  + name + "_calcSize(" + name + " const * ptr) {\n\treturn UA_RequestHeader_getSize()", end='', file=fc) 
-		print("Int32 "  + name + "_calcSize(" + name + " const * ptr) {\n\treturn 0", end='', file=fc) 
+		print("UA_Int32 "  + name + "_calcSize(" + name + " const * ptr) {\n\treturn 0", end='', file=fc) 
     else:
 	# code 
-        print("Int32 "  + name + "_calcSize(" + name + " const * ptr) {\n\treturn 0", end='', file=fc)
+        print("UA_Int32 "  + name + "_calcSize(" + name + " const * ptr) {\n\treturn 0", end='', file=fc)
 
     # code _calcSize
     for n,t in valuemap.iteritems():
@@ -188,7 +188,7 @@ def createStructured(element):
                 print('\tretval |= UA_'+t+"_encode(&(src->"+n+"),pos,dst);", end='\n', file=fc)
     print("\treturn retval;\n}\n", end='\n', file=fc)
 
-    print("Int32 "+name+"_decode(char const * src, UA_UInt32* pos, " + name + "* dst) {\n\tUA_Int32 retval = UA_SUCCESS;", end='\n', file=fc)
+    print("Int32 "+name+"_decode(char const * src, UA_Int32* pos, " + name + "* dst) {\n\tUA_Int32 retval = UA_SUCCESS;", end='\n', file=fc)
     # code _decode
     for n,t in valuemap.iteritems():
         if t in elementary_size:

+ 1 - 0
tool/opcua_basictypes.c

@@ -8,6 +8,7 @@
 #include <stdio.h>	// printf
 #include <stdlib.h>	// alloc, free
 #include <string.h>
+#include "opcua_basictypes.h"
 
 
 UA_Int32 UA_encode(void* const data, UA_Int32 *pos, UA_Int32 type, char* dst) {

+ 14 - 26
tool/opcua_basictypes.h

@@ -23,6 +23,19 @@ typedef uint64_t UInt64;
 typedef float Float;
 typedef double Double;
 
+/* Basic types */
+typedef _Bool UA_Boolean;
+typedef int8_t UA_Byte;
+typedef uint8_t UA_SByte;
+typedef int16_t UA_Int16;
+typedef uint16_t UA_UInt16;
+typedef int32_t UA_Int32;
+typedef uint32_t UA_UInt32;
+typedef int64_t UA_Int64;
+typedef uint64_t UA_UInt64;
+typedef float UA_Float;
+typedef double UA_Double;
+
 /* Function return values */
 #define UA_SUCCESS 0
 #define UA_NO_ERROR UA_SUCCESS
@@ -38,9 +51,6 @@ typedef double Double;
 #define UA_FALSE (!UA_TRUE)
 #define FALSE UA_FALSE
 
-// This is the standard return value, need to have this definition here to make the macros work
-typedef int32_t UA_Int32;
-
 /* heap memory functions */
 UA_Int32 UA_free(void * ptr);
 UA_Int32 UA_memcpy(void *dst, void const *src, int size);
@@ -97,39 +107,17 @@ UA_Int32 TYPE##_encode(TYPE const * src, UA_Int32* pos, char *dst) { \
 	return TYPE_AS##_encode((TYPE_AS*) src,pos,dst); \
 }
 
-/* Prototypes for basic types */
-typedef _Bool UA_Boolean;
+/*** Prototypes for basic types **/
 UA_TYPE_METHOD_PROTOTYPES (UA_Boolean)
-
-typedef int8_t UA_Byte;
 UA_TYPE_METHOD_PROTOTYPES (UA_Byte)
-
-typedef uint8_t UA_SByte;
 UA_TYPE_METHOD_PROTOTYPES (UA_SByte)
-
-typedef int16_t UA_Int16;
 UA_TYPE_METHOD_PROTOTYPES (UA_Int16)
-
-typedef uint16_t UA_UInt16;
 UA_TYPE_METHOD_PROTOTYPES (UA_UInt16)
-
-
-/* typedef int32_t UA_Int32; // see typedef above */
 UA_TYPE_METHOD_PROTOTYPES (UA_Int32)
-
-typedef int32_t UA_UInt32;
 UA_TYPE_METHOD_PROTOTYPES (UA_UInt32)
-
-typedef int64_t UA_Int64;
 UA_TYPE_METHOD_PROTOTYPES (UA_Int64)
-
-typedef uint64_t UA_UInt64;
 UA_TYPE_METHOD_PROTOTYPES (UA_UInt64)
-
-typedef float UA_Float;
 UA_TYPE_METHOD_PROTOTYPES (UA_Float)
-
-typedef double UA_Double;
 UA_TYPE_METHOD_PROTOTYPES (UA_Double)
 
 /**