diff --git a/README.md b/README.md index b62f8e9e841323f08d7b6c3e24fe8bd1ba62a814..29d562cf8f8b65150b678760c8972af6aa82b74f 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,8 @@ Compressed update site and SHA512 checksum: * https://github.com/eclipse/titan.ProtocolModules.UDP * https://github.com/eclipse/titan.ProtocolModules.WebSocket * https://github.com/eclipse/titan.ProtocolModules.XMPP -* http://git.eclipse.org/c/titan/titan.ProtocolModules.CoAP.git -* http://git.eclipse.org/c/titan/titan.ProtocolModules.MQTT.git +* http://git.eclipse.org/gitroot/titan/titan.ProtocolModules.CoAP +* http://git.eclipse.org/gitroot/titan/titan.ProtocolModules.MQTT ## Libraries: @@ -114,4 +114,4 @@ Compressed update site and SHA512 checksum: ## Miscellaneous projects: * https://github.com/eclipse/titan.misc -(VSBOT, SIP_ETSI,DIAMETER_Rx_ETSI, CoAP and MQTT protocol modules for IOT, more to come...) +(VSBOT, SIP_ETSI,DIAMETER_Rx_ETSI, CoAP Conformance test cases, CoAP and MQTT protocol modules for IOT-moved to Eclipse git, more to come...) diff --git a/compiler2/Type_codegen.cc b/compiler2/Type_codegen.cc index 8edd57190f48943fdfa028924c9e5fcaf51f34f4..f9bb996a29e9ad680d2eab76ef47b3e8010a12a4 100644 --- a/compiler2/Type_codegen.cc +++ b/compiler2/Type_codegen.cc @@ -2254,6 +2254,8 @@ void Type::generate_code_done(output_struct *target) "if (!component_reference.is_bound()) " "TTCN_error(\"Performing a done operation on an unbound component " "reference.\");\n" + "if (value_template.get_selection() == ANY_OR_OMIT) " + "TTCN_error(\"Done operation using '*' as matching template\");\n" "Text_Buf *text_buf;\n" "alt_status ret_val = TTCN_Runtime::component_done(" "(component)component_reference, \"%s\", text_buf);\n" diff --git a/compiler2/main.cc b/compiler2/main.cc index a9143eb202b71174e186bbf6a9d964257ccc3c64..69275ce9aea34f707afe144de44a841732d68881 100644 --- a/compiler2/main.cc +++ b/compiler2/main.cc @@ -78,6 +78,7 @@ using namespace Common; const char *output_dir = NULL; const char *tcov_file_name = NULL; const char *profiler_file_name = NULL; +const char *file_list_file_name = NULL; tcov_file_list *tcov_files = NULL; expstring_t effective_module_lines = NULL; expstring_t effective_module_functions = NULL; @@ -384,7 +385,7 @@ static boolean is_valid_asn1_filename(const char* file_name) static void usage() { fprintf(stderr, "\n" - "usage: %s [-abcdEfgijlLMnOpqrRsStuwxXyY] [-K file] [-z file] [-V verb_level]\n" + "usage: %s [-abcdEfgijlLMnOpqrRsStuwxXyY] [-J file] [-K file] [-z file] [-V verb_level]\n" " [-o dir] [-U none|type|'number'] [-P modulename.top_level_pdu_name] [-Q number] ...\n" " [-T] module.ttcn [-A] module.asn ...\n" " or %s -v\n" @@ -401,6 +402,7 @@ static void usage() " -g: emulate GCC error/warning message format\n" " -i: use only line numbers in error/warning messages\n" " -j: disable JSON encoder/decoder functions\n" + " -J file: read input files from file\n" " -K file: enable selective code coverage\n" " -l: include source line info in C++ code\n" " -L: add source line info for logging\n" @@ -494,6 +496,8 @@ int main(int argc, char *argv[]) size_t n_modules = 0; module_struct *module_list = NULL; char* json_schema_name = NULL; + size_t n_files_from_file = 0; + char ** files_from_file = NULL; if (0 == strcmp(argv[1], "--ttcn2json")) { ttcn2json = true; @@ -575,7 +579,7 @@ int main(int argc, char *argv[]) if (!ttcn2json) { for ( ; ; ) { - int c = getopt(argc, argv, "aA:bBcC:dEfFgijK:lLMno:pP:qQ:rRsStT:uU:vV:wxXyYz:0-"); + int c = getopt(argc, argv, "aA:bBcC:dEfFgijJ:K:lLMno:pP:qQ:rRsStT:uU:vV:wxXyYz:0-"); if (c == -1) break; switch (c) { case 'a': @@ -645,6 +649,9 @@ int main(int argc, char *argv[]) SET_FLAG(i); output_only_linenum = TRUE; break; + case 'J': + file_list_file_name = optarg; + break; case 'K': SET_FLAG(K); tcov_file_name = optarg; @@ -832,7 +839,70 @@ int main(int argc, char *argv[]) output_dir); errflag = true; } - if (optind == argc && n_modules == 0) { + + if (file_list_file_name != NULL) { + FILE *fp = fopen(file_list_file_name, "r"); + if (fp != NULL) { + char buff[1024]; + // We store the -A and -T here too + while (fscanf(fp, "%s", buff) == 1) { + n_files_from_file++; + files_from_file = (char**) + Realloc(files_from_file, n_files_from_file * sizeof(*files_from_file)); + files_from_file[n_files_from_file - 1] = mcopystr(buff); + } + fclose(fp); + } else { + ERROR("Cannot open file `%s' for reading: %s", file_list_file_name, + strerror(errno)); + errno = 0; + errflag = true; + } + bool next_is_asn1 = false; + bool next_is_ttcn = false; + for (size_t i = 0; i < n_files_from_file; i++) { + // Check if -A or -T is present and continue to the next word if yes + if (next_is_ttcn == false && next_is_asn1 == false) { + if (strcmp(files_from_file[i], "-A") == 0) { + next_is_asn1 = true; + continue; + } else if (strcmp(files_from_file[i], "-T") == 0) { + next_is_ttcn = true; + continue; + } + } + Module::moduletype_t module_type = Module::MOD_UNKNOWN; + const char* file = files_from_file[i]; + if (next_is_asn1) { + module_type = Module::MOD_ASN; + next_is_asn1 = false; + } else if(next_is_ttcn) { + module_type = Module::MOD_TTCN; + next_is_ttcn = false; + } else if (strlen(files_from_file[i]) > 2) { + // The -A or -T can be given as -TMyTtcnfile.ttcn too + if (files_from_file[i][0] == '-') { + if (files_from_file[i][1] == 'A') { + file = files_from_file[i] + 2; + module_type = Module::MOD_ASN; + } else if (files_from_file[i][1] == 'T') { + file = files_from_file[i] + 2; + module_type = Module::MOD_TTCN; + } + } + } + if (module_type == Module::MOD_TTCN) { +#ifdef LICENSE + ttcn3_modules_present = true; +#endif + } else if (module_type == Module::MOD_ASN) { + asn1_modules_present = true; + } + add_module(n_modules, module_list, file, module_type); + } + } + + if (optind == argc && n_modules == 0 && n_files_from_file == 0) { ERROR("No input TTCN-3 or ASN.1 module was given."); errflag = true; } @@ -1156,6 +1226,10 @@ int main(int argc, char *argv[]) if (zflag) { free_profiler_data(); } + for (size_t i = 0; i < n_files_from_file; i++) { + Free(files_from_file[i]); + } + Free(files_from_file); // dbgnew.hh already does it: check_mem_leak(argv[0]); diff --git a/compiler2/makefile.c b/compiler2/makefile.c index 34c9176b15fc230357b2831f9b9b9fe0665cf740..2e33c9298db9fc980329c3cdf692ee8104e7ee63 100644 --- a/compiler2/makefile.c +++ b/compiler2/makefile.c @@ -4590,7 +4590,7 @@ static void usage(void) { fprintf(stderr, "\n" "usage: %s [-abc" C_flag "dDEfFglLmMnprRsStTVwWXZ] [-K file] [-z file ] [-P dir]" - " [-j file] [-U none|type|'number'] [-e ets_name] [-o dir|file]\n" + " [-J file] [-U none|type|'number'] [-e ets_name] [-o dir|file]\n" " [-t project_descriptor.tpd [-b buildconfig]]\n" " [-O file] ... module_name ... testport_name ...\n" " or %s -v\n" @@ -4607,7 +4607,7 @@ static void usage(void) " -f: force overwriting of the output Makefile\n" " -g: generate Makefile for use with GNU make\n" " -I path: Add path to the search paths when using TPD files\n" - " -j file: The names of files taken from file instead of command line" + " -J file: The names of files taken from file instead of command line" " -K file: enable selective code coverage\n" " -l: use dynamic linking\n" " -L: create makefile with library archive as the default target\n" @@ -4720,7 +4720,7 @@ int main(int argc, char *argv[]) } for ( ; ; ) { - int c = getopt(argc, argv, "O:ab:c" C_flag "dDe:EfFgI:j:K:o:lLmMnpP:rRsSt:TU:vVwWXYz:ZH"); + int c = getopt(argc, argv, "O:ab:c" C_flag "dDe:EfFgI:J:K:o:lLmMnpP:rRsSt:TU:vVwWXYz:ZH"); if (c == -1) break; switch (c) { case 'O': @@ -4779,7 +4779,7 @@ int main(int argc, char *argv[]) case 'H': SET_FLAG(H); break; - case 'j': + case 'J': file_list_file_name = optarg; break; case 'o': diff --git a/compiler2/ttcn3/Statement.cc b/compiler2/ttcn3/Statement.cc index 2a29f7426b0d217078850a070b8eb62c81bdb184..3a108084c5d57fd865bbde90fdc0d89bd77e3953 100644 --- a/compiler2/ttcn3/Statement.cc +++ b/compiler2/ttcn3/Statement.cc @@ -3318,7 +3318,7 @@ error: msg_type = out_msgs->get_type_byIndex(0); } else { // there are more than one outgoing message types - msg_type = get_outgoing_type(port_op.s.sendpar); + msg_type = get_msg_sig_type(port_op.s.sendpar); if (msg_type) { size_t nof_comp_types = out_msgs->get_nof_compatible_types(msg_type); @@ -3351,7 +3351,7 @@ error: } // determining the message type if it is not done so far if (!msg_type_determined) { - msg_type = get_outgoing_type(port_op.s.sendpar); + msg_type = get_msg_sig_type(port_op.s.sendpar); } if (!msg_type) msg_type = Type::get_pooltype(Type::T_ERROR); // checking the parameter (template instance) @@ -3396,7 +3396,7 @@ error: signature = out_sigs->get_type_byIndex(0); } else { // there are more than one outgoing signatures - signature = get_outgoing_type(port_op.s.sendpar); + signature = get_msg_sig_type(port_op.s.sendpar); if (signature) { if (!out_sigs->has_type(signature)) { port_op.s.sendpar->error("Signature `%s' is not present on the " @@ -3421,7 +3421,7 @@ error: } } if (!signature_determined) - signature = get_outgoing_type(port_op.s.sendpar); + signature = get_msg_sig_type(port_op.s.sendpar); if (!signature) signature = Type::get_pooltype(Type::T_ERROR); // checking the parameter (template instance) port_op.s.sendpar->chk(signature); @@ -3504,7 +3504,7 @@ error: signature = in_sigs->get_type_byIndex(0); } else { // there are more than one incoming signatures - signature = get_outgoing_type(port_op.s.sendpar); + signature = get_msg_sig_type(port_op.s.sendpar); if (signature) { if (!in_sigs->has_type(signature)) { port_op.s.sendpar->error("Signature `%s' is not present on the " @@ -3529,7 +3529,7 @@ error: } } if (!signature_determined) - signature = get_outgoing_type(port_op.s.sendpar); + signature = get_msg_sig_type(port_op.s.sendpar); if (!signature) signature = Type::get_pooltype(Type::T_ERROR); // checking the parameter (template instance) port_op.s.sendpar->chk(signature); @@ -3625,7 +3625,7 @@ error: exc_type = exceptions->get_type_byIndex(0); } else { // the signature has more than one exception types - exc_type = get_outgoing_type(port_op.s.sendpar); + exc_type = get_msg_sig_type(port_op.s.sendpar); if (exc_type) { size_t nof_comp_types = exceptions->get_nof_compatible_types(exc_type); @@ -3653,7 +3653,7 @@ error: } // determining the type of exception if it is not done so far if (!exc_type_determined) { - exc_type = get_outgoing_type(port_op.s.sendpar); + exc_type = get_msg_sig_type(port_op.s.sendpar); } if (!exc_type) exc_type = Type::get_pooltype(Type::T_ERROR); // checking the exception template @@ -3707,7 +3707,7 @@ error: msg_type = in_msgs->get_type_byIndex(0); } else { // there are more than one incoming message types - msg_type = get_incoming_type(port_op.r.rcvpar, port_op.r.redirect.value); + msg_type = get_msg_sig_type(port_op.r.rcvpar); if (msg_type) { size_t nof_comp_types = in_msgs->get_nof_compatible_types(msg_type); @@ -3747,11 +3747,16 @@ error: } } if (!msg_type_determined) { - msg_type = get_incoming_type(port_op.r.rcvpar, port_op.r.redirect.value); + msg_type = get_msg_sig_type(port_op.r.rcvpar); } if (!msg_type) msg_type = Type::get_pooltype(Type::T_ERROR); // check the template instance using the message type port_op.r.rcvpar->chk(msg_type); + if (port_op.r.rcvpar->get_Template()->get_template_refd_last()-> + get_templatetype() == Template::ANY_OR_OMIT) { + port_op.r.rcvpar->error("'*' cannot be used as a matching template " + "for a '%s' operation", stmt_name); + } // check the value redirect if it exists if (port_op.r.redirect.value != NULL) { port_op.r.redirect.value->chk(msg_type); @@ -3805,7 +3810,7 @@ error: signature = in_sigs->get_type_byIndex(0); } else { // there are more than one incoming signatures - signature = get_outgoing_type(port_op.r.rcvpar); + signature = get_msg_sig_type(port_op.r.rcvpar); if (signature) { if (!in_sigs->has_type(signature)) { port_op.r.rcvpar->error("Signature `%s' is not present on the " @@ -3838,7 +3843,7 @@ error: } } if (!signature_determined) - signature = get_outgoing_type(port_op.r.rcvpar); + signature = get_msg_sig_type(port_op.r.rcvpar); if (!signature) signature = Type::get_pooltype(Type::T_ERROR); // checking the parameter (template instance) port_op.r.rcvpar->chk(signature); @@ -3909,7 +3914,7 @@ error: signature = out_sigs->get_type_byIndex(0); } else { // there are more than one outgoing signatures - signature = get_outgoing_type(port_op.r.rcvpar); + signature = get_msg_sig_type(port_op.r.rcvpar); if (signature) { if (!out_sigs->has_type(signature)) { port_op.r.rcvpar->error("Signature `%s' is not present on the " @@ -3950,7 +3955,7 @@ error: } } if (!signature_determined) - signature = get_outgoing_type(port_op.r.rcvpar); + signature = get_msg_sig_type(port_op.r.rcvpar); if (!signature) signature = Type::get_pooltype(Type::T_ERROR); // checking the parameter (template instance) port_op.r.rcvpar->chk(signature); @@ -3992,9 +3997,14 @@ error: } // checking the value match if present if (port_op.r.getreply_valuematch) { - Error_Context cntxt2(port_op.s.replyval, "In value match"); - if (!return_type) return_type = Type::get_pooltype(Type::T_ERROR); - port_op.r.getreply_valuematch->chk(return_type); + Error_Context cntxt2(port_op.s.replyval, "In value match"); + if (!return_type) return_type = Type::get_pooltype(Type::T_ERROR); + port_op.r.getreply_valuematch->chk(return_type); + if (port_op.r.getreply_valuematch->get_Template()->get_template_refd_last()-> + get_templatetype() == Template::ANY_OR_OMIT) { + port_op.r.getreply_valuematch->error("'*' cannot be used as a return " + "value matching template for a '%s' operation", stmt_name); + } } // checking the value redirect if present if (port_op.r.redirect.value != NULL) { @@ -4098,7 +4108,7 @@ error: exc_type = exceptions->get_type_byIndex(0); } else { // the signature has more than one exception types - exc_type = get_incoming_type(port_op.r.rcvpar, port_op.r.redirect.value); + exc_type = get_msg_sig_type(port_op.r.rcvpar); if (exc_type) { size_t nof_comp_types = exceptions->get_nof_compatible_types(exc_type); @@ -4125,11 +4135,16 @@ error: } } if (!exc_type_determined) { - exc_type = get_incoming_type(port_op.r.rcvpar, port_op.r.redirect.value); + exc_type = get_msg_sig_type(port_op.r.rcvpar); } if (!exc_type) exc_type = Type::get_pooltype(Type::T_ERROR); // check the template instance using the exception type port_op.r.rcvpar->chk(exc_type); + if (port_op.r.rcvpar->get_Template()->get_template_refd_last()-> + get_templatetype() == Template::ANY_OR_OMIT) { + port_op.r.rcvpar->error("'*' cannot be used as a matching template for " + "a '%s' operation", stmt_name); + } // check the value redirect if it exists if (port_op.r.redirect.value != NULL) { port_op.r.redirect.value->chk(exc_type); @@ -4405,8 +4420,7 @@ error: // specific component reference if (comp_op.donereturn.donematch) { // try to determine the type of the return value - Type *return_type = get_incoming_type(comp_op.donereturn.donematch, - comp_op.donereturn.redirect); + Type *return_type = get_msg_sig_type(comp_op.donereturn.donematch); if (return_type) { bool return_type_correct = false; for (Type *t = return_type; ; t = t->get_type_refd()) { @@ -4426,6 +4440,11 @@ error: return_type = Type::get_pooltype(Type::T_ERROR); } comp_op.donereturn.donematch->chk(return_type); + if (comp_op.donereturn.donematch->get_Template()->get_template_refd_last()-> + get_templatetype() == Template::ANY_OR_OMIT) { + comp_op.donereturn.donematch->error("'*' cannot be used as a matching " + "template for a 'done' operation"); + } if (comp_op.donereturn.redirect != NULL) { comp_op.donereturn.redirect->chk(return_type); } @@ -4977,7 +4996,7 @@ error: "not caught"); } - Type *Statement::get_outgoing_type(TemplateInstance *p_ti) + Type *Statement::get_msg_sig_type(TemplateInstance *p_ti) { // first analyze the template instance as is Type *ret_val = p_ti->get_expr_governor(Type::EXPECTED_TEMPLATE); @@ -4990,27 +5009,6 @@ error: return t_templ->get_expr_governor(Type::EXPECTED_TEMPLATE); } - Type *Statement::get_incoming_type(TemplateInstance *p_ti, - ValueRedirect *p_val_redir) - { - // first analyze the template instance - Type *ret_val = p_ti->get_expr_governor(Type::EXPECTED_TEMPLATE); - // return if this step was successful - if (ret_val) return ret_val; - // try to convert the undef identifier in the template instance to - // a reference because it cannot be an enum value anymore - Template *t_templ = p_ti->get_Template(); - t_templ->set_lowerid_to_ref(); - ret_val = t_templ->get_expr_governor(Type::EXPECTED_TEMPLATE); - // return if this step was successful - if (ret_val) return ret_val; - // finally try to determine the type from the value redirect - if (p_val_redir != NULL) { - ret_val = p_val_redir->get_type(); - } - return ret_val; - } - Type *Statement::chk_sender_redirect(Type *address_type) { if (!port_op.r.redirect.sender) return 0; diff --git a/compiler2/ttcn3/Statement.hh b/compiler2/ttcn3/Statement.hh index ee5714c858e2bc33f10d0c062b55a3788eb6e172..96b0f23bb4e7bb0526c185d91bbcdfb64fe80660 100644 --- a/compiler2/ttcn3/Statement.hh +++ b/compiler2/ttcn3/Statement.hh @@ -700,13 +700,9 @@ namespace Ttcn { * operation. Arguments \a port_type \a signature point to the * port type and signature used in the call operation. */ void chk_call_body(Type *port_type, Type *signature); - /** Determines and returns the type of the outgoing message or + /** Determines and returns the type of the incoming or outgoing message or * signature based on a template instance \a p_ti. */ - static Type *get_outgoing_type(TemplateInstance *p_ti); - /** Determines and returns the type of the incoming message or - * signature based on a template instance \a p_ti and an optional - * value redirect \a p_val_redir. */ - Type *get_incoming_type(TemplateInstance *p_ti, ValueRedirect *p_val_redir); + static Type *get_msg_sig_type(TemplateInstance *p_ti); /** Checks the variable reference of a sender redirect. The type * of the variable (or NULL in case of non-existent sender clause * or error) is returned. The type of the variable is also diff --git a/compiler2/ttcn3/Ttcnstuff.cc b/compiler2/ttcn3/Ttcnstuff.cc index 685cd4132a95402e67bb4ee043550655b5e1445d..21c2dcaceabb4f97ec6f2314a41b04ed66047e28 100644 --- a/compiler2/ttcn3/Ttcnstuff.cc +++ b/compiler2/ttcn3/Ttcnstuff.cc @@ -1867,6 +1867,7 @@ namespace Ttcn { signature->is_nonblocking_signature(); pdef.proc_in.elements[i].has_exceptions = signature->get_signature_exceptions() ? TRUE : FALSE; + pdef.proc_in.elements[i].has_return_value = FALSE; } } else { pdef.proc_in.nElements = 0; @@ -1886,6 +1887,8 @@ namespace Ttcn { signature->is_nonblocking_signature(); pdef.proc_out.elements[i].has_exceptions = signature->get_signature_exceptions() ? TRUE : FALSE; + pdef.proc_out.elements[i].has_return_value = + signature->get_signature_return_type() != NULL ? TRUE : FALSE; } } else { pdef.proc_out.nElements = 0; diff --git a/compiler2/ttcn3/port.c b/compiler2/ttcn3/port.c index fa0276e9182f18ad70aad552a445e0aa00e12e5a..175fdb6aad67f7b405925a4c0b1143ae8e620a49 100644 --- a/compiler2/ttcn3/port.c +++ b/compiler2/ttcn3/port.c @@ -573,6 +573,8 @@ static void generate_receive(char **def_ptr, char **src_ptr, "value_template, %s_Redirect_Interface *value_redirect, const %s_template& " "sender_template, %s *sender_ptr)\n" "{\n" + "if (value_template.get_selection() == ANY_OR_OMIT) " + "TTCN_error(\"%s operation using '*' as matching template\");\n" "msg_queue_item *my_head = (msg_queue_item*)msg_queue_head;\n" "if (msg_queue_head == NULL) {\n" "if (is_started) return ALT_MAYBE;\n" @@ -583,7 +585,7 @@ static void generate_receive(char **def_ptr, char **src_ptr, "return ALT_NO;\n" "}\n" "} else ", class_name, function_name, message_type->name, - message_type->name_w_no_prefix, sender_type, sender_type); + message_type->name_w_no_prefix, sender_type, sender_type, operation_name); if (is_address) { src = mputprintf(src, "if (my_head->sender_component != " "SYSTEM_COMPREF) {\n" @@ -1099,16 +1101,23 @@ static void generate_getreply(char **def_ptr, char **src_ptr, src = mputprintf(src, "alt_status %s::%s(const %s_template& " "getreply_template, const %s_template& sender_template, " "const %s_reply_redirect& param_ref, %s *sender_ptr)\n" - "{\n" + "{\n", class_name, function_name, signature->name, sender_type, + signature->name, sender_type); + if (signature->has_return_value) { + src = mputprintf(src, + "if (getreply_template.return_value().get_selection() == ANY_OR_OMIT) " + "TTCN_error(\"%s operation using '*' as return value matching template\");\n", + operation_name); + } + src = mputstr(src, "if (proc_queue_head == NULL) {\n" "if (is_started) return ALT_MAYBE;\n" "else {\n" "TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, \"Matching on " - "port %%s failed: Port is not started and the queue is empty.\", " + "port %s failed: Port is not started and the queue is empty.\", " "port_name);\n" "return ALT_NO;\n" - "}\n", class_name, function_name, signature->name, sender_type, - signature->name, sender_type); + "}\n"); if (is_address) { src = mputprintf(src, "} else if (proc_queue_head->sender_component != SYSTEM_COMPREF) " @@ -1221,6 +1230,8 @@ static void generate_catch(char **def_ptr, char **src_ptr, "catch_template, const %s_template& sender_template, " "%s *sender_ptr)\n" "{\n" + "if (catch_template.is_any_or_omit()) TTCN_error(\"%s operation using '*' " + "as matching template\");\n" "if (proc_queue_head == NULL) {\n" "if (is_started) return ALT_MAYBE;\n" "else {\n" @@ -1229,7 +1240,7 @@ static void generate_catch(char **def_ptr, char **src_ptr, "port_name);\n" "return ALT_NO;\n" "}\n", class_name, function_name, signature->name, sender_type, - sender_type); + sender_type, operation_name); if (is_address) { src = mputprintf(src, "} else if (proc_queue_head->sender_component != SYSTEM_COMPREF) " diff --git a/compiler2/ttcn3/port.h b/compiler2/ttcn3/port.h index e0673c0dcbc6d8b0e884681c8ed69abf6e31ddae..792b88aabd78f2f689d851dbe218219ac6938ed1 100644 --- a/compiler2/ttcn3/port.h +++ b/compiler2/ttcn3/port.h @@ -76,6 +76,7 @@ typedef struct port_proc_signature_tag { const char *dispname; boolean is_noblock; boolean has_exceptions; + boolean has_return_value; } port_proc_signature; typedef struct port_proc_signature_list_tag { diff --git a/compiler2/ttcn3/signature.c b/compiler2/ttcn3/signature.c index aac84fdcf202a63a5ddd6a05b4419953139ad4aa..70f57338f78154e50bb302c4d50d3c2c36b9a00a 100644 --- a/compiler2/ttcn3/signature.c +++ b/compiler2/ttcn3/signature.c @@ -689,7 +689,6 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output) /* value redirect base classes (interfaces) */ for (i = 0; i < sdef->exceptions.nElements; i++) { def = mputprintf(def, - "public:\n" "class %s_Redirect_Interface {\n" "public:\n" "virtual void set_values(const %s&) = 0;\n" @@ -852,6 +851,27 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output) "TTCN_error(\"Internal error: Invalid selector when performing " "value redirect on an exception of signature %s.\");\n" "}\n\n", dispname); + + /* is_any_or_omit function */ + def = mputprintf(def, "boolean is_any_or_omit() const;\n"); + src = mputprintf(src, + "boolean %s_exception_template::is_any_or_omit() const\n" + "{\n" + "switch (exception_selection) {\n", name); + for (i = 0; i < sdef->exceptions.nElements; i++) { + src = mputprintf(src, + "case %s_%s:\n" + "return field_%s->get_selection() == ANY_OR_OMIT;\n", + selection_prefix, sdef->exceptions.elements[i].altname, + sdef->exceptions.elements[i].altname); + } + src = mputprintf(src, + "default:\n" + "break;\n" + "}\n" + "TTCN_error(\"Internal error: Invalid selector when checking for '*' in " + "an exception template of signature %s.\");\n" + "}\n\n", dispname); def = mputstr(def, "};\n\n"); /* end of class xxx_exception_template */ diff --git a/function_test/Semantic_Analyser/TTCN3_SA_1_TD.script b/function_test/Semantic_Analyser/TTCN3_SA_1_TD.script index 32c25be3184a313a620df954eea827962c28b1be..e77b895612162bbf96326ffb83ac985f02be4267 100644 --- a/function_test/Semantic_Analyser/TTCN3_SA_1_TD.script +++ b/function_test/Semantic_Analyser/TTCN3_SA_1_TD.script @@ -6863,7 +6863,7 @@ module ModuleA { var MyCompType MyVar2; } // others should be covered in 'VariableRef' - altstep MyAltstep41() runs on MyCompType {[] MyPort2.catch(MyProc2, ?) -> value MyVar1 sender Nonexi41 {}} + altstep MyAltstep41() runs on MyCompType {[] MyPort2.catch(MyProc2, MyType1: ?) -> value MyVar1 sender Nonexi41 {}} } <END_MODULE> <RESULT IF_PASS COUNT 1> diff --git a/function_test/Semantic_Analyser/TTCN3_SA_ttcn3adhoc_TD.script b/function_test/Semantic_Analyser/TTCN3_SA_ttcn3adhoc_TD.script index dc803dc690265a6aeeb40ffecfcf147a627c97df..ca5b19b780ab8c73b9a40252ccfa6ff01b771ade 100644 --- a/function_test/Semantic_Analyser/TTCN3_SA_ttcn3adhoc_TD.script +++ b/function_test/Semantic_Analyser/TTCN3_SA_ttcn3adhoc_TD.script @@ -565,14 +565,14 @@ testcase TC() runs on MyComponent { var float F; alt { []any port.receive(integer:?) -> value I { } - []any port.check(receive(integer:*) -> value I) { } + []any port.check(receive(integer:?) -> value I) { } []any port.getcall(Sig:{0}) -> param(I) { } []any port.getreply(Sig:{0}) -> value J param(I) { } - []any port.catch(Sig, float:*) -> value F { } + []any port.catch(Sig, float:?) -> value F { } []any port.check(getcall(Sig:{0}) -> param(I)) { } []any port.check(getreply(Sig:{0}) -> value J param(I)) { } - []any port.check(catch(Sig, float:*) -> value F) { } + []any port.check(catch(Sig, float:?) -> value F) { } } } @@ -1374,6 +1374,80 @@ testcase TC() runs on MyComponent { :exmp. +.*---------------------------------------------------------------------* +:h3.Adhoc - port operation: '*' in matching template +.*---------------------------------------------------------------------* +:xmp tab=0. + +<TC - Adhoc - port operation: '*' in matching template> + +<COMPILE> +<VERDICT_LEAF PASS> +<MODULE TTCN Temp Temp.ttcn> +module Temp { + +type port PT message { + inout integer, charstring +} + +signature sig() return integer exception (integer, charstring); + +type port PT2 procedure { + inout sig +} + +type component CT { + port PT pt; + port PT2 pt2; +} + +template integer t := *; + +testcase TC() runs on CT { + var integer x; + alt { + [] pt.receive(*) { } + [] pt.receive(integer: *) -> value x { } + [] pt.receive(t) { } + [] pt2.getreply(sig: { } value *) -> value x { } + [] pt2.getreply(sig: { } value integer: *) { } + [] pt2.getreply(sig: { } value t) -> value x { } + [] pt2.catch(sig, *) { } + [] pt2.catch(sig, integer: *) -> value x { } + [] pt2.catch(sig, t) { } + [] pt.check(receive(*) -> value x) { } + [] pt.check(receive(integer: *)) { } + [] pt.check(receive(t) -> value x) { } + [] pt2.check(getreply(sig: { } value *)) { } + [] pt2.check(getreply(sig: { } value integer: *) -> value x) { } + [] pt2.check(getreply(sig: { } value t)) { } + [] pt2.check(catch(sig, *) -> value x) { } + [] pt2.check(catch(sig, integer: *)) { } + [] pt2.check(catch(sig, t) -> value x) { } + } +} + +} +<END_MODULE> +<RESULT COUNT 2> +(?im)Cannot.+?\bdetermine\b.+?the.+?\btype\b.+?of.+?the\b.+?incoming\b.+?message +<END_RESULT> +<RESULT COUNT 2> +(?im)Cannot.+?\bdetermine\b.+?the.+?\btype\b.+?of.+?the\b.+?exception +<END_RESULT> +<RESULT COUNT 18> +(?im)\'\*\'.+?\bcannot\b.+?be.+?\bused\b.+?as.+?matching\b.+?template\b.+?for\b.+?operation +<END_RESULT> +<RESULT COUNT 22> +(?is)\berror: +<END_RESULT> +<RESULT> +(?im)\bnotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b +<END_RESULT> +<END_TC> + +:exmp. + .*---------------------------------------------------------------------* :h3.Adhoc - component operation in control part .*---------------------------------------------------------------------* diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_pref1_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_pref1_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..808ba6a548242d542d5708ef15f722629b5177e2 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_pref1_e.ttcn @@ -0,0 +1,95 @@ +/******************************************************************************* +* Copyright (c) 2000-2016 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R5B01 +* +* 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_pref1_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Sep 29 08:47:37 2015 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - www_example_org_perf1_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/pref1/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_pref1_e { + + +import from XSD all; + + +import from www_example_org_pref2 all; + + +import from www_example_org_pref3 all; + + +type record MyElement_2 +{ + www_example_org_pref2.MyElement myElement optional, + www_example_org_pref2.MyElement2 myElement2 optional, + XSD.Integer myField, + www_example_org_pref2.MyType myField2, + www_example_org_pref2.MyElement myElement_1, + www_example_org_pref2.MyElement2 myElement2_1 +} +with { + variant "name as 'MyElement'"; + variant "element"; + variant (myElement) "name as capitalized"; + variant (myElement) "namespace as 'www.example.org/pref2' prefix 'ns2'"; + variant (myElement) "attribute"; + variant (myElement2) "name as capitalized"; + variant (myElement2) "namespace as 'www.example.org/pref2' prefix 'ns2'"; + variant (myElement2) "attribute"; + variant (myElement_1) "name as 'MyElement'"; + variant (myElement_1) "namespace as 'www.example.org/pref2' prefix 'ns2'"; + variant (myElement2_1) "name as 'MyElement2'"; + variant (myElement2_1) "namespace as 'www.example.org/pref2' prefix 'ns2'"; +}; + + +type www_example_org_pref2.MyElement MyElement +with { + variant "element"; +}; + + +type www_example_org_pref2.MyElement2 MyElement_1 +with { + variant "name as 'MyElement'"; + variant "element"; +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/pref1/e' prefix 'ns'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; + variant "elementFormQualified"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_pref2_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_pref2_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..8681260da827aa6f0d6bf8d1d7702b7bc2631160 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_pref2_e.ttcn @@ -0,0 +1,68 @@ +/******************************************************************************* +* Copyright (c) 2000-2016 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R5B01 +* +* 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_pref2_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Sep 29 08:47:37 2015 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - www_example_org_pref2_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/pref2/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_pref2 { + + +import from XSD all; + + +type MyType MyElement +with { + variant "element"; +}; + + +type MyType MyElement2 +with { + variant "element"; +}; + + +type record MyType +{ + XSD.Integer myField +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/pref2/e' prefix 'ns'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_pref3_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_pref3_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..8deff0c691e4a1f74b5c5a60a356dc8b2d82048e --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_pref3_e.ttcn @@ -0,0 +1,62 @@ +/******************************************************************************* +* Copyright (c) 2000-2016 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R5B01 +* +* 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_pref3_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Sep 29 08:47:37 2015 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - www_example_org_pref3_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/pref3/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_pref3 { + + +import from XSD all; + + +type MyType MyElement2 +with { + variant "element"; +}; + + +type record MyType +{ + XSD.Integer myField +}; + + +} +with { + encode "XML"; + variant "namespace as 'www.example.org/pref3/e' prefix 'ns'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/bin/prj2mk.pl b/regression_test/XML/XmlWorkflow/bin/prj2mk.pl index 84021f21b73b20effe15578bcdfc410f25d490e2..54f0f68ecaff894cbda52757ef5727c16b15d619 100644 --- a/regression_test/XML/XmlWorkflow/bin/prj2mk.pl +++ b/regression_test/XML/XmlWorkflow/bin/prj2mk.pl @@ -116,9 +116,9 @@ close FILE; # Generate the makefile print("LD_LIBRARY_PATH is $ENV{LD_LIBRARY_PATH}\n");#temporary debug printout -print("$ENV{TTCN3_DIR}/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -j files.txt $xsdfiles2 \n"); +print("$ENV{TTCN3_DIR}/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -J files.txt $xsdfiles2 \n"); -system( "\$TTCN3_DIR/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -o Makefile.1 -j files.txt $xsdfiles2"); +system( "\$TTCN3_DIR/bin/ttcn3_makefilegen -gs $split $rt2 -e XmlTest -o Makefile.1 -J files.txt $xsdfiles2"); unlink $outfile; diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest.prj b/regression_test/XML/XmlWorkflow/src/xmlTest.prj index 6c60f9bb1496c907aa1f07621704274a1aa7a505..df3e15608e4dc6aa8795339064de45c065ef1143 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj +++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj @@ -165,6 +165,9 @@ <File path="../xsd/list_complextype.xsd" /> <File path="../xsd/enumeration_restriction3.xsd" /> <File path="../xsd/MyXMLSchema.xsd" /> + <File path="../xsd/www_example_org_pref1.xsd" /> + <File path="../xsd/www_example_org_pref2.xsd" /> + <File path="../xsd/www_example_org_pref3.xsd" /> </File_Group> <File_Group name="XmlTest_xsds" > <File path="../XmlTest_xsds/XmlTest_boolean.xsd" /> @@ -400,6 +403,9 @@ <File path="../XmlTest_expectedTtcns/www_example_org_list_complextype_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_enumeration_restriction3_e.ttcn" /> <File path="../XmlTest_expectedTtcns/http_www_example_org_2001_XMLSchema_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_pref1_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_pref2_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_pref3_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 681e3887724a2edb4d5acd8149eff18fbe5dfe90..f47e971cca76b19a2f28c1728863219c443ae5e1 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn +++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn @@ -1812,6 +1812,23 @@ group ComplexType { } }//tc_ + testcase tc_ambiguous_type_namespace_prefix() runs on xmlTest_CT { + f_shellCommandWithVerdict(xsd2ttcn_command & " www_example_org_pref1.xsd www_example_org_pref2.xsd www_example_org_pref3.xsd","",c_shell_successWithoutWarningAndError); + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_pref1_e.ttcn","www_example_org_pref1.ttcn", c_numOfDiff_headerAndModuleName); + } + if(getverdict==pass) { + f_compareFiles( + "www_example_org_pref2_e.ttcn","www_example_org_pref2.ttcn", c_numOfDiff_headerAndModuleName); + } + if(getverdict==pass) { + f_compareFiles( + "www_example_org_pref3_e.ttcn","www_example_org_pref3.ttcn", c_numOfDiff_headerAndModuleName); + } + }//tc_ + //========================================================================= // tc_complex_any_pos1_encDec @@ -2683,6 +2700,7 @@ control { execute(tc_complex_import_nameCollision2_converter()); execute(tc_complex_any_pos_converter()); execute(tc_imported_type_prefix()); + execute(tc_ambiguous_type_namespace_prefix()); execute(tc_complex_any_pos1_encDec()); //Failed, TR: HL37887 execute(tc_complex_any_pos2_encDec()); execute(tc_complex_any_pos3_encDec());//failed, TR: diff --git a/regression_test/XML/XmlWorkflow/xsd/www_example_org_pref1.xsd b/regression_test/XML/XmlWorkflow/xsd/www_example_org_pref1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..d55221cf6aa75ebbb9b86dc6e82d1f40d2673227 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/www_example_org_pref1.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + elementFormDefault="qualified" + targetNamespace="www.example.org/pref1" + xmlns:ns="www.example.org/pref1" + xmlns:ns2="www.example.org/pref2" + xmlns:ns3="www.example.org/pref3"> + <import namespace="www_example_org_pref2" schemaLocation="www_example_org_pref2.xsd" /> + <import namespace="www_example_org_pref3" schemaLocation="www_example_org_pref3.xsd" /> + <element name="MyElement"> + <complexType> + <sequence> + <element name="myField" type="integer" /> + <element name="myField2" type="ns2:MyType"/> + <element ref="ns2:MyElement"/> + <element ref="ns2:MyElement2"/> + </sequence> + <attribute ref="ns2:MyElement"/> + <attribute ref="ns2:MyElement2"/> + </complexType> + </element> + + <element name="MyElement" type="ns2:MyElement"/> + + <element name="MyElement" type="ns2:MyElement2"/> + +</schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/www_example_org_pref2.xsd b/regression_test/XML/XmlWorkflow/xsd/www_example_org_pref2.xsd new file mode 100644 index 0000000000000000000000000000000000000000..4502f259e555eb32deecb1ea28a712e25f61c41c --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/www_example_org_pref2.xsd @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + elementFormDefault="unqualified" + targetNamespace="www.example.org/pref2" + xmlns:ns="www.example.org/pref2"> + <element name="MyElement" type="ns:MyType" /> + <element name="MyElement2" type="ns:MyType" /> + <complexType name="MyType"> + <sequence> + <element name="myField" type="integer" /> + </sequence> + </complexType> +</schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/www_example_org_pref3.xsd b/regression_test/XML/XmlWorkflow/xsd/www_example_org_pref3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..fefec8c141ce914a77f77fd0d60283ada08e3c0f --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/www_example_org_pref3.xsd @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + elementFormDefault="unqualified" + targetNamespace="www.example.org/pref3" + xmlns:ns="www.example.org/pref3"> + <element name="MyElement2" type="ns:MyType" /> + <complexType name="MyType"> + <sequence> + <element name="myField" type="integer" /> + </sequence> + </complexType> +</schema> diff --git a/regression_test/commMessage/TcommMessage.ttcn b/regression_test/commMessage/TcommMessage.ttcn index 96435e76a9d9868d8c9532fd0c109c5355de1144..ace360bbd1a200ccd19ba7f0076ce3d38bbf50cf 100644 --- a/regression_test/commMessage/TcommMessage.ttcn +++ b/regression_test/commMessage/TcommMessage.ttcn @@ -1609,6 +1609,46 @@ testcase commMessageDecodedValueRedirect() runs on commMessage_comp_dec { setverdict(pass); } +// '*' is not allowed as a matching template in receive operations +testcase commMessageReceiveAnyOrOmit() runs on commMessage_comp1 { + connect(self:Port1, self:Port1); + var template integer vt := *; + + // receive + Port1.send(5); + @try { + alt { + [] Port1.receive(vt) { } + } + setverdict(fail, "Receive operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, pattern "*Receive operation using '\*' as matching template")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (receive test): ", msg); + } + } + + // check-receive + Port1.send(5); + @try { + alt { + [] Port1.check(receive(vt)) { } + } + setverdict(fail, "Check-receive operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, pattern "*Check-receive operation using '\*' as matching template")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (check-receive test): ", msg); + } + } +} + control { execute(commMessageIntegerEncode()); execute(commMessageValue()); @@ -1650,5 +1690,6 @@ control { execute(commMessageDualFacedPorts2()); execute(commMessageMultiValueRedirect()); execute(commMessageDecodedValueRedirect()); + execute(commMessageReceiveAnyOrOmit()); } } diff --git a/regression_test/commProcedure/ProcPort.ttcn b/regression_test/commProcedure/ProcPort.ttcn index c15fb44d6d2300a1e03d838bf8967955cfb45520..c01431f853e96de27269df13a3ec884082fb97fa 100644 --- a/regression_test/commProcedure/ProcPort.ttcn +++ b/regression_test/commProcedure/ProcPort.ttcn @@ -172,6 +172,11 @@ type port ProcPort4 procedure { } with { extension "internal" } +type port ProcPort5 procedure { + inout MyProc; +} +with { extension "internal" } + type component ProcComponent { port ProcPort1 Port0; @@ -209,6 +214,10 @@ type component ProcComponent4 { port ProcPort4 Port4; } +type component ProcComponent5 { + port ProcPort5 Port5; +} + function GetCall_behav1() runs on ProcComponent2 { while(true) { alt { @@ -1090,6 +1099,82 @@ testcase tc_DecodedRedirect4() runs on ProcComponent4 { setverdict(pass); } +// '*' is not allowed as a matching template for the return value +// in getreply operations or for the exception in catch operations +testcase tc_MatchingWithAnyOrOmit() runs on ProcComponent5 { + connect(self:Port5, self:Port5); + var template boolean vt_bool := *; + var template integer vt_int := *; + + // getreply + Port5.reply(MyProc: { -, "a", 0.1 } value false); + @try { + alt { + [] Port5.getreply(MyProc: { ?, ?, ? } value vt_bool) { } + } + setverdict(fail, "Getreply operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, pattern "*Getreply operation using '\*' as return value matching template")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (getreply test): ", msg); + } + } + + // check-getreply + Port5.reply(MyProc: { -, "a", 0.1 } value false); + @try { + alt { + [] Port5.check(getreply(MyProc: { ?, ?, ? } value vt_bool)) { } + } + setverdict(fail, "Check-getreply operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, pattern "*Check-getreply operation using '\*' as return value matching template")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (check-getreply test): ", msg); + } + } + + // catch + Port5.raise(MyProc, 10); + @try { + alt { + [] Port5.catch(MyProc, vt_int) { } + } + setverdict(fail, "Catch operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, pattern "*Catch operation using '\*' as matching template")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (catch test): ", msg); + } + } + + // check-catch + Port5.raise(MyProc, 10); + @try { + alt { + [] Port5.check(catch(MyProc, vt_int)) { } + } + setverdict(fail, "Check-catch operation succeeded. Expected error."); + } + @catch (msg) { + if (match(msg, pattern "*Check-catch operation using '\*' as matching template")) { + setverdict(pass); + } + else { + setverdict(fail, "Incorrect error message received (check-catch test): ", msg); + } + } +} + control { execute(tc1_Call()); execute(tc2_Call()); @@ -1109,5 +1194,6 @@ control { execute(tc_DecodedRedirect2()); execute(tc_DecodedRedirect3()); execute(tc_DecodedRedirect4()); + execute(tc_MatchingWithAnyOrOmit()); } } diff --git a/regression_test/compileonly/readFromFile/Makefile b/regression_test/compileonly/readFromFile/Makefile index ecd3814cd432e7835dd2ef9aad5e7cd2669d1b91..7e3ef05bf942a4152272d9fc8283443acfae48a4 100644 --- a/regression_test/compileonly/readFromFile/Makefile +++ b/regression_test/compileonly/readFromFile/Makefile @@ -17,7 +17,9 @@ COVERAGE_FLAG := -C endif MFGEN := $(TTCN3_DIR)/bin/ttcn3_makefilegen -MFGEN_FLAGS := -f $(RT2_FLAG) $(SPLIT_FLAG) +MFGEN_FLAGS := -fs $(RT2_FLAG) $(SPLIT_FLAG) -e Main +COMPILER := $(TTCN3_DIR)/bin/ttcn3_compiler +COMPILER_FLAGS := $(RT2_FLAG) $(SPLIT_FLAG) # ${MAKEPROG} has the same content as the built-in ${MAKE}, # except the special handling of ${MAKE} does not apply. @@ -25,8 +27,24 @@ MFGEN_FLAGS := -f $(RT2_FLAG) $(SPLIT_FLAG) # then fail on every subsequent invocation until a 'make clean' is done. MAKEPROG := ${MAKE} -all: - mkdir -p bin && cp files.txt bin/files.txt && cd bin && $(MFGEN) $(MFGEN_FLAGS) -j files.txt \ - && $(MAKEPROG) && make clean && cd .. && rm -rf bin +all: compiler makefile -.PHONY: all clean distclean run +compiler: + mkdir -p bin && cp compiler_files1.txt bin/files.txt && cd bin \ + && $(COMPILER) $(COMPILER_FLAGS) -J files.txt ../src/ASN1Module3.asn \ + && cd .. && rm -rf bin + + mkdir -p bin && cp compiler_files2.txt bin/files.txt && cd bin \ + && $(COMPILER) $(COMPILER_FLAGS) -J files.txt ../src/ASN1Module3.asn \ + && cd .. && rm -rf bin + +makefile: + mkdir -p bin && cp mfgen_files1.txt bin/files.txt && cd bin \ + && $(MFGEN) $(MFGEN_FLAGS) -J files.txt ../src/ASN1Module3.asn \ + && $(MAKEPROG) && ./Main && make clean && cd .. && rm -rf bin + + mkdir -p bin && cp mfgen_files2.txt bin/files.txt && cd bin \ + && $(MFGEN) $(MFGEN_FLAGS) -J files.txt ../src/ASN1Module3.asn \ + && $(MAKEPROG) && ./Main && make clean && cd .. && rm -rf bin + +.PHONY: all clean distclean run compiler makefile diff --git a/regression_test/compileonly/readFromFile/compiler_files1.txt b/regression_test/compileonly/readFromFile/compiler_files1.txt new file mode 100644 index 0000000000000000000000000000000000000000..ffa25e65f3ea76848641d7a7b6e8dc4413368085 --- /dev/null +++ b/regression_test/compileonly/readFromFile/compiler_files1.txt @@ -0,0 +1 @@ +../src/UsefulTtcn3Types.ttcn ../src/XSD.ttcn ../src/Module1.ttcn ../src/Module2.ttcn ../src/Module3.ttcn ../src/Module4.ttcn ../src/Module5.ttcn ../src/ASN1Module1.asn ../src/ASN1Module2.asn ../src/Main.ttcn \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/compiler_files2.txt b/regression_test/compileonly/readFromFile/compiler_files2.txt new file mode 100644 index 0000000000000000000000000000000000000000..3041a7225b1d84c33eaa24eccb74f2e24aed0b18 --- /dev/null +++ b/regression_test/compileonly/readFromFile/compiler_files2.txt @@ -0,0 +1,29 @@ + + + + ../src/UsefulTtcn3Types.ttcn + + -T ../src/XSD.ttcn + + + ../src/Module1.ttcn -T + + + ../src/Module2.ttcn + + + ../src/Module3.ttcn -T ../src/Module4.ttcn ../src/Module5.ttcn -A + + + + + + + ../src/ASN1Module1.asn -A../src/ASN1Module2.asn + + + + + + + -T../src/Main.ttcn \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/files.txt b/regression_test/compileonly/readFromFile/files.txt deleted file mode 100644 index 836ca8b34956c00dc6d4c0e00f397e3181efc2d6..0000000000000000000000000000000000000000 --- a/regression_test/compileonly/readFromFile/files.txt +++ /dev/null @@ -1,5 +0,0 @@ - ../src/Definitions.xsd ../src/MainNormal.ttcn - - - - ../src/MainExtNormal.ttcn \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/mfgen_files1.txt b/regression_test/compileonly/readFromFile/mfgen_files1.txt new file mode 100644 index 0000000000000000000000000000000000000000..ffa25e65f3ea76848641d7a7b6e8dc4413368085 --- /dev/null +++ b/regression_test/compileonly/readFromFile/mfgen_files1.txt @@ -0,0 +1 @@ +../src/UsefulTtcn3Types.ttcn ../src/XSD.ttcn ../src/Module1.ttcn ../src/Module2.ttcn ../src/Module3.ttcn ../src/Module4.ttcn ../src/Module5.ttcn ../src/ASN1Module1.asn ../src/ASN1Module2.asn ../src/Main.ttcn \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/mfgen_files2.txt b/regression_test/compileonly/readFromFile/mfgen_files2.txt new file mode 100644 index 0000000000000000000000000000000000000000..26b40d0e0951a98a8620d8456ef049de31c2da8b --- /dev/null +++ b/regression_test/compileonly/readFromFile/mfgen_files2.txt @@ -0,0 +1,31 @@ + + + + ../src/UsefulTtcn3Types.ttcn + + ../src/XSD.ttcn + + + ../src/Module1.ttcn + + + ../src/Module2.ttcn + + + ../src/Module3.ttcn ../src/Module4.ttcn ../src/Module5.ttcn + + + + + + + ../src/ASN1Module1.asn ../src/ASN1Module2.asn + + + + + + + + + ../src/Main.ttcn \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/ASN1Module1.asn b/regression_test/compileonly/readFromFile/src/ASN1Module1.asn new file mode 100644 index 0000000000000000000000000000000000000000..dac6b4c59846892d38fa37db378987851b4fe202 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/ASN1Module1.asn @@ -0,0 +1,25 @@ +--///////////////////////////////////////////////////////////////////////////// +-- 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 +-- +--///////////////////////////////////////////////////////////////////////////// +ASN1Module1 +DEFINITIONS + +AUTOMATIC TAGS + +::= + +BEGIN + +IMPORTS ; -- nothing + +asn1module1 INTEGER ::= 1 + +END \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/ASN1Module2.asn b/regression_test/compileonly/readFromFile/src/ASN1Module2.asn new file mode 100644 index 0000000000000000000000000000000000000000..75988338d0c3b7c5764bfc146656d2d6382e0a02 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/ASN1Module2.asn @@ -0,0 +1,25 @@ +--///////////////////////////////////////////////////////////////////////////// +-- 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 +-- +--///////////////////////////////////////////////////////////////////////////// +ASN1Module2 +DEFINITIONS + +AUTOMATIC TAGS + +::= + +BEGIN + +IMPORTS ; -- nothing + +asn1module2 INTEGER ::= 2 + +END \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/ASN1Module3.asn b/regression_test/compileonly/readFromFile/src/ASN1Module3.asn new file mode 100644 index 0000000000000000000000000000000000000000..7764bee53ab0cbcd4cda519a5457e87ae02e5f36 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/ASN1Module3.asn @@ -0,0 +1,25 @@ +--///////////////////////////////////////////////////////////////////////////// +-- 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 +-- +--///////////////////////////////////////////////////////////////////////////// +ASN1Module3 +DEFINITIONS + +AUTOMATIC TAGS + +::= + +BEGIN + +IMPORTS ; -- nothing + +asn1module3 INTEGER ::= 3 + +END \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/Definitions.xsd b/regression_test/compileonly/readFromFile/src/Definitions.xsd deleted file mode 100644 index 497f1dc98d0ac8a56d8ee3dfcdbdd5dd879a2847..0000000000000000000000000000000000000000 --- a/regression_test/compileonly/readFromFile/src/Definitions.xsd +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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 ---> -<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" -xmlns:xsd="http://www.w3.org/2001/XMLSchema" -xmlns:this="www.example.org/Definitions" -targetNamespace="www.example.org/Definitions"> - -<xsd:element name="MyInt" type="xsd:integer"/> - -</xsd:schema> diff --git a/regression_test/compileonly/readFromFile/src/Main.ttcn b/regression_test/compileonly/readFromFile/src/Main.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..f3e9dbd16bb9f18d6b5524e394ec11ae69db9071 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/Main.ttcn @@ -0,0 +1,40 @@ +/****************************************************************************** + * 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 Main { + import from Module1 all; + import from Module2 all; + import from Module3 all; + import from Module4 all; + import from Module5 all; + import from ASN1Module1 language "ASN.1:2002" all; + import from ASN1Module2 language "ASN.1:2002" all; + import from ASN1Module3 language "ASN.1:2002" all; + import from XSD all; + import from UsefulTtcn3Types all; + + type component EmptyCT {} + + testcase tc_test() runs on EmptyCT { + var XSD.Integer sum := module1 + module2 + module3 + module4 + module5 + + asn1module1 + asn1module2 + asn1module3; + if (sum == 21) { + setverdict(pass); + } else { + setverdict(fail); + } + } + + control { + execute(tc_test()); + } + +} \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/MainNormal.ttcn b/regression_test/compileonly/readFromFile/src/Module1.ttcn similarity index 66% rename from regression_test/compileonly/readFromFile/src/MainNormal.ttcn rename to regression_test/compileonly/readFromFile/src/Module1.ttcn index 64b797c0b89cb2688d6f8792e0b9b6116ad102e5..c7fb83c51e1707b3630c9d90d80cf22433eded35 100644 --- a/regression_test/compileonly/readFromFile/src/MainNormal.ttcn +++ b/regression_test/compileonly/readFromFile/src/Module1.ttcn @@ -9,25 +9,6 @@ * Szabo, Bence Janos * ******************************************************************************/ -module MainNormal { - - -type component EmptyCT {} - -const integer myInt := 5; - -testcase tc_test() runs on EmptyCT { - var integer tempInt := myInt; - if (tempInt == 5) { - setverdict(pass); - } else { - setverdict(fail); - } -} - -control { - execute(tc_test()); -} - -} - + module Module1{ + const integer module1 := 1; +} \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/MainExtNormal.ttcn b/regression_test/compileonly/readFromFile/src/Module2.ttcn similarity index 53% rename from regression_test/compileonly/readFromFile/src/MainExtNormal.ttcn rename to regression_test/compileonly/readFromFile/src/Module2.ttcn index 5a580d67b24734758f9c8ec04b20d6d17260dc58..e1129a7074f35d637a89a1ba38955f5c290cee92 100644 --- a/regression_test/compileonly/readFromFile/src/MainExtNormal.ttcn +++ b/regression_test/compileonly/readFromFile/src/Module2.ttcn @@ -9,32 +9,6 @@ * Szabo, Bence Janos * ******************************************************************************/ -module MainExtNormal { - -import from MainNormal all; - -type component EmptyCT {} - -const universal charstring myString := "almafa"; - -testcase tc_test() runs on EmptyCT { - var universal charstring tempString := myString; - if (tempString == "almafa") { - setverdict(pass); - } else { - setverdict(fail); - } - var integer tempInt := 5; - if (tempInt == 5) { - setverdict(pass); - } else { - setverdict(fail); - } -} - -control { - execute(tc_test()); -} - -} - + module Module2{ + const integer module2 := 2; +} \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/Module3.ttcn b/regression_test/compileonly/readFromFile/src/Module3.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..41c63ceb99e6bb111ac755151193ab1fd19a2680 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/Module3.ttcn @@ -0,0 +1,14 @@ +/****************************************************************************** + * 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 Module3{ + const integer module3 := 3; +} \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/Module4.ttcn b/regression_test/compileonly/readFromFile/src/Module4.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..a171970b7cebbec0a11e1602952169c1826baf79 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/Module4.ttcn @@ -0,0 +1,14 @@ +/****************************************************************************** + * 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 Module4{ + const integer module4 := 4; +} \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/Module5.ttcn b/regression_test/compileonly/readFromFile/src/Module5.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..54e60c665d6deb5f3a2d4c0c02c18dd4dc72eb63 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/Module5.ttcn @@ -0,0 +1,14 @@ +/****************************************************************************** + * 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 Module5{ + const integer module5 := 5; +} \ No newline at end of file diff --git a/regression_test/compileonly/readFromFile/src/UsefulTtcn3Types.ttcn b/regression_test/compileonly/readFromFile/src/UsefulTtcn3Types.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..3d91ab24b5d0e6d912cf8182d5375c18bfb84a94 --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/UsefulTtcn3Types.ttcn @@ -0,0 +1,86 @@ +/****************************************************************************** + * 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 UsefulTtcn3Types { + + + type integer byte (-128 .. 127) with { variant "/* 8 bit */" }; + + type integer unsignedbyte (0 .. 255) with { variant "/*unsigned 8 bit*/" }; + + type integer short (-32768 .. 32767) with { variant "/*16 bit*/" }; + + type integer unsignedshort (0 .. 65535) with { variant "/*unsigned 16 bit*/" }; + + type integer long (-2147483648 .. 2147483647) with { variant "/*32 bit*/" }; + + type integer unsignedlong (0 .. 4294967295) with { variant "/*unsigned 32 bit*/" }; + + type integer longlong /* ( -9223372036854775808 .. 9223372036854775807 ) */ with { variant "/*64 bit*/" }; + + type integer unsignedlonglong /* ( 0 .. 18446744073709551615 ) */ with { variant "/*unsigned 64 bit*/" }; + + type float IEEE754float with { variant "/*IEEE754 float*/" }; + + type float IEEE754double with { variant "/*IEEE754 double*/" }; + + type float IEEE754extfloat with { variant "/*IEEE754 extended float*/" }; + + type float IEEE754extdouble with { variant "/*IEEE754 extended double*/" }; + + type universal charstring utf8string with { variant "/*UTF-8*/" }; + + type universal charstring bmpstring ( char ( 0,0,0,0 ) .. char ( 0,0,255,255) ) with { variant "/*UCS-2*/" }; + + type universal charstring utf16string ( char ( 0,0,0,0 ) .. char ( 0,16,255,255) ) with { variant "/*UTF-16*/" }; + + type universal charstring iso8859string ( char ( 0,0,0,0 ) .. char ( 0,0,0,255) ) with { variant "/*8 bit*/" }; + + type record IDLfixed + { + unsignedshort digits, + short scale, + charstring value_ + } + with { + variant "/*IDL:fixed FORMAL/01-12-01 v.2.6*/"; + }; + + /* + type charstring char length (1); + + NOTE 1: The name of this useful type is the same as the TTCN-3 keyword used to denote universal + charstring values in the quadraple form. In general it is disallowed to use TTCN-3 keywords as + identifiers. The "char" useful type is a solitary exception and allowed only for backward compatibility + with previous versions of the TTCN-3 standard. (except Titan doesn't) + + NOTE 2: The special string "8 bit" defined in clause 28.2.3 may be used with this type to specify a given encoding + for its values. Also, other properties of the base type can be changed by using attribute mechanisms. + */ + + type universal charstring uchar length (1); + + /* + NOTE: Special strings defined in clause 28.2.3 except "8 bit" may be used with this type to specify a given + encoding for its values. Also, other properties of the base type can be changed by using attribute + mechanisms. + */ + + type bitstring bit length (1); + + type hexstring hex length (1); + + type octetstring octet length (1); + +} +with { +encode "XML"; +} diff --git a/regression_test/compileonly/readFromFile/src/XSD.ttcn b/regression_test/compileonly/readFromFile/src/XSD.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..af65a6e8de24c2e599c6962c43ba4a5da697449d --- /dev/null +++ b/regression_test/compileonly/readFromFile/src/XSD.ttcn @@ -0,0 +1,328 @@ +/****************************************************************************** + * 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 XSD { + +import from UsefulTtcn3Types all; + +//These constants are used in the XSD date/time type definitions +const charstring + dash := "-", + cln := ":", + year := "[0-9]#4", + yearExpansion := "(-([1-9][0-9]#(0,))#(,1))#(,1)", + month := "(0[1-9]|1[0-2])", + dayOfMonth := "(0[1-9]|[12][0-9]|3[01])", + hour := "([01][0-9]|2[0-3])", + minute := "([0-5][0-9])", + second := "([0-5][0-9])", + sFraction := "(.[0-9]#(1,))#(,1)", + endOfDayExt := "24:00:00(.0#(1,))#(,1)", + nums := "[0-9]#(1,)", + ZorTimeZoneExt := "(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))#(,1)", + durTime := "(T[0-9]#(1,)"& + "(H([0-9]#(1,)(M([0-9]#(1,)(S|.[0-9]#(1,)S))#(,1)|.[0-9]#(1,)S|S))#(,1)|"& + "M([0-9]#(1,)(S|.[0-9]#(1,)S)|.[0-9]#(1,)M)#(,1)|"& + "S|"& + ".[0-9]#(1,)S))" + +//anySimpleType + +type XMLCompatibleString AnySimpleType +with { +variant "XSD:anySimpleType"; +}; + +//anyType; + +type record AnyType +{ + record of String embed_values optional, + record of String attr optional, + record of String elem_list +} +with { +variant "XSD:anyType"; +variant "embedValues"; +variant (attr) "anyAttributes"; +variant (elem_list) "anyElement"; +}; +// String types + +type XMLCompatibleString String +with { +variant "XSD:string"; +}; + +type XMLStringWithNoCRLFHT NormalizedString +with { +variant "XSD:normalizedString"; +}; + +type NormalizedString Token +with { +variant "XSD:token"; +}; + +type XMLStringWithNoWhitespace Name +with { +variant "XSD:Name"; +}; + +type XMLStringWithNoWhitespace NMTOKEN +with { +variant "XSD:NMTOKEN"; +}; + +type Name NCName +with { +variant "XSD:NCName"; +}; + +type NCName ID +with { +variant "XSD:ID"; +}; + +type NCName IDREF +with { +variant "XSD:IDREF"; +}; + +type NCName ENTITY +with { +variant "XSD:ENTITY"; +}; + +type octetstring HexBinary +with { +variant "XSD:hexBinary"; +}; + +type octetstring Base64Binary +with { +variant "XSD:base64Binary"; +}; + +type XMLStringWithNoCRLFHT AnyURI +with { +variant "XSD:anyURI"; +}; + +type charstring Language (pattern "[a-zA-Z]#(1,8)(-\w#(1,8))#(0,)") +with { +variant "XSD:language"; +}; +// Integer types + +type integer Integer +with { +variant "XSD:integer"; +}; + +type integer PositiveInteger (1 .. infinity) +with { +variant "XSD:positiveInteger"; +}; + +type integer NonPositiveInteger (-infinity .. 0) +with { +variant "XSD:nonPositiveInteger"; +}; + +type integer NegativeInteger (-infinity .. -1) +with { +variant "XSD:negativeInteger"; +}; + +type integer NonNegativeInteger (0 .. infinity) +with { +variant "XSD:nonNegativeInteger"; +}; + +type longlong Long +with { +variant "XSD:long"; +}; + +type unsignedlonglong UnsignedLong +with { +variant "XSD:unsignedLong"; +}; + +type long Int +with { +variant "XSD:int"; +}; + +type unsignedlong UnsignedInt +with { +variant "XSD:unsignedInt"; +}; + +type short Short +with { +variant "XSD:short"; +}; + +type unsignedshort UnsignedShort +with { +variant "XSD:unsignedShort"; +}; + +type byte Byte +with { +variant "XSD:byte"; +}; + +type unsignedbyte UnsignedByte +with { +variant "XSD:unsignedByte"; +}; + +// Float types + +type float Decimal +with { +variant "XSD:decimal"; +}; + +type IEEE754float Float +with { +variant "XSD:float"; +}; + +type IEEE754double Double +with { +variant "XSD:double"; +}; + +// Time types + +type charstring Duration (pattern + "{dash}#(,1)P({nums}(Y({nums}(M({nums}D{durTime}#(,1)|{durTime}#(,1))|D{durTime}#(,1))|" & + "{durTime}#(,1))|M({nums}D{durTime}#(,1)|{durTime}#(,1))|D{durTime}#(,1))|{durTime})") +with { +variant "XSD:duration"; +}; + +type charstring DateTime (pattern + "{yearExpansion}{year}{dash}{month}{dash}{dayOfMonth}T({hour}{cln}{minute}{cln}{second}" & + "{sFraction}|{endOfDayExt}){ZorTimeZoneExt}" ) +with { +variant "XSD:dateTime"; +}; + +type charstring Time (pattern + "({hour}{cln}{minute}{cln}{second}{sFraction}|{endOfDayExt}){ZorTimeZoneExt}" ) +with { +variant "XSD:time"; +}; + +type charstring Date (pattern + "{yearExpansion}{year}{dash}{month}{dash}{dayOfMonth}{ZorTimeZoneExt}" ) +with { +variant "XSD:date"; +}; + +type charstring GYearMonth (pattern + "{yearExpansion}{year}{dash}{month}{ZorTimeZoneExt}" ) +with { +variant "XSD:gYearMonth"; +}; + +type charstring GYear (pattern + "{yearExpansion}{year}{ZorTimeZoneExt}" ) +with { +variant "XSD:gYear"; +}; + +type charstring GMonthDay (pattern + "{dash}{dash}{month}{dash}{dayOfMonth}{ZorTimeZoneExt}" ) +with { +variant "XSD:gMonthDay"; +}; + +type charstring GDay (pattern + "{dash}{dash}{dash}{dayOfMonth}{ZorTimeZoneExt}" ) +with { +variant "XSD:gDay"; +}; + +type charstring GMonth (pattern + "{dash}{dash}{month}{ZorTimeZoneExt}" ) +with { +variant "XSD:gMonth"; +}; + +// Sequence types + +type record of NMTOKEN NMTOKENS +with { +variant "XSD:NMTOKENS"; +}; + +type record of IDREF IDREFS +with { +variant "XSD:IDREFS"; +}; + +type record of ENTITY ENTITIES +with { +variant "XSD:ENTITIES"; +}; + +type record QName +{ + AnyURI uri optional, + NCName name +} +with { +variant "XSD:QName"; +}; + +// Boolean type + +type boolean Boolean +with { +variant "XSD:boolean"; +}; + +//TTCN-3 type definitions supporting the mapping of W3C XML Schema built-in datatypes + +type utf8string XMLCompatibleString +( + char(0,0,0,9)..char(0,0,0,9), + char(0,0,0,10)..char(0,0,0,10), + char(0,0,0,13)..char(0,0,0,13), + char(0,0,0,32)..char(0,0,215,255), + char(0,0,224,0)..char(0,0,255,253), + char(0,1,0,0)..char(0,16,255,253) +) + +type utf8string XMLStringWithNoWhitespace +( + char(0,0,0,33)..char(0,0,215,255), + char(0,0,224,0)..char(0,0,255,253), + char(0,1,0,0)..char(0,16,255,253) +) + +type utf8string XMLStringWithNoCRLFHT +( + char(0,0,0,32)..char(0,0,215,255), + char(0,0,224,0)..char(0,0,255,253), + char(0,1,0,0)..char(0,16,255,253) +) + +} +with{ +encode "XML" +} diff --git a/regression_test/implicitMsgEncoding/TimplicitEnc.ttcn b/regression_test/implicitMsgEncoding/TimplicitEnc.ttcn index 2d094ce252d63b04ba921a5185bbdc4aa8452514..47e9e26a1cac96c391cf8b17e50aa3f59155958a 100644 --- a/regression_test/implicitMsgEncoding/TimplicitEnc.ttcn +++ b/regression_test/implicitMsgEncoding/TimplicitEnc.ttcn @@ -193,7 +193,7 @@ module TimplicitEnc P.send(3.14); f_PReceiveCharstring("3.140000", 1.0); P.send(mypdu); - P.receive(?) -> value mypdu; + P.receive(MyPDU: ?) -> value mypdu; diff --git a/regression_test/logFiles/CommonStuff.ttcn b/regression_test/logFiles/CommonStuff.ttcn index 515bac9bbdd3a240b4f3bbe801579b1b71a911f7..acd1d6756cb0690916c185380ff8aa4706fd045d 100644 --- a/regression_test/logFiles/CommonStuff.ttcn +++ b/regression_test/logFiles/CommonStuff.ttcn @@ -729,7 +729,7 @@ private altstep as_EPTF_Base_stopAllComponents() runs on EPTF_Base_CT_private { private altstep as_handle_main_EPTF_Base_MgmtIf() runs on EPTF_Base_CT_private { var EPTF_Base_MgmtMsg vl_EPTF_Base_MgmtIf_msg; var EPTF_Base_CT vl_EPTF_Base_MgmtIf_msg_sender; - [] EPTF_Base_MgmtIf.receive(*) -> value vl_EPTF_Base_MgmtIf_msg sender vl_EPTF_Base_MgmtIf_msg_sender { + [] EPTF_Base_MgmtIf.receive(?) -> value vl_EPTF_Base_MgmtIf_msg sender vl_EPTF_Base_MgmtIf_msg_sender { if (f_handle_main_EPTF_Base_MgmtIf(vl_EPTF_Base_MgmtIf_msg,vl_EPTF_Base_MgmtIf_msg_sender)) {repeat;} } [] as_EPTF_Base_stopAllComponents(); diff --git a/usrguide/referenceguide.doc b/usrguide/referenceguide.doc index a8ca4d9e14b097535084a653f30472824c13139a..b59bc15c0d7ad0dd19ec9c7e706702660face78e 100644 Binary files a/usrguide/referenceguide.doc and b/usrguide/referenceguide.doc differ diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc index 130189a24991342fa8f41cf844505eac48c68bfb..9e0ddb9e5a21acc1e1956742d4110a1776237fbc 100644 --- a/xsdconvert/ComplexType.cc +++ b/xsdconvert/ComplexType.cc @@ -1616,7 +1616,8 @@ void ComplexType::resolveAttribute(AttributeType* attr) { if (st->getType().convertedValue == "record" || st->getType().convertedValue == "union") { st->addToNameDepList(attr); } - } + } + attr->getReference().set_resolved(st); } else { printError(module->getSchemaname(), name.convertedValue, "Reference for a non-defined type: " + attr->getReference().repr()); diff --git a/xsdconvert/GeneralFunctions.cc b/xsdconvert/GeneralFunctions.cc index 4c7a4780b5801282171eff6fd01177014d94e967..d0c6e85e197c68f14bc85509946380b5d74f89b0 100644 --- a/xsdconvert/GeneralFunctions.cc +++ b/xsdconvert/GeneralFunctions.cc @@ -729,7 +729,10 @@ int multi(const TTCN3Module *module, ReferenceData const& outside_reference, RootType * ct = ::lookup1(module, outside_reference.get_val(), outside_reference.get_uri(), obj, want_CT); if (st || ct) { multiplicity = 1; // locally defined, no qualif needed - } else for (List<const TTCN3Module*>::iterator it = module->getImportedModules().begin(); it; it = it->Next) { + // means that outside_reference.get_uri() == module->getTargetNamespace()) + } else { + // Look for definitions in the imported modules + for (List<const TTCN3Module*>::iterator it = module->getImportedModules().begin(); it; it = it->Next) { // Artificial lookup st = ::lookup1(it->Data, outside_reference.get_val(), it->Data->getTargetNamespace(), obj, want_ST); ct = ::lookup1(it->Data, outside_reference.get_val(), it->Data->getTargetNamespace(), obj, want_CT); @@ -737,6 +740,17 @@ int multi(const TTCN3Module *module, ReferenceData const& outside_reference, ++multiplicity; } } + // If multiplicity > 1 then the qualif needed + // But if == 1 we need to check this module for a type definition with + // the same name as outsize_reference.get_val() + if (multiplicity == 1) { + st = ::lookup1(module, outside_reference.get_val(), module->getTargetNamespace(), obj, want_ST); + ct = ::lookup1(module, outside_reference.get_val(), module->getTargetNamespace(), obj, want_CT); + if (st || ct) { + ++multiplicity; + } + } + } return multiplicity; } diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc index 5021f7e2ea420e1c4187ff1492d1215498d97845..fa3a7fdc6a44986c741a206960e4934d948fc4d8 100644 --- a/xsdconvert/SimpleType.cc +++ b/xsdconvert/SimpleType.cc @@ -775,18 +775,6 @@ void SimpleType::finalModification() { } isOptional = isOptional || (getMinOccurs() == 0 && getMaxOccurs() == 0); - - // If the type name is the same as the identifier then we have to prefix it - // with the module identifier. - if (type.convertedValue == name.convertedValue && !outside_reference.empty()) { - List<const TTCN3Module*>::iterator import_module = module->getImportedModules().begin(); - for (; import_module; import_module = import_module->Next) { - if (import_module->Data->getTargetNamespace() == outside_reference.get_uri()) { - type.upload(import_module->Data->getModulename() + Mstring(".") + type.convertedValue); - break; - } - } - } } bool SimpleType::hasUnresolvedReference() { @@ -835,8 +823,8 @@ void SimpleType::printToFile(FILE * file) { int multiplicity = multi(module, outside_reference, this); const RootType *type_ref = outside_reference.get_ref(); - if ((multiplicity > 1) && type_ref - && type_ref->getModule() != module) { + if ((multiplicity > 1 && type_ref && type_ref->getModule() != module) + || name.convertedValue == type.convertedValue) { fprintf(file, "%s.", type_ref->getModule()->getModulename().c_str()); } diff --git a/xsdconvert/SimpleType.hh b/xsdconvert/SimpleType.hh index 9a141048f83b09bf3f420ebfcd22f4ae2f6ae423..dc893650292b61b444aa521195187dc29fd017d9 100644 --- a/xsdconvert/SimpleType.hh +++ b/xsdconvert/SimpleType.hh @@ -331,7 +331,11 @@ public: const ReferenceData& getReference() const { return outside_reference; } - + + ReferenceData& getReference() { + return outside_reference; + } + EnumerationType & getEnumeration() { return enumeration; }