diff --git a/common/UnicharPattern.cc b/common/UnicharPattern.cc index 6b471f76f0544916e45f1871bc1ff9d50851da76..42fe288b60e1f92bfbdf01cb4823a239da6fbf65 100644 --- a/common/UnicharPattern.cc +++ b/common/UnicharPattern.cc @@ -107,12 +107,16 @@ UnicharPattern::UnicharPattern() : mappings_head(NULL) // read one line at a time char line[1024]; while (fgets(line, sizeof(line), fp) != NULL) { + // skip empty lines + if (strcmp(line,"\n") == 0 || strcmp(line,"\r\n") == 0) { + continue; + } // ignore everything after the '#' (this is the 'comment' indicator) char* line_end = strchr(line, '#'); if (line_end != NULL) { *line_end = '\0'; } - //TODO:Valgrind reports uninitialized value coming form here to remove_spaces + // each column ends with a ';', use that as the separator for strtok char* from_str = remove_spaces(strtok(line, ";")); size_t from_str_len = from_str != NULL ? strlen(from_str) : 0; diff --git a/compiler2/PredefFunc.cc b/compiler2/PredefFunc.cc index de4ca2c7019bccafbcb52937a13db9bd20e37078..f01c9aa83881d7f301d7bf2ead38523272e5bdd9 100644 --- a/compiler2/PredefFunc.cc +++ b/compiler2/PredefFunc.cc @@ -794,12 +794,12 @@ static CharCoding::CharCodingType is_ascii (size_t length, const unsigned char* static CharCoding::CharCodingType is_utf8(size_t length, const unsigned char* strptr) { - const char MSB = 1 << 7; // MSB is 1 in case of non ASCII character - const char MSBmin1 = 1 << 6; // 0100 0000 + const unsigned char MSB = 1 << 7; // MSB is 1 in case of non ASCII character + const unsigned char MSBmin1 = 1 << 6; // 0100 0000 size_t i = 0; while (length > i) { if ( strptr[i] & MSB) { // non ASCII char - char maskUTF8 = 1 << 6; // 111x xxxx shows how many additional bytes are there + unsigned char maskUTF8 = 1 << 6; // 111x xxxx shows how many additional bytes are there if (!(strptr[i] & maskUTF8)) return CharCoding::UNKNOWN; // accepted 11xxx xxxx but received 10xx xxxx unsigned int noofUTF8 = 0; // 11xx xxxxx -> 2 bytes, 111x xxxxx -> 3 bytes , 1111 xxxxx -> 4 bytes in UTF-8 while (strptr[i] & maskUTF8) { diff --git a/compiler2/Type.cc b/compiler2/Type.cc index 94757c41f73e6a92e7c485802519f4f888d44c0e..b2c4f7d5d71e9366880998b9ce38b2c1eb49c861 100644 --- a/compiler2/Type.cc +++ b/compiler2/Type.cc @@ -1703,7 +1703,58 @@ namespace Common { } // check the index value Value *index_value = ref->get_val(); - if (t->typetype == T_ARRAY) { + index_value->set_lowerid_to_ref(); + + // pt is the type with the indexing is made, while t is the type on the + // indexing is applied. + Type* pt = index_value->get_expr_governor_last(); + if (pt != NULL && + // The indexer type is an array or record of + (pt->get_typetype() == T_ARRAY || pt->get_typetype() == T_SEQOF) && + // The indexed type is a record of or set of or array + (t->get_typetype() == T_SEQOF || t->get_typetype() == T_SETOF || t->get_typetype() == T_ARRAY)) { + + // The indexer type must be of type integer + if (pt->get_ofType()->get_type_refd_last()->get_typetype() != T_INT) { + ref->error("Only fixed length array or record of integer types are allowed for short-hand notation for nested indexes."); + return 0; + } + int len = 0; + // Get the length of the array or record of + if (pt->get_typetype() == T_ARRAY) { + len = (int)pt->get_dimension()->get_size(); + } else if (pt->get_typetype() == T_SEQOF) { + SubType* sub = pt->get_sub_type(); + if (sub == NULL) { + ref->error("The type `%s' must have single size length restriction when used as a short-hand notation for nested indexes.", + pt->get_typename().c_str()); + return 0; + } + len = pt->get_sub_type()->get_length_restriction(); + if (len == -1) { + ref->error("The type `%s' must have single size length restriction when used as a short-hand notation for nested indexes.", + pt->get_typename().c_str()); + return 0; + } + } + embedded_type = embedded_type->get_type_refd_last(); + int j = 0; + // Get the len - 1'th inner type + while (j < len - 1) { + switch (embedded_type->get_typetype()) { + case T_SEQOF: + case T_SETOF: + case T_ARRAY: + embedded_type = embedded_type->get_ofType()->get_type_refd_last(); + break; + default: + ref->error("The type `%s' contains too many indexes (%i) in the short-hand notation for nested indexes.", + pt->get_typename().c_str(), len); + return 0; + } + j++; + } + } else if (t->typetype == T_ARRAY) { // checking of array index is performed by the array dimension t->u.array.dimension->chk_index(index_value, expected_index); } else { diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc index b73bcdf367089180cbd81ea10add98201c1aa2eb..118a56b38967ccbf92dfe01078bd66060546996a 100644 --- a/compiler2/Type_chk.cc +++ b/compiler2/Type_chk.cc @@ -828,7 +828,12 @@ Value *Type::new_value_for_dfe(Type *last, const char *dfe_str, Common::Referenc if (is_ref_dfe) { Value* v = new Value(Value::V_REFD, ref->clone()); v->set_my_scope(get_my_scope()->get_scope_mod()); - if (!is_compatible_tt_tt(last->typetype, v->get_expr_governor_last()->typetype, last->is_asn1(), v->get_expr_governor_last()->is_asn1())) { + Type * t = v->get_expr_governor_last(); + if (t == NULL) { + delete v; + return 0; + } + if (!is_compatible_tt_tt(last->typetype, v->get_expr_governor_last()->typetype, last->is_asn1(), t->is_asn1())) { v->get_reference()->error("Incompatible types were given to defaultForEmpty variant: `%s' instead of `%s'.\n", v->get_expr_governor_last()->get_typename().c_str(), last->get_typename().c_str()); delete v; diff --git a/compiler2/XerAttributes.cc b/compiler2/XerAttributes.cc index e1534d7fe4c493ffd3c51b4fc8636a643f03b8af..5a7e85764d8a91bfc5e08cfecd31bedf246f6029 100644 --- a/compiler2/XerAttributes.cc +++ b/compiler2/XerAttributes.cc @@ -292,7 +292,8 @@ other.print("other"); defaultForEmptyIsRef_ = other.defaultForEmptyIsRef_; } - if (other.defaultForEmptyIsRef_ && other.defaultForEmptyRef_ != 0) { + defaultForEmptyIsRef_ |= other.defaultForEmptyIsRef_; + if (other.defaultForEmptyRef_ != 0) { Free(defaultForEmptyRef_); defaultForEmptyRef_ = other.defaultForEmptyRef_->clone(); } diff --git a/compiler2/makefile.c b/compiler2/makefile.c index 64efcf9a91a0d5b1d306a4404da07e7637060006..cb188c2125ff703ddf60b23ed79ce731572e1750 100644 --- a/compiler2/makefile.c +++ b/compiler2/makefile.c @@ -4995,6 +4995,8 @@ int main(int argc, char *argv[]) if (error_flag) { usage(); + Free(other_files); + Free(search_paths); return EXIT_FAILURE; } @@ -5007,6 +5009,8 @@ int main(int argc, char *argv[]) #ifdef LICENSE print_license_info(); #endif + Free(other_files); + Free(search_paths); return EXIT_SUCCESS; } @@ -5017,16 +5021,21 @@ int main(int argc, char *argv[]) free_openssl(); if (!valid_license) { free_license(&lstr); + Free(other_files); + Free(search_paths); exit(EXIT_FAILURE); } if (!check_feature(&lstr, FEATURE_TPGEN)) { ERROR("The license key does not allow the generation of " "Makefile skeletons."); + Free(other_files); + Free(search_paths); return EXIT_FAILURE; } free_license(&lstr); #endif + boolean free_argv = FALSE; if (tflag) { char* abs_work_dir = NULL; FILE* prj_graph_fp = NULL; @@ -5104,7 +5113,7 @@ int main(int argc, char *argv[]) boolean temp_wflag = FALSE; tpd_processed = process_tpd(tpd_file_name, tpd_build_config, file_list_path, - &argc, &argv, &optind, &ets_name, &project_name, + &argc, &argv, &free_argv, &optind, &ets_name, &project_name, &gflag, &sflag, &cflag, &aflag, &pflag, &Rflag, &lflag, &mflag, &Pflag, &Lflag, rflag, Fflag, Tflag, output_file, &abs_work_dir, sub_project_dirs, program_name, prj_graph_fp, create_symlink_list, ttcn3_prep_includes, ttcn3_prep_defines, ttcn3_prep_undefines, prep_includes, prep_defines, prep_undefines, &csflag, @@ -5118,14 +5127,17 @@ int main(int argc, char *argv[]) wflag = temp_wflag; } - Free(abs_work_dir); if (prj_graph_fp) { fprintf(prj_graph_fp, "</project_hierarchy_graph>\n"); fclose(prj_graph_fp); } if (tpd_processed == TPD_FAILED) { ERROR("Failed to process %s", tpd_file_name); - goto end; + // process_tpd has already cleaned everything up + return EXIT_FAILURE; + } + else { + Free(abs_work_dir); } if (zflag) { WARNING("Compiler option '-z' and its argument will be overwritten by " @@ -5160,8 +5172,12 @@ int main(int argc, char *argv[]) executeMakefileScript(makefileScript, output_file); } } + else { + free_string2_list(run_command_list); + free_string2_list(create_symlink_list); + Free(project_name); + } -end: free_string_list(sub_project_dirs); free_string_list(ttcn3_prep_includes); free_string_list(ttcn3_prep_defines); @@ -5185,10 +5201,9 @@ end: free_string2_list(target_placement_list); free_string2_list(required_configs); Free(makefileScript); - + Free(other_files); if (tpd_processed == TPD_SUCCESS) { - int E; if (!(eflag && ets_name)) Free(ets_name); if (cxxcompiler) @@ -5200,6 +5215,9 @@ end: if (ttcn3prep) Free(ttcn3prep); /* Free(output_file); */ + } + if (free_argv) { + int E; for (E = 0; E < argc; ++E) Free(argv[E]); Free(argv); } diff --git a/compiler2/map.hh b/compiler2/map.hh index fdc01c43565abe9cd71a7d70e426138208146d07..532bfb23ba91c38e1f26c81f8994f49c2e1f91c9 100644 --- a/compiler2/map.hh +++ b/compiler2/map.hh @@ -81,7 +81,7 @@ private: public: - static const size_t max_map_length = -1; + static const size_t max_map_length = (size_t) -1; /** Creates an empty map. */ map() : num_m(0), max_m(0), last_searched_key(0), m_ptr(NULL) { } diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index fdd64d15229f945d321e17be690ab86de53c6ca8..1a81106363a1293e82b549f277fb0501ba9d1ba5 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -369,9 +369,29 @@ namespace Ttcn { } } else { // Generate code for array reference. - expr->expr = mputc(expr->expr, '['); - ref->get_val()->generate_code_expr(expr); - expr->expr = mputc(expr->expr, ']'); + Value* v = ref->get_val(); + Type * pt = v->get_expr_governor_last(); + // If the value is indexed with an array or record of then generate + // the indexes of the array or record of into the code, one by one. + if (pt->get_typetype() == Type::T_ARRAY || pt->get_typetype() == Type::T_SEQOF) { + int len = 0, start = 0; + if (pt->get_typetype() == Type::T_ARRAY) { + len = (int)pt->get_dimension()->get_size(); + start = pt->get_dimension()->get_offset(); + } else if (pt->get_typetype() == Type::T_SEQOF) { + len = pt->get_sub_type()->get_length_restriction(); + } + // Generate the indexes as [x][y]... + for (int j = start; j < start + len; j++) { + expr->expr = mputc(expr->expr, '['); + v->generate_code_expr(expr); + expr->expr = mputprintf(expr->expr, "[%i]]", j); + } + } else { + expr->expr = mputc(expr->expr, '['); + v->generate_code_expr(expr); + expr->expr = mputc(expr->expr, ']'); + } if (type) { // Follow the embedded type. switch (type->get_typetype()) { diff --git a/compiler2/ttcn3/Statement.cc b/compiler2/ttcn3/Statement.cc index 28418078b80eaabfe82bb69e08ac6c7a61da5613..966e797a8e4aabd3d820177abe502c25cdac6f24 100644 --- a/compiler2/ttcn3/Statement.cc +++ b/compiler2/ttcn3/Statement.cc @@ -4652,6 +4652,20 @@ error: ptb1->report_connection_errors(ptb2); if (ptb1 != ptb2) ptb2->report_connection_errors(ptb1); } + + { + Error_Context cntxt2(config_op.compref1, "In first endpoint"); + if (ptb1->get_testport_type() == PortTypeBody::TP_ADDRESS) { + error("An address supporting port cannot be used in a connect operation"); + } + } + + { + Error_Context cntxt2(config_op.compref1, "In second endpoint"); + if (ptb2->get_testport_type() == PortTypeBody::TP_ADDRESS) { + error("An address supporting port cannot be used in a connect operation"); + } + } } void Statement::chk_map() diff --git a/compiler2/ttcn3/Templatestuff.cc b/compiler2/ttcn3/Templatestuff.cc index 1a2d91251fc99157bf8f90063e8dfeee81726b34..768cc961cb8c6f07aa1e0c3a11a8950dd914c1e9 100644 --- a/compiler2/ttcn3/Templatestuff.cc +++ b/compiler2/ttcn3/Templatestuff.cc @@ -243,6 +243,7 @@ namespace Ttcn { // ================================= IndexedTemplate::IndexedTemplate(const IndexedTemplate& p) + : Node(p), Location(p) { index = p.index->clone(); temp = p.temp->clone(); @@ -357,6 +358,7 @@ namespace Ttcn { } NamedTemplate::NamedTemplate(const NamedTemplate& p) + : Node(p), Location(p) { name = p.name->clone(); temp = p.temp->clone(); diff --git a/compiler2/ttcn3/port.c b/compiler2/ttcn3/port.c index 45fba3875a9566c23481a5b71820810d72906798..1aa49c95ec459a74af5f7d8cc67b7bf90d798dcd 100644 --- a/compiler2/ttcn3/port.c +++ b/compiler2/ttcn3/port.c @@ -17,6 +17,7 @@ * Kremer, Peter * Raduly, Csaba * Szabados, Kristof + * Szabo, Bence Janos * Szabo, Janos Zoltan – initial implementation * ******************************************************************************/ @@ -1644,7 +1645,12 @@ void defPortClass(const port_def* pdef, output_struct* output) src = mputstr(src, "TTCN_error(\"Message cannot be sent to system " "on internal port %s.\", port_name);\n"); } else { - src = mputprintf(src, "outgoing_send(send_par%s);\n", + src = mputprintf(src, + "{\n" + // To generate DTE-s if not mapped or connected. + "(void)get_default_destination();\n" + "outgoing_send(send_par%s);\n" + "}\n", pdef->testport_type == ADDRESS ? ", NULL" : ""); } src = mputprintf(src, "else {\n" @@ -1680,6 +1686,8 @@ void defPortClass(const port_def* pdef, output_struct* output) " send_par.log()," " TTCN_Logger::end_event_log2str()));\n" "}\n", class_name, msg->name, pdef->address_name, msg->dispname); + // To generate DTE-s if not mapped or connected. + src = mputstr(src, "(void)get_default_destination();\n"); if (pdef->port_type != USER || (msg->nTargets == 1 && msg->targets[0].mapping_type == M_SIMPLE)) { src = mputstr(src, "outgoing_send(send_par, " diff --git a/compiler2/vector.hh b/compiler2/vector.hh index fd977d806a8171b22bf7993cab287cec7e9415d7..b38f6680c32fb181ff1519e37f8e3e549ef41085 100644 --- a/compiler2/vector.hh +++ b/compiler2/vector.hh @@ -67,7 +67,7 @@ private: public: - static const size_t max_vector_length = -1; + static const size_t max_vector_length = (size_t) -1; /** Creates an empty vector. */ vector() : num_e(0), e_ptr(NULL) { } diff --git a/compiler2/xpather.cc b/compiler2/xpather.cc index 4b3e9634085d1dd9deb91dc5006251f882dd83f1..488c787c0a6fbee4b6f9980ee8992f372e71cca4 100644 --- a/compiler2/xpather.cc +++ b/compiler2/xpather.cc @@ -1068,6 +1068,8 @@ static boolean analyse_child(struct config_struct* const all_configs, const char // Go to the next required config req_config = req_config->next; continue; + } else { + found = TRUE; } // Get the project_name's act_config config_struct (tmp holds it) @@ -1090,7 +1092,7 @@ static boolean analyse_child(struct config_struct* const all_configs, const char } insert_to_tmp_config(tmp_configs, project_name, act_config, is_active); - // Analyse referenced project's of project_name project + // Analyze referenced projects of project_name project struct string_list* last_child = tmp->children; while (last_child && last_child->str != NULL) { result = analyse_child(all_configs, last_child->str, NULL, required_configs, tmp_configs); @@ -1103,8 +1105,8 @@ static boolean analyse_child(struct config_struct* const all_configs, const char } last = last->next; } - - if (found == FALSE) { // No one said anything about this project's configuration + // No one said anything about this project's configuration or we still don't know the configuration + if (found == FALSE || get_act_config(required_configs, project_name) == NULL) { //Get the active configuration of this project last = all_configs; while (last && last->project_name != NULL && last->project_conf != NULL) { @@ -1218,13 +1220,14 @@ static tpd_result config_struct_get_required_configs(struct config_struct* const if (result == FALSE) return TPD_FAILED; insert_to_tmp_config(*tmp_configs, last->project_name, last->project_conf, TRUE); - // last variable holds the top level project's active configuration which needed to be analysed + // last variable holds the top level project's active configuration which needed to be analyzed // Insert every required config of the top level project active configuration struct string2_list* last_proj_config = last->requirements; while (last_proj_config && last_proj_config->str1 != NULL && last_proj_config->str2 != NULL) { // todo ezek a null cuccok mindenhova, every param should not be null struct string_list* children = last->children; // This if allows that a top level project can require an other project's configuration // without referencing it. + if (children->str != NULL || strcmp(last_proj_config->str1, last->project_name) == 0) { result = insert_to_required_config(all_configs, last_proj_config->str1, last_proj_config->str2, required_configs); if (result == FALSE) return TPD_FAILED; @@ -1233,7 +1236,7 @@ static tpd_result config_struct_get_required_configs(struct config_struct* const } last->processed = TRUE; - //Analyse the referenced project of the top level project + //Analyze the referenced project of the top level project struct string_list* last_child = last->children; while (last_child && last_child->str != NULL) { result = analyse_child(all_configs, last_child->str, NULL, required_configs, *tmp_configs); // todo check if everywhere is handled @@ -1250,7 +1253,7 @@ static tpd_result config_struct_get_required_configs(struct config_struct* const } static tpd_result process_tpd_internal(const char *p_tpd_name, char* tpdName, const char *actcfg, - const char *file_list_path, int *p_argc, char ***p_argv, + const char *file_list_path, int *p_argc, char ***p_argv, boolean* p_free_argv, int *p_optind, char **p_ets_name, char **p_project_name, boolean *p_gflag, boolean *p_sflag, boolean *p_cflag, boolean *p_aflag, boolean *preprocess, boolean *p_Rflag, boolean *p_lflag, boolean *p_mflag, boolean *p_Pflag, @@ -1270,7 +1273,7 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char* tpdName, co const char **search_paths, size_t n_search_paths, char** makefileScript, struct config_struct * const all_configs); extern "C" tpd_result process_tpd(const char *p_tpd_name, const char *actcfg, - const char *file_list_path, int *p_argc, char ***p_argv, + const char *file_list_path, int *p_argc, char ***p_argv, boolean* p_free_argv, int *p_optind, char **p_ets_name, char **p_project_name, boolean *p_gflag, boolean *p_sflag, boolean *p_cflag, boolean *p_aflag, boolean *preprocess, boolean *p_Rflag, boolean *p_lflag, boolean *p_mflag, boolean *p_Pflag, @@ -1301,7 +1304,7 @@ extern "C" tpd_result process_tpd(const char *p_tpd_name, const char *actcfg, // The first round only collects the configurations about the tpd-s into the // all_configs variable. It does not do anything else. tpd_result success = process_tpd_internal(p_tpd_name, tpdName, - actcfg, file_list_path, p_argc, p_argv, p_optind, p_ets_name, p_project_name, + actcfg, file_list_path, p_argc, p_argv, p_free_argv, p_optind, p_ets_name, p_project_name, p_gflag, p_sflag, p_cflag, p_aflag, preprocess, p_Rflag, p_lflag, p_mflag, p_Pflag, p_Lflag, recursive, force_overwrite, gen_only_top_level, @@ -1329,7 +1332,7 @@ extern "C" tpd_result process_tpd(const char *p_tpd_name, const char *actcfg, // optimal case. In the not optimal case errors are produced. // This round does get the information from the tpd to generate the makefile. success = process_tpd_internal(p_tpd_name, tpdName, - actcfg, file_list_path, p_argc, p_argv, p_optind, p_ets_name, p_project_name, + actcfg, file_list_path, p_argc, p_argv, p_free_argv, p_optind, p_ets_name, p_project_name, p_gflag, p_sflag, p_cflag, p_aflag, preprocess, p_Rflag, p_lflag, p_mflag, p_Pflag, p_Lflag, recursive, force_overwrite, gen_only_top_level, @@ -1368,7 +1371,7 @@ extern "C" tpd_result process_tpd(const char *p_tpd_name, const char *actcfg, } seen_tpd_files.clear(); - return success; + return TPD_SUCCESS; failure: /* free everything before exiting */ @@ -1391,20 +1394,33 @@ failure: Free(search_paths); Free(*generatorCommandOutput); + free_string2_list(run_command_list); free_string2_list(create_symlink_list); free_string2_list(target_placement_list); free_string2_list(required_configs); Free(*makefileScript); Free(*p_project_name); + Free(*abs_work_dir_p); Free(*p_ets_name); Free(*cxxcompiler); Free(*optlevel); Free(*optflags); Free(*ttcn3prep); - for (int E = 0; E < *p_argc; ++E) Free((*p_argv)[E]); - Free(*p_argv); - exit(EXIT_FAILURE); + if (*p_free_argv) { + for (int E = 0; E < *p_argc; ++E) Free((*p_argv)[E]); + Free(*p_argv); + } + + for (size_t i = 0, num = seen_tpd_files.size(); i < num; ++i) { + const cstring& key = seen_tpd_files.get_nth_key(i); + int *elem = seen_tpd_files.get_nth_elem(i); + key.destroy(); + delete elem; + } + seen_tpd_files.clear(); + + return TPD_FAILED; } // optind is the index of the next element of argv to be processed. @@ -1418,7 +1434,7 @@ failure: // If process_tpd() preserves the content of such a string (e.g. ets_name), // it must nevertheless make a copy on the heap via mcopystr(). static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, const char *actcfg, - const char *file_list_path, int *p_argc, char ***p_argv, + const char *file_list_path, int *p_argc, char ***p_argv, boolean* p_free_argv, int *p_optind, char **p_ets_name, char **p_project_name, boolean *p_gflag, boolean *p_sflag, boolean *p_cflag, boolean *p_aflag, boolean *preprocess, boolean *p_Rflag, boolean *p_lflag, boolean *p_mflag, boolean *p_Pflag, @@ -1579,6 +1595,9 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, co XPathObject projectNameObj(run_xpath(xpathCtx, projectNameXpath)); Free(projectNameXpath); if (projectNameObj->nodesetval && projectNameObj->nodesetval->nodeNr > 0) { + if (*p_project_name != NULL) { + Free(*p_project_name); + } *p_project_name = mcopystr((const char*)projectNameObj->nodesetval->nodeTab[0]->content); projGenHelper.addTarget(*p_project_name); projGenHelper.setToplevelProjectName(*p_project_name); @@ -2882,6 +2901,7 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, co int my_argc = 0; char *my_args[] = { NULL }; char **my_argv = my_args + 0; + boolean my_free_argv = FALSE; int my_optind = 0; boolean my_gflag = *p_gflag, my_aflag = *p_aflag, my_cflag = *p_cflag, // pass down my_Rflag = *p_Rflag, my_Pflag = *p_Pflag, my_Zflag = *p_Zflag, my_Hflag = *p_Hflag, @@ -2925,6 +2945,7 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, co next_child->next = NULL; last_child->next = next_child; last_child = next_child; + //break; needed??? } } tmp = tmp->next; @@ -2932,7 +2953,7 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, co } tpd_result success = process_tpd_internal((const char*)abs_projectLocationURI, tpdName_loc, - my_actcfg, file_list_path, &my_argc, &my_argv, &my_optind, &my_ets, &my_proj_name, + my_actcfg, file_list_path, &my_argc, &my_argv, &my_free_argv, &my_optind, &my_ets, &my_proj_name, &my_gflag, &my_sflag, &my_cflag, &my_aflag, preprocess, &my_Rflag, &my_lflag, &my_mflag, &my_Pflag, &my_Lflag, recursive, force_overwrite, gen_only_top_level, NULL, &sub_proj_abs_work_dir, sub_project_dirs, program_name, prj_graph_fp, create_symlink_list, ttcn3_prep_includes, ttcn3_prep_defines, ttcn3_prep_undefines, @@ -3013,21 +3034,31 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, co const cstring tmp(my_argv[z]); if (!files.has_key(tmp)){ files.add(tmp, my_argv[z]); - } else { + } else if (my_free_argv) { Free(my_argv[z]); } } } - Free(my_argv); // free the array; we keep the pointers + if (my_free_argv) { + Free(my_argv); // free the array; we keep the pointers + } Free(my_ets); - Free(my_proj_name); } - else if (success == TPD_FAILED) { - ERROR("Failed to process %s", (const char*)abs_projectLocationURI); - result = TPD_FAILED; + else { + if (my_free_argv) { + for (int z = 0; z < my_argc; ++z) { + Free(my_argv[z]); + } + Free(my_argv); + } + if (success == TPD_FAILED) { + ERROR("Failed to process %s", (const char*)abs_projectLocationURI); + result = TPD_FAILED; + } + // else TPD_SKIPPED, keep quiet } - // else TPD_SKIPPED, keep quiet + Free(my_proj_name); Free(tpdName_loc); name = projectLocationURI = tpdName_loc = NULL; // forget all } @@ -3161,6 +3192,15 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, co } // replace argv only if not config mode if (!get_config_mode) { + if (*p_free_argv) { + for (int i = 0; i < *p_argc; ++i) { + Free((*p_argv)[i]); + } + Free(*p_argv); + } + else { + *p_free_argv = TRUE; + } *p_argv = new_argv; *p_argc = new_argc; *p_optind = 0; @@ -3169,7 +3209,6 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, co Free(new_argv[i]); } Free(new_argv); - Free(*p_project_name); } // finally... diff --git a/compiler2/xpather.h b/compiler2/xpather.h index e93420d13847e999f866ded5d291eb71036a81ef..c4565b7c51e84e1d6f407f4b4b6c706fa53d7642 100644 --- a/compiler2/xpather.h +++ b/compiler2/xpather.h @@ -272,7 +272,7 @@ enum #endif tpd_result process_tpd(const char *p_tpd_name, const char *actcfg, const char *file_list_path, - int *argc, char ***argv, + int *argc, char ***argv, boolean* p_free_argv, int *optind, char **ets_name, char **project_name, boolean *gnu_make, boolean *single_mode, boolean *central_storage, boolean *absolute_paths, diff --git a/core/Addfunc.cc b/core/Addfunc.cc index d3ad9e218b6ff428ab26cad096c29de03c15c406..716cf8be5911ae8eebb98422545b85fc8b3d20e4 100644 --- a/core/Addfunc.cc +++ b/core/Addfunc.cc @@ -214,15 +214,15 @@ static CharCoding::CharCodingType is_ascii ( const OCTETSTRING& ostr ) static CharCoding::CharCodingType is_utf8 ( const OCTETSTRING& ostr ) { - const char MSB = 1 << 7; // MSB is 1 in case of non ASCII character - const char MSBmin1 = 1 << 6; // 0100 0000 + const unsigned char MSB = 1 << 7; // MSB is 1 in case of non ASCII character + const unsigned char MSBmin1 = 1 << 6; // 0100 0000 int i = 0; const unsigned char* strptr = (const unsigned char*)ostr; // std::cout << "UTF-8 strptr" << strptr << std::endl; while (ostr.lengthof() > i) { if ( strptr[i] & MSB) { // non ASCII char // std::cout << "UTF-8 strptr[" << i << "]: " << std::hex << (int)strptr[i] << std::endl; - char maskUTF8 = 1 << 6; // 111x xxxx shows how many additional bytes are there + unsigned char maskUTF8 = 1 << 6; // 111x xxxx shows how many additional bytes are there if (!(strptr[i] & maskUTF8)) return CharCoding::UNKNOWN; // accepted 11xxx xxxx but received 10xx xxxx unsigned int noofUTF8 = 0; // 11xx xxxxx -> 2 bytes, 111x xxxxx -> 3 bytes , 1111 xxxxx -> 4 bytes in UTF-8 while (strptr[i] & maskUTF8) { diff --git a/core/Port.cc b/core/Port.cc index 67673f0a403c2f26ff7ebec11041d5b766391924..d432b6f9a19969f48fa0f468aa7579a2cf46002e 100644 --- a/core/Port.cc +++ b/core/Port.cc @@ -1297,7 +1297,11 @@ port_connection *PORT::add_connection(component remote_component, else if (ret_val > 0) break; } else if (conn_ptr->remote_component > remote_component) break; } - + + if (n_system_mappings > 0) { + TTCN_error("Connect operation cannot be performed on a mapped port (%s).", port_name); + } + port_connection *new_conn = new port_connection; new_conn->owner_port = this; @@ -2414,6 +2418,9 @@ void PORT::map_port(const char *component_port, const char *system_port) PORT *port_ptr = lookup_by_name(component_port); if (port_ptr == NULL) TTCN_error("Map operation refers to " "non-existent port %s.", component_port); + if (port_ptr->connection_list_head != NULL) { + TTCN_error("Map operation is not allowed on a connected port (%s).", component_port); + } port_ptr->map(system_port); if (!TTCN_Runtime::is_single()) TTCN_Communication::send_mapped(component_port, system_port); diff --git a/function_test/Semantic_Analyser/Makefile.semantic b/function_test/Semantic_Analyser/Makefile.semantic index da579923da1a258d05d89bf93d9e58dc5846d33d..b1b87e0f08012cb4d618e3595b14305e1634fb03 100644 --- a/function_test/Semantic_Analyser/Makefile.semantic +++ b/function_test/Semantic_Analyser/Makefile.semantic @@ -12,7 +12,7 @@ # Szabo, Bence Janos # ############################################################################## -SADIRS := ver xer encode param template any_from pattern_ref float +SADIRS := ver xer encode param template any_from pattern_ref float recof_index ifeq ($(RT2), yes) SADIRS += deprecated endif diff --git a/function_test/Semantic_Analyser/TTCN3_SA_5_TD.script b/function_test/Semantic_Analyser/TTCN3_SA_5_TD.script index 5cfce65898962c3c61fea3f706ae6f13554265fc..5b8dd9d7d6a1978dd0c5f75a9d4fd1b1135972ae 100644 --- a/function_test/Semantic_Analyser/TTCN3_SA_5_TD.script +++ b/function_test/Semantic_Analyser/TTCN3_SA_5_TD.script @@ -10000,6 +10000,57 @@ module ModuleA { :exmp. +.*---------------------------------------------------------------------* +:h3.Address port - connect operation +.*---------------------------------------------------------------------* +:xmp tab=0. + +<TC - Address port - connect operation> + +<COMPILE> +<VERDICT_LEAF PASS> +<MODULE TTCN ModuleA ModuleA.ttcn> +module ModuleA { + type record MyAddressType { // user-defined type + integer field1, + boolean field2 + } + + type MyAddressType address; + + type integer MyMessType; + + type port PortType message { + // address MyAddress; + inout MyMessType; + } with {extension "address"}; + + type component TestCaseComp { + port PortType p; + var address v_addr:= {5, true} + } + + testcase tc_connect() runs on TestCaseComp system TestCaseComp { + + var TestCaseComp v_ptcA := TestCaseComp.create alive; + connect(self:p, v_ptcA:p); + connect(v_ptcA:p, self:p); + } +} +<END_MODULE> +<RESULT IF_PASS COUNT 4> +(?im)address.+?port.+?cannot.+?used.+?connect +<END_RESULT> +<RESULT IF_PASS COUNT 4> +(?is)\berror: +<END_RESULT> +<RESULT IF_PASS POSITIVE> +(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b +<END_RESULT> +<END_TC> + +:exmp. + .*---------------------------------------------------------------------* :h3.Bitstring concatenation - type restriction on result but not on parameters .*---------------------------------------------------------------------* diff --git a/function_test/Semantic_Analyser/recof_index/Makefile b/function_test/Semantic_Analyser/recof_index/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..895b6a5b94888a0f8c7dd0d149825c99ec6fcc4d --- /dev/null +++ b/function_test/Semantic_Analyser/recof_index/Makefile @@ -0,0 +1,12 @@ +############################################################################## +# Copyright (c) 2000-2016 Ericsson Telecom AB +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Bence Janos Szabo +# +############################################################################## +include ../common.mk diff --git a/function_test/Semantic_Analyser/recof_index/recof_index_SE.ttcn b/function_test/Semantic_Analyser/recof_index/recof_index_SE.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..42fc6cfcea51c325a54831f9b25923eb1681e5b3 --- /dev/null +++ b/function_test/Semantic_Analyser/recof_index/recof_index_SE.ttcn @@ -0,0 +1,50 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Szabo, Bence Janos + * + ******************************************************************************/ +module recof_index_SE { //^In TTCN-3 module// + + type record of record of integer RoRoI; + type record length(1..2) of integer RoI1; + type record length(3) of integer RoI2; + type record of integer RoI; + + type record length(1) of float RoF1; + + function f() { //^In function definition `f'// + var RoRoI v_rec := {{0, 1}, {2, 3}}; + var RoI1 v_index := { 1 } + if (v_rec[v_index] == {2, 3}) { //^In if statement:// //error: The type \`@recof_index_SE\.RoI1\' must have single size length restriction when used as a short-hand notation for nested indexes\.// + } + + var RoI2 v_index2 := { 1, 2, 3 } + if (v_rec[v_index2] == {2, 3}) { //^In if statement:// //error: The type \`@recof_index_SE.RoI2\' contains too many indexes \(3\) in the short-hand notation for nested indexes\.// + } + + var integer v_arr[3] := { 1, 2, 3 } + if (v_rec[v_arr] == {2, 3}) { //^In if statement:// //error: The type \`integer\[3\]\' contains too many indexes \(3\) in the short-hand notation for nested indexes\.// + } + + var RoF1 v_index3 := { 1.0 } + if (v_rec[v_index3] == {2, 3}) { //^In if statement:// //error\: Only fixed length array or record of integer types are allowed for short\-hand notation for nested indexes\.// + } + + var integer v_arr2[0] := { } //In variable definition \`v_arr2\'\:// //error\: A positive integer value was expected as array size instead of \`0\'// + if (v_rec[v_arr2] == {2, 3}) { + } + + var RoI v_index4 := { 1, 1 } + if (v_rec[v_index4] == {2, 3}) { //^In if statement:// //error\: The type \`\@recof_index_SE\.RoI\' must have single size length restriction when used as a short\-hand notation for nested indexes\.// + } + + } + + +} diff --git a/function_test/Semantic_Analyser/recof_index/t b/function_test/Semantic_Analyser/recof_index/t new file mode 100755 index 0000000000000000000000000000000000000000..3a4b58ec16cf2f1390a36c7a92f8823e3b94b425 --- /dev/null +++ b/function_test/Semantic_Analyser/recof_index/t @@ -0,0 +1,9 @@ +#!/usr/bin/perl +# note this is called through "perl -w" +use strict; + +my $self = $0; +$self =~ s!/t!!; + +exec('make check --no-print-directory -s -C ' . $self); + diff --git a/function_test/Semantic_Analyser/xer/dfe_ref_SE.ttcn b/function_test/Semantic_Analyser/xer/dfe_ref_SE.ttcn index c1da95836afc669687d87664304d11c1324a5aa8..958e34e9bd13eeedba7bfc38511224b0a380adfc 100644 --- a/function_test/Semantic_Analyser/xer/dfe_ref_SE.ttcn +++ b/function_test/Semantic_Analyser/xer/dfe_ref_SE.ttcn @@ -18,7 +18,8 @@ type record DFEConst { //^In type definition// universal charstring us, //^In record field \`us\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_us// integer i, //^In record field \`i\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_i// float f, //^In record field \`f\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_f// - boolean b //^In record field \`b\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_b// + boolean b, //^In record field \`b\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_b// + charstring csmissing //^In record field \`csmissing\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_csmissing// } with { variant "element"; @@ -27,6 +28,7 @@ with { variant (i) "defaultForEmpty as c_oct"; //^error: Incompatible types were given to defaultForEmpty variant\: \`octetstring\' instead of \`integer\'\.// variant (f) "defaultForEmpty as c_oct"; //^error: Incompatible types were given to defaultForEmpty variant\: \`octetstring\' instead of \`float\'\.// variant (b) "defaultForEmpty as c_oct"; //^error: Incompatible types were given to defaultForEmpty variant\: \`octetstring\' instead of \`boolean\'\.// + variant (csmissing) "defaultForEmpty as c_missing"; //^error\: There is no local or imported definition with name \`c_missing\'// } } diff --git a/regression_test/Makefile b/regression_test/Makefile index 274622c4f26272c1021aecec4efa4d8844673443..d3eb4c2432ed2b0c24fe12add1f0d14e127927bd 100644 --- a/regression_test/Makefile +++ b/regression_test/Makefile @@ -47,7 +47,8 @@ macros visibility hexstrOper ucharstrOper objidOper CRTR00015758 slider \ XML ipv6 implicitOmit testcase_defparam transparent HQ16404 cfgFile \ all_from lazyEval tryCatch text2ttcn json junitlogger ttcn2json profiler templateOmit \ customEncoding makefilegen uidChars checkstate hostid templateIstemplatekind \ -selectUnion templateExclusiveRange any_from templatePatternRef +selectUnion templateExclusiveRange any_from templatePatternRef indexWithRecofArray \ +connectMapOperTest ifdef DYN DIRS += loggerplugin diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_XmlTest_org_po_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_XmlTest_org_po_e.ttcn index fa15d212bd5a7b051dd7c58c2021ec20bc6b9015..f43841d5667870b8389bfa67e904ac3cd85f1ca6 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_XmlTest_org_po_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/http_www_XmlTest_org_po_e.ttcn @@ -45,6 +45,9 @@ module http_www_XmlTest_org_po { import from XSD all; +const XSD.NMTOKEN c_defaultForEmpty_1 := "US"; + + /* Purchase order schema for Example.com. Copyright 2000 Example.com. All rights reserved. */ @@ -78,7 +81,7 @@ with { type record USAddress { - XSD.NMTOKEN country ("US") optional, + XSD.NMTOKEN country (c_defaultForEmpty_1) optional, XSD.String name, XSD.String street, XSD.String city, @@ -86,7 +89,7 @@ type record USAddress XSD.Decimal zip } with { - variant (country) "defaultForEmpty as 'US'"; + variant (country) "defaultForEmpty as c_defaultForEmpty_1"; variant (country) "attribute"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/urn_ietf_params_xml_ns_conference_info_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/urn_ietf_params_xml_ns_conference_info_e.ttcn index 10ed39d60ff5a7aabec8667914fd8dfe41d8399a..68777993120572be5abd81cfc268b9783fc7e960 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/urn_ietf_params_xml_ns_conference_info_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/urn_ietf_params_xml_ns_conference_info_e.ttcn @@ -46,6 +46,9 @@ module urn_ietf_params_xml_ns_conference_info { import from XSD all; +const State_type c_defaultForEmpty_1 := full; + + /* CONFERENCE ELEMENT */ @@ -77,7 +80,7 @@ with { variant "name as 'conference-type'"; variant (attr) "attribute"; variant (entity) "attribute"; - variant (state) "defaultForEmpty as 'full'"; + variant (state) "defaultForEmpty as c_defaultForEmpty_1"; variant (state) "attribute"; variant (attr_1) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'"; variant (attr_1) "name as 'attr'"; @@ -231,7 +234,7 @@ type record Uris_type } with { variant "name as 'uris-type'"; - variant (state) "defaultForEmpty as 'full'"; + variant (state) "defaultForEmpty as c_defaultForEmpty_1"; variant (state) "attribute"; variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'"; variant (entry_list) "untagged"; @@ -282,7 +285,7 @@ type record Users_type } with { variant "name as 'users-type'"; - variant (state) "defaultForEmpty as 'full'"; + variant (state) "defaultForEmpty as c_defaultForEmpty_1"; variant (state) "attribute"; variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'"; variant (user_list) "untagged"; @@ -311,7 +314,7 @@ type record User_type with { variant "name as 'user-type'"; variant (entity) "attribute"; - variant (state) "defaultForEmpty as 'full'"; + variant (state) "defaultForEmpty as c_defaultForEmpty_1"; variant (state) "attribute"; variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'"; variant (display_text) "name as 'display-text'"; @@ -372,7 +375,7 @@ type record Endpoint_type with { variant "name as 'endpoint-type'"; variant (entity) "attribute"; - variant (state) "defaultForEmpty as 'full'"; + variant (state) "defaultForEmpty as c_defaultForEmpty_1"; variant (state) "attribute"; variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'"; variant (display_text) "name as 'display-text'"; @@ -557,7 +560,7 @@ type record Sidebars_by_val_type } with { variant "name as 'sidebars-by-val-type'"; - variant (state) "defaultForEmpty as 'full'"; + variant (state) "defaultForEmpty as c_defaultForEmpty_1"; variant (state) "attribute"; variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'"; variant (entry_list) "untagged"; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_XmlTest_org_element_recordOfElements_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_XmlTest_org_element_recordOfElements_e.ttcn index 8a08b002b0c8b33d22ee18e6b033cffb3e490d27..10b59dfa1c66b8688838b3925e7a25827d57c6ed 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_XmlTest_org_element_recordOfElements_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_XmlTest_org_element_recordOfElements_e.ttcn @@ -46,6 +46,12 @@ module www_XmlTest_org_element_recordOfElements { import from XSD all; +const XSD.String c_defaultForEmpty_1 := "Msc"; + + +const XSD.String c_defaultForEmpty_2 := "American"; + + /* This documentum tests based on XML Schema Part 1: Structures Second Edition */ @@ -58,7 +64,7 @@ type record PersonInfo1 XSD.String degree optional } with { - variant (degree) "defaultForEmpty as 'Msc'"; + variant (degree) "defaultForEmpty as c_defaultForEmpty_1"; }; @@ -71,7 +77,7 @@ type record PersonInfo2 XSD.Integer age optional } with { - variant (nationality) "defaultForEmpty as 'American'"; + variant (nationality) "defaultForEmpty as c_defaultForEmpty_2"; variant (nationality) "attribute"; variant (title) "attribute"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_attrib_order_a_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_attrib_order_a_e.ttcn index 16afe87f5ed9bd2c1eb22316fe92e14b28311171..486a4126206ee2ff628b1779208a170e5003abe7 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_attrib_order_a_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_attrib_order_a_e.ttcn @@ -50,10 +50,13 @@ import from www_example_org_attrib_order_b all; import from NoTargetNamespace2 all; -type XSD.String Local1 ("fixed") +const XSD.String c_defaultForEmpty_1 := "fixed"; + + +type XSD.String Local1 (c_defaultForEmpty_1) with { + variant "defaultForEmpty as c_defaultForEmpty_1"; variant "name as uncapitalized"; - variant "defaultForEmpty as 'fixed'"; variant "attribute"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_attribgroup_ingroup_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_attribgroup_ingroup_e.ttcn index b69ffd3955f42f3e4d5ec76319b01b4935384502..ce64260bc8dc454f248eeeac8e237fe4373e919a 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_attribgroup_ingroup_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_attribgroup_ingroup_e.ttcn @@ -44,16 +44,19 @@ module www_example_org_attribgroup_ingroup { import from XSD all; +const XSD.String c_defaultForEmpty_1 := "simple"; + + type record AttrGroupinGroup { RemoteSchema remoteSchema optional, - XSD.String type_ ("simple") optional + XSD.String type_ (c_defaultForEmpty_1) optional } with { variant (remoteSchema) "attribute"; + variant (type_) "defaultForEmpty as c_defaultForEmpty_1"; variant (type_) "form as qualified"; variant (type_) "name as 'type'"; - variant (type_) "defaultForEmpty as 'simple'"; variant (type_) "attribute"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn index e26d85495dfa42c0c1d087aa43f69500e1e0f6d5..dd19bbeebda4a77ac1fe86dd66347fe1848e61b3 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn @@ -43,6 +43,9 @@ module www_example_org_complextype_aliases { import from XSD all; +const XSD.Integer c_defaultForEmpty_1 := 2; + + /* Theese types needed to force the nameconversion */ @@ -245,7 +248,7 @@ type record ComplexTypeRestrictionNotAlias5 { XSD.String attr optional, record length(0 .. 2) of record { - XSD.Integer elem (2) optional, + XSD.Integer elem (c_defaultForEmpty_1) optional, record length(1 .. 2) of XSD.Integer elem1_list } sequence_list } @@ -253,7 +256,7 @@ with { variant (attr) "attribute"; variant (sequence_list) "untagged"; variant (sequence_list[-]) "untagged"; - variant (sequence_list[-].elem) "defaultForEmpty as '2'"; + variant (sequence_list[-].elem) "defaultForEmpty as c_defaultForEmpty_1"; variant (sequence_list[-].elem1_list) "untagged"; variant (sequence_list[-].elem1_list[-]) "name as 'elem1'"; }; @@ -266,14 +269,14 @@ type record ComplexTypeRestrictionNotAlias6 { XSD.String attr optional, record length(0 .. 2) of record { - XSD.Integer elem (2) + XSD.Integer elem (c_defaultForEmpty_1) } sequence_list } with { variant (attr) "attribute"; variant (sequence_list) "untagged"; variant (sequence_list[-]) "untagged"; - variant (sequence_list[-].elem) "defaultForEmpty as '2'"; + variant (sequence_list[-].elem) "defaultForEmpty as c_defaultForEmpty_1"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..1983998e872299ac1f0c7f9e95e1579d073e3164 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_e.ttcn @@ -0,0 +1,455 @@ +/******************************************************************************* +* Copyright (c) 2000-2017 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Szabo, Bence Janos +* +*******************************************************************************/ +// +// File: www_example_org_defaultforempty.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Jan 19 13:08:35 2017 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - defaultforempty.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/defaultforempty" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_defaultforempty { + + +import from XSD all; + + +const XSD.String c_defaultForEmpty_1 := "defaultValue"; + + +const XSD.String c_defaultForEmpty_2 := "fixedValue"; + + +const XSD.Date c_defaultForEmpty_3 := "1999-11-11"; + + +const XSD.Integer c_defaultForEmpty_4 := 3; + + +const XSD.Float c_defaultForEmpty_5 := 3.0; + + +const XSD.Float c_defaultForEmpty_6 := infinity; + + +const XSD.Float c_defaultForEmpty_7 := -infinity; + + +const XSD.Float c_defaultForEmpty_8 := not_a_number; + + +const XSD.Boolean c_defaultForEmpty_9 := true; + + +const XSD.Boolean c_defaultForEmpty_10 := false; + + +const MyString_1 c_defaultForEmpty_11 := "fix"; + + +const MyString2_1 c_defaultForEmpty_12 := "fix"; + + +const EnumString c_defaultForEmpty_13 := a; + + +const EnumDate c_defaultForEmpty_14 := x1888_01_01; + + +const EnumFloat c_defaultForEmpty_15 := infinity; + + +const EnumFloat c_defaultForEmpty_16 := not_a_number; + + +const EnumFloat c_defaultForEmpty_17 := 1.0; + + +const EnumInteger c_defaultForEmpty_18 := int3; + + +const EnumInteger c_defaultForEmpty_19 := int_3; + + +/* Basic defaultForEmpty */ + + +type XSD.String StringDefault +with { + variant "defaultForEmpty as c_defaultForEmpty_1"; + variant "element"; +}; + + +type XSD.String StringFixed (c_defaultForEmpty_2) +with { + variant "defaultForEmpty as c_defaultForEmpty_2"; + variant "element"; +}; + + +type XSD.Date DateDefault +with { + variant "defaultForEmpty as c_defaultForEmpty_3"; + variant "element"; +}; + + +type XSD.Date DateFixed (c_defaultForEmpty_3) +with { + variant "defaultForEmpty as c_defaultForEmpty_3"; + variant "element"; +}; + + +type XSD.Integer IntegerDefault +with { + variant "defaultForEmpty as c_defaultForEmpty_4"; + variant "element"; +}; + + +type XSD.Integer IntegerFixed (c_defaultForEmpty_4) +with { + variant "defaultForEmpty as c_defaultForEmpty_4"; + variant "element"; +}; + + +type XSD.Float FloatDefault +with { + variant "defaultForEmpty as c_defaultForEmpty_5"; + variant "element"; +}; + + +type XSD.Float FloatFixed (c_defaultForEmpty_5) +with { + variant "defaultForEmpty as c_defaultForEmpty_5"; + variant "element"; +}; + + +type XSD.Float FloatDefault2 +with { + variant "defaultForEmpty as c_defaultForEmpty_5"; + variant "element"; +}; + + +type XSD.Float FloatFixed2 (c_defaultForEmpty_5) +with { + variant "defaultForEmpty as c_defaultForEmpty_5"; + variant "element"; +}; + + +type XSD.Float FloatDefault3 +with { + variant "defaultForEmpty as c_defaultForEmpty_6"; + variant "element"; +}; + + +type XSD.Float FloatFixed3 (c_defaultForEmpty_6) +with { + variant "defaultForEmpty as c_defaultForEmpty_6"; + variant "element"; +}; + + +type XSD.Float FloatDefault4 +with { + variant "defaultForEmpty as c_defaultForEmpty_7"; + variant "element"; +}; + + +type XSD.Float FloatFixed4 (c_defaultForEmpty_7) +with { + variant "defaultForEmpty as c_defaultForEmpty_7"; + variant "element"; +}; + + +type XSD.Float FloatDefault5 +with { + variant "defaultForEmpty as c_defaultForEmpty_8"; + variant "element"; +}; + + +type XSD.Float FloatFixed5 (c_defaultForEmpty_8) +with { + variant "defaultForEmpty as c_defaultForEmpty_8"; + variant "element"; +}; + + +type XSD.Boolean BooleanDefault +with { + variant "defaultForEmpty as c_defaultForEmpty_9"; + variant "element"; + //variant "text 'true' as '1'"; + //variant "text 'false' as '0'"; +}; + + +type XSD.Boolean BooleanFixed (c_defaultForEmpty_9) +with { + variant "defaultForEmpty as c_defaultForEmpty_9"; + variant "element"; + //variant "text 'true' as '1'"; + //variant "text 'false' as '0'"; +}; + + +type XSD.Boolean BooleanDefault2 +with { + variant "defaultForEmpty as c_defaultForEmpty_9"; + variant "element"; + //variant "text 'true' as '1'"; + //variant "text 'false' as '0'"; +}; + + +type XSD.Boolean BooleanFixed2 (c_defaultForEmpty_9) +with { + variant "defaultForEmpty as c_defaultForEmpty_9"; + variant "element"; + //variant "text 'true' as '1'"; + //variant "text 'false' as '0'"; +}; + + +type XSD.Boolean BooleanDefault3 +with { + variant "defaultForEmpty as c_defaultForEmpty_10"; + variant "element"; + //variant "text 'true' as '1'"; + //variant "text 'false' as '0'"; +}; + + +type XSD.Boolean BooleanFixed3 (c_defaultForEmpty_10) +with { + variant "defaultForEmpty as c_defaultForEmpty_10"; + variant "element"; + //variant "text 'true' as '1'"; + //variant "text 'false' as '0'"; +}; + + +/* Check if the name conversion follows to the constants too */ + + +type XSD.AnyType AttrfixedMyString3 +with { + variant "name as 'AttrfixedMyString3_'"; + variant "element"; +}; + + +type XSD.AnyType MyString +with { + variant "name as 'MyString_'"; + variant "element"; +}; + + +type XSD.AnyType MyString2 +with { + variant "name as 'MyString2_'"; + variant "element"; +}; + + +type XSD.String MyString_1 (pattern "fix") +with { + variant "name as 'MyString'"; +}; + + +type MyString_1 MyStringFixed (c_defaultForEmpty_11) +with { + variant "defaultForEmpty as c_defaultForEmpty_11"; + variant "element"; +}; + + +type XSD.String MyString2_1 +with { + variant "name as 'MyString2'"; +}; + + +type MyString2_1 MyStringFixed2 (c_defaultForEmpty_12) +with { + variant "defaultForEmpty as c_defaultForEmpty_12"; + variant "element"; +}; + + +type MyString_1 AttrfixedMyString3_1 (c_defaultForEmpty_11) +with { + variant "defaultForEmpty as c_defaultForEmpty_11"; + variant "name as 'AttrfixedMyString3'"; + variant "attribute"; +}; + + +type record Complex +{ + XSD.Integer attrfixedInteger (c_defaultForEmpty_4) optional, + MyString2_1 attrfixedMyString2 (c_defaultForEmpty_12) optional, + AttrfixedMyString3_1 attrfixedMyString3 optional, + MyString_1 birthPlaceAttrGroup optional, + MyString_1 myStringFixed (c_defaultForEmpty_11), + MyString2_1 myStringFixed2 (c_defaultForEmpty_12) +} +with { + variant (attrfixedInteger) "defaultForEmpty as c_defaultForEmpty_4"; + variant (attrfixedInteger) "name as capitalized"; + variant (attrfixedInteger) "attribute"; + variant (attrfixedMyString2) "defaultForEmpty as c_defaultForEmpty_12"; + variant (attrfixedMyString2) "name as capitalized"; + variant (attrfixedMyString2) "attribute"; + variant (attrfixedMyString3) "name as capitalized"; + variant (attrfixedMyString3) "attribute"; + variant (birthPlaceAttrGroup) "attribute"; + variant (myStringFixed) "defaultForEmpty as c_defaultForEmpty_11"; + variant (myStringFixed) "name as capitalized"; + variant (myStringFixed2) "defaultForEmpty as c_defaultForEmpty_12"; + variant (myStringFixed2) "name as capitalized"; +}; + + +/* Enumerations */ + + +type EnumString EnumStringFixed (c_defaultForEmpty_13) +with { + variant "defaultForEmpty as c_defaultForEmpty_13"; + variant "element"; +}; + + +type enumerated EnumString +{ + a, + b +} +with { + variant "text 'a' as capitalized"; + variant "text 'b' as capitalized"; +}; + + +type EnumDate EnumDateFixed (c_defaultForEmpty_14) +with { + variant "defaultForEmpty as c_defaultForEmpty_14"; + variant "element"; +}; + + +type enumerated EnumDate +{ + x1888_01_01, + x1999_11_11 +} +with { + variant "text 'x1888_01_01' as '1888-01-01'"; + variant "text 'x1999_11_11' as '1999-11-11'"; +}; + + +type EnumFloat EnumFloatFixed (c_defaultForEmpty_15) +with { + variant "defaultForEmpty as c_defaultForEmpty_15"; + variant "element"; +}; + + +type EnumFloat EnumFloatFixed2 (c_defaultForEmpty_16) +with { + variant "defaultForEmpty as c_defaultForEmpty_16"; + variant "element"; +}; + + +type EnumFloat EnumFloatFixed3 (c_defaultForEmpty_17) +with { + variant "defaultForEmpty as c_defaultForEmpty_17"; + variant "element"; +}; + + +type EnumFloat EnumFloatFixed4 (c_defaultForEmpty_17) +with { + variant "defaultForEmpty as c_defaultForEmpty_17"; + variant "element"; +}; + + +type XSD.Float EnumFloat (1.0, infinity, not_a_number); + + +type EnumInteger EnumIntegerFixed (c_defaultForEmpty_18) +with { + variant "defaultForEmpty as c_defaultForEmpty_18"; + variant "element"; +}; + + +type EnumInteger EnumIntegerFixed2 (c_defaultForEmpty_19) +with { + variant "defaultForEmpty as c_defaultForEmpty_19"; + variant "element"; +}; + + +type enumerated EnumInteger +{ + int_3(-3), + int3(3) +} +with { + variant "useNumber"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/defaultforempty' prefix 'dfe'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_mod1_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_mod1_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..4ae6ba1e73a83e47d2c437076c725281eafa10c5 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_mod1_e.ttcn @@ -0,0 +1,98 @@ +/******************************************************************************* +* Copyright (c) 2000-2017 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Szabo, Bence Janos +* +*******************************************************************************/ +// +// File: www_example_org_defaultforempty_mod1.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Jan 19 13:28:24 2017 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - defaultforempty_mod1.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/defaultforempty/mod1" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_defaultforempty_mod1 { + + +import from XSD all; + + +const XSD.String c_defaultForEmpty_1 := "fix"; + + +const XSD.Integer c_defaultForEmpty_2 := 3; + + +const XSD.String c_defaultForEmpty_3 := "fixext"; + + +const XSD.Integer c_defaultForEmpty_4 := 4; + + +type record Complex +{ + XSD.Integer attrfixedInteger (c_defaultForEmpty_2) optional, + XSD.String myStringFixed (c_defaultForEmpty_1) +} +with { + variant (attrfixedInteger) "defaultForEmpty as c_defaultForEmpty_2"; + variant (attrfixedInteger) "name as capitalized"; + variant (attrfixedInteger) "attribute"; + variant (myStringFixed) "defaultForEmpty as c_defaultForEmpty_1"; + variant (myStringFixed) "name as capitalized"; +}; + + +type record ComplexExt +{ + XSD.Integer attrfixedInteger (c_defaultForEmpty_2) optional, + XSD.Integer attrfixedIntegerExt (c_defaultForEmpty_4) optional, + XSD.String myStringFixed (c_defaultForEmpty_1), + XSD.String myStringFixedExt (c_defaultForEmpty_3) +} +with { + variant (attrfixedInteger) "defaultForEmpty as c_defaultForEmpty_2"; + variant (attrfixedInteger) "name as capitalized"; + variant (attrfixedInteger) "attribute"; + variant (attrfixedIntegerExt) "defaultForEmpty as c_defaultForEmpty_4"; + variant (attrfixedIntegerExt) "name as capitalized"; + variant (attrfixedIntegerExt) "attribute"; + variant (myStringFixed) "defaultForEmpty as c_defaultForEmpty_1"; + variant (myStringFixed) "name as capitalized"; + variant (myStringFixedExt) "defaultForEmpty as c_defaultForEmpty_3"; + variant (myStringFixedExt) "name as capitalized"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/defaultforempty/mod1' prefix 'dfe1'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_mod2_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_mod2_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..89b109d4cabd13bee13bbf059e76cabcbb36eeb7 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_mod2_e.ttcn @@ -0,0 +1,101 @@ +/******************************************************************************* +* Copyright (c) 2000-2017 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Szabo, Bence Janos +* +*******************************************************************************/ +// +// File: www_example_org_defaultforempty_mod2.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Jan 19 13:28:24 2017 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - defaultforempty_mod2.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/defaultforempty/mod2" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_defaultforempty_mod2 { + + +import from XSD all; + + +import from www_example_org_defaultforempty_mod1 all; + + +const XSD.String c_defaultForEmpty_1 := "fix2"; + + +const XSD.Integer c_defaultForEmpty_2 := 10; + + +const XSD.String c_defaultForEmpty_3 := "fixext2"; + + +const XSD.Integer c_defaultForEmpty_4 := 11; + + +type record MyComplex +{ + XSD.Integer fixed2 (c_defaultForEmpty_2) optional, + XSD.String fixed1 (c_defaultForEmpty_1) +} +with { + variant (fixed2) "defaultForEmpty as c_defaultForEmpty_2"; + variant (fixed2) "name as capitalized"; + variant (fixed2) "attribute"; + variant (fixed1) "defaultForEmpty as c_defaultForEmpty_1"; + variant (fixed1) "name as capitalized"; +}; + + +type record ComplexExt +{ + XSD.Integer attrfixedInteger (www_example_org_defaultforempty_mod1.c_defaultForEmpty_2) optional, + XSD.Integer attrfixedIntegerExt2 (c_defaultForEmpty_4) optional, + XSD.String myStringFixed (www_example_org_defaultforempty_mod1.c_defaultForEmpty_1), + XSD.String myStringFixedExt2 (c_defaultForEmpty_3) +} +with { + variant (attrfixedInteger) "defaultForEmpty as www_example_org_defaultforempty_mod1.c_defaultForEmpty_2"; + variant (attrfixedInteger) "name as capitalized"; + variant (attrfixedInteger) "attribute"; + variant (attrfixedIntegerExt2) "defaultForEmpty as c_defaultForEmpty_4"; + variant (attrfixedIntegerExt2) "name as capitalized"; + variant (attrfixedIntegerExt2) "attribute"; + variant (myStringFixed) "defaultForEmpty as www_example_org_defaultforempty_mod1.c_defaultForEmpty_1"; + variant (myStringFixed) "name as capitalized"; + variant (myStringFixedExt2) "defaultForEmpty as c_defaultForEmpty_3"; + variant (myStringFixedExt2) "name as capitalized"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/defaultforempty/mod2' prefix 'dfe2'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_same_ns_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_same_ns_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..d9fdebeec6d0bfba51bf4eeeb461306159edbfcb --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_defaultforempty_same_ns_e.ttcn @@ -0,0 +1,74 @@ +/******************************************************************************* +* Copyright (c) 2000-2017 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Szabo, Bence Janos +* +*******************************************************************************/ +// +// File: www_example_org_defaultforempty_same_ns.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Jan 19 14:04:00 2017 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - defaultforempty_same_ns1.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/defaultforempty/same_ns" */ +// - defaultforempty_same_ns2.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/defaultforempty/same_ns" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_defaultforempty_same_ns { + + +import from XSD all; + + +type XSD.String StringFixed (c_defaultForEmpty_2) +with { + variant "defaultForEmpty as c_defaultForEmpty_2"; + variant "element"; +}; + + +const XSD.Integer c_defaultForEmpty_1 := 3; + + +const XSD.String c_defaultForEmpty_2 := "fix"; + + +type XSD.Integer IntegerFixed (c_defaultForEmpty_1) +with { + variant "defaultForEmpty as c_defaultForEmpty_1"; + variant "element"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/defaultforempty/same_ns' prefix 'dfe1'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_fixed_value_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_fixed_value_e.ttcn index d3478eb1fe3f20ecc10dc3b119a9cf158bfc368f..be9cfea42f3c555df9e269e3ca0bfb77e0c8984e 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_fixed_value_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_fixed_value_e.ttcn @@ -44,125 +44,236 @@ module www_example_org_fixed_value { import from XSD all; -type XSD.String StringType ("a") +const XSD.String c_defaultForEmpty_1 := "a"; + + +const XSD.Integer c_defaultForEmpty_2 := 7; + + +const XSD.Float c_defaultForEmpty_3 := 7.0; + + +const XSD.Float c_defaultForEmpty_4 := infinity; + + +const XSD.Float c_defaultForEmpty_5 := -infinity; + + +const XSD.Float c_defaultForEmpty_6 := not_a_number; + + +const XSD.Float c_defaultForEmpty_7 := 3.0; + + +const XSD.Float c_defaultForEmpty_8 := -3.0; + + +const XSD.Float c_defaultForEmpty_9 := -1E4; + + +const XSD.Float c_defaultForEmpty_10 := 12.78e-2; + + +const XSD.Float c_defaultForEmpty_11 := 0.0; + + +const XSD.Float c_defaultForEmpty_12 := -0.0; + + +const XSD.Double c_defaultForEmpty_13 := 7.0; + + +const XSD.Boolean c_defaultForEmpty_14 := true; + + +const XSD.Boolean c_defaultForEmpty_15 := false; + + +const XSD.Date c_defaultForEmpty_16 := "2011-11-11"; + + +const XSD.Time c_defaultForEmpty_17 := "11:11:11"; + + +const XSD.DateTime c_defaultForEmpty_18 := "2002-05-30T09:00:00"; + + +const XSD.GDay c_defaultForEmpty_19 := "---13"; + + +const XSD.GMonth c_defaultForEmpty_20 := "--11"; + + +const XSD.GMonthDay c_defaultForEmpty_21 := "--11-30"; + + +const XSD.GYear c_defaultForEmpty_22 := "1999"; + + +const XSD.GYearMonth c_defaultForEmpty_23 := "1999-11"; + + +type XSD.String StringType (c_defaultForEmpty_1) +with { + variant "defaultForEmpty as c_defaultForEmpty_1"; + variant "element"; +}; + + +type XSD.Integer IntegerType (c_defaultForEmpty_2) +with { + variant "defaultForEmpty as c_defaultForEmpty_2"; + variant "element"; +}; + + +type XSD.Float FloatType (c_defaultForEmpty_3) +with { + variant "defaultForEmpty as c_defaultForEmpty_3"; + variant "element"; +}; + + +type XSD.Float FloatType2 (c_defaultForEmpty_4) +with { + variant "defaultForEmpty as c_defaultForEmpty_4"; + variant "element"; +}; + + +type XSD.Float FloatType3 (c_defaultForEmpty_5) +with { + variant "defaultForEmpty as c_defaultForEmpty_5"; + variant "element"; +}; + + +type XSD.Float FloatType4 (c_defaultForEmpty_6) +with { + variant "defaultForEmpty as c_defaultForEmpty_6"; + variant "element"; +}; + + +type XSD.Float FloatType5 (c_defaultForEmpty_7) with { - variant "defaultForEmpty as 'a'"; + variant "defaultForEmpty as c_defaultForEmpty_7"; variant "element"; }; -type XSD.Integer IntegerType (7) +type XSD.Float FloatType6 (c_defaultForEmpty_8) with { - variant "defaultForEmpty as '7'"; + variant "defaultForEmpty as c_defaultForEmpty_8"; variant "element"; }; -type XSD.Float FloatType (7.0) +type XSD.Float FloatType7 (c_defaultForEmpty_9) with { - variant "defaultForEmpty as '7.0'"; + variant "defaultForEmpty as c_defaultForEmpty_9"; variant "element"; }; -type XSD.Float FloatType2 (infinity) +type XSD.Float FloatType8 (c_defaultForEmpty_10) with { - variant "defaultForEmpty as 'INF'"; + variant "defaultForEmpty as c_defaultForEmpty_10"; variant "element"; }; -type XSD.Float FloatType3 (-infinity) +type XSD.Float FloatType9 (c_defaultForEmpty_11) with { - variant "defaultForEmpty as '-INF'"; + variant "defaultForEmpty as c_defaultForEmpty_11"; variant "element"; }; -type XSD.Float FloatType4 (not_a_number) +type XSD.Float FloatType10 (c_defaultForEmpty_12) with { - variant "defaultForEmpty as 'NaN'"; + variant "defaultForEmpty as c_defaultForEmpty_12"; variant "element"; }; -type XSD.Double DoubleType (7.0) +type XSD.Double DoubleType (c_defaultForEmpty_13) with { - variant "defaultForEmpty as '7.0'"; + variant "defaultForEmpty as c_defaultForEmpty_13"; variant "element"; }; -type XSD.Boolean BooleanType (true) +type XSD.Boolean BooleanType (c_defaultForEmpty_14) with { - variant "defaultForEmpty as 'true'"; + variant "defaultForEmpty as c_defaultForEmpty_14"; variant "element"; //variant "text 'true' as '1'"; //variant "text 'false' as '0'"; }; -type XSD.Boolean BooleanType2 (false) +type XSD.Boolean BooleanType2 (c_defaultForEmpty_15) with { - variant "defaultForEmpty as '0'"; + variant "defaultForEmpty as c_defaultForEmpty_15"; variant "element"; //variant "text 'true' as '1'"; //variant "text 'false' as '0'"; }; -type XSD.Date DateType ("2011-11-11") +type XSD.Date DateType (c_defaultForEmpty_16) with { - variant "defaultForEmpty as '2011-11-11'"; + variant "defaultForEmpty as c_defaultForEmpty_16"; variant "element"; }; -type XSD.Time TimeType ("11:11:11") +type XSD.Time TimeType (c_defaultForEmpty_17) with { - variant "defaultForEmpty as '11:11:11'"; + variant "defaultForEmpty as c_defaultForEmpty_17"; variant "element"; }; -type XSD.DateTime DateTimeType ("2002-05-30T09:00:00") +type XSD.DateTime DateTimeType (c_defaultForEmpty_18) with { - variant "defaultForEmpty as '2002-05-30T09:00:00'"; + variant "defaultForEmpty as c_defaultForEmpty_18"; variant "element"; }; -type XSD.GDay DayType ("---13") +type XSD.GDay DayType (c_defaultForEmpty_19) with { - variant "defaultForEmpty as '---13'"; + variant "defaultForEmpty as c_defaultForEmpty_19"; variant "element"; }; -type XSD.GMonth MonthType ("--11") +type XSD.GMonth MonthType (c_defaultForEmpty_20) with { - variant "defaultForEmpty as '--11'"; + variant "defaultForEmpty as c_defaultForEmpty_20"; variant "element"; }; -type XSD.GMonthDay MonthDayType ("--11-30") +type XSD.GMonthDay MonthDayType (c_defaultForEmpty_21) with { - variant "defaultForEmpty as '--11-30'"; + variant "defaultForEmpty as c_defaultForEmpty_21"; variant "element"; }; -type XSD.GYear YearType ("1999") +type XSD.GYear YearType (c_defaultForEmpty_22) with { - variant "defaultForEmpty as '1999'"; + variant "defaultForEmpty as c_defaultForEmpty_22"; variant "element"; }; -type XSD.GYearMonth YearMonthType ("1999-11") +type XSD.GYearMonth YearMonthType (c_defaultForEmpty_23) with { - variant "defaultForEmpty as '1999-11'"; + variant "defaultForEmpty as c_defaultForEmpty_23"; variant "element"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_nillable_fixed_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_nillable_fixed_e.ttcn index 9acbcdcb964fa3df9b5725ca8048aa9724b59576..53e3cfd80b0ec704e26acb64eb88c8c3b7df11cc 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_nillable_fixed_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_nillable_fixed_e.ttcn @@ -44,6 +44,9 @@ module www_example_org_nillable_fixed { import from XSD all; +const XSD.Integer c_defaultForEmpty_1 := 1; + + type record RemarkNillable { XSD.String content optional @@ -72,7 +75,7 @@ with { type record SeqNillable { XSD.Integer bar optional, - XSD.Integer foo (1) optional, + XSD.Integer foo (c_defaultForEmpty_1) optional, record { record { XSD.String content optional @@ -89,7 +92,7 @@ with { variant "useNil"; variant "element"; variant (bar) "attribute"; - variant (foo) "defaultForEmpty as '1'"; + variant (foo) "defaultForEmpty as c_defaultForEmpty_1"; variant (foo) "attribute"; variant (content.forename) "useNil"; variant (content.surname) "useNil"; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_ranges_float_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_ranges_float_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..65d7b7fbc585c066495bd1259e73091c8d54ac01 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_ranges_float_e.ttcn @@ -0,0 +1,99 @@ +/******************************************************************************* +* Copyright (c) 2000-2017 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Szabo, Bence Janos +* +*******************************************************************************/ +// +// File: www_example_org_ranges_float.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Fri Jan 20 10:28:48 2017 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - ranges_float.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/ranges/float" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_ranges_float { + + +import from XSD all; + + +/* minInclusive, maxInclusive, minExclusive, maxExclusive */ + + +type XSD.Float E9b (-5.0 .. infinity) +with { + variant "name as uncapitalized"; +}; + + +type XSD.Float E9c +with { + variant "name as uncapitalized"; +}; + + +type XSD.Float E9d ( not_a_number ) +with { + variant "name as uncapitalized"; +}; + + +/* mixed */ + + +type XSD.Float E19b (-5.0 .. !-1.0) +with { + variant "name as uncapitalized"; +}; + + +type XSD.Float E19c (-infinity .. -1.0) +with { + variant "name as uncapitalized"; +}; + + +type XSD.Float E19d ( not_a_number ) +with { + variant "name as uncapitalized"; +}; + + +type XSD.Float Enum (-infinity, infinity, not_a_number) +with { + variant "name as uncapitalized"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/ranges/float'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_ranges_integer_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_ranges_integer_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..82ac11ee6face6597be4a8940207b1db237cc67a --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_ranges_integer_e.ttcn @@ -0,0 +1,99 @@ +/******************************************************************************* +* Copyright (c) 2000-2017 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Szabo, Bence Janos +* +*******************************************************************************/ +// +// File: www_example_org_ranges_integer.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Fri Jan 20 10:32:38 2017 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - ranges_integer.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/ranges/integer" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_ranges_integer { + + +import from XSD all; + + +/* minInclusive, maxInclusive, minExclusive, maxExclusive */ + + +type XSD.Integer E9a (-5 .. infinity) +with { + variant "name as uncapitalized"; +}; + + +type XSD.PositiveInteger E10a (1 .. 100) +with { + variant "name as uncapitalized"; +}; + + +type XSD.Integer E11a (!-5 .. infinity) +with { + variant "name as uncapitalized"; +}; + + +type XSD.PositiveInteger E12a (1 .. !100) +with { + variant "name as uncapitalized"; +}; + + +/* mixed */ + + +type XSD.Integer E19a (-5 .. -1) +with { + variant "name as uncapitalized"; +}; + + +type XSD.PositiveInteger E110a (1 .. 100) +with { + variant "name as uncapitalized"; +}; + + +type XSD.Integer E111a (!-5 .. !100) +with { + variant "name as uncapitalized"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/ranges/integer'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest.prj b/regression_test/XML/XmlWorkflow/src/xmlTest.prj index a63ecb8046cd9455b9de413565d9c3f6d19ace1a..138d7680d3da9e51fa8f12e2a86c40aba9bb730a 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj +++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj @@ -172,6 +172,11 @@ <File path="../xsd/simpletype_aliases.xsd" /> <File path="../xsd/complextype_aliases.xsd" /> <File path="../xsd/attribute_rename.xsd" /> + <File path="../xsd/defaultforempty.xsd" /> + <File path="../xsd/defaultforempty_mod1.xsd" /> + <File path="../xsd/defaultforempty_mod2.xsd" /> + <File path="../xsd/defaultforempty_same_ns1.xsd" /> + <File path="../xsd/defaultforempty_same_ns2.xsd" /> </File_Group> <File_Group name="XmlTest_xsds" > <File path="../XmlTest_xsds/XmlTest_boolean.xsd" /> @@ -415,6 +420,12 @@ <File path="../XmlTest_expectedTtcns/www_example_org_simpletype_aliases_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_complextype_aliases_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_attribute_rename_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_ranges_integer_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_ranges_float_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_defaultforempty_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_defaultforempty_mod1_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_defaultforempty_mod2_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_defaultforempty_same_ns_e.ttcn" /> </File_Group> <File_Group name="XmlTest_src" > <File path="xmlTest_Shell.ttcn" /> diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn index 76515e9eb2ec66ac0f196c84a625703e373422f1..e77cc51fecd5554fd098708b5231942599a11bcd 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn +++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn @@ -898,9 +898,28 @@ group IntegerTest { } }//tc_ + testcase tc_ranges_integer() runs on xmlTest_CT { + f_shellCommandWithVerdict(xsd2ttcn_command & " ranges_integer.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_ranges_integer_e.ttcn", + "www_example_org_ranges_integer.ttcn", c_numOfDiff); + } + }//tc_ + }//IntegerTest + testcase tc_ranges_float() runs on xmlTest_CT { + f_shellCommandWithVerdict(xsd2ttcn_command & " ranges_float.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_ranges_float_e.ttcn", + "www_example_org_ranges_float.ttcn", c_numOfDiff); + } + }//tc_ testcase tc_float_not_a_number() runs on xmlTest_CT { f_shellCommandWithVerdict(xsd2ttcn_command & " not_a_number_minex_inf_maxex_-inf.xsd","",c_shell_successWithoutWarningAndError) @@ -2392,6 +2411,48 @@ group Elements{ }//tc_ + testcase tc_defaultforempty() runs on xmlTest_CT { + + f_shellCommandWithVerdict(xsd2ttcn_command & " defaultforempty.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_defaultforempty_e.ttcn", + "www_example_org_defaultforempty.ttcn", c_numOfDiff); + } + + }//tc_ + + testcase tc_defaultforempty_diff_module() runs on xmlTest_CT { + + f_shellCommandWithVerdict(xsd2ttcn_command & " defaultforempty_mod1.xsd defaultforempty_mod2.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_defaultforempty_mod1_e.ttcn", + "www_example_org_defaultforempty_mod1.ttcn", c_numOfDiff); + } + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_defaultforempty_mod2_e.ttcn", + "www_example_org_defaultforempty_mod2.ttcn", c_numOfDiff); + } + + }//tc_ + + testcase tc_defaultforempty_same_ns() runs on xmlTest_CT { + + f_shellCommandWithVerdict(xsd2ttcn_command & " defaultforempty_same_ns1.xsd defaultforempty_same_ns2.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_defaultforempty_same_ns_e.ttcn", + "www_example_org_defaultforempty_same_ns.ttcn", c_numOfDiff); + } + + }//tc_ + //======================================================== // Alias tests //======================================================== @@ -2631,6 +2692,7 @@ control { execute(tc_integer_withMaxIncl());//Passed execute(tc_integer_withMinExcl());//Passed execute(tc_integer_withMaxExcl());//Passed + execute(tc_ranges_integer());//Passed //===Time=== execute(tc_time());//passed execute(tc_time_withEnum());//Passed TR HL22058 @@ -2642,6 +2704,7 @@ control { execute(tc_list_complextype()); execute(tc_list_minmaxoccurs()); //===Float=== + execute(tc_ranges_float()); execute(tc_float_not_a_number()); //===simpleType enum==== @@ -2774,6 +2837,10 @@ control { execute(tc_type_substitution_complex_cascade()); execute(tc_type_substitution_simple_cascade()); + execute(tc_defaultforempty()); + execute(tc_defaultforempty_diff_module()); + execute(tc_defaultforempty_same_ns()); + //===aliases=== execute(tc_simpletype_aliases()); execute(tc_complextype_aliases()); diff --git a/regression_test/XML/XmlWorkflow/xsd/defaultforempty.xsd b/regression_test/XML/XmlWorkflow/xsd/defaultforempty.xsd new file mode 100644 index 0000000000000000000000000000000000000000..e08c9fa2619faf19ec7a270be1817400ceed8dd5 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/defaultforempty.xsd @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:dfe="www.example.org/defaultforempty" targetNamespace="www.example.org/defaultforempty"> + + +<!-- Basic defaultForEmpty --> + +<xs:element name="StringDefault" type="xs:string" default="defaultValue"/> + +<xs:element name="StringFixed" type="xs:string" fixed="fixedValue"/> + +<xs:element name="DateDefault" type="xs:date" default="1999-11-11"/> + +<xs:element name="DateFixed" type="xs:date" fixed="1999-11-11"/> + +<xs:element name="IntegerDefault" type="xs:integer" default="3"/> + +<xs:element name="IntegerFixed" type="xs:integer" fixed="3"/> + +<xs:element name="FloatDefault" type="xs:float" default="3"/> + +<xs:element name="FloatFixed" type="xs:float" fixed="3"/> + +<xs:element name="FloatDefault2" type="xs:float" default="3.0"/> + +<xs:element name="FloatFixed2" type="xs:float" fixed="3.0"/> + +<xs:element name="FloatDefault3" type="xs:float" default="INF"/> + +<xs:element name="FloatFixed3" type="xs:float" fixed="INF"/> + +<xs:element name="FloatDefault4" type="xs:float" default="-INF"/> + +<xs:element name="FloatFixed4" type="xs:float" fixed="-INF"/> + +<xs:element name="FloatDefault5" type="xs:float" default="NaN"/> + +<xs:element name="FloatFixed5" type="xs:float" fixed="NaN"/> + +<xs:element name="BooleanDefault" type="xs:boolean" default="true"/> + +<xs:element name="BooleanFixed" type="xs:boolean" fixed="true"/> + +<xs:element name="BooleanDefault2" type="xs:boolean" default="1"/> + +<xs:element name="BooleanFixed2" type="xs:boolean" fixed="1"/> + +<xs:element name="BooleanDefault3" type="xs:boolean" default="0"/> + +<xs:element name="BooleanFixed3" type="xs:boolean" fixed="0"/> + + + +<!-- Check if the name conversion follows to the constants too --> +<xs:element name="AttrfixedMyString3_"/> +<xs:element name="MyString_"/> +<xs:element name="MyString2_"/> + +<xs:simpleType name="MyString"> + <xs:restriction base="xs:string"> + <xs:pattern value="fix"/> + </xs:restriction> +</xs:simpleType> + +<xs:element name="MyStringFixed" type="dfe:MyString" fixed="fix"/> + +<xs:simpleType name="MyString2"> + <xs:restriction base="xs:string"/> +</xs:simpleType> + +<xs:element name="MyStringFixed2" type="dfe:MyString2" fixed="fix"/> +<xs:attributeGroup name="attrgroup"> + <xs:attribute name="birthPlaceAttrGroup" type="dfe:MyString"/> + </xs:attributeGroup> + + +<xs:attribute name="AttrfixedMyString3" type="dfe:MyString" fixed="fix"/> + +<xs:complexType name="Complex"> + <xs:sequence> + <xs:element name="MyStringFixed" type="dfe:MyString" fixed="fix"/> + <xs:element name="MyStringFixed2" type="dfe:MyString2" fixed="fix"/> + </xs:sequence> + <xs:attributeGroup ref="dfe:attrgroup"/> + <xs:attribute name="AttrfixedInteger" type="xs:integer" fixed="3"/> + <xs:attribute ref="dfe:AttrfixedMyString3" /> + <xs:attribute name="AttrfixedMyString2" type="dfe:MyString2" fixed="fix"/> +</xs:complexType> + +<!-- Enumerations --> + +<xs:element name="EnumStringFixed" type="dfe:EnumString" fixed="A"/> + +<xs:simpleType name="EnumString"> + <xs:restriction base="xs:string"> + <xs:enumeration value="A"/> + <xs:enumeration value="B"/> + </xs:restriction> +</xs:simpleType> + + +<xs:element name="EnumDateFixed" type="dfe:EnumDate" fixed="1888-01-01"/> + +<xs:simpleType name="EnumDate"> + <xs:restriction base="xs:date"> + <xs:enumeration value="1999-11-11"/> + <xs:enumeration value="1888-01-01"/> + </xs:restriction> +</xs:simpleType> + +<xs:element name="EnumFloatFixed" type="dfe:EnumFloat" fixed="INF"/> + +<xs:element name="EnumFloatFixed2" type="dfe:EnumFloat" fixed="NaN"/> + +<xs:element name="EnumFloatFixed3" type="dfe:EnumFloat" fixed="1.0"/> + +<xs:element name="EnumFloatFixed4" type="dfe:EnumFloat" fixed="1"/> + +<xs:simpleType name="EnumFloat"> + <xs:restriction base="xs:float"> + <xs:enumeration value="INF"/> + <xs:enumeration value="1.0"/> + <xs:enumeration value="NaN"/> + <xs:enumeration value="1"/> + </xs:restriction> +</xs:simpleType> + +<xs:element name="EnumIntegerFixed" type="dfe:EnumInteger" fixed="3"/> + +<xs:element name="EnumIntegerFixed2" type="dfe:EnumInteger" fixed="-3"/> + +<xs:simpleType name="EnumInteger"> + <xs:restriction base="xs:integer"> + <xs:enumeration value="3"/> + <xs:enumeration value="-3"/> + </xs:restriction> +</xs:simpleType> + + +</xs:schema> \ No newline at end of file diff --git a/regression_test/XML/XmlWorkflow/xsd/defaultforempty_mod1.xsd b/regression_test/XML/XmlWorkflow/xsd/defaultforempty_mod1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..2cff08937c466612ee8a0d71957b5bf115a6ad4b --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/defaultforempty_mod1.xsd @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:dfe1="www.example.org/defaultforempty/mod1" targetNamespace="www.example.org/defaultforempty/mod1"> + +<xs:complexType name="Complex"> + <xs:sequence> + <xs:element name="MyStringFixed" type="xs:string" fixed="fix"/> + </xs:sequence> + <xs:attribute name="AttrfixedInteger" type="xs:integer" fixed="3"/> +</xs:complexType> + +<xs:complexType name="ComplexExt"> + <xs:complexContent> + <xs:extension base="dfe1:Complex"> + <xs:sequence> + <xs:element name="MyStringFixedExt" type="xs:string" fixed="fixext"/> + </xs:sequence> + <xs:attribute name="AttrfixedIntegerExt" type="xs:integer" fixed="4"/> + </xs:extension> + </xs:complexContent> +</xs:complexType> + + +</xs:schema> \ No newline at end of file diff --git a/regression_test/XML/XmlWorkflow/xsd/defaultforempty_mod2.xsd b/regression_test/XML/XmlWorkflow/xsd/defaultforempty_mod2.xsd new file mode 100644 index 0000000000000000000000000000000000000000..b850b0ccfa26af80d222f3a9b6ae3c3547af3401 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/defaultforempty_mod2.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:dfe2="www.example.org/defaultforempty/mod2" targetNamespace="www.example.org/defaultforempty/mod2" + xmlns:dfe1="www.example.org/defaultforempty/mod1"> + +<xs:import namespace="DFE" schemaLocation="defaultforempty_mod1.xsd"/> + +<xs:complexType name="MyComplex"> + <xs:sequence> + <xs:element name="Fixed1" type="xs:string" fixed="fix2"/> + </xs:sequence> + <xs:attribute name="Fixed2" type="xs:integer" fixed="10"/> +</xs:complexType> + +<xs:complexType name="ComplexExt"> + <xs:complexContent> + <xs:extension base="dfe1:Complex"> + <xs:sequence> + <xs:element name="MyStringFixedExt2" type="xs:string" fixed="fixext2"/> + </xs:sequence> + <xs:attribute name="AttrfixedIntegerExt2" type="xs:integer" fixed="11"/> + </xs:extension> + </xs:complexContent> +</xs:complexType> + +</xs:schema> \ No newline at end of file diff --git a/regression_test/XML/XmlWorkflow/xsd/defaultforempty_same_ns1.xsd b/regression_test/XML/XmlWorkflow/xsd/defaultforempty_same_ns1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..b961c151fdf91686635c95892034872c481ffef6 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/defaultforempty_same_ns1.xsd @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:dfe1="www.example.org/defaultforempty/same_ns" targetNamespace="www.example.org/defaultforempty/same_ns"> + +<xs:element name="StringFixed" type="xs:string" fixed="fix"/> + +</xs:schema> \ No newline at end of file diff --git a/regression_test/XML/XmlWorkflow/xsd/defaultforempty_same_ns2.xsd b/regression_test/XML/XmlWorkflow/xsd/defaultforempty_same_ns2.xsd new file mode 100644 index 0000000000000000000000000000000000000000..9504e3b36585cc51310c5846c864752044c00d28 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/defaultforempty_same_ns2.xsd @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="www.example.org/defaultforempty/same_ns" xmlns:this="www.example.org/defaultforempty/same_ns"> + +<xs:element name="IntegerFixed" type="xs:integer" fixed="3"/> + +</xs:schema> \ No newline at end of file diff --git a/regression_test/XML/XmlWorkflow/xsd/fixed_value.xsd b/regression_test/XML/XmlWorkflow/xsd/fixed_value.xsd index b7e4d7900bee2e01d71fcb7342608f028cb9ee92..8841ea4e6f202e6991653c9742a83cc438ee1c30 100644 --- a/regression_test/XML/XmlWorkflow/xsd/fixed_value.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/fixed_value.xsd @@ -9,6 +9,12 @@ <xsd:element name="FloatType2" type="xsd:float" fixed="INF"/> <xsd:element name="FloatType3" type="xsd:float" fixed="-INF"/> <xsd:element name="FloatType4" type="xsd:float" fixed="NaN"/> +<xsd:element name="FloatType5" type="xsd:float" fixed="3"/> +<xsd:element name="FloatType6" type="xsd:float" fixed="-3"/> +<xsd:element name="FloatType7" type="xsd:float" fixed="-1E4"/> +<xsd:element name="FloatType8" type="xsd:float" fixed="12.78e-2"/> +<xsd:element name="FloatType9" type="xsd:float" fixed="0"/> +<xsd:element name="FloatType10" type="xsd:float" fixed="-0"/> <xsd:element name="DoubleType" type="xsd:double" fixed="7.0"/> <xsd:element name="BooleanType" type="xsd:boolean" fixed="true"/> <xsd:element name="BooleanType2" type="xsd:boolean" fixed="0"/> diff --git a/regression_test/XML/XmlWorkflow/xsd/ranges_float.xsd b/regression_test/XML/XmlWorkflow/xsd/ranges_float.xsd index 02c71f415eb304dbc5cda173fe4101b129c40453..16480eeb67f5c92bb305e5013f44775f4d135be9 100644 --- a/regression_test/XML/XmlWorkflow/xsd/ranges_float.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/ranges_float.xsd @@ -9,6 +9,7 @@ Contributors: Balasko, Jeno Raduly, Csaba + Szabo, Bence Janos --> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" @@ -69,4 +70,13 @@ targetNamespace="www.example.org/ranges/float"> </restriction> </simpleType> +<simpleType name="enum"> + <restriction base="float"> + <enumeration value="INF"/> + <enumeration value="-INF"/> + <enumeration value="NaN"/> + </restriction> +</simpleType> + + </schema> diff --git a/regression_test/checkstate/PortCheckstate.ttcn b/regression_test/checkstate/PortCheckstate.ttcn index 0dd071b0dba6fa43a801193d31f4a1bef092b3e3..a9a8a191388c1d0696d0865f616f75b17219417f 100644 --- a/regression_test/checkstate/PortCheckstate.ttcn +++ b/regression_test/checkstate/PortCheckstate.ttcn @@ -70,6 +70,7 @@ module PortCheckstate setverdict(fail); } + unmap(mtc:MyPCO2, system:MyPCO4); var MyMTCType myComp1 := MyMTCType.create; connect(myComp1:MyPCO2, mtc:MyPCO2); @@ -154,6 +155,7 @@ module PortCheckstate setverdict(fail); } + unmap(mtc:MyPCO2, system:MyPCO4); var MyMTCType myComp1 := MyMTCType.create; connect(myComp1:MyPCO2, mtc:MyPCO2); @@ -253,6 +255,7 @@ module PortCheckstate setverdict(fail); } + unmap(mtc:MyPCO1, system:MyPCO3); var MyMTCType myComp1 := MyMTCType.create; connect(myComp1:MyPCO1, mtc:MyPCO1); @@ -263,6 +266,7 @@ module PortCheckstate setverdict(fail); } + unmap(mtc:MyPCO2, system:MyPCO4); var MyMTCType myComp2 := MyMTCType.create; connect(myComp2:MyPCO2, mtc:MyPCO2); diff --git a/regression_test/commMessage/AddressPortNegTest.ttcn b/regression_test/commMessage/AddressPortNegTest.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..b521902cc7c6c74e1b0a4808823908d84a0fd61a --- /dev/null +++ b/regression_test/commMessage/AddressPortNegTest.ttcn @@ -0,0 +1,123 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Szabo, Bence Janos + * + ******************************************************************************/ +module AddressPortNegTest { + + type record SIP_address_type + { + charstring host optional, // hostname, IPv4 or IPv6 + integer portField optional, // represented as an integer + boolean tcporudp optional // true if TCP false if UDP + } + + + type SIP_address_type address; + + type port PortType1 message { + inout integer; + } with {extension "address"} + + type port PortType2 message { + inout integer; + } + + type component TestCaseComp { + port PortType1 p1; + } + + type component TestCaseComp2 { + port PortType2 p1; + } + + type component SystemComp { + port PortType1 p1; + } + + + testcase tc_neg_address_port_not_mapped() runs on TestCaseComp system SystemComp { + + var address v_addr := {"Host", 4400, false} + + @try { + p1.send(5) to v_addr; + setverdict(fail, "Send operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, pattern "Dynamic test case error: Port p1 has neither connections nor mappings. Message cannot be sent on it.")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (receive test): ", msg); + } + } + + // After map it is good + map(self:p1, system:p1); + p1.send(5) to v_addr; + + setverdict(pass); + } + + + + testcase tc_neg_address_port_not_mapped_system() runs on TestCaseComp system SystemComp { + + @try { + p1.send(5) to system; + setverdict(fail, "Send operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, pattern "Dynamic test case error: Port p1 has neither connections nor mappings. Message cannot be sent on it.")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (receive test): ", msg); + } + } + + // After map it is good + map(self:p1, system:p1); + p1.send(5) to system; + + setverdict(pass); + } + + + testcase tc_neg_port_not_mapped_system() runs on TestCaseComp2 system SystemComp { + + @try { + p1.send(5) to system; + setverdict(fail, "Send operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, pattern "Dynamic test case error: Port p1 has neither connections nor mappings. Message cannot be sent on it.")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (receive test): ", msg); + } + } + + // After map it is good + map(self:p1, system:p1); + p1.send(5) to system; + + setverdict(pass); + } + + control { + execute(tc_neg_address_port_not_mapped()); + execute(tc_neg_address_port_not_mapped_system()); + + execute(tc_neg_port_not_mapped_system()); + } + +} diff --git a/regression_test/commMessage/Makefile b/regression_test/commMessage/Makefile index ddb1f1a9bf18d1e686b5eae1486243d7dc0f36a8..58f4e1cf1d81016c3c8de6ef755e48607d5777fa 100644 --- a/regression_test/commMessage/Makefile +++ b/regression_test/commMessage/Makefile @@ -27,7 +27,7 @@ include $(TOPDIR)/Makefile.regression TTCN3_LIB = ttcn3$(RT2_SUFFIX)-parallel$(DYNAMIC_SUFFIX) TTCN3_LIB_SINGLE = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) -TTCN3_MODULES = TcommMessage.ttcn HS41022.ttcn +TTCN3_MODULES = TcommMessage.ttcn HS41022.ttcn AddressPortNegTest.ttcn ifdef RT2 TTCN3_MODULES += TmultipleRedirects.ttcn @@ -46,7 +46,11 @@ GENERATED_SOURCES2 := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(f GENERATED_SOURCES += $(GENERATED_SOURCES2) endif -OBJECTS = $(GENERATED_SOURCES:.cc=.o) +PORT_SOURCES = PortType1.cc PortType2.cc +PORT_HEADERS = PortType1.hh PortType2.hh + + +OBJECTS = $(GENERATED_SOURCES:.cc=.o) $(PORT_SOURCES:.cc=.o) TARGET = TcommMessage$(EXESUFFIX) TARGET_SINGLE = TcommMessage_single$(EXESUFFIX) @@ -62,12 +66,12 @@ $(TARGET_SINGLE): $(OBJECTS) .cc.o: $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -$(GENERATED_SOURCES) $(GENERATED_HEADERS): $(TTCN3_MODULES) $(ASN1_MODULES) - $(TTCN3_COMPILER) $^ +$(GENERATED_SOURCES) $(GENERATED_HEADERS) $(PORT_SOURCES) $(PORT_HEADERS): $(TTCN3_MODULES) $(ASN1_MODULES) + $(TTCN3_COMPILER) -t $^ clean distclean: -rm -f $(TARGET) $(TARGET_SINGLE) $(OBJECTS) $(GENERATED_HEADERS) \ - $(GENERATED_SOURCES) *.log Makefile.bak + $(GENERATED_SOURCES) $(PORT_HEADERS) $(PORT_SOURCES) *.log Makefile.bak dep: $(GENERATED_SOURCES) makedepend $(CPPFLAGS) $(GENERATED_SOURCES) diff --git a/regression_test/commMessage/config-rt2.cfg b/regression_test/commMessage/config-rt2.cfg index 64b54d60fc6ba1d588ecf12f5ac8f177bfe8420a..453b2ecb9ef4cee5158a9eac3c69fad83c56fcc7 100644 --- a/regression_test/commMessage/config-rt2.cfg +++ b/regression_test/commMessage/config-rt2.cfg @@ -9,6 +9,7 @@ # Balasko, Jeno # Baranyi, Botond # Dimitrov, Peter +# Szabo, Bence Janos # ############################################################################### [LOGGING] @@ -20,4 +21,5 @@ ConsoleMask := TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS TcommMessage.commMessageInterPTCLocalConnection1 TcommMessage.commMessageInterPTCLocalConnection2 TmultipleRedirects.control +AddressPortNegTest.control diff --git a/regression_test/commMessage/config.cfg b/regression_test/commMessage/config.cfg index 17046784ad9c4defe8c1ca962aac9640237be8f5..7d3abb8088624a8f072fbf9a2fdedc5a31301a80 100644 --- a/regression_test/commMessage/config.cfg +++ b/regression_test/commMessage/config.cfg @@ -8,6 +8,7 @@ # Contributors: # Balasko, Jeno # Dimitrov, Peter +# Szabo, Bence Janos # ############################################################################### [LOGGING] @@ -18,4 +19,5 @@ ConsoleMask := TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS [EXECUTE] TcommMessage.commMessageInterPTCLocalConnection1 TcommMessage.commMessageInterPTCLocalConnection2 +AddressPortNegTest.control diff --git a/regression_test/commMessage/config_parallel-rt2.cfg b/regression_test/commMessage/config_parallel-rt2.cfg index d9202831f2561436b92d82aa2c8e5c8a7e16ef81..f827d4169253e7b236cf11cf9ac51bc2caaba128 100644 --- a/regression_test/commMessage/config_parallel-rt2.cfg +++ b/regression_test/commMessage/config_parallel-rt2.cfg @@ -8,6 +8,7 @@ # Contributors: # Balasko, Jeno # Baranyi, Botond +# Szabo, Bence Janos # ############################################################################### [LOGGING] @@ -19,4 +20,4 @@ ConsoleMask := TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS TcommMessage.control HS41022.control TmultipleRedirects.control - +AddressPortNegTest.control diff --git a/regression_test/commMessage/config_parallel.cfg b/regression_test/commMessage/config_parallel.cfg index 6f2151233854d813b180893354a045ec83688be8..838d92f8308744ad28507dea0638739683ff4b4f 100644 --- a/regression_test/commMessage/config_parallel.cfg +++ b/regression_test/commMessage/config_parallel.cfg @@ -8,6 +8,7 @@ # Contributors: # Balasko, Jeno # Baranyi, Botond +# Szabo, Bence Janos # ############################################################################### [LOGGING] @@ -18,3 +19,4 @@ ConsoleMask := TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS [EXECUTE] TcommMessage.control HS41022.control +AddressPortNegTest.control \ No newline at end of file diff --git a/regression_test/commProcedure/ProcPort.ttcn b/regression_test/commProcedure/ProcPort.ttcn index fe80f22bcbedef621af688c73895a81faeed551c..6c1e792b384ffbf0c1b38db531f73c641c6539cc 100644 --- a/regression_test/commProcedure/ProcPort.ttcn +++ b/regression_test/commProcedure/ProcPort.ttcn @@ -620,9 +620,10 @@ testcase tc_Check_2() runs on ProcComponent { } } +// Address port cannot be connected. testcase tc_PortAddress_internal_usage() runs on ProcComponentMultiPort { /* procedure based internal communication with address-supporting port */ - var ProcComponent2 PC2; + /*var ProcComponent2 PC2; var integer i:=0; PC2:=ProcComponent2.create; PC2.start(GetCall_behav3()); @@ -649,7 +650,8 @@ testcase tc_PortAddress_internal_usage() runs on ProcComponentMultiPort { []Port4.catch(timeout) { setverdict(fail); } - } + }*/ + setverdict(pass); } testcase tc_PortAddress_external_usage1() runs on addressComponent @@ -792,7 +794,7 @@ control { execute(tc_Call_MultiPTC_anyport()); execute(tc_Check_1()); execute(tc_Check_2()); - execute(tc_PortAddress_internal_usage()); + execute(tc_PortAddress_internal_usage()); // auto pass: address port cannot be connected. execute(tc_PortAddress_external_usage1()); execute(tc_PortAddress_external_usage2()); execute(tc_GetReplyParameters()); diff --git a/regression_test/compileonly/mfgen-tpd/required_config/58/Makefile b/regression_test/compileonly/mfgen-tpd/required_config/58/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..2cfdfe8cfa292a1966cede4303e2b40c2f842ce8 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/required_config/58/Makefile @@ -0,0 +1,60 @@ +############################################################################## +# Copyright (c) 2000-2016 Ericsson Telecom AB +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Szabo, Bence Janos +# +############################################################################## +TOPDIR := ../../../.. +include $(TOPDIR)/Makefile.regression + +ifdef LCOV +COVERAGE_FLAG := -C +endif + +# ${MAKEPROG} has the same content as the built-in ${MAKE}, +# except the special handling of ${MAKE} does not apply. +# If we used ${MAKE} in the rules below, 'make -n' would succeed once, +# then fail on every subsequent invocation until a 'make clean' is done. + +#This tests that 'a' references 'b' and 'b' references 'c' and 'b' requires +#'c''s '1' configuration. The extra is that 'a' has some configs which requires +# 'b''s other config, but the 'a''s defualt config does not require anything. +# a +# | +# | +# | +# b +# | +# |c:1 +# | +# c + +MAKEPROG := ${MAKE} + +all: CheckTpd + +BuildTpd: + $(TTCN3_DIR)/bin/ttcn3_makefilegen -F $(MFGEN_FLAGS) $(COVERAGE_FLAG) \ + -t a.tpd -r -c -W -g + +CheckTpd: BuildTpd + if [ ! -f "./a_binDefault/Makefile" ] || [ `grep -c "EXECUTABLE = binDefault" ./a_binDefault/Makefile` -ne 1 ]; \ + then echo "Makefilegen required config test 58 failed: Overall verdict: fail" && exit 1; fi + if [ ! -f "./b_binDefault/Makefile" ] || [ `grep -c "EXECUTABLE = binDefault" ./b_binDefault/Makefile` -ne 1 ]; \ + then echo "Makefilegen required config test 58 failed: Overall verdict: fail" && exit 1; fi + if [ ! -f "./c_bin1/Makefile" ] || [ `grep -c "EXECUTABLE = bin1" ./c_bin1/Makefile` -ne 1 ]; \ + then echo "Makefilegen required config test 58 failed: Overall verdict: fail" && exit 1; fi + +clean: + -rm -rf a_binDefault b_binDefault c_bin1 + +distclean: clean + -rm -f *.out + +.PHONY: all clean distclean BuildTpd CheckTpd + diff --git a/regression_test/compileonly/mfgen-tpd/required_config/58/a.tpd b/regression_test/compileonly/mfgen-tpd/required_config/58/a.tpd new file mode 100644 index 0000000000000000000000000000000000000000..c0b91361121837ffe2c5516c2c466f7d37689f72 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/required_config/58/a.tpd @@ -0,0 +1,45 @@ +<!-- + Copyright (c) 2000-2016 Ericsson Telecom AB + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + + Contributors: + Szabo, Bence Janos – initial implementation +--> +<TITAN_Project_File_Information version="1.0"> + <ProjectName>a</ProjectName> + <ReferencedProjects> + <ReferencedProject name="b" projectLocationURI="b.tpd"/> + </ReferencedProjects> + <ActiveConfiguration>Default</ActiveConfiguration> + <Configurations> + <Configuration name="Default"> + <ProjectProperties> + <MakefileSettings> + <targetExecutable>binDefault</targetExecutable> + </MakefileSettings> + <LocalBuildSettings> + <workingDirectory>binDefault</workingDirectory> + </LocalBuildSettings> + </ProjectProperties> + </Configuration> + <Configuration name="a"> + <ProjectProperties> + <MakefileSettings> + <targetExecutable>binDefault</targetExecutable> + </MakefileSettings> + <LocalBuildSettings> + <workingDirectory>binDefault</workingDirectory> + </LocalBuildSettings> + <ConfigurationRequirements> + <configurationRequirement> + <projectName>b</projectName> + <requiredConfiguration>1</requiredConfiguration> + </configurationRequirement> + </ConfigurationRequirements> + </ProjectProperties> + </Configuration> + </Configurations> +</TITAN_Project_File_Information> diff --git a/regression_test/compileonly/mfgen-tpd/required_config/58/b.tpd b/regression_test/compileonly/mfgen-tpd/required_config/58/b.tpd new file mode 100644 index 0000000000000000000000000000000000000000..0d43262dde15bcbcd054567c9163b93fa801ffa2 --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/required_config/58/b.tpd @@ -0,0 +1,45 @@ +<!-- + Copyright (c) 2000-2016 Ericsson Telecom AB + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + + Contributors: + Szabo, Bence Janos – initial implementation +--> +<TITAN_Project_File_Information version="1.0"> + <ProjectName>b</ProjectName> + <ReferencedProjects> + <ReferencedProject name="c" projectLocationURI="c.tpd"/> + </ReferencedProjects> + <ActiveConfiguration>Default</ActiveConfiguration> + <Configurations> + <Configuration name="Default"> + <ProjectProperties> + <MakefileSettings> + <targetExecutable>binDefault</targetExecutable> + </MakefileSettings> + <LocalBuildSettings> + <workingDirectory>binDefault</workingDirectory> + </LocalBuildSettings> + <ConfigurationRequirements> + <configurationRequirement> + <projectName>c</projectName> + <requiredConfiguration>1</requiredConfiguration> + </configurationRequirement> + </ConfigurationRequirements> + </ProjectProperties> + </Configuration> + <Configuration name="1"> + <ProjectProperties> + <MakefileSettings> + <targetExecutable>bin1</targetExecutable> + </MakefileSettings> + <LocalBuildSettings> + <workingDirectory>bin1</workingDirectory> + </LocalBuildSettings> + </ProjectProperties> + </Configuration> + </Configurations> +</TITAN_Project_File_Information> diff --git a/regression_test/compileonly/mfgen-tpd/required_config/58/c.tpd b/regression_test/compileonly/mfgen-tpd/required_config/58/c.tpd new file mode 100644 index 0000000000000000000000000000000000000000..00ce28721869b56a32f4f22b15f69072cc2eeaed --- /dev/null +++ b/regression_test/compileonly/mfgen-tpd/required_config/58/c.tpd @@ -0,0 +1,38 @@ +<!-- + Copyright (c) 2000-2016 Ericsson Telecom AB + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + + Contributors: + Szabo, Bence Janos – initial implementation +--> +<TITAN_Project_File_Information version="1.0"> + <ProjectName>c</ProjectName> + <ReferencedProjects> + </ReferencedProjects> + <ActiveConfiguration>Default</ActiveConfiguration> + <Configurations> + <Configuration name="Default"> + <ProjectProperties> + <MakefileSettings> + <targetExecutable>binDefault</targetExecutable> + </MakefileSettings> + <LocalBuildSettings> + <workingDirectory>binDefault</workingDirectory> + </LocalBuildSettings> + </ProjectProperties> + </Configuration> + <Configuration name="1"> + <ProjectProperties> + <MakefileSettings> + <targetExecutable>bin1</targetExecutable> + </MakefileSettings> + <LocalBuildSettings> + <workingDirectory>bin1</workingDirectory> + </LocalBuildSettings> + </ProjectProperties> + </Configuration> + </Configurations> +</TITAN_Project_File_Information> diff --git a/regression_test/compileonly/mfgen-tpd/required_config/Makefile b/regression_test/compileonly/mfgen-tpd/required_config/Makefile index 13490173ac3b5e4a2d7110fa48afc6b627f697c6..7517fed9b808643996ec74b6ed68440c0727f05f 100644 --- a/regression_test/compileonly/mfgen-tpd/required_config/Makefile +++ b/regression_test/compileonly/mfgen-tpd/required_config/Makefile @@ -14,7 +14,7 @@ include $(TOPDIR)/Makefile.regression CODIRS := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 \ 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 \ - 48 49 50 51 52 53 54 55 56 57 + 48 49 50 51 52 53 54 55 56 57 58 #The configurations of the TPD files only differ in the name of the working diff --git a/regression_test/connectMapOperTest/ConnectMapOperNegTest.ttcn b/regression_test/connectMapOperTest/ConnectMapOperNegTest.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..02f04844628dac3b09e4aeaffa4680a534235c02 --- /dev/null +++ b/regression_test/connectMapOperTest/ConnectMapOperNegTest.ttcn @@ -0,0 +1,88 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Szabo, Bence Janos + * + ******************************************************************************/ +module ConnectMapOperNegTest { + + type port loopbackPort message { + inout integer + } with {extension "internal"} + + type component GeneralComp { + port loopbackPort p1; + port loopbackPort p2; + } + + type component System { + port loopbackPort p1; + port loopbackPort p2; + + } + + testcase tc_neg_connect_after_map() runs on GeneralComp system System { + map(self:p1, system:p1); + @try { + connect(self:p1, self:p2); + setverdict(fail, "Connect operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, "Dynamic test case error: Connect operation cannot be performed on a mapped port (p1).")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (receive test): ", msg); + } + } + setverdict(pass); + } + + testcase tc_neg_connect_after_map2() runs on GeneralComp system System { + var GeneralComp v_comp := GeneralComp.create; + map(self:p1, system:p1); + @try { + connect(self:p1, v_comp:p2); + setverdict(fail, "Connect operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, "Dynamic test case error: Connect operation cannot be performed on a mapped port (p1).")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (receive test): ", msg); + } + } + setverdict(pass); + } + + testcase tc_neg_map_after_connect() runs on GeneralComp system System { + var GeneralComp v_comp := GeneralComp.create; + connect(self:p1, v_comp:p2); + @try { + map(self:p1, system:p1); + setverdict(fail, "Connect operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, "Dynamic test case error: Map operation is not allowed on a connected port (p1).")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (receive test): ", msg); + } + } + setverdict(pass); + } + + control{ + execute(tc_neg_connect_after_map()); + execute(tc_neg_connect_after_map2()); + + execute(tc_neg_map_after_connect()); + } +} \ No newline at end of file diff --git a/regression_test/connectMapOperTest/Makefile b/regression_test/connectMapOperTest/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7d68db122e97b6e0bf750e4fa1c68ee85611c19f --- /dev/null +++ b/regression_test/connectMapOperTest/Makefile @@ -0,0 +1,59 @@ +############################################################################## +# Copyright (c) 2000-2016 Ericsson Telecom AB +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Szabo, Bence Janos +# +############################################################################## +TOPDIR := .. +include $(TOPDIR)/Makefile.regression + +.SUFFIXES: .ttcn .hh +.PHONY: all clean dep run + +TTCN3_LIB = ttcn3$(RT2_SUFFIX)-parallel$(DYNAMIC_SUFFIX) + +TTCN3_MODULES = ConnectMapOperNegTest.ttcn + +GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) +GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh) +ifdef CODE_SPLIT +GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc _seqof.cc _setof.cc _union.cc)) +else ifdef SPLIT_TO_SLICES +POSTFIXES := $(foreach file, $(SPLIT_TO_SLICES), $(addsuffix $(file), _part_)) +POSTFIXES := $(foreach file, $(POSTFIXES), $(addprefix $(file), .cc)) +GENERATED_SOURCES2 := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), $(POSTFIXES))) +GENERATED_SOURCES += $(GENERATED_SOURCES2) +endif +USER_SOURCES = +USER_HEADERS = $(USER_SOURCES:.cc=.hh) +OBJECTS = $(GENERATED_SOURCES:.cc=.o) $(USER_SOURCES:.cc=.o) + +TARGET = ConnectMapOperNegTest$(EXESUFFIX) + +all: $(TARGET) + +$(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) -L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS) + +.ttcn.cc .ttcn.hh: + $(TTCN3_COMPILER) $< + +clean distclean: + -rm -f $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ + $(GENERATED_SOURCES) *.log Makefile.bak + +dep: $(GENERATED_SOURCES) + makedepend $(CPPFLAGS) $(GENERATED_SOURCES) + +run: $(TARGET) + $(TTCN3_DIR)/bin/ttcn3_start $(TARGET) + +.NOTPARALLEL: + +vpath $(USER_SOURCES) $(ABS_SRC) + diff --git a/regression_test/indexWithRecofArray/IndexWithRecofArray.ttcn b/regression_test/indexWithRecofArray/IndexWithRecofArray.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..c759c8b8c2fc226f48702b26dc57a01f4e1763bb --- /dev/null +++ b/regression_test/indexWithRecofArray/IndexWithRecofArray.ttcn @@ -0,0 +1,1688 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Szabo, Bence Janos + * + ******************************************************************************/ + +module IndexWithRecofArray { + + type component GeneralComp { + } + + + type record of record of integer RoRoI; + type record of record of RoRoI RoIRoIRoIRoI; + type set of set of integer SoISoI; + type set of set of SoISoI SoISoISoISoI + type record length(1) of integer RoI1; + type record length(2) of integer RoI2; + + +//###########################################################################// +// Record of indexed with array or record of + + testcase tc_recordof_indexed_with_array() runs on GeneralComp { + + var RoRoI v_rec := {{0, 1}, {2, 3}}; + var integer v_index[1] := { 1 } + +//////////////////////////////////////////////////// + + if (v_rec[v_index] == {2, 3}) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index] := {5, 6}; + if (v_rec[v_index] == {5, 6}) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index] := {2, 3}; + +//////////////////////////////////////////////////// + + + if (v_rec[v_index][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index][0] := 99; + if (v_rec[v_index][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index][0] := 2; + +//////////////////////////////////////////////////// + + if (v_rec[0][v_index] == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[0][v_index] := 99; + if (v_rec[0][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[0][v_index] := 1; + + +//////////////////////////////////////////////////// + + + if (v_rec[v_index][v_index] == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index][v_index] := 99; + if (v_rec[v_index][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index][v_index] := 3; + +//////////////////////////////////////////////////// + + var integer v_index2[2] := {1, 0}; + if (v_rec[v_index2] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index2] := 99; + if (v_rec[v_index2] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index2] := 2; + } + + testcase tc_recordof_indexed_with_recordof() runs on GeneralComp { + + var RoRoI v_rec := {{0, 1}, {2, 3}}; + var RoI1 v_index := { 1 } + //////////////////////////////////////////////////// + + if (v_rec[v_index] == {2, 3}) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index] := {5, 6}; + if (v_rec[v_index] == {5, 6}) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index] := {2, 3}; + +//////////////////////////////////////////////////// + + + if (v_rec[v_index][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index][0] := 99; + if (v_rec[v_index][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index][0] := 2; + +//////////////////////////////////////////////////// + + if (v_rec[0][v_index] == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[0][v_index] := 99; + if (v_rec[0][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[0][v_index] := 1; + + +//////////////////////////////////////////////////// + + + if (v_rec[v_index][v_index] == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index][v_index] := 99; + if (v_rec[v_index][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index][v_index] := 3; + +//////////////////////////////////////////////////// + + var integer v_index2[2] := {1, 0}; + if (v_rec[v_index2] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index2] := 99; + if (v_rec[v_index2] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index2] := 2; + } + + testcase tc_recordof_indexed_with_recordof_and_array() runs on GeneralComp { + var RoIRoIRoIRoI v_rec := { + { + { + {0, 1}, + {2, 3} + }, + { + {4, 5}, + {6, 7} + } + }, + { + { + {8, 9}, + {10, 11} + }, + { + {12, 13}, + {14, 15} + } + } + } + var integer v_index[1] := {0}; + var integer v_index2[2] := {0, 1}; + var RoI1 v_roi1 := {0}; + var RoI2 v_roi2 := {0, 1}; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_rec[v_index][v_index2][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index][v_index2][v_index] := 99; + if (v_rec[v_index][v_index2][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index][v_index2][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_rec[v_index][v_index2][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index][v_index2][0] := 99; + if (v_rec[v_index][v_index2][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index][v_index2][0] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_rec[v_index][0][1][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_index][0][1][v_index] := 99; + if (v_rec[v_index][0][1][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_index][0][1][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_rec[v_roi1][v_index2][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_roi1][v_index2][v_index] := 99; + if (v_rec[v_roi1][v_index2][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_roi1][v_index2][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_rec[v_roi1][v_roi2][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_roi1][v_roi2][v_index] := 99; + if (v_rec[v_roi1][v_roi2][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_roi1][v_roi2][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_rec[v_roi1][v_roi2][v_roi1] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_roi1][v_roi2][v_roi1] := 99; + if (v_rec[v_roi1][v_roi2][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_roi1][v_roi2][v_roi1] := 2; + + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_rec[v_roi1][v_roi2][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_roi1][v_roi2][0] := 99; + if (v_rec[v_roi1][v_roi2][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_roi1][v_roi2][0] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_rec[0][v_roi2][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[0][v_roi2][0] := 99; + if (v_rec[0][v_roi2][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[0][v_roi2][0] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_rec[v_roi1][0][1][v_roi1] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_roi1][0][1][v_roi1] := 99; + if (v_rec[v_roi1][0][1][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_roi1][0][1][v_roi1] := 2; + +//////////////////////////////////////////////////// + + // [0][1][1][0] + if (v_rec[v_roi1][1][1][v_roi1] == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_roi1][1][1][v_roi1] := 99; + if (v_rec[v_roi1][1][1][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_roi1][1][1][v_roi1] := 6; + +//////////////////////////////////////////////////// + + // [0][1][1][0] + if (v_rec[v_roi1][v_roi2[1]][1][v_roi1] == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_roi1][v_roi2[1]][1][v_roi1] := 99; + if (v_rec[v_roi1][v_roi2[1]][1][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_roi1][v_roi2[1]][1][v_roi1] := 6; + +//////////////////////////////////////////////////// + + // [0][1][1][0] + if (v_rec[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] := 99; + if (v_rec[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] := 6; + +//////////////////////////////////////////////////// + + // [1][0][1][1] + if (v_rec[v_roi2[1]][v_index2][v_index2[1]] == 11) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_rec[v_roi2[1]][v_index2][v_index2[1]] := 99; + if (v_rec[v_roi2[1]][v_index2][v_index2[1]] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_rec[v_roi2[1]][v_index2][v_index2[1]] := 11; + } + + +//###########################################################################// +// Set of indexed with array or record of + + + testcase tc_setof_indexed_with_array() runs on GeneralComp { + + var SoISoI v_set := {{0, 1}, {2, 3}}; + var integer v_index[1] := { 1 } +//////////////////////////////////////////////////// + + if (v_set[v_index] == {2, 3}) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index] := {5, 6}; + if (v_set[v_index] == {5, 6}) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index] := {2, 3}; + +//////////////////////////////////////////////////// + + + if (v_set[v_index][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index][0] := 99; + if (v_set[v_index][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index][0] := 2; + +//////////////////////////////////////////////////// + + if (v_set[0][v_index] == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[0][v_index] := 99; + if (v_set[0][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[0][v_index] := 1; + + +//////////////////////////////////////////////////// + + + if (v_set[v_index][v_index] == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index][v_index] := 99; + if (v_set[v_index][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index][v_index] := 3; + +//////////////////////////////////////////////////// + + var integer v_index2[2] := {1, 0}; + if (v_set[v_index2] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index2] := 99; + if (v_set[v_index2] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index2] := 2; + } + + testcase tc_setof_indexed_with_recordof() runs on GeneralComp { + + var SoISoI v_set := {{0, 1}, {2, 3}}; + var RoI1 v_index := { 1 } +//////////////////////////////////////////////////// + + if (v_set[v_index] == {2, 3}) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index] := {5, 6}; + if (v_set[v_index] == {5, 6}) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index] := {2, 3}; + +//////////////////////////////////////////////////// + + + if (v_set[v_index][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index][0] := 99; + if (v_set[v_index][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index][0] := 2; + +//////////////////////////////////////////////////// + + if (v_set[0][v_index] == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[0][v_index] := 99; + if (v_set[0][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[0][v_index] := 1; + + +//////////////////////////////////////////////////// + + + if (v_set[v_index][v_index] == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index][v_index] := 99; + if (v_set[v_index][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index][v_index] := 3; + +//////////////////////////////////////////////////// + + var integer v_index2[2] := {1, 0}; + if (v_set[v_index2] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index2] := 99; + if (v_set[v_index2] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index2] := 2; + } + + testcase tc_setof_indexed_with_recordof_and_array() runs on GeneralComp { + var SoISoISoISoI v_set := { + { + { + {0, 1}, + {2, 3} + }, + { + {4, 5}, + {6, 7} + } + }, + { + { + {8, 9}, + {10, 11} + }, + { + {12, 13}, + {14, 15} + } + } + } + var integer v_index[1] := {0}; + var integer v_index2[2] := {0, 1}; + var RoI1 v_roi1 := {0}; + var RoI2 v_roi2 := {0, 1}; + + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_set[v_index][v_index2][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index][v_index2][v_index] := 99; + if (v_set[v_index][v_index2][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index][v_index2][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_set[v_index][v_index2][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index][v_index2][0] := 99; + if (v_set[v_index][v_index2][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index][v_index2][0] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_set[v_index][0][1][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_index][0][1][v_index] := 99; + if (v_set[v_index][0][1][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_index][0][1][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_set[v_roi1][v_index2][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_roi1][v_index2][v_index] := 99; + if (v_set[v_roi1][v_index2][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_roi1][v_index2][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_set[v_roi1][v_roi2][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_roi1][v_roi2][v_index] := 99; + if (v_set[v_roi1][v_roi2][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_roi1][v_roi2][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_set[v_roi1][v_roi2][v_roi1] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_roi1][v_roi2][v_roi1] := 99; + if (v_set[v_roi1][v_roi2][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_roi1][v_roi2][v_roi1] := 2; + + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_set[v_roi1][v_roi2][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_roi1][v_roi2][0] := 99; + if (v_set[v_roi1][v_roi2][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_roi1][v_roi2][0] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_set[0][v_roi2][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[0][v_roi2][0] := 99; + if (v_set[0][v_roi2][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[0][v_roi2][0] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_set[v_roi1][0][1][v_roi1] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_roi1][0][1][v_roi1] := 99; + if (v_set[v_roi1][0][1][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_roi1][0][1][v_roi1] := 2; + +//////////////////////////////////////////////////// + + // [0][1][1][0] + if (v_set[v_roi1][1][1][v_roi1] == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_roi1][1][1][v_roi1] := 99; + if (v_set[v_roi1][1][1][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_roi1][1][1][v_roi1] := 6; + +//////////////////////////////////////////////////// + + // [0][1][1][0] + if (v_set[v_roi1][v_roi2[1]][1][v_roi1] == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_roi1][v_roi2[1]][1][v_roi1] := 99; + if (v_set[v_roi1][v_roi2[1]][1][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_roi1][v_roi2[1]][1][v_roi1] := 6; + +//////////////////////////////////////////////////// + + // [0][1][1][0] + if (v_set[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] := 99; + if (v_set[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] := 6; + +//////////////////////////////////////////////////// + + // [1][0][1][1] + if (v_set[v_roi2[1]][v_index2][v_index2[1]] == 11) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_set[v_roi2[1]][v_index2][v_index2[1]] := 99; + if (v_set[v_roi2[1]][v_index2][v_index2[1]] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_set[v_roi2[1]][v_index2][v_index2[1]] := 11; + } + + +//###########################################################################// +// Array indexed with array or record of + + + testcase tc_array_indexed_with_array() runs on GeneralComp { + var integer v_arr[2][2] := {{0, 1}, {2, 3}}; + var integer v_index[1] := { 1 } +//////////////////////////////////////////////////// + + if (v_arr[v_index] == {2, 3}) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index] := {5, 6}; + if (v_arr[v_index] == {5, 6}) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index] := {2, 3}; + +//////////////////////////////////////////////////// + + + if (v_arr[v_index][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][0] := 99; + if (v_arr[v_index][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][0] := 2; + +//////////////////////////////////////////////////// + + if (v_arr[0][v_index] == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[0][v_index] := 99; + if (v_arr[0][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[0][v_index] := 1; + + +//////////////////////////////////////////////////// + + + if (v_arr[v_index][v_index] == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][v_index] := 99; + if (v_arr[v_index][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][v_index] := 3; + +//////////////////////////////////////////////////// + + var integer v_index2[2] := {1, 0}; + if (v_arr[v_index2] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index2] := 99; + if (v_arr[v_index2] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index2] := 2; + } + + testcase tc_array_indexed_with_recordof() runs on GeneralComp { + var integer v_arr[2][2] := {{0, 1}, {2, 3}}; + var RoI1 v_index := { 1 } +//////////////////////////////////////////////////// + + if (v_arr[v_index] == {2, 3}) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index] := {5, 6}; + if (v_arr[v_index] == {5, 6}) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index] := {2, 3}; + +//////////////////////////////////////////////////// + + + if (v_arr[v_index][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][0] := 99; + if (v_arr[v_index][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][0] := 2; + +//////////////////////////////////////////////////// + + if (v_arr[0][v_index] == 1) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[0][v_index] := 99; + if (v_arr[0][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[0][v_index] := 1; + + +//////////////////////////////////////////////////// + + + if (v_arr[v_index][v_index] == 3) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][v_index] := 99; + if (v_arr[v_index][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][v_index] := 3; + +//////////////////////////////////////////////////// + + var integer v_index2[2] := {1, 0}; + if (v_arr[v_index2] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index2] := 99; + if (v_arr[v_index2] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index2] := 2; + } + + + testcase tc_array_indexed_with_recordof_and_array() runs on GeneralComp { + var integer v_arr[2][2][2][2] := { + { + { + {0, 1}, + {2, 3} + }, + { + {4, 5}, + {6, 7} + } + }, + { + { + {8, 9}, + {10, 11} + }, + { + {12, 13}, + {14, 15} + } + } + } + var integer v_index[1] := {0}; + var integer v_index2[2] := {0, 1}; + var RoI1 v_roi1 := {0}; + var RoI2 v_roi2 := {0, 1}; + + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_arr[v_index][v_index2][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][v_index2][v_index] := 99; + if (v_arr[v_index][v_index2][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][v_index2][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_arr[v_index][v_index2][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][v_index2][0] := 99; + if (v_arr[v_index][v_index2][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][v_index2][0] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_arr[v_index][0][1][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][0][1][v_index] := 99; + if (v_arr[v_index][0][1][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][0][1][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_arr[v_roi1][v_index2][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_roi1][v_index2][v_index] := 99; + if (v_arr[v_roi1][v_index2][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_roi1][v_index2][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_arr[v_roi1][v_roi2][v_index] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_roi1][v_roi2][v_index] := 99; + if (v_arr[v_roi1][v_roi2][v_index] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_roi1][v_roi2][v_index] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_arr[v_roi1][v_roi2][v_roi1] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_roi1][v_roi2][v_roi1] := 99; + if (v_arr[v_roi1][v_roi2][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_roi1][v_roi2][v_roi1] := 2; + + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_arr[v_roi1][v_roi2][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_roi1][v_roi2][0] := 99; + if (v_arr[v_roi1][v_roi2][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_roi1][v_roi2][0] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_arr[0][v_roi2][0] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[0][v_roi2][0] := 99; + if (v_arr[0][v_roi2][0] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[0][v_roi2][0] := 2; + +//////////////////////////////////////////////////// + + // [0][0][1][0] + if (v_arr[v_roi1][0][1][v_roi1] == 2) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_roi1][0][1][v_roi1] := 99; + if (v_arr[v_roi1][0][1][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_roi1][0][1][v_roi1] := 2; + +//////////////////////////////////////////////////// + + // [0][1][1][0] + if (v_arr[v_roi1][1][1][v_roi1] == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_roi1][1][1][v_roi1] := 99; + if (v_arr[v_roi1][1][1][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_roi1][1][1][v_roi1] := 6; + +//////////////////////////////////////////////////// + + // [0][1][1][0] + if (v_arr[v_roi1][v_roi2[1]][1][v_roi1] == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_roi1][v_roi2[1]][1][v_roi1] := 99; + if (v_arr[v_roi1][v_roi2[1]][1][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_roi1][v_roi2[1]][1][v_roi1] := 6; + +//////////////////////////////////////////////////// + + // [0][1][1][0] + if (v_arr[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] == 6) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] := 99; + if (v_arr[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_roi1][v_roi2[1]][v_index2[1]][v_roi1] := 6; + +//////////////////////////////////////////////////// + + // [1][0][1][1] + if (v_arr[v_roi2[1]][v_index2][v_index2[1]] == 11) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_roi2[1]][v_index2][v_index2[1]] := 99; + if (v_arr[v_roi2[1]][v_index2][v_index2[1]] == 99) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_roi2[1]][v_index2][v_index2[1]] := 11; + + } + + +//###########################################################################// +// Array of charstring indexed with record of + + testcase tc_arrayfstr_indexed_with_recordof() runs on GeneralComp { + var charstring v_arr[2][2] := {{"a", "b"}, {"c", "d"}}; + var RoI1 v_index := { 1 } + +//////////////////////////////////////////////////// + + if (v_arr[v_index] == {"c", "d"}) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index] := {"x", "y"}; + if (v_arr[v_index] == {"x", "y"}) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index] := {"c", "d"}; + +//////////////////////////////////////////////////// + + if (v_arr[v_index][0] == "c") { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][0] := "x"; + if (v_arr[v_index][0] == "x") { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][0] := "c"; + +//////////////////////////////////////////////////// + + if (v_arr[0][v_index] == "b") { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[0][v_index] := "x"; + if (v_arr[0][v_index] == "x") { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[0][v_index] := "b"; + +//////////////////////////////////////////////////// + + if (v_arr[v_index][v_index] == "d") { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][v_index] := "x"; + if (v_arr[v_index][v_index] == "x") { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][v_index] := "d"; + +//////////////////////////////////////////////////// + + var RoI2 v_index2 := {1, 0}; + if (v_arr[v_index2] == "c") { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index2] := "x"; + if (v_arr[v_index2] == "x") { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index2] := "c"; + + } + + +//###########################################################################// +// Array of charstring indexed with special indexing array + + type integer MyInt; + + testcase tc_array_indexed_with_spec_array() runs on GeneralComp { + var charstring v_arr[2..4][2..4] := {{"a", "b", "c"}, {"d", "e", "f"}, {"g", "h", "i"}}; + var MyInt v_index[1..1] := {3}; + +//////////////////////////////////////////////////// + + if (v_arr[v_index] == {"d", "e", "f"}) { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index] := {"x", "y", "z"}; + if (v_arr[v_index] == {"x", "y", "z"}) { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index] := {"d", "e", "f"}; + +//////////////////////////////////////////////////// + + if (v_arr[v_index][2] == "d") { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][2] := "x"; + if (v_arr[v_index][2] == "x") { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][2] := "d"; + +//////////////////////////////////////////////////// + + if (v_arr[2][v_index] == "b") { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[2][v_index] := "x"; + if (v_arr[2][v_index] == "x") { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[2][v_index] := "b"; + +//////////////////////////////////////////////////// + + if (v_arr[v_index][v_index] == "e") { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index][v_index] := "x"; + if (v_arr[v_index][v_index] == "x") { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index][v_index] := "e"; + +//////////////////////////////////////////////////// + + var MyInt v_index2[3..4] := {3, 2}; + if (v_arr[v_index2] == "d") { + setverdict(pass); + } else { + setverdict(fail); + } + + // Assignment test + v_arr[v_index2] := "x"; + if (v_arr[v_index2] == "x") { + setverdict(pass); + } else { + setverdict(fail); + } + // Restore to original value + v_arr[v_index2] := "d"; + } + + control { + execute(tc_recordof_indexed_with_array()); + execute(tc_recordof_indexed_with_recordof()); + execute(tc_recordof_indexed_with_recordof_and_array()); + + execute(tc_setof_indexed_with_array()); + execute(tc_setof_indexed_with_recordof()); + execute(tc_setof_indexed_with_recordof_and_array()); + + execute(tc_array_indexed_with_array()); + execute(tc_array_indexed_with_recordof()); + execute(tc_array_indexed_with_recordof_and_array()); + + execute(tc_arrayfstr_indexed_with_recordof()); + execute(tc_array_indexed_with_spec_array()); + } + +} diff --git a/regression_test/indexWithRecofArray/Makefile b/regression_test/indexWithRecofArray/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..afb9b4e0e6c0bc0bcfba35d3a8c855133175fee1 --- /dev/null +++ b/regression_test/indexWithRecofArray/Makefile @@ -0,0 +1,56 @@ +############################################################################## +# Copyright (c) 2000-2016 Ericsson Telecom AB +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Szabo, Bence Janos +# +############################################################################## +TOPDIR := .. +include $(TOPDIR)/Makefile.regression + +.SUFFIXES: .ttcn .hh +.PHONY: all clean dep run + +TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) + +TTCN3_MODULES = IndexWithRecofArray.ttcn + +GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) +GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh) +ifdef CODE_SPLIT +GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc _seqof.cc _setof.cc _union.cc)) +else ifdef SPLIT_TO_SLICES +POSTFIXES := $(foreach file, $(SPLIT_TO_SLICES), $(addsuffix $(file), _part_)) +POSTFIXES := $(foreach file, $(POSTFIXES), $(addprefix $(file), .cc)) +GENERATED_SOURCES2 := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), $(POSTFIXES))) +GENERATED_SOURCES += $(GENERATED_SOURCES2) +endif + +OBJECTS = $(GENERATED_SOURCES:.cc=.o) + +TARGET = IndexWithRecofArray$(EXESUFFIX) + +all: $(TARGET) + +$(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) -L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS) + +.ttcn.cc .ttcn.hh: + $(TTCN3_COMPILER) $< + +clean distclean: + -rm -f $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ + $(GENERATED_SOURCES) *.log Makefile.bak + +dep: $(GENERATED_SOURCES) + makedepend $(CPPFLAGS) $(GENERATED_SOURCES) + +run: $(TARGET) + ./$^ + +.NOTPARALLEL: + diff --git a/usrguide/referenceguide.doc b/usrguide/referenceguide.doc index 6623ea5c7658622fe6a069e600ff7502729e3587..2c65d8a95dc9d0aafe3e69ef8ff941bff9adce9b 100644 Binary files a/usrguide/referenceguide.doc and b/usrguide/referenceguide.doc differ diff --git a/xsdconvert/AttributeType.cc b/xsdconvert/AttributeType.cc index 6db3daffe38263f9ba38314a90e8866e1febe52a..9d5b4717fbf7b7bd3c233fbd1e6d5adfc5074fba 100644 --- a/xsdconvert/AttributeType.cc +++ b/xsdconvert/AttributeType.cc @@ -105,7 +105,7 @@ void AttributeType::nameConversion_names(QualifiedNames& used_ns) { used_ns.push_back(used_names.back()); } - for (List<SimpleType*>::iterator st = nameDepList.begin(); st; st = st->Next) { + for (List<RootType*>::iterator st = nameDepList.begin(); st; st = st->Next) { st->Data->setTypeValue(res); } } diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc index 07b30dbcdb28e4793e6d71b99439e008e2e3a490..1accb2edf39447e4079772e0a198291151c2d5e4 100644 --- a/xsdconvert/ComplexType.cc +++ b/xsdconvert/ComplexType.cc @@ -433,8 +433,6 @@ void ComplexType::loadWithValues() { attribute->addVariant(V_attribute); attribute->applyMinMaxOccursAttribute(0, 1); attribute->setXsdtype(n_attribute); - attribute->applyDefaultAttribute(atts.default_); - attribute->applyFixedAttribute(atts.fixed); attribute->setUseVal(atts.use); attribute->setAttributeFormAs(atts.form); lastType = n_attribute; @@ -445,6 +443,8 @@ void ComplexType::loadWithValues() { } else { attribute->applyRefAttribute(atts.ref); } + attribute->applyDefaultAttribute(atts.default_); + attribute->applyFixedAttribute(atts.fixed); actfield = attribute; //In case of nillable parent it is difficult... @@ -862,7 +862,7 @@ void ComplexType::nameConversion_names(const List<NamespaceType> &) { if (!found) { addVariant(V_onlyValue, var); } - for (List<SimpleType*>::iterator dep = nameDepList.begin(); dep; dep = dep->Next) { + for (List<RootType*>::iterator dep = nameDepList.begin(); dep; dep = dep->Next) { dep->Data->setTypeValue(res); } } @@ -1009,7 +1009,7 @@ void ComplexType::setFieldPaths(Mstring path) { } } -void ComplexType::finalModification2() { +void ComplexType::subFinalModification() { //Call SimpleType finalModification SimpleType::finalModification(); @@ -1027,7 +1027,7 @@ void ComplexType::finalModification2() { complexfields.remove(field); } else { //Recursive call - field->Data->finalModification2(); + field->Data->subFinalModification(); //collect <xsd:all> elements if (field->Data->fromAll) { enumNames.push_back(field->Data->getName().convertedValue); @@ -1126,14 +1126,29 @@ void ComplexType::finalModification2() { } void ComplexType::finalModification() { - finalModification2(); + subFinalModification(); setFieldPaths(empty_string); +} + +void ComplexType::finalModification2() { + subFinalModification2(); List<Mstring> container; collectVariants(container); variant.clear(); variant = container; } +void ComplexType::subFinalModification2() { + SimpleType::finalModification2(); + for (List<ComplexType*>::iterator field = complexfields.begin(); field; field = field->Next) { + //Recursive call + field->Data->subFinalModification2(); + } + for (List<AttributeType*>::iterator field = attribfields.begin(); field; field = field->Next) { + field->Data->SimpleType::finalModification2(); + } +} + void ComplexType::printToFile(FILE * file) { printToFile(file, 0, false); } @@ -1690,12 +1705,18 @@ void ComplexType::resolveAttribute(AttributeType* attr) { attr->setNameOfField(st->getName().originalValueWoPrefix); attr->setOrigModule(st->getModule()); st->addToNameDepList(attr); + if (attr->getConstantDefaultForEmpty() != NULL) { + st->addToNameDepList((RootType*)attr->getConstantDefaultForEmpty()); + } } else { attr->setTypeOfField(st->getName().convertedValue); if (st->getType().convertedValue == "record" || st->getType().convertedValue == "union" || st->getXsdtype() == n_NOTSET) // It really is a simpleType { st->addToNameDepList(attr); + if (attr->getConstantDefaultForEmpty() != NULL) { + st->addToNameDepList((RootType*)attr->getConstantDefaultForEmpty()); + } } } attr->getReference().set_resolved(st); @@ -1833,12 +1854,21 @@ void ComplexType::resolveElement(SimpleType *st) { if(st->getSubstitution() != NULL){ st->getSubstitution()->addToNameDepList(this); nameDep = st->getSubstitution(); + if (defaultForEmptyConstant != NULL) { + st->getSubstitution()->addToNameDepList((RootType*)defaultForEmptyConstant); + } }if(st->getTypeSubstitution() != NULL){ st->getTypeSubstitution()->addToNameDepList(this); nameDep = st->getTypeSubstitution(); + if (defaultForEmptyConstant != NULL) { + st->getTypeSubstitution()->addToNameDepList((RootType*)defaultForEmptyConstant); + } }else { st->addToNameDepList(this); nameDep = st; + if (defaultForEmptyConstant != NULL) { + st->addToNameDepList((RootType*)defaultForEmptyConstant); + } } } } diff --git a/xsdconvert/ComplexType.hh b/xsdconvert/ComplexType.hh index 83a639b86fc0fe31df5c4dd8ce1762605de5af49..713cc6fe8750fe47394185b3c49a9d757aaba5ce 100644 --- a/xsdconvert/ComplexType.hh +++ b/xsdconvert/ComplexType.hh @@ -79,12 +79,12 @@ private: TagName lastType; Mstring actualPath; RootType * actfield; - SimpleType * nameDep; + SimpleType * nameDep; // not owned RootType * nillable_field; ComplexType * basefield; ComplexType_Mode cmode; Resolv_State resolved; - ComplexType * parentTypeSubsGroup; + ComplexType * parentTypeSubsGroup; // not owned // Returns true if the attributes really restricted and not just aliased @@ -100,7 +100,9 @@ private: void applyNamespaceAttribute(VariantMode varLabel, const Mstring& ns_list); void applyReference(const SimpleType & other, const bool on_attributes = false); void setParent(ComplexType * par, SimpleType * child); + void subFinalModification(); void finalModification2(); + void subFinalModification2(); Mstring findRoot(const BlockValue value, SimpleType * elem, const Mstring& head_type, const bool first); //Reference resolving functions diff --git a/xsdconvert/Constant.cc b/xsdconvert/Constant.cc new file mode 100644 index 0000000000000000000000000000000000000000..1dda201cfaed779cdd459c0a1519442fbfb2a6e8 --- /dev/null +++ b/xsdconvert/Constant.cc @@ -0,0 +1,196 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Szabo, Bence Janos + * + ******************************************************************************/ +#include "Constant.hh" + + +Constant::Constant(SimpleType* p_parent, Mstring p_type, Mstring p_value) + : RootType(p_parent->getParser(), p_parent->getModule(), p_parent->getConstruct()) +{ + parent = p_parent; + type.upload(p_type); + value = p_value; + alterego = NULL; + checked = false; +} + +void Constant::nameConversion(const NameConversionMode conversion_mode, const List<NamespaceType> & ns) { + switch (conversion_mode) { + case nameMode: + // Nameconversion of the constants name is postponed to finalFinalModification + break; + case typeMode: + nameConversion_types(ns); + break; + case fieldMode: + break; + } +} + +void Constant::nameConversion_types(const List<NamespaceType> & ns) { + + Mstring prefix = type.convertedValue.getPrefix(':'); + Mstring value_str = type.convertedValue.getValueWithoutPrefix(':'); + + Mstring uri; + for (List<NamespaceType>::iterator namesp = ns.begin(); namesp; namesp = namesp->Next) { + if (prefix == namesp->Data.prefix) { + uri = namesp->Data.uri; + break; + } + } + + QualifiedName tmp(uri, value_str); + + QualifiedNames::iterator origTN = TTCN3ModuleInventory::getInstance().getTypenames().begin(); + for (; origTN; origTN = origTN->Next) { + if (tmp == origTN->Data) { + QualifiedName tmp_name(module->getTargetNamespace(), name.convertedValue); + if (tmp_name == origTN->Data) + continue; // get a new type name + else + break; + } + } + if (origTN != NULL) { + setTypeValue(origTN->Data.name); + // This ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ is always value_str + // The only effect here is to remove the "xs:" prefix from type.convertedValue, + // otherwise the new value is always the same as the old. + } else { + Mstring res, var; + XSDName2TTCN3Name(value_str, TTCN3ModuleInventory::getInstance().getTypenames(), type_reference_name, res, var); + setTypeValue(res); + } +} + +void Constant::finalModification() { + if (checked) return; + Mstring tmp_type; + // Find the buildInType which the type is derived from + if (isBuiltInType(type.originalValueWoPrefix)) { + tmp_type = type.originalValueWoPrefix; + } else if (!parent->getReference().empty() && parent->getReference().get_ref() != NULL) { + SimpleType * st = (SimpleType*)parent->getReference().get_ref(); + if (isBuiltInType(st->getBuiltInBase())) { + tmp_type = st->getBuiltInBase(); + } else { + tmp_type = type.originalValueWoPrefix; + } + } else { + tmp_type = type.originalValueWoPrefix; + } + + // String and time types need the quote character around the value + if (parent->getEnumeration().modified || + (parent->getReference().get_ref() != NULL && + ((SimpleType*)(parent->getReference().get_ref()))->getEnumeration().modified)) { + + EnumerationType* enumeration = + &(parent->getEnumeration().modified ? parent->getEnumeration() : + ((SimpleType*)(parent->getReference().get_ref()))->getEnumeration()); + + // float enumeration handled differently + if (isFloatType(enumeration->parent->getBuiltInBase())) { + value = xmlFloat2TTCN3FloatStr(value); + } else { + // We pushed the converted enumeration values to the converted_facets, + // here we find the converted value based on the position in the list. + int i = 0, j = 0; + for(List<Mstring>::iterator it = enumeration->facets.begin(); it ; it = it->Next) { + if (it->Data == value) break; + i++; + } + for(List<Mstring>::iterator it = enumeration->converted_facets.begin(); it ; it = it->Next) { + if (i == j) { + value = it->Data; + break; + } + j++; + } + } + } else if (isStringType(tmp_type) || isTimeType(tmp_type)) { + value = Mstring("\"") + value + Mstring("\""); + } else if (isFloatType(tmp_type)) { + value = xmlFloat2TTCN3FloatStr(value); + } else if (isBooleanType(tmp_type)) { + if (value == "1") { + value = "true"; + } else if (value == "0") { + value = "false"; + } + } else if (isQNameType(tmp_type) || isAnyType(tmp_type)) { + // These are not supported by TITAN. + // Do not generate constant to a Qname or anytype fixed or default value + // Little hack: set the name of the constant to the value with apostrophes + name.convertedValue = "'" + value + "'"; + // Set the constant to invisible so it won't be generated into the code + // but in the defaultForEmpty variant the name will be generated which + // contains the value for the defaultForempty + setInvisible(); + } + checked = true; +} + +void Constant::finalFinalModification(List<RootType*> constantDefs) { + // Make the pointers point to the constant which have the same type and value, + // and set one of them invisible, so only one constant will be generated for + // each unique type and value pair. + for (List<RootType*>::iterator it = constantDefs.begin(); it; it = it->Next) { + if (!it->Data->isVisible()) continue; + for (List<RootType*>::iterator it2 = it->Next; it2; it2 = it2->Next) { + if (!it2->Data->isVisible()) continue; + if (*(Constant*)(it->Data) == *(Constant*)(it2->Data)) { + ((Constant*)it2->Data)->alterego = (Constant*)(it->Data); + it2->Data->setInvisible(); + } + } + } + if (!constantDefs.empty()) { + TTCN3Module* module = constantDefs.begin()->Data->getModule(); + expstring_t tmpname = NULL; + for (List<RootType*>::iterator it = constantDefs.begin(); it; it = it->Next) { + if (!it->Data->isVisible()) continue; + tmpname = mputprintf(tmpname, "c_defaultForEmpty_%u", module->getConstCounter()); + module->increaseConstCounter(); + const_cast<NameType&>(it->Data->getName()).upload(Mstring(tmpname)); + Free(tmpname); + tmpname = NULL; + } + } +} + +Mstring Constant::getConstantName(const TTCN3Module* other_mod) const { + Mstring qname; + if (alterego != NULL) { + qname = alterego->getName().convertedValue; + } else { + qname = getName().convertedValue; + } + if (other_mod->getModulename() != getModule()->getModulename()) { + qname = getModule()->getModulename() + "." + qname; + } + return qname; +} + +void Constant::printToFile(FILE * file) { + if (!visible) return; + fprintf(file, "const %s %s := %s;\n\n\n", + type.convertedValue.c_str(), + name.convertedValue.c_str(), + value.c_str()); +} + +void Constant::dump(const unsigned int depth) const { + fprintf(stderr, "%*s Constant '%s' -> '%s' with value: '%s' at %p\n", depth * 2, "", + name.originalValueWoPrefix.c_str(), name.convertedValue.c_str(), value.c_str(), + (const void*) this); +} \ No newline at end of file diff --git a/xsdconvert/Constant.hh b/xsdconvert/Constant.hh new file mode 100644 index 0000000000000000000000000000000000000000..4a7cbf9d75a8863eaf374ca65eeb39028876ec2f --- /dev/null +++ b/xsdconvert/Constant.hh @@ -0,0 +1,59 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Szabo, Bence Janos + * + ******************************************************************************/ +#include "SimpleType.hh" + +#ifndef CONSTANT_HH_ +#define CONSTANT_HH_ + +class Constant : public RootType { + + SimpleType* parent; // not owned + Mstring value; // The value of the constant + // Points to the constant which have the same type and value as this + Constant* alterego; // not owned + bool checked; + + public: + Constant(SimpleType* p_parent, Mstring p_type, Mstring p_value); + Constant(Constant &); // Not implemented + Constant & operator=(Constant &); // Not implemented + bool operator==(const Constant &other) const { + return (parent->getModule() == other.parent->getModule() && + type.convertedValue == other.type.convertedValue && + value == other.value); + } + + void loadWithValues() {} + void printToFile(FILE * file); + void dump(const unsigned int) const; + void nameConversion(const NameConversionMode, const List<NamespaceType> &); + void nameConversion_types(const List<NamespaceType> & ns); + // Here the value is converted to a TTCN value string which matches the constant type. + void finalModification(); + + // Returns the maybe qualified final name of the constant. + Mstring getConstantName(const TTCN3Module* other_mod) const; + + Constant * getAlterego() { + if (alterego != NULL) { + return alterego; + } else { + return this; + } + } + + // Remove 'equal' constants and give them names. + static void finalFinalModification(List<RootType*> constantDefs); +}; + +#endif /* CONSTANT_HH_ */ + diff --git a/xsdconvert/GeneralFunctions.cc b/xsdconvert/GeneralFunctions.cc index e610c74edb41c5093e51cd04956b580d49399a89..818e4fee94a136f5c1215dab29ce2d5381fcbf36 100644 --- a/xsdconvert/GeneralFunctions.cc +++ b/xsdconvert/GeneralFunctions.cc @@ -622,6 +622,24 @@ void indent(FILE* file, const unsigned int x) { } } +Mstring xmlFloat2TTCN3FloatStr(const Mstring& xmlFloat) { + Mstring result; + if (xmlFloat == "INF") { + result = "infinity"; + } else if (xmlFloat == "-INF") { + result = "-infinity"; + } else if (xmlFloat == "NaN") { + result = "not_a_number"; + } else if (!xmlFloat.isFound('.') && !xmlFloat.isFound('e') && !xmlFloat.isFound('E')) { + // Float types need the .0 if it is a single integer or + // translate special float values to TTCN3. + result = xmlFloat + Mstring(".0"); + } else { + result = xmlFloat; + } + return result; +} + long double stringToLongDouble(const char *input) { long double result = 0.0; // `strtold()' is not available on older platforms. diff --git a/xsdconvert/GeneralFunctions.hh b/xsdconvert/GeneralFunctions.hh index fe2ab579e7bfa04d0b10a610eb863c61bfbfed1b..1b7f830c401a0f7501745b9b3067d4f018417185 100644 --- a/xsdconvert/GeneralFunctions.hh +++ b/xsdconvert/GeneralFunctions.hh @@ -50,6 +50,9 @@ void printError(const Mstring& filename, int lineNumber, const Mstring& text); void printError(const Mstring& filename, const Mstring& typeName, const Mstring& text); void indent(FILE * file, const unsigned int x); +// Converts an XML float value as string to a correct ttcn float value as string +Mstring xmlFloat2TTCN3FloatStr(const Mstring& xmlFloat); + long double stringToLongDouble(const char * input); class RootType; diff --git a/xsdconvert/Makefile b/xsdconvert/Makefile index f61a7933cbf067c5c70a00a64557b8e03231fa72..69f3f68a49f224f4f3610549b457a54884079bfd 100644 --- a/xsdconvert/Makefile +++ b/xsdconvert/Makefile @@ -22,7 +22,7 @@ SOURCES := converter.cc \ RootType.cc SimpleType.cc AttributeType.cc ComplexType.cc \ Annotation.cc ImportStatement.cc \ PredefinedModules.cc GeneralFunctions.cc \ - Mstring.cc + Mstring.cc Constant.cc # No generated sources STATIC_SOURCES := $(SOURCES) diff --git a/xsdconvert/Mstring.cc b/xsdconvert/Mstring.cc index 4c020d8bac91614fce28e8a65dfb7eb089669090..e3b8ab8dff8cf47fbbe4c64d61627cce0087f95a 100644 --- a/xsdconvert/Mstring.cc +++ b/xsdconvert/Mstring.cc @@ -86,19 +86,19 @@ void Mstring::insertChar(size_t pos, char c) { text = mcopystr(temp.text); } -bool Mstring::isFound(const Mstring & s) { +bool Mstring::isFound(const Mstring & s) const { return strstr(text, s.text); } -bool Mstring::isFound(const char * s) { +bool Mstring::isFound(const char * s) const { return strstr(text, s); } -bool Mstring::isFound(char c) { +bool Mstring::isFound(char c) const { return strchr(text, c); } -char * Mstring::foundAt(const char * s) { +char * Mstring::foundAt(const char * s) const { return strstr(text, s); } diff --git a/xsdconvert/Mstring.hh b/xsdconvert/Mstring.hh index 244b277e1e66e4bac4e43772ae2c528c5928f087..5e8af1621933be13e891af05735763dfe6d629b6 100644 --- a/xsdconvert/Mstring.hh +++ b/xsdconvert/Mstring.hh @@ -98,21 +98,21 @@ public: * true if s is found * false otherwise */ - bool isFound(const Mstring & s); + bool isFound(const Mstring & s) const; /** * Look for s c-string content * true if s is found * false otherwise */ - bool isFound(const char * s); + bool isFound(const char * s) const; /** * Look for c character content * true if s is found * false otherwise */ - bool isFound(char c); + bool isFound(char c) const; /** * Look for c-string content @@ -120,7 +120,7 @@ public: * character where the matching found, * returns null otherwise */ - char * foundAt(const char * c); + char * foundAt(const char * c) const; /** * The first character of the Mstring is set to uppercase diff --git a/xsdconvert/RootType.cc b/xsdconvert/RootType.cc index 1bae4a0961a16d6ca906f729b2f83cfd8700167d..941d5ee580eb1fb6fdd7436b8290acc160078bf8 100644 --- a/xsdconvert/RootType.cc +++ b/xsdconvert/RootType.cc @@ -103,7 +103,9 @@ void RootType::addVariant(const VariantMode var, const Mstring& var_value, const variantstring = "\"controlNamespace" + var_value + "\""; break; case V_defaultForEmpty: - variantstring = "\"defaultForEmpty as \'" + var_value + "\'\""; // chapter 7.1.5 + // The apostrophes are not needed because the var_value will be a constant + // reference. + variantstring = "\"defaultForEmpty as " + var_value + "\""; // chapter 7.1.5 break; case V_element: variantstring = "\"element\""; diff --git a/xsdconvert/RootType.hh b/xsdconvert/RootType.hh index 363f4a0244f90418b0d0d9026749eb77608dd0fe..f50cc3b6b42ff8c9e5f902d438fb5a21b3039486 100644 --- a/xsdconvert/RootType.hh +++ b/xsdconvert/RootType.hh @@ -144,7 +144,7 @@ protected: /// List of types that depend on this one. /// Used to propagate the effect of name conversion to the dependents - List<SimpleType*> nameDepList; // no responsibility for elements + List<RootType*> nameDepList; // no responsibility for elements private: unsigned long long int minOccurs; @@ -173,6 +173,9 @@ public: virtual void finalModification() { } + + virtual void finalModification2() { + } virtual bool hasUnresolvedReference() { return false; @@ -263,7 +266,7 @@ public: return comment; } - List<SimpleType*> & getNameDepList() { + List<RootType*> & getNameDepList() { return nameDepList; } diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc index b186c6b0f0ddaee09e4c91ce7664aabc91161494..cad677b8e0e142170b98163170274236e78eb859 100644 --- a/xsdconvert/SimpleType.cc +++ b/xsdconvert/SimpleType.cc @@ -21,6 +21,7 @@ #include "TTCN3ModuleInventory.hh" #include "TTCN3Module.hh" #include "ComplexType.hh" +#include "Constant.hh" #include <cmath> // for using "pow" function #include <cfloat> @@ -28,6 +29,18 @@ extern bool g_flag_used; extern bool h_flag_used; +#ifndef INFINITY +#define INFINITY (DBL_MAX*DBL_MAX) +#endif +const double PLUS_INFINITY(INFINITY); +const double MINUS_INFINITY(-INFINITY); + +#ifdef NAN +const double NOT_A_NUMBER(NAN); +#else +const double NOT_A_NUMBER((double)PLUS_INFINITY+(double)MINUS_INFINITY); +#endif + SimpleType::SimpleType(XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct) : RootType(a_parser, a_module, a_construct) , builtInBase() @@ -51,6 +64,7 @@ SimpleType::SimpleType(XMLParser * a_parser, TTCN3Module * a_module, ConstructTy , block(not_set) , inList(false) , alias(NULL) +, defaultForEmptyConstant(NULL) , parent(NULL) { } @@ -77,6 +91,7 @@ SimpleType::SimpleType(const SimpleType& other) , block(other.block) , inList(other.inList) , alias(other.alias) +, defaultForEmptyConstant(other.defaultForEmptyConstant) , parent(NULL) { length.parent = this; pattern.parent = this; @@ -248,10 +263,14 @@ void SimpleType::loadWithValues() { void SimpleType::applyDefaultAttribute(const Mstring& default_value) { if (!default_value.empty()) { value.default_value = default_value; - const Mstring nameT = type.originalValueWoPrefix.getValueWithoutPrefix(':'); + const Mstring typeT = type.originalValueWoPrefix.getValueWithoutPrefix(':'); //Not supported for hexBinary and base64Binary - if (nameT != "hexBinary" && nameT != "base64Binary") { - addVariant(V_defaultForEmpty, default_value); + if (typeT != "hexBinary" && typeT != "base64Binary") { + Constant * c = new Constant(this, type.convertedValue, default_value); + module->addConstant(c); + defaultForEmptyConstant = c; + // Delay adding the defaultForEmpty variant after the nameconversion + // happened on the constants } } } @@ -260,10 +279,14 @@ void SimpleType::applyFixedAttribute(const Mstring& fixed_value) { if (!fixed_value.empty()) { value.fixed_value = fixed_value; value.modified = true; - const Mstring nameT = type.originalValueWoPrefix.getValueWithoutPrefix(':'); + const Mstring typeT = type.originalValueWoPrefix.getValueWithoutPrefix(':'); //Not supported for hexBinary and base64Binary - if (nameT != "hexBinary" && nameT != "base64Binary") { - addVariant(V_defaultForEmpty, fixed_value); + if (typeT != "hexBinary" && typeT != "base64Binary") { + Constant * c = new Constant(this, type.convertedValue, fixed_value); + module->addConstant(c); + defaultForEmptyConstant = c; + // Delay adding the defaultForEmpty variant after the nameconversion + // happened on the constants } } } @@ -316,7 +339,7 @@ void SimpleType::addToSubstitutions(){ //Simpletype if(st->subsGroup == NULL){ ComplexType * head_element = new ComplexType(*st, ComplexType::fromTagSubstitution); - for(List<SimpleType*>::iterator simpletype = st->nameDepList.begin(); simpletype; simpletype = simpletype->Next){ + for(List<RootType*>::iterator simpletype = st->nameDepList.begin(); simpletype; simpletype = simpletype->Next){ head_element->getNameDepList().push_back(simpletype->Data); } st->nameDepList.clear(); @@ -371,12 +394,14 @@ void SimpleType::addToTypeSubstitutions() { if(st->getTypeSubstitution() == NULL){ ComplexType * head_element = new ComplexType(*st, ComplexType::fromTypeSubstitution); head_element->getNameDepList().clear(); - for(List<SimpleType*>::iterator simpletype = st->nameDepList.begin(), nextST; simpletype; simpletype = nextST){ - nextST = simpletype->Next; + for(List<RootType*>::iterator roottype = st->nameDepList.begin(), nextST; roottype; roottype = nextST){ + nextST = roottype->Next; //Don't add if it is in a type substitution - if(simpletype->Data->getTypeSubstitution() == NULL){ - head_element->getNameDepList().push_back(simpletype->Data); - st->getNameDepList().remove(simpletype); + SimpleType* simpletype = dynamic_cast<SimpleType*>(roottype->Data); + if (simpletype == NULL) continue; + if(simpletype->getTypeSubstitution() == NULL){ + head_element->getNameDepList().push_back(roottype->Data); + st->getNameDepList().remove(roottype); } } @@ -734,9 +759,15 @@ void SimpleType::nameConversion_names() { XSDName2TTCN3Name(name.convertedValue, TTCN3ModuleInventory::getInstance().getTypenames(), type_name, res, var); name.convertedValue = res; addVariant(V_onlyValue, var); - for (List<SimpleType*>::iterator st = nameDepList.begin(); st; st = st->Next) { + for (List<RootType*>::iterator st = nameDepList.begin(); st; st = st->Next) { st->Data->setTypeValue(res); } + if (outside_reference.get_ref() != NULL && defaultForEmptyConstant!= NULL) { + // We don't know if the name conversion already happened on the get_ref() + // so we push defaultForEmptyConstant to it's namedeplist. + defaultForEmptyConstant->setTypeValue(outside_reference.get_ref()->getType().convertedValue); + outside_reference.get_ref()->getNameDepList().push_back(defaultForEmptyConstant); + } } void SimpleType::nameConversion_types(const List<NamespaceType> & ns) { @@ -807,6 +838,17 @@ void SimpleType::finalModification() { } isOptional = isOptional || (getMinOccurs() == 0 && getMaxOccurs() == 0); + + +} + +void SimpleType::finalModification2() { + // Delayed adding the defaultForEmpty variant after the nameconversion + // happened on the constants + if (defaultForEmptyConstant != NULL) { + TTCN3Module * mod = parent != NULL ? parent->getModule() : getModule(); + addVariant(V_defaultForEmpty, defaultForEmptyConstant->getAlterego()->getConstantName(mod)); + } } bool SimpleType::hasUnresolvedReference() { @@ -1181,7 +1223,8 @@ EnumerationType::EnumerationType(SimpleType * a_simpleType) , items_float() , items_time() , items_misc() -, variants() { +, variants() +, converted_facets() { } void EnumerationType::applyReference(const EnumerationType & other) { @@ -1211,6 +1254,7 @@ void EnumerationType::applyFacets() // string types, integer types, float types, Mstring res, var; XSDName2TTCN3Name(facet->Data, items_string, enum_id_name, res, var); text_variants.push_back(var); + converted_facets.push_back(res); } } text_variants.sort(); @@ -1230,7 +1274,17 @@ void EnumerationType::applyFacets() // string types, integer types, float types, break; } } - if (!found) items_int.push_back(int_value); + if (!found) { + items_int.push_back(int_value); + expstring_t tmp = NULL; + if (int_value < 0) { + tmp = mputprintf(tmp, "int_%d", abs(int_value)); + } else { + tmp = mputprintf(tmp, "int%d", int_value); + } + converted_facets.push_back(Mstring(tmp)); + Free(tmp); + } if (variants.empty() || variants.back() != "\"useNumber\"") { variants.push_back(Mstring("\"useNumber\"")); @@ -1242,7 +1296,11 @@ void EnumerationType::applyFacets() // string types, integer types, float types, for (List<Mstring>::iterator facet = facets.begin(); facet; facet = facet->Next) { double float_value = atof(facet->Data.c_str()); const ValueType & value = parent->getValue(); - if (value.lower <= float_value && float_value <= value.upper) { + // Value uses DBL_MAX as infinity or -DBL_MAX as -infinity + if ((value.lower <= float_value && float_value <= value.upper) + || (facet->Data == "-INF" && value.lower == -DBL_MAX) + || (facet->Data == "INF" && value.upper == DBL_MAX) + || facet->Data == "NaN") { bool found = false; for (List<double>::iterator itemFloat = items_float.begin(); itemFloat; itemFloat = itemFloat->Next) { if (float_value == itemFloat->Data) { @@ -1252,6 +1310,8 @@ void EnumerationType::applyFacets() // string types, integer types, float types, } if (!found) { items_float.push_back(float_value); + Mstring res = xmlFloat2TTCN3FloatStr(facet->Data); + converted_facets.push_back(res); } } } @@ -1261,6 +1321,7 @@ void EnumerationType::applyFacets() // string types, integer types, float types, Mstring res, var; XSDName2TTCN3Name(facet->Data, items_time, enum_id_name, res, var); text_variants.push_back(var); + converted_facets.push_back(res); } text_variants.sort(); for (List<Mstring>::iterator var = text_variants.end(); var; var = var->Prev) { @@ -1307,13 +1368,21 @@ void EnumerationType::printToFile(FILE * file, unsigned int indent_level) const for (List<double>::iterator itemFloat = items_float.begin(); itemFloat; itemFloat = itemFloat->Next) { if (itemFloat != items_float.begin()) fputs(", ", file); - double intpart = 0; - double fracpart = 0; - fracpart = modf(itemFloat->Data, &intpart); - if (fracpart == 0) { - fprintf(file, "%lld.0", (long long int) (itemFloat->Data)); + if (itemFloat->Data == PLUS_INFINITY) { + fprintf(file, "infinity"); + } else if (itemFloat->Data == MINUS_INFINITY) { + fprintf(file, "-infinity"); + } else if (isnan(itemFloat->Data)) { + fprintf(file, "not_a_number"); } else { - fprintf(file, "%g", itemFloat->Data); + double intpart = 0; + double fracpart = 0; + fracpart = modf(itemFloat->Data, &intpart); + if (fracpart == 0) { + fprintf(file, "%lld.0", (long long int) (itemFloat->Data)); + } else { + fprintf(file, "%g", itemFloat->Data); + } } } } else if (isTimeType(base)) { @@ -1526,45 +1595,44 @@ void ValueType::printToFile(FILE * file) const { return; } if (!fixed_value.empty()) { - //Base64binary and hexbyte does not supported - Mstring type; - if(isBuiltInType(parent->getType().originalValueWoPrefix)){ - type = parent->getType().originalValueWoPrefix; - }else { - type = getPrefixByNameSpace(parent, parent->getReference().get_uri()) + Mstring(":") + parent->getReference().get_val(); - } - if(!isBuiltInType(type)){ - type = findBuiltInType(parent, type); - } - if (isStringType(type) || isTimeType(type) || isQNameType(type) || isAnyType(type)) { - const Mstring& name = type.getValueWithoutPrefix(':'); - if (name != "hexBinary" && name != "base64Binary") { - fprintf(file, " (\"%s\")", fixed_value.c_str()); + if (parent->getConstantDefaultForEmpty() != NULL) { + // Insert the constant's name in the TTCN type restriction. + TTCN3Module * mod = parent->parent != NULL ? parent->parent->getModule() : + parent->getModule(); + Mstring val = parent->getConstantDefaultForEmpty()->getAlterego()->getConstantName(mod); + fprintf(file, " (%s)", val.c_str()); + } else { + //Base64binary and hexbyte does not supported + Mstring type; + if(isBuiltInType(parent->getType().originalValueWoPrefix)){ + type = parent->getType().originalValueWoPrefix; + }else { + type = getPrefixByNameSpace(parent, parent->getReference().get_uri()) + Mstring(":") + parent->getReference().get_val(); } - } else if (isBooleanType(type)) { - Mstring val; - if (fixed_value == "1") { - val = "true"; - } else if (fixed_value == "0") { - val = "false"; - } else { - val = fixed_value; + if(!isBuiltInType(type)){ + type = findBuiltInType(parent, type); } - fprintf(file, " (%s)", val.c_str()); - } else if (isFloatType(type)) { - Mstring val; - if (fixed_value == "INF") { - val = "infinity"; - } else if (fixed_value == "-INF") { - val = "-infinity"; - } else if (fixed_value == "NaN") { - val = "not_a_number"; + if (isStringType(type) || isTimeType(type) || isQNameType(type) || isAnyType(type)) { + const Mstring& name = type.getValueWithoutPrefix(':'); + if (name != "hexBinary" && name != "base64Binary") { + fprintf(file, " (\"%s\")", fixed_value.c_str()); + } + } else if (isBooleanType(type)) { + Mstring val; + if (fixed_value == "1") { + val = "true"; + } else if (fixed_value == "0") { + val = "false"; + } else { + val = fixed_value; + } + fprintf(file, " (%s)", val.c_str()); + } else if (isFloatType(type)) { + Mstring val = xmlFloat2TTCN3FloatStr(fixed_value); + fprintf(file, " (%s)", val.c_str()); } else { - val = fixed_value; + fprintf(file, " (%s)", fixed_value.c_str()); } - fprintf(file, " (%s)", val.c_str()); - } else { - fprintf(file, " (%s)", fixed_value.c_str()); } return; } diff --git a/xsdconvert/SimpleType.hh b/xsdconvert/SimpleType.hh index 37de61867421168432154d74b4a95adfe01a86ba..9d8ed1b1ca90763ecb2dea200d824730ea66930b 100644 --- a/xsdconvert/SimpleType.hh +++ b/xsdconvert/SimpleType.hh @@ -20,6 +20,7 @@ #include "RootType.hh" class SimpleType; +class Constant; class LengthType { LengthType & operator=(const LengthType &); // not implemented @@ -70,6 +71,7 @@ public: List<QualifiedName> items_time; List<Mstring> items_misc; List<Mstring> variants; + List<Mstring> converted_facets; EnumerationType(SimpleType * p_parent); // Default copy constructor and destructor are used @@ -230,9 +232,9 @@ protected: bool isOptional; Mstring substitutionGroup; //Pointer to the generated element substitution group - ComplexType * subsGroup; + ComplexType * subsGroup; // not owned //Pointer to the generated type substitution group - ComplexType * typeSubsGroup; + ComplexType * typeSubsGroup; // not owned //To determine if already added to type substitution bool addedToTypeSubstitution; BlockValue block; @@ -244,7 +246,9 @@ protected: // We are inside a list if inList is true and mode == listMode // If this type is an alias then the alias field points to the original type - SimpleType * alias; + SimpleType * alias; // not owned + + Constant * defaultForEmptyConstant; // not owned //Element substitution void addToSubstitutions(); @@ -280,6 +284,7 @@ public: void referenceResolving(); void nameConversion(const NameConversionMode mode, const List<NamespaceType> & ns); void finalModification(); + virtual void finalModification2(); virtual bool hasUnresolvedReference(); virtual void modifyList(); void dump(const unsigned int depth) const; @@ -389,7 +394,7 @@ public: inList = list; } - void addToNameDepList(SimpleType * t) { + void addToNameDepList(RootType * t) { //If the type has a substitution, we add the namedep to the substitution if(subsGroup != NULL && this != (SimpleType*)subsGroup){ SimpleType * substitution = (SimpleType*)subsGroup; @@ -406,6 +411,10 @@ public: return alias; } + Constant * getConstantDefaultForEmpty() const { + return defaultForEmptyConstant; + } + // Returns true if the type really restricts or extends the type not // just aliases it. bool hasRestrictionOrExtension() const; diff --git a/xsdconvert/TTCN3Module.cc b/xsdconvert/TTCN3Module.cc index 0f9ffdc75abf3bfc7477d07baaea77ed4aff4d4d..abd603900228ffa8ce3d74528bf63f34f2b92ba1 100644 --- a/xsdconvert/TTCN3Module.cc +++ b/xsdconvert/TTCN3Module.cc @@ -22,6 +22,7 @@ #include "ComplexType.hh" #include "ImportStatement.hh" #include "Annotation.hh" +#include "Constant.hh" #include "../common/version_internal.h" @@ -41,6 +42,7 @@ TTCN3Module::TTCN3Module(const char * a_filename, XMLParser * a_parser) , schemaname() , modulename() , definedTypes() +, constantDefs() , actualXsdConstruct(c_unknown) , xsdVersion() , xsdEncoding() @@ -57,7 +59,8 @@ TTCN3Module::TTCN3Module(const char * a_filename, XMLParser * a_parser) , variant() , xmlSchemaPrefixes() , moduleNotIntoFile(false) -, moduleNotIntoNameConversion(false) { +, moduleNotIntoNameConversion(false) +, const_counter(1) { #if defined(WIN32) && !defined(MINGW) // Transform a Windows style path: "C:\cygwin\tmp\a.xsd" // into a POSIX style path: "/home/a/xsd", so getValueWithoutPrefix('/') @@ -89,6 +92,10 @@ TTCN3Module::~TTCN3Module() { for (List<RootType*>::iterator type = definedTypes.begin(); type; type = type->Next) { delete type->Data; } + + for (List<RootType*>::iterator type = constantDefs.begin(); type; type = type->Next) { + delete type->Data; + } } void TTCN3Module::loadValuesFromXMLDeclaration(const char *a_version, @@ -286,6 +293,9 @@ void TTCN3Module::generate_TTCN3_included_types(FILE * file) { } void TTCN3Module::generate_TTCN3_types(FILE * file) { + for (List<RootType*>::iterator type = constantDefs.begin(); type; type = type->Next) { + type->Data->printToFile(file); + } for (List<RootType*>::iterator type = definedTypes.begin(); type; type = type->Next) { if (type->Data->getConstruct() != c_include && type->Data->getConstruct() != c_import) { type->Data->printToFile(file); @@ -451,6 +461,10 @@ void TTCN3Module::TargetNamespace2ModuleName() { void TTCN3Module::dump() const { fprintf(stderr, "Module '%s' at %p (from %s)\n", modulename.c_str(), (const void*) this, schemaname.c_str()); + + for (List<RootType*>::iterator type = constantDefs.begin(); type; type = type->Next) { + type->Data->dump(1); + } for (List<RootType*>::iterator type = definedTypes.begin(); type; type = type->Next) { type->Data->dump(1); diff --git a/xsdconvert/TTCN3Module.hh b/xsdconvert/TTCN3Module.hh index aec34860daa19794e2dce31d49c78b6a3085d53b..358948e0f86f7be99ffc268f02b2983ddeed5e5b 100644 --- a/xsdconvert/TTCN3Module.hh +++ b/xsdconvert/TTCN3Module.hh @@ -57,6 +57,10 @@ class TTCN3Module { * contains all main types defined in the module */ List<RootType*>definedTypes; + /** + * contains all constant definitions defined in the module + */ + List<RootType*>constantDefs; /** * Type of the currently processed main type */ @@ -92,6 +96,8 @@ class TTCN3Module { bool moduleNotIntoFile; bool moduleNotIntoNameConversion; + + unsigned int const_counter; TTCN3Module & operator=(const TTCN3Module &); // not implemented TTCN3Module(const TTCN3Module &); // not implemented @@ -171,8 +177,9 @@ public: void addAnnotation(); void addMainType(const ConstructType typeOfMainType); - void addMainType(RootType * type){ definedTypes.push_back(type); } - + void addMainType(RootType * type) { definedTypes.push_back(type); } + void addConstant(RootType * constant) { constantDefs.push_back(constant); } + bool hasDefinedMainType() const { return !definedTypes.empty(); } @@ -181,6 +188,10 @@ public: const List<RootType*> & getDefinedTypes() const { return definedTypes; } + + List<RootType*> & getConstantDefs() { + return constantDefs; + } RootType & getLastMainType() { return *definedTypes.back(); @@ -254,6 +265,14 @@ public: void TargetNamespace2ModuleName(); friend bool compareModules(TTCN3Module * lhs, TTCN3Module * rhs); + + unsigned int getConstCounter() { + return const_counter; + } + + void increaseConstCounter() { + ++const_counter; + } void dump() const; }; diff --git a/xsdconvert/TTCN3ModuleInventory.cc b/xsdconvert/TTCN3ModuleInventory.cc index 95d11eee5deafb47a28cd28deb94b406d283bdaa..1f89a9d1e716649c7914fab472d96517520fdb21 100644 --- a/xsdconvert/TTCN3ModuleInventory.cc +++ b/xsdconvert/TTCN3ModuleInventory.cc @@ -22,6 +22,7 @@ #include "TTCN3Module.hh" #include "SimpleType.hh" #include "ComplexType.hh" +#include "Constant.hh" extern bool h_flag_used; extern bool q_flag_used; @@ -101,6 +102,17 @@ void TTCN3ModuleInventory::finalModification() { type->Data->finalModification(); } } + for (List<TTCN3Module*>::iterator module = definedModules.begin(); module; module = module->Next) { + for (List<RootType*>::iterator type = module->Data->getConstantDefs().begin(); type; type = type->Next) { + type->Data->finalModification(); + } + Constant::finalFinalModification(module->Data->getConstantDefs()); + } + for (List<TTCN3Module*>::iterator module = definedModules.begin(); module; module = module->Next) { + for (List<RootType*>::iterator type = module->Data->getDefinedTypes().begin(); type; type = type->Next) { + type->Data->finalModification2(); + } + } } void TTCN3ModuleInventory::nameConversion() { @@ -115,6 +127,7 @@ void TTCN3ModuleInventory::nameConversion() { for (List<TTCN3Module*>::iterator module = definedModules.begin(); module; module = module->Next) { if (module->Data->isnotIntoNameConversion()) continue; + List<RootType*> definedConstants_inABC; List<RootType*> definedElements_inABC; List<RootType*> definedAttributes_inABC; List<RootType*> definedSimpleTypes_inABC; @@ -124,6 +137,19 @@ void TTCN3ModuleInventory::nameConversion() { for (List<TTCN3Module*>::iterator module2 = module; module2; module2 = module2->Next) { if (module2->Data->getModulename() != module->Data->getModulename()) continue; + + for (List<RootType*>::iterator type = module2->Data->getConstantDefs().begin(); type; type = type->Next) { + definedConstants_inABC.push_back(type->Data); + } + // If two module has the same module name then they will be generated into + // one module, so the constants shall be moved. + if (module->Data != module2->Data) { + for (List<RootType*>::iterator type = module->Data->getConstantDefs().begin(), nextType; type; type = nextType) { + nextType = type->Next; + module2->Data->getConstantDefs().push_back(type->Data); + module->Data->getConstantDefs().remove(type); + } + } for (List<RootType*>::iterator type = module2->Data->getDefinedTypes().begin(); type; type = type->Next) { switch (type->Data->getConstruct()) { @@ -152,6 +178,7 @@ void TTCN3ModuleInventory::nameConversion() { module2->Data->notIntoNameConversion(); } + definedSimpleTypes_inABC.sort(compareTypes); definedElements_inABC.sort(compareTypes); definedAttributes_inABC.sort(compareTypes); definedSimpleTypes_inABC.sort(compareTypes); @@ -164,6 +191,9 @@ void TTCN3ModuleInventory::nameConversion() { typenames.push_back(QualifiedName(module->Data->getTargetNamespace(), mod->Data->getModulename())); } + for (List<RootType*>::iterator type = definedConstants_inABC.begin(); type; type = type->Next) { + type->Data->nameConversion(nameMode, module->Data->getDeclaredNamespaces()); + } for (List<RootType*>::iterator type = definedElements_inABC.begin(); type; type = type->Next) { type->Data->nameConversion(nameMode, module->Data->getDeclaredNamespaces()); } @@ -188,6 +218,9 @@ void TTCN3ModuleInventory::nameConversion() { * Conversion of the type of types * ******************************************************/ for (List<TTCN3Module*>::iterator module = definedModules.begin(); module; module = module->Next) { + for (List<RootType*>::iterator type = module->Data->getConstantDefs().begin(); type; type = type->Next) { + type->Data->nameConversion(typeMode, module->Data->getDeclaredNamespaces()); + } for (List<RootType*>::iterator type = module->Data->getDefinedTypes().begin(); type; type = type->Next) { type->Data->nameConversion(typeMode, module->Data->getDeclaredNamespaces()); }