Selaa lähdekoodia

hard remove of all _print functions if DEBUG is not set, @jpfr or @uleon: who does own ua_xml.c? Please review changes there, I fear i was too hard. Relates to #101

Stasik0 10 vuotta sitten
vanhempi
commit
3b9218def8

+ 8 - 1
.travis.yml

@@ -29,7 +29,14 @@ before_install:
 - cd ..
 - rm -rf check-code
 - sudo pip install cpp-coveralls
-script: ./autogen.sh && ./configure --enable-doxygen --enable-coverage && make && make check
+script: 
+   - ./autogen.sh 
+   - ./configure 
+   - echo "Production build + checks"
+   - make && make check && make clean
+   - echo "Extended debug build + checks + coverage + doxygen"
+   - ./configure --enable-debug --enable-coverage --enable-doxygen
+   - make all && make check
 after_success:
    - git clone --depth=50 -b gh-pages https://$GITAUTH@github.com/acplt/open62541
    - rm -rf open62541/doxygen

+ 2 - 0
examples/src/opcuaServerACPLT.c

@@ -104,7 +104,9 @@ void server_run() {
 			if (n > 0) {
                 slMessage.data = (UA_Byte*) buffer;
 				slMessage.length = n;
+#ifdef DEBUG
 				UA_ByteString_printx("server_run - received=",&slMessage);
+#endif
 				TL_Process(&connection, &slMessage);
 			} else if (n <= 0) {
 				perror("ERROR reading from socket1");

+ 2 - 0
src/Makefile.am

@@ -64,3 +64,5 @@ all-local: convenience-link
 clean-local: clean-convenience-link
 	rm -rf ua_types_generated.c ua_types_generated.h || true;
 	rm -rf ua_namespace_0.c ua_namespace_0.h || true;
+	rm -rf *.gcov || true;
+	rm -rf util/*.gcov || true;

+ 2 - 0
src/ua_services_discovery.c

@@ -1,6 +1,8 @@
 #include "ua_services.h"
 UA_Int32 Service_GetEndpoints(SL_Channel *channel, const UA_GetEndpointsRequest* request, UA_GetEndpointsResponse *response) {
+#ifdef DEBUG
 	UA_String_printx("endpointUrl=", &request->endpointUrl);
+#endif
 
 	response->endpointsSize = 1;
 	UA_Array_new((void**) &response->endpoints,response->endpointsSize,&UA_.types[UA_ENDPOINTDESCRIPTION]);

+ 2 - 0
src/ua_services_monitoreditems.c

@@ -10,7 +10,9 @@ UA_Int32 Service_CreateMonitoredItems(SL_Channel *channel, const UA_CreateMonito
 
 		UA_Array_new((void**)&(response->results),response->resultsSize,&UA_.types[UA_MONITOREDITEMCREATERESULT]);
 		for (int i=0;request->itemsToCreateSize > 0 && i < request->itemsToCreateSize;i++) {
+#ifdef DEBUG
 			UA_NodeId_printf("CreateMonitoredItems - itemToCreate=",&(request->itemsToCreate[i].itemToMonitor.nodeId));
+#endif
 			//FIXME: search the object in the namespace
 
 			if (request->itemsToCreate[i].itemToMonitor.nodeId.identifier.numeric == 2253) { // server

+ 4 - 0
src/ua_services_session.c

@@ -7,7 +7,9 @@ Session sessionMockup = {
 };
 
 UA_Int32 Service_CreateSession(SL_Channel *channel, const UA_CreateSessionRequest *request, UA_CreateSessionResponse *response) {
+#ifdef DEBUG
 	UA_String_printf("CreateSession Service - endpointUrl=", &(request->endpointUrl));
+#endif
 	// FIXME: create session
 
 	response->sessionId.encodingByte = UA_NODEIDTYPE_FOURBYTE;
@@ -18,10 +20,12 @@ UA_Int32 Service_CreateSession(SL_Channel *channel, const UA_CreateSessionReques
 
 UA_Int32 Service_ActivateSession(SL_Channel *channel, const UA_ActivateSessionRequest *request, UA_ActivateSessionResponse *response) {
 	// FIXME: activate session
+#ifdef DEBUG
 	UA_NodeId_printf("ActivateSession - authToken=", &(request->requestHeader.authenticationToken));
 	// 321 == AnonymousIdentityToken_Encoding_DefaultBinary
 	UA_NodeId_printf("ActivateSession - uIdToken.type=", &(request->userIdentityToken.typeId));
 	UA_ByteString_printx_hex("ActivateSession - uIdToken.body=", &(request->userIdentityToken.body));
+#endif
 
 	// FIXME: channel->session->application = <Application Ptr>
 	channel->session = &sessionMockup;

+ 2 - 0
src/ua_transport_binary_secure.c

@@ -114,7 +114,9 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString *msg, UA_UInt
 	// Every Message starts with a NodeID which names the serviceRequestType
 	UA_NodeId serviceRequestType;
 	UA_NodeId_decodeBinary(msg, offset, &serviceRequestType);
+#ifdef DEBUG
 	UA_NodeId_printf("SL_processMessage - serviceRequestType=", &serviceRequestType);
+#endif
 
 	UA_ByteString response_msg;
 	int serviceid = serviceRequestType.identifier.numeric-2; // binary encoding has 2 added to the id

+ 62 - 0
src/ua_types.c

@@ -25,82 +25,104 @@ UA_TYPE_DELETE_DEFAULT(UA_Boolean)
 UA_TYPE_DELETEMEMBERS_NOACTION(UA_Boolean)
 UA_TYPE_NEW_DEFAULT(UA_Boolean)
 UA_TYPE_COPY_DEFAULT(UA_Boolean)
+#ifdef DEBUG
 void UA_Boolean_print(const UA_Boolean *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	if(*p) fprintf(stream, "UA_TRUE");
 	else fprintf(stream, "UA_FALSE");
 }
+#endif
 
 /* SByte */
 UA_TYPE_DEFAULT(UA_SByte)
+#ifdef DEBUG
 void UA_SByte_print(const UA_SByte *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	UA_SByte x = *p;
 	fprintf(stream, "%s%x\n", x<0?"-":"", x<0?-x:x);
 }
+#endif
 
 /* Byte */
 UA_TYPE_DEFAULT(UA_Byte)
+#ifdef DEBUG
 void UA_Byte_print(const UA_Byte *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "%x", *p);
 }
+#endif
 
 /* Int16 */
 UA_TYPE_DEFAULT(UA_Int16)
+#ifdef DEBUG
 void UA_Int16_print(const UA_Int16 *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "%d", *p);
 }
+#endif
 
 /* UInt16 */
 UA_TYPE_DEFAULT(UA_UInt16)
+#ifdef DEBUG
 void UA_UInt16_print(const UA_UInt16 *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "%u", *p);
 }
+#endif
 
 /* Int32 */
 UA_TYPE_DEFAULT(UA_Int32)
+#ifdef DEBUG
 void UA_Int32_print(const UA_Int32 *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "%d", *p);
 }
+#endif
 
 /* UInt32 */
 UA_TYPE_DEFAULT(UA_UInt32)
+#ifdef DEBUG
 void UA_UInt32_print(const UA_UInt32 *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "%u", *p);
 }
+#endif
 
 /* Int64 */
 UA_TYPE_DEFAULT(UA_Int64)
+#ifdef DEBUG
 void UA_Int64_print(const UA_Int64 *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "%" PRIi64, *p);
 }
+#endif
 
 /* UInt64 */
 UA_TYPE_DEFAULT(UA_UInt64)
+#ifdef DEBUG
 void UA_UInt64_print(const UA_UInt64 *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "%" PRIu64, *p);
 }
+#endif
 
 /* Float */
 UA_TYPE_DEFAULT(UA_Float)
+#ifdef DEBUG
 void UA_Float_print(const UA_Float *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "%f", *p);
 }
+#endif
 
 /* Double */
 UA_TYPE_DEFAULT(UA_Double)
+#ifdef DEBUG
 void UA_Double_print(const UA_Double *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "%f", *p);
 }
+#endif
 
 /* String */
 UA_TYPE_NEW_DEFAULT(UA_String)
@@ -137,6 +159,7 @@ UA_Int32 UA_String_copy(UA_String const *src, UA_String *dst) {
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_String_print(const UA_String *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_String){%d,", p->length);
@@ -145,6 +168,7 @@ void UA_String_print(const UA_String *p, FILE *stream) {
 	else
 		fprintf(stream, "UA_NULL}");
 }
+#endif
 
 UA_Int32 UA_String_copycstring(char const *src, UA_String *dst) {
 	UA_Int32 retval = UA_SUCCESS;
@@ -201,11 +225,14 @@ UA_Int32 UA_String_equal(const UA_String *string1, const UA_String *string2) {
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_String_printf(char const *label, const UA_String *string) {
 	printf("%s {Length=%d, Data=%.*s}\n", label, string->length,
 	       string->length, (char *)string->data);
 }
+#endif
 
+#ifdef DEBUG
 void UA_String_printx(char const *label, const UA_String *string) {
 	if(string == UA_NULL) {
 		printf("%s {NULL}\n", label); return;
@@ -220,7 +247,9 @@ void UA_String_printx(char const *label, const UA_String *string) {
 		printf("{");
 	printf("}}\n");
 }
+#endif
 
+#ifdef DEBUG
 void UA_String_printx_hex(char const *label, const UA_String *string) {
 	printf("%s {Length=%d, Data=", label, string->length);
 	if(string->length > 0) {
@@ -230,6 +259,7 @@ void UA_String_printx_hex(char const *label, const UA_String *string) {
 		printf("{");
 	printf("}}\n");
 }
+#endif
 
 /* DateTime */
 UA_TYPE_AS(UA_DateTime, UA_Int64)
@@ -313,11 +343,13 @@ UA_Int32 UA_Guid_copy(UA_Guid const *src, UA_Guid *dst) {
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_Guid_print(const UA_Guid *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_Guid){%u, %u %u {%x,%x,%x,%x,%x,%x,%x,%x}}", p->data1, p->data2, p->data3, p->data4[0],
 			p->data4[1], p->data4[2], p->data4[3], p->data4[4], p->data4[5], p->data4[6], p->data4[7]);
 }
+#endif
 
 /* ByteString */
 UA_TYPE_AS(UA_ByteString, UA_String)
@@ -325,17 +357,23 @@ UA_Int32 UA_ByteString_equal(const UA_ByteString *string1, const UA_ByteString *
 	return UA_String_equal((const UA_String *)string1, (const UA_String *)string2);
 }
 
+#ifdef DEBUG
 void UA_ByteString_printf(char *label, const UA_ByteString *string) {
 	UA_String_printf(label, (UA_String *)string);
 }
+#endif
 
+#ifdef DEBUG
 void UA_ByteString_printx(char *label, const UA_ByteString *string) {
 	UA_String_printx(label, (UA_String *)string);
 }
+#endif
 
+#ifdef DEBUG
 void UA_ByteString_printx_hex(char *label, const UA_ByteString *string) {
 	UA_String_printx_hex(label, (UA_String *)string);
 }
+#endif
 
 UA_Byte       UA_Byte_securityPoliceNoneData[] = "http://opcfoundation.org/UA/SecurityPolicy#None";
 // sizeof()-1 : discard the implicit null-terminator of the c-char-string
@@ -423,6 +461,7 @@ UA_Int32 UA_NodeId_deleteMembers(UA_NodeId *p) {
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_NodeId_print(const UA_NodeId *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_NodeId){");
@@ -472,7 +511,9 @@ void UA_NodeId_print(const UA_NodeId *p, FILE *stream) {
 	}
 	fprintf(stream, "}");
 }
+#endif
 
+#ifdef DEBUG
 void UA_NodeId_printf(char *label, const UA_NodeId *node) {
 	UA_Int32 l;
 
@@ -509,6 +550,7 @@ void UA_NodeId_printf(char *label, const UA_NodeId *node) {
 	}
 	printf("}\n");
 }
+#endif
 
 UA_Int32 UA_NodeId_equal(const UA_NodeId *n1, const UA_NodeId *n2) {
 	if(n1 == UA_NULL || n2 == UA_NULL || n1->namespace != n2->namespace)
@@ -590,6 +632,7 @@ UA_Int32 UA_ExpandedNodeId_copy(UA_ExpandedNodeId const *src, UA_ExpandedNodeId
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_ExpandedNodeId_print(const UA_ExpandedNodeId *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_ExpandedNodeId){");
@@ -600,6 +643,7 @@ void UA_ExpandedNodeId_print(const UA_ExpandedNodeId *p, FILE *stream) {
 	UA_UInt32_print(&p->serverIndex, stream);
 	fprintf(stream, "}");
 }
+#endif
 
 UA_Boolean UA_ExpandedNodeId_isNull(const UA_ExpandedNodeId *p) {
 	return UA_NodeId_isNull(&p->nodeId);
@@ -634,6 +678,7 @@ UA_Int32 UA_QualifiedName_copy(UA_QualifiedName const *src, UA_QualifiedName *ds
 
 }
 
+#ifdef DEBUG
 void UA_QualifiedName_print(const UA_QualifiedName *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_QualifiedName){");
@@ -642,11 +687,14 @@ void UA_QualifiedName_print(const UA_QualifiedName *p, FILE *stream) {
 	UA_String_print(&p->name, stream);
 	fprintf(stream, "}");
 }
+#endif
 
+#ifdef DEBUG
 void UA_QualifiedName_printf(char const *label, const UA_QualifiedName *qn) {
 	printf("%s {NamespaceIndex=%u, Length=%d, Data=%.*s}\n", label, qn->namespaceIndex,
 		   qn->name.length, qn->name.length, (char *)qn->name.data);
 }
+#endif
 
 /* LocalizedText */
 UA_TYPE_DELETE_DEFAULT(UA_LocalizedText)
@@ -688,6 +736,7 @@ UA_Int32 UA_LocalizedText_copy(UA_LocalizedText const *src, UA_LocalizedText *ds
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_LocalizedText_print(const UA_LocalizedText *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_LocalizedText){");
@@ -696,6 +745,7 @@ void UA_LocalizedText_print(const UA_LocalizedText *p, FILE *stream) {
 	UA_String_print(&p->text, stream);
 	fprintf(stream, "}");
 }
+#endif
 
 /* ExtensionObject */
 UA_TYPE_DELETE_DEFAULT(UA_ExtensionObject)
@@ -725,6 +775,7 @@ UA_Int32 UA_ExtensionObject_copy(UA_ExtensionObject const *src, UA_ExtensionObje
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_ExtensionObject_print(const UA_ExtensionObject *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_ExtensionObject){");
@@ -739,6 +790,7 @@ void UA_ExtensionObject_print(const UA_ExtensionObject *p, FILE *stream) {
 	UA_ByteString_print(&p->body, stream);
 	fprintf(stream, "}");
 }
+#endif
 
 /* DataValue */
 UA_TYPE_DELETE_DEFAULT(UA_DataValue)
@@ -775,6 +827,7 @@ UA_Int32 UA_DataValue_copy(UA_DataValue const *src, UA_DataValue *dst) {
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_DataValue_print(const UA_DataValue *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_DataValue){");
@@ -793,6 +846,7 @@ void UA_DataValue_print(const UA_DataValue *p, FILE *stream) {
 	UA_Int16_print(&p->serverPicoseconds, stream);
 	fprintf(stream, "}");
 }
+#endif
 
 /* Variant */
 UA_TYPE_DELETE_DEFAULT(UA_Variant)
@@ -840,6 +894,7 @@ UA_Int32 UA_Variant_copy(UA_Variant const *src, UA_Variant *dst) {
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_Variant_print(const UA_Variant *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	UA_UInt32 ns0id = UA_ns0ToVTableIndex(&p->vt->typeId);
@@ -859,6 +914,7 @@ void UA_Variant_print(const UA_Variant *p, FILE *stream) {
 	UA_Array_print(p->arrayDimensions, p->arrayDimensionsLength, &UA_.types[UA_INT32], stream);
 	fprintf(stream, "}");
 }
+#endif
 
 UA_Int32 UA_Variant_copySetValue(UA_Variant *v, UA_VTable_Entry *vt, const void *value) {
 	if(v == UA_NULL || vt == UA_NULL || value == UA_NULL)
@@ -949,6 +1005,7 @@ UA_Int32 UA_DiagnosticInfo_copy(UA_DiagnosticInfo const *src, UA_DiagnosticInfo
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_DiagnosticInfo_print(const UA_DiagnosticInfo *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_DiagnosticInfo){");
@@ -974,6 +1031,7 @@ void UA_DiagnosticInfo_print(const UA_DiagnosticInfo *p, FILE *stream) {
 	}
 	fprintf(stream, "}");
 }
+#endif
 
 /* InvalidType */
 UA_Int32 UA_InvalidType_free(UA_InvalidType *p) {
@@ -1000,10 +1058,12 @@ UA_Int32 UA_InvalidType_new(UA_InvalidType **p) {
 	return UA_ERR_INVALID_VALUE;
 }
 
+#ifdef DEBUG
 void UA_InvalidType_print(const UA_InvalidType *p, FILE *stream) {
 	if(p == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(UA_InvalidType){ERROR (invalid type)}");
 }
+#endif
 
 /*********/
 /* Array */
@@ -1098,6 +1158,7 @@ UA_Int32 UA_Array_copy(const void *src, UA_Int32 noElements, UA_VTable_Entry *vt
 	return retval;
 }
 
+#ifdef DEBUG
 void UA_Array_print(const void *p, UA_Int32 noElements, UA_VTable_Entry *vt, FILE *stream) {
 	if(p == UA_NULL || vt == UA_NULL || stream == UA_NULL) return;
 	fprintf(stream, "(%s){", vt->name);
@@ -1109,3 +1170,4 @@ void UA_Array_print(const void *p, UA_Int32 noElements, UA_VTable_Entry *vt, FIL
 		cp += memSize;
 	}
 }
+#endif

+ 12 - 1
src/ua_types.h

@@ -383,7 +383,9 @@ struct UA_VTable_Entry {
 	UA_Int32   (*copy)(void const *src, void *dst);
 	UA_Int32   (*delete)(void *p);
 	UA_Int32   (*deleteMembers)(void *p);
+#ifdef DEBUG
 	void       (*print)(const void *p, FILE *stream);
+#endif
 	UA_UInt32  memSize;       // size of the struct only in memory (no dynamic components)
 	UA_Boolean dynMembers;    // does the type contain members that are dynamically
 	                          // allocated (strings, ..)? Otherwise, the size on
@@ -462,8 +464,9 @@ typedef struct UA_VTable {
 #define UA_TYPE_PRINT_AS(TYPE, TYPE_AS)                        \
     void TYPE##_print(TYPE const *p, FILE *stream) {		   \
 		TYPE_AS##_print((TYPE_AS *)p, stream);				   \
-	}
+	}														   \
 
+#ifdef DEBUG //print functions only in debug mode
 #define UA_TYPE_AS(TYPE, TYPE_AS)           \
     UA_TYPE_NEW_DEFAULT(TYPE)               \
     UA_TYPE_INIT_AS(TYPE, TYPE_AS)          \
@@ -471,6 +474,14 @@ typedef struct UA_VTable {
     UA_TYPE_DELETEMEMBERS_AS(TYPE, TYPE_AS) \
     UA_TYPE_COPY_AS(TYPE, TYPE_AS)			\
 	UA_TYPE_PRINT_AS(TYPE, TYPE_AS)
+#else
+#define UA_TYPE_AS(TYPE, TYPE_AS)           \
+    UA_TYPE_NEW_DEFAULT(TYPE)               \
+    UA_TYPE_INIT_AS(TYPE, TYPE_AS)          \
+    UA_TYPE_DELETE_AS(TYPE, TYPE_AS)        \
+    UA_TYPE_DELETEMEMBERS_AS(TYPE, TYPE_AS) \
+    UA_TYPE_COPY_AS(TYPE, TYPE_AS)
+#endif
 
 /// @} /* end of group */
 

+ 4 - 0
src/ua_xml.c

@@ -668,6 +668,7 @@ _Bool UA_NodeId_isBuiltinType(UA_NodeId* nodeid) {
 /* 	return UA_SUCCESS; */
 /* } */
 
+#ifdef DEBUG
 void print_node(UA_Node const * node) {
 	if (node != UA_NULL) {
 		UA_NodeId_printf("node.nodeId=", &(node->nodeId));
@@ -742,6 +743,7 @@ void print_node(UA_Node const * node) {
 		}
 	}
 }
+#endif
 
 UA_Int32 UA_NodeSetAlias_decodeXmlFromStack(XML_Stack *s, XML_Attr *attr, UA_NodeSetAlias *dst, _Bool isStart) {
 	DBG_VERBOSE(printf("UA_NodeSetAlias entered with dst=%p,isStart=%d\n", (void * )dst, isStart));
@@ -921,7 +923,9 @@ void XML_Stack_handleText(void * data, const char *txt, int len) {
 char* theGatherBuffer;
 void textGatherListTotalLength(void* payload) {
 	UA_ByteString* b = (UA_ByteString*) payload;
+	#ifdef DEBUG
 	UA_ByteString_printf("\t",b);
+	#endif
 	UA_memcpy(theGatherBuffer,b->data,b->length-1); // remove trailing zero
 	theGatherBuffer += (b->length-1);
 }

+ 2 - 2
tests/Makefile.am

@@ -26,8 +26,8 @@ check_memory-mem: check_memory
 	
 clean-local:
 	rm -rf coverage || true;
-	rm -rf *.gcda *.gcdo *.gcno 
-	lcov --directory . --zerocounters
+	rm -rf *.gcda *.gcdo *.gcno *.o *.gcov *.log *.trs
+	lcov --directory . --zerocounters || true;
 	
 # --- no changes beyond this line needed ---
 INCLUDE = @CHECK_CFLAGS@ -I$(top_builddir)/src -I$(top_builddir)/include

+ 2 - 0
tests/check_memory.c

@@ -13,7 +13,9 @@ START_TEST(newAndEmptyObjectShallBeDeleted) {
 	void    *obj;
 	// when
 	retval  = UA_.types[_i].new(&obj);
+#ifdef DEBUG //no print functions if not in debug mode
 	UA_.types[_i].print(obj, stdout);
+#endif
 	retval |= UA_.types[_i].delete(obj);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);

+ 4 - 1
tools/generate_builtin.py

@@ -240,6 +240,7 @@ def createStructured(element):
     printc("\treturn retval;\n}\n")
 
     # 13) Print
+    printc('''#ifdef DEBUG''') 
     printc('''void %(name)s_print(const %(name)s *p, FILE *stream) {
     fprintf(stream, "(%(name)s){");''')
     for i,(n,t) in enumerate(membermap.iteritems()):
@@ -251,7 +252,9 @@ def createStructured(element):
         if i == len(membermap)-1:
             continue
 	printc('\tfprintf(stream, ",");')
-    printc('''\tfprintf(stream, "}");\n}\n''')
+    printc('''\tfprintf(stream, "}");\n}''')
+    printc('#endif');
+    printc('''\n''')
     
 	
 printh('''/**

+ 37 - 32
tools/generate_namespace.py

@@ -126,8 +126,9 @@ for row in rows:
     i = i+1
 
 printh("};\n")
-printc('''\n}\nreturn retval;\n}\n
-const UA_VTable UA_ = {
+printc('''\n}\nreturn retval;\n}\n''');
+
+printc('''const UA_VTable UA_ = {
 \t.getTypeIndex = UA_ns0ToVTableIndex,
 \t.types = (UA_VTable_Entry[]){''')
 
@@ -144,21 +145,23 @@ for row in rows:
     printh('#define '+name.upper()+'_NS0 '+row[1])
 
     printc("\t{.typeId={UA_NODEIDTYPE_FOURBYTE,0,.identifier.numeric=" + row[1] + "}" + 
-          ",.name=(UA_Byte*)&\"%(name)s\"" +
-          ",.new=(UA_Int32(*)(void **))%(name)s_new" +
-          ",.init=(UA_Int32(*)(void *))%(name)s_init"+
-          ",.copy=(UA_Int32(*)(void const * ,void*))%(name)s_copy" +
-          ",.delete=(UA_Int32(*)(void *))%(name)s_delete" +
-          ",.deleteMembers=(UA_Int32(*)(void *))%(name)s_deleteMembers" +
-          ",.print=(void(*)(const void *, FILE *))%(name)s_print" +
-          ",.memSize=" + ("sizeof(%(name)s)" if (name != "UA_InvalidType") else "0") +
-          ",.dynMembers=" + ("UA_FALSE" if (name in fixed_size) else "UA_TRUE") +
-          ",.encodings={{.calcSize=(UA_calcSize)%(name)s_calcSizeBinary" +
-          ",.encode=(UA_encode)%(name)s_encodeBinary" +
-          ",.decode=(UA_decode)%(name)s_decodeBinary}" +
-          ",{.calcSize=(UA_calcSize)%(name)s_calcSizeXml" +
-          ",.encode=(UA_encode)%(name)s_encodeXml" +
-          ",.decode=(UA_decode)%(name)s_decodeXml}" +
+          ",\n.name=(UA_Byte*)&\"%(name)s\"" +
+          ",\n.new=(UA_Int32(*)(void **))%(name)s_new" +
+          ",\n.init=(UA_Int32(*)(void *))%(name)s_init"+
+          ",\n.copy=(UA_Int32(*)(void const * ,void*))%(name)s_copy" +
+          ",\n.delete=(UA_Int32(*)(void *))%(name)s_delete" +
+          ",\n.deleteMembers=(UA_Int32(*)(void *))%(name)s_deleteMembers" +
+          ",\n#ifdef DEBUG //FIXME: seems to be okay atm, however a pointer to a noop function would be more safe" + 
+          "\n.print=(void(*)(const void *, FILE *))%(name)s_print," +
+          "\n#endif" + 
+          "\n.memSize=" + ("sizeof(%(name)s)" if (name != "UA_InvalidType") else "0") +
+          ",\n.dynMembers=" + ("UA_FALSE" if (name in fixed_size) else "UA_TRUE") +
+          ",\n.encodings={{.calcSize=(UA_calcSize)%(name)s_calcSizeBinary" +
+          ",\n.encode=(UA_encode)%(name)s_encodeBinary" +
+          ",\n.decode=(UA_decode)%(name)s_decodeBinary}" +
+          ",\n{.calcSize=(UA_calcSize)%(name)s_calcSizeXml" +
+          ",\n.encode=(UA_encode)%(name)s_encodeXml" +
+          ",\n.decode=(UA_decode)%(name)s_decodeXml}" +
           "}},")
 
 printc('''}};
@@ -178,21 +181,23 @@ for row in rows:
 	name = "UA_" + row[0]
 
     printc("\t{.typeId={UA_NODEIDTYPE_FOURBYTE,0,.identifier.numeric=" + row[1] + "}" + 
-          ",.name=(UA_Byte*)&\"%(name)s\"" +
-          ",.new=(UA_Int32(*)(void **))%(name)s_new" +
-          ",.init=(UA_Int32(*)(void *))%(name)s_init" +
-          ",.copy=(UA_Int32(*)(void const * ,void*))%(name)s_copy" +
-          ",.delete=(UA_Int32(*)(void *))phantom_delete" +
-          ",.deleteMembers=(UA_Int32(*)(void *))phantom_delete" +
-          ",.print=(void(*)(const void *, FILE *))%(name)s_print" +
-          ",.memSize=" + ("sizeof(%(name)s)" if (name != "UA_InvalidType") else "0") +
-          ",.dynMembers=" + ("UA_FALSE" if (name in fixed_size) else "UA_TRUE") +
-          ",.encodings={{.calcSize=(UA_calcSize)" + name +"_calcSizeBinary" +
-          ",.encode=(UA_encode)%(name)s_encodeBinary" +
-          ",.decode=(UA_decode)%(name)s_decodeBinary}" +
-          ",{.calcSize=(UA_calcSize)%(name)s_calcSizeXml" +
-          ",.encode=(UA_encode)%(name)s_encodeXml" +
-          ",.decode=(UA_decode)%(name)s_decodeXml}" +
+          ",\n.name=(UA_Byte*)&\"%(name)s\"" +
+          ",\n.new=(UA_Int32(*)(void **))%(name)s_new" +
+          ",\n.init=(UA_Int32(*)(void *))%(name)s_init" +
+          ",\n.copy=(UA_Int32(*)(void const * ,void*))%(name)s_copy" +
+          ",\n.delete=(UA_Int32(*)(void *))phantom_delete" +
+          ",\n.deleteMembers=(UA_Int32(*)(void *))phantom_delete" +
+          ",\n#ifdef DEBUG //FIXME: seems to be okay atm, however a pointer to a noop function would be more safe" + 
+          "\n.print=(void(*)(const void *, FILE *))%(name)s_print," +
+          "\n#endif" + 
+          "\n.memSize=" + ("sizeof(%(name)s)" if (name != "UA_InvalidType") else "0") +
+          ",\n.dynMembers=" + ("UA_FALSE" if (name in fixed_size) else "UA_TRUE") +
+          ",\n.encodings={{.calcSize=(UA_calcSize)" + name +"_calcSizeBinary" +
+          ",\n.encode=(UA_encode)%(name)s_encodeBinary" +
+          ",\n.decode=(UA_decode)%(name)s_decodeBinary}" +
+          ",\n{.calcSize=(UA_calcSize)%(name)s_calcSizeXml" +
+          ",\n.encode=(UA_encode)%(name)s_encodeXml" +
+          ",\n.decode=(UA_decode)%(name)s_decodeXml}" +
           "}},")
 
 printc("}};")