diff --git a/Config.cmake/test_fmi2.cmake b/Config.cmake/test_fmi2.cmake index 90aa44eb..5358a96b 100644 --- a/Config.cmake/test_fmi2.cmake +++ b/Config.cmake/test_fmi2.cmake @@ -113,7 +113,7 @@ set_target_properties( set(FAIL_NAME_CHECK 0) set(PASS_NAME_CHECK 1) -add_test(ctest_fmi2_xml_parsing_test fmi2_xml_parsing_test ${FMI2_TEST_XML_DIR}/) +add_test(ctest_fmi2_xml_parsing_test fmi2_xml_parsing_test ${FMI2_TEST_XML_DIR}/) # Trailing '/' necessary (for building system independent path) add_test(ctest_fmi2_import_xml_test_brief fmi2_import_xml_test ${FMU2_DUMMY_FOLDER}) # 'brief' as in close to minimal XML add_test(ctest_fmi2_import_xml_test_me fmi2_import_xml_test ${TEST_OUTPUT_FOLDER}/BouncingBall2_me) add_test(ctest_fmi2_import_xml_test_cs fmi2_import_xml_test ${TEST_OUTPUT_FOLDER}/BouncingBall2_cs) diff --git a/Test/fmi_testutil.h b/Test/fmi_testutil.h index 91281f95..7fbac090 100644 --- a/Test/fmi_testutil.h +++ b/Test/fmi_testutil.h @@ -21,6 +21,9 @@ extern "C" { else if (strcmp(S1, S2) != 0) { FAIL(S1 << " != " << S2); } \ } while (0); +// XXX: Currently cotains duplicated code for FMI 2 & 3 (also in fmi_testutil.c) +// Could replace via macros + typedef struct fmi2_testutil_import_t { fmi2_import_t* fmu; jm_vector(jm_voidp) log; // All logged messages diff --git a/src/XML/src/FMI3/fmi3_xml_vendor_annotations.c b/src/XML/src/FMI3/fmi3_xml_vendor_annotations.c index 2497ab7d..47531837 100644 --- a/src/XML/src/FMI3/fmi3_xml_vendor_annotations.c +++ b/src/XML/src/FMI3/fmi3_xml_vendor_annotations.c @@ -24,8 +24,7 @@ static const char* module = "FMI3XML"; int fmi3_xml_handle_VendorAnnotations(fmi3_xml_parser_context_t *context, const char* data) { if(!data) { jm_log_verbose(context->callbacks, module, "Parsing XML element VendorAnnotations"); - } - else { + } else { /* might give out a warning if(data[0] != 0) */ } return 0; @@ -34,8 +33,7 @@ int fmi3_xml_handle_VendorAnnotations(fmi3_xml_parser_context_t *context, const int fmi3_xml_handle_Annotations(fmi3_xml_parser_context_t *context, const char* data) { if(!data) { jm_log_verbose(context->callbacks, module, "Parsing XML element Annotations"); - } - else { + } else { /* might give out a warning if(data[0] != 0) */ } return 0; @@ -43,30 +41,31 @@ int fmi3_xml_handle_Annotations(fmi3_xml_parser_context_t *context, const char* int fmi3_xml_handle_VariableTool(fmi3_xml_parser_context_t *context, const char* data) { if(!data) { - size_t len; - fmi3_xml_model_description_t* md = context->modelDescription; - jm_vector(char)* bufName = fmi3_xml_reserve_parse_buffer(context,1,100); - jm_string *pvendor; - char* vendor = 0; - - if(!bufName) return -1; - /* */ - if( fmi3_xml_parse_attr_as_string(context, fmi3_xml_elmID_Tool, fmi_attr_id_name, 1, bufName)) - return -1; - pvendor = jm_vector_push_back(jm_string)(&md->vendorList, vendor); - len = jm_vector_get_size(char)(bufName); - if(pvendor ) - *pvendor = vendor = (char*)(context->callbacks->malloc(len + 1)); - if(!pvendor || !vendor) { - fmi3_xml_parse_fatal(context, "Could not allocate memory"); - return -1; - } - memcpy(vendor, jm_vector_get_itemp(char)(bufName,0), len); - vendor[len] = 0; - - context->anyToolName = vendor; - context->anyParent = jm_vector_get_last(jm_voidp)(&md->variablesOrigOrder); - context->useAnyHandleFlg = 1; + size_t len; + fmi3_xml_model_description_t* md = context->modelDescription; + jm_vector(char)* bufName = fmi3_xml_reserve_parse_buffer(context,1,100); + jm_string *pvendor; + char* vendor = 0; + + if(!bufName) return -1; + /* */ + if( fmi3_xml_parse_attr_as_string(context, fmi3_xml_elmID_Tool, fmi_attr_id_name, 1, bufName)) + return -1; + pvendor = jm_vector_push_back(jm_string)(&md->vendorList, vendor); + len = jm_vector_get_size(char)(bufName); + if (pvendor) { + *pvendor = vendor = (char*)(context->callbacks->malloc(len + 1)); + } + if (!pvendor || !vendor) { + fmi3_xml_parse_fatal(context, "Could not allocate memory"); + return -1; + } + memcpy(vendor, jm_vector_get_itemp(char)(bufName,0), len); + vendor[len] = 0; + + context->anyToolName = vendor; + context->anyParent = jm_vector_get_last(jm_voidp)(&md->variablesOrigOrder); + context->useAnyHandleFlg = 1; } else { /* don't do anything. might give out a warning if(data[0] != 0) */ @@ -90,8 +89,9 @@ int fmi3_xml_handle_Tool(fmi3_xml_parser_context_t *context, const char* data) { return -1; pvendor = jm_vector_push_back(jm_string)(&md->vendorList, vendor); len = jm_vector_get_size(char)(bufName); - if (pvendor) + if (pvendor) { *pvendor = vendor = (char*)(context->callbacks->malloc(len + 1)); + } if (!pvendor || !vendor) { fmi3_xml_parse_fatal(context, "Could not allocate memory"); return -1;