diff --git a/common/version.h b/common/version.h index 8f25a76df35c22f8c13144a390b4a01c40f497b8..a6d33ae5a8fb9aa10813b172107fb64d34860055 100644 --- a/common/version.h +++ b/common/version.h @@ -11,7 +11,7 @@ /* Version numbers */ #define TTCN3_MAJOR 5 #define TTCN3_MINOR 4 -#define TTCN3_PATCHLEVEL 0 +#define TTCN3_PATCHLEVEL 1 //#define TTCN3_BUILDNUMBER 0 /* The aggregated version number must be set manually since some stupid @@ -22,7 +22,7 @@ * TTCN3_VERSION = TTCN3_MAJOR * 1000000 + TTCN3_MINOR * 10000 + * TTCN3_PATCHLEVEL * 100 + TTCN3_BUILDNUMBER */ -#define TTCN3_VERSION 50400 +#define TTCN3_VERSION 50401 /* A monotonically increasing version number. * An official release is deemed to have the highest possible build number (99) diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc index d3bf10e6936bd6158ce31d48271f2213883a5ccc..31df571cd29d739205e052344323182412595356 100644 --- a/compiler2/Type_chk.cc +++ b/compiler2/Type_chk.cc @@ -2301,6 +2301,27 @@ void Type::chk_xer() { // XERSTUFF semantic check } empties.clear(); } // if secho + + if (xerattrib->abstract_ || xerattrib->block_) { + switch (ownertype) { + case OT_COMP_FIELD: + if (parent_type->typetype == T_CHOICE_A || + parent_type->typetype == T_CHOICE_T) { + if (parent_type->xerattrib != NULL && parent_type->xerattrib->useUnion_) { + error("ABSTRACT and BLOCK cannot be used on fields of a union with " + "attribute USE-UNION."); + } + break; + } + // else fall through + case OT_RECORD_OF: + case OT_TYPE_DEF: + warning("ABSTRACT and BLOCK only affects union fields."); + break; + default: + break; + } + } } @@ -3215,7 +3236,7 @@ bool Type::chk_this_refd_value(Value *value, Common::Assignment *lhs, expected_v #endif case Assignment::A_EXT_CONST: if (expected_value == EXPECTED_CONSTANT) { - value->error("Reference to an (evaluatable) constant value was " + value->error("Reference to an (evaluable) constant value was " "expected instead of %s", ass->get_description().c_str()); error_flag = true; diff --git a/compiler2/Type_codegen.cc b/compiler2/Type_codegen.cc index cfddb7ab7eb3cbdac05a271ff4e336fa06928d84..af6de3601ad6ecb296e60db5a952624d75bc9df0 100644 --- a/compiler2/Type_codegen.cc +++ b/compiler2/Type_codegen.cc @@ -490,7 +490,7 @@ void Type::generate_code_xerdescriptor(output_struct* target) int atrib=0, any_atr=0, any_elem=0, base64=0, decimal=0, embed=0, list=0, text=0, untagged=0, use_nil=0, use_number=0, use_order=0, use_qname=0, use_type_attr=0, ws=0, has_1untag=0, form_qualified=0, any_from=0, - any_except=0, nof_ns_uris=0; + any_except=0, nof_ns_uris=0, blocked=0; const char* dfe_str = 0; char** ns_uris = 0; char* oftype_descr_name = 0; @@ -507,6 +507,7 @@ void Type::generate_code_xerdescriptor(output_struct* target) any_elem= has_ae(xerattrib); atrib = xerattrib->attribute_; base64 = xerattrib->base64_; + blocked = xerattrib->abstract_ || xerattrib->block_; decimal = xerattrib->decimal_; embed = xerattrib->embedValues_; form_qualified = (xerattrib->form_ & XerAttributes::QUALIFIED) @@ -607,7 +608,7 @@ void Type::generate_code_xerdescriptor(output_struct* target) // Generate the XER descriptor itself target->source.global_vars = mputprintf(target->source.global_vars, "const XERdescriptor_t %s_xer_ = { {\"%s>\\n\", \"%s>\\n\"}," - " {%lu, %lu}, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s, WHITESPACE_%s, %c%s, " + " {%lu, %lu}, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s, WHITESPACE_%s, %c%s, " "&%s, %ld, %u, %s, %s };\n", gennameown_str, bxer_name.c_str(), last_s.c_str(), // names @@ -616,6 +617,7 @@ void Type::generate_code_xerdescriptor(output_struct* target) (any_elem ? " |ANY_ELEMENT" : ""), (atrib ? " |XER_ATTRIBUTE" : ""), (base64 ? " |BASE_64" : ""), + (blocked ? " |BLOCKED" : ""), (decimal ? " |XER_DECIMAL" : ""), (embed ? " |EMBED_VALUES" : ""), (list ? " |XER_LIST" : ""), @@ -630,6 +632,7 @@ void Type::generate_code_xerdescriptor(output_struct* target) (form_qualified ? "" : " |FORM_UNQUALIFIED"), (any_from ? " |ANY_FROM" : ""), (any_except ? " |ANY_EXCEPT" : ""), + (is_optional_field() ? " |XER_OPTIONAL" : ""), whitespace_action[ws], (dfe_str ? '&' : ' '), (dfe_str ? dfe_str : "NULL"), "module_object", diff --git a/compiler2/Value.cc b/compiler2/Value.cc index 1ea0cb0971475148d83a6140d347c69f84b29f4a..d7c4e8e612954a1eda5bc9f630dfb829539951fb 100644 --- a/compiler2/Value.cc +++ b/compiler2/Value.cc @@ -4376,7 +4376,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1, } switch (exp_val) { case Type::EXPECTED_CONSTANT: - error("An evaluatable constant value was expected instead of operation " + error("An evaluable constant value was expected instead of operation " "`apply()'"); set_valuetype(V_ERROR); break; @@ -5637,7 +5637,7 @@ error: case Assignment::A_MODULEPAR: case Assignment::A_MODULEPAR_TEMP: if(exp_val==Type::EXPECTED_CONSTANT) { - u.expr.ti1->error("Reference to an (evaluatable) constant value was " + u.expr.ti1->error("Reference to an (evaluable) constant value was " "expected instead of %s", t_ass->get_description().c_str()); goto error; } @@ -5980,7 +5980,7 @@ error: Ttcn::StatementBlock *my_sb; switch (exp_val) { case Type::EXPECTED_CONSTANT: - error("An evaluatable constant value was expected instead of operation " + error("An evaluable constant value was expected instead of operation " "`%s'", get_opname()); goto error; case Type::EXPECTED_STATIC_VALUE: @@ -11113,15 +11113,13 @@ error: Ttcn::ActualParList *parlist = u.ref.ref->get_parlist(); if (parlist) { str = parlist->rearrange_init_code(str, - u.ref.ref->get_refd_assignment()->get_my_scope()->get_scope_mod_gen() - == my_scope->get_scope_mod_gen()); + u.ref.ref->get_refd_assignment()->get_my_scope()->get_scope_mod_gen()); } break; } case V_INVOKE: { str = u.invoke.v->rearrange_init_code(str); - bool type_is_local = u.invoke.v->get_expr_governor_last()->get_my_scope() - ->get_scope_mod_gen() == my_scope->get_scope_mod_gen(); - str = u.invoke.ap_list->rearrange_init_code(str, type_is_local); + str = u.invoke.ap_list->rearrange_init_code(str, + u.invoke.v->get_expr_governor_last()->get_my_scope()->get_scope_mod_gen()); break; } case V_EXPR: switch (u.expr.v_optype) { @@ -11167,15 +11165,11 @@ error: case OPTYPE_DECODE: { Ttcn::ActualParList *parlist = u.expr.r1->get_parlist(); Common::Assignment *ass = u.expr.r1->get_refd_assignment(); - bool rearrange = (ass->get_my_scope()->get_scope_mod_gen() == - my_scope->get_scope_mod_gen()); - if (parlist) str = parlist->rearrange_init_code(str, rearrange); + if (parlist) str = parlist->rearrange_init_code(str, ass->get_my_scope()->get_scope_mod_gen()); parlist = u.expr.r2->get_parlist(); ass = u.expr.r2->get_refd_assignment(); - rearrange = (ass->get_my_scope()->get_scope_mod_gen() == - my_scope->get_scope_mod_gen()); - if (parlist) str = parlist->rearrange_init_code(str, rearrange); + if (parlist) str = parlist->rearrange_init_code(str, ass->get_my_scope()->get_scope_mod_gen()); break; } case OPTYPE_ADD: case OPTYPE_SUBTRACT: @@ -11214,13 +11208,13 @@ error: if (u.expr.v2) str = u.expr.v2->rearrange_init_code(str); break; case OPTYPE_SUBSTR: - str = u.expr.ti1->rearrange_init_code(str); + str = u.expr.ti1->rearrange_init_code(str, my_scope->get_scope_mod_gen()); str = u.expr.v2->rearrange_init_code(str); str = u.expr.v3->rearrange_init_code(str); break; case OPTYPE_REGEXP: - str = u.expr.ti1->rearrange_init_code(str); - str = u.expr.t2->rearrange_init_code(str); + str = u.expr.ti1->rearrange_init_code(str, my_scope->get_scope_mod_gen()); + str = u.expr.t2->rearrange_init_code(str, my_scope->get_scope_mod_gen()); str = u.expr.v3->rearrange_init_code(str); break; case OPTYPE_DECOMP: @@ -11229,10 +11223,10 @@ error: str = u.expr.v3->rearrange_init_code(str); break; case OPTYPE_REPLACE: - str = u.expr.ti1->rearrange_init_code(str); + str = u.expr.ti1->rearrange_init_code(str, my_scope->get_scope_mod_gen()); str = u.expr.v2->rearrange_init_code(str); str = u.expr.v3->rearrange_init_code(str); - str = u.expr.ti4->rearrange_init_code(str); + str = u.expr.ti4->rearrange_init_code(str, my_scope->get_scope_mod_gen()); break; case OPTYPE_LENGTHOF: case OPTYPE_SIZEOF: @@ -11240,14 +11234,14 @@ error: case OPTYPE_ENCODE: case OPTYPE_ISPRESENT: case OPTYPE_TTCN2STRING: - str = u.expr.ti1->rearrange_init_code(str); + str = u.expr.ti1->rearrange_init_code(str, my_scope->get_scope_mod_gen()); break; case OPTYPE_ISCHOSEN_T: - str = u.expr.t1->rearrange_init_code(str); + str = u.expr.t1->rearrange_init_code(str, my_scope->get_scope_mod_gen()); break; case OPTYPE_MATCH: str = u.expr.v1->rearrange_init_code(str); - str = u.expr.t2->rearrange_init_code(str); + str = u.expr.t2->rearrange_init_code(str, my_scope->get_scope_mod_gen()); break; default: // other kinds of expressions cannot appear within templates diff --git a/compiler2/XerAttributes.cc b/compiler2/XerAttributes.cc index 62dd84b1be74075cba47b981751400312093935f..c4a9f57daefffddf14e1607c34423af2c6747b05 100644 --- a/compiler2/XerAttributes.cc +++ b/compiler2/XerAttributes.cc @@ -25,10 +25,12 @@ static const NamespaceRestriction empty_nsr = { static const XerAttributes::NameChange nochange= { NamespaceSpecification::NO_MANGLING }; XerAttributes::XerAttributes() -: attribute_(false) +: abstract_(false) +, attribute_(false) , anyAttributes_(empty_nsr) , anyElement_(empty_nsr) , base64_(false) +, block_(false) , decimal_(false) , defaultForEmpty_(0) , defaultValue_(0) @@ -127,6 +129,7 @@ void XerAttributes::print(const char *type_name) const { fprintf(stderr, "XER attributes(%p) for %s:\n", (const void*)this, type_name); if (empty()) fputs("...Empty...\n", stderr); else { + fputs(abstract_ ? "ABSTRACT\n" : "", stderr); fputs(attribute_ ? "ATTRIBUTE\n" : "", stderr); if (has_aa(this)) { @@ -153,6 +156,7 @@ void XerAttributes::print(const char *type_name) const { } } fputs(base64_ ? "BASE64\n" : "", stderr); + fputs(block_ ? "BLOCK\n" : "", stderr); fputs(decimal_ ? "DECIMAL\n" : "", stderr); if (defaultForEmpty_) fprintf(stderr, "DEFAULT-FOR-EMPTY '%s'\n", defaultForEmpty_); @@ -238,6 +242,7 @@ fprintf(stderr, "@@@ replacing:\n"); print("orig."); other.print("other"); */ + abstract_ |= other.abstract_; attribute_ |= other.attribute_; if (has_aa(&other)) { FreeNamespaceRestriction(anyAttributes_); @@ -260,6 +265,7 @@ other.print("other"); } } base64_ |= other.base64_; + block_ |= other.block_; decimal_ |= other.decimal_; if (other.defaultForEmpty_ != 0) { @@ -362,10 +368,12 @@ other.print("other"); bool XerAttributes::empty() const { - return !attribute_ + return !abstract_ + && !attribute_ && !has_aa(this) && !has_ae(this) && !base64_ + && !block_ && !decimal_ && defaultForEmpty_ == 0 && !element_ diff --git a/compiler2/XerAttributes.hh b/compiler2/XerAttributes.hh index 82e6028a84a64e04dd0ada6654e76429edd8bdcc..06ea432df6571eb66184d299e64ed5e283fe2f9e 100644 --- a/compiler2/XerAttributes.hh +++ b/compiler2/XerAttributes.hh @@ -136,11 +136,13 @@ public: /// If the NamespaceSpecification contains a string, free it. static void FreeNamespace(NamespaceSpecification& ns); public: + bool abstract_; bool attribute_; NamespaceRestriction anyAttributes_; NamespaceRestriction anyElement_; /// Base64 encoding for string-like types (XSD:base64Binary) bool base64_; + bool block_; /// No scientific notation for float bool decimal_; /// String parsed out from the encoding attribute diff --git a/compiler2/record.c b/compiler2/record.c index 097ffe76319b8cdac427362e554d3f6d3a3123b0..3199d1fe1115833436f89ce3fa26175b3740deab 100644 --- a/compiler2/record.c +++ b/compiler2/record.c @@ -1942,7 +1942,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc) " && *p_td.my_module->get_ns(p_td.ns_index)->px == '\\0';\n" ); - src = mputstr(src, " const boolean delay_close = e_xer"); + src = mputstr(src, " boolean delay_close = e_xer"); if (!(num_attributes | sdef->xerUseQName)) { src = mputprintf(src, " && (need_control_ns%s || empty_ns_hack)", (start_at < sdef->nElements) ? " || num_collected" : ""); @@ -1973,9 +1973,11 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc) " if (chopped_chars) {\n" " p_buf.increase_length(-chopped_chars);\n" " }\n" + "%s" " }\n" , (want_namespaces ? "-(delay_close || (e_xer && (p_td.xer_bits & HAS_1UNTAGGED)))" : "") - , (want_namespaces ? " || delay_close" : "")); + , (want_namespaces ? " || delay_close" : "") + , (want_namespaces ? " delay_close = TRUE;\n" : "")); } src = mputprintf(src, diff --git a/compiler2/record_of.c b/compiler2/record_of.c index 875a06c41ce975732007a7454a3a86d53ea021eb..e72d8d99e8159a649f82a7f7d19f0354c8057fdf 100644 --- a/compiler2/record_of.c +++ b/compiler2/record_of.c @@ -1390,7 +1390,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) " if ((XML_READER_TYPE_ELEMENT == type && p_reader.MoveToFirstAttribute() == 1)\n" " || XML_READER_TYPE_ATTRIBUTE == type) {\n" " verify_name(p_reader, p_td, e_xer);\n" - " break;" + " break;\n" " }\n" " }\n" " if (e_xer && (p_td.xer_bits & XER_LIST)) {\n" @@ -1545,6 +1545,9 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) " }\n" /* next read */ " }\n" /* if not empty element */ " }\n" /* if not LIST */ + " if (!own_tag && e_xer && (p_td.xer_bits & XER_OPTIONAL) && val_ptr->n_elements == 0) {\n" + " clean_up();\n" /* set it to unbound, so the OPTIONAL class sets it to omit */ + " }\n" " return 1;\n" "}\n\n" ); diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index efe3c18a4eacd189d19e0c32f17b5adab00352cb..cb936e8abd486671738e9c6e9d2aa5d92b205d48 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -7382,7 +7382,7 @@ namespace Ttcn { TemplateInstance *p_defval, bool p_lazy_eval) : Definition(p_asstype, p_name), type(p_type), my_parlist(0), used_as_lvalue(false), template_restriction(TR_NONE), - lazy_eval(p_lazy_eval) + lazy_eval(p_lazy_eval), defval_generated(false) { switch (p_asstype) { case A_PAR_VAL: @@ -7408,7 +7408,7 @@ namespace Ttcn { Identifier* p_name, TemplateInstance *p_defval, bool p_lazy_eval) : Definition(p_asstype, p_name), type(p_type), my_parlist(0), used_as_lvalue(false), template_restriction(p_template_restriction), - lazy_eval(p_lazy_eval) + lazy_eval(p_lazy_eval), defval_generated(false) { switch (p_asstype) { case A_PAR_TEMPL_IN: @@ -7427,7 +7427,8 @@ namespace Ttcn { FormalPar::FormalPar(asstype_t p_asstype, Identifier* p_name, TemplateInstance *p_defval) : Definition(p_asstype, p_name), type(0), my_parlist(0), - used_as_lvalue(false), template_restriction(TR_NONE), lazy_eval(false) + used_as_lvalue(false), template_restriction(TR_NONE), lazy_eval(false), + defval_generated(false) { if (p_asstype != A_PAR_TIMER) FATAL_ERROR("Ttcn::FormalPar::FormalPar(): invalid parameter type"); @@ -8100,34 +8101,23 @@ namespace Ttcn { } } } - - void FormalPar::generate_code_defval(output_struct *target, bool) + + char* FormalPar::generate_code_defval(char* str) { - if (!defval.ap) return; + if (!defval.ap || defval_generated) return str; + defval_generated = true; switch (defval.ap->get_selection()) { case ActualPar::AP_VALUE: { Value *val = defval.ap->get_Value(); - const_def cdef; - Code::init_cdef(&cdef); - type->generate_code_object(&cdef, val); - Code::merge_cdef(target, &cdef); - Code::free_cdef(&cdef); if (use_runtime_2 && TypeConv::needs_conv_refd(val)) { - target->functions.post_init = TypeConv::gen_conv_code_refd(target-> - functions.post_init, val->get_lhs_name().c_str(), val); + str = TypeConv::gen_conv_code_refd(str, val->get_lhs_name().c_str(), val); } else { - target->functions.post_init = val->generate_code_init( - target->functions.post_init, val->get_lhs_name().c_str()); + str = val->generate_code_init(str, val->get_lhs_name().c_str()); } break; } case ActualPar::AP_TEMPLATE: { TemplateInstance *ti = defval.ap->get_TemplateInstance(); Template *temp = ti->get_Template(); - const_def cdef; - Code::init_cdef(&cdef); - type->generate_code_object(&cdef, temp); - Code::merge_cdef(target, &cdef); - Code::free_cdef(&cdef); Ref_base *dref = ti->get_DerivedRef(); if (dref) { expression_struct expr; @@ -8135,22 +8125,16 @@ namespace Ttcn { expr.expr = mputprintf(expr.expr, "%s = ", temp->get_lhs_name().c_str()); dref->generate_code(&expr); - target->functions.post_init = - Code::merge_free_expr(target->functions.post_init, &expr, false); + str = Code::merge_free_expr(str, &expr, false); } if (use_runtime_2 && TypeConv::needs_conv_refd(temp)) { - target->functions.post_init = TypeConv::gen_conv_code_refd(target-> - functions.post_init, temp->get_lhs_name().c_str(), temp); + str = TypeConv::gen_conv_code_refd(str, temp->get_lhs_name().c_str(), temp); } else { - target->functions.post_init = - temp->generate_code_init(target->functions.post_init, - temp->get_lhs_name().c_str()); + str = temp->generate_code_init(str, temp->get_lhs_name().c_str()); } if (defval.ap->get_gen_restriction_check() != TR_NONE) { - target->functions.post_init = - Template::generate_restriction_check_code( - target->functions.post_init, temp->get_lhs_name().c_str(), - defval.ap->get_gen_restriction_check()); + str = Template::generate_restriction_check_code(str, + temp->get_lhs_name().c_str(), defval.ap->get_gen_restriction_check()); } break; } case ActualPar::AP_REF: @@ -8158,6 +8142,36 @@ namespace Ttcn { default: FATAL_ERROR("FormalPar::generate_code()"); } + return str; + } + + void FormalPar::generate_code_defval(output_struct *target, bool) + { + if (!defval.ap) return; + switch (defval.ap->get_selection()) { + case ActualPar::AP_VALUE: { + Value *val = defval.ap->get_Value(); + const_def cdef; + Code::init_cdef(&cdef); + type->generate_code_object(&cdef, val); + Code::merge_cdef(target, &cdef); + Code::free_cdef(&cdef); + break; } + case ActualPar::AP_TEMPLATE: { + TemplateInstance *ti = defval.ap->get_TemplateInstance(); + Template *temp = ti->get_Template(); + const_def cdef; + Code::init_cdef(&cdef); + type->generate_code_object(&cdef, temp); + Code::merge_cdef(target, &cdef); + Code::free_cdef(&cdef); + break; } + case ActualPar::AP_REF: + break; + default: + FATAL_ERROR("FormalPar::generate_code()"); + } + target->functions.post_init = generate_code_defval(target->functions.post_init); } char *FormalPar::generate_code_fpar(char *str) @@ -8900,11 +8914,20 @@ namespace Ttcn { } return str; } + + char* FormalParList::generate_code_defval(char* str) + { + for (size_t i = 0; i < pars_v.size(); i++) { + str = pars_v[i]->generate_code_defval(str); + } + return str; + } void FormalParList::generate_code_defval(output_struct *target) { - for (size_t i = 0; i < pars_v.size(); i++) + for (size_t i = 0; i < pars_v.size(); i++) { pars_v[i]->generate_code_defval(target); + } } char *FormalParList::generate_code_actual_parlist(char *str, @@ -9288,18 +9311,18 @@ namespace Ttcn { } } - char *ActualPar::rearrange_init_code(char *str, bool is_local) + char *ActualPar::rearrange_init_code(char *str, Common::Module* usage_mod) { switch (selection) { case AP_VALUE: str = val->rearrange_init_code(str); break; case AP_TEMPLATE: - str = temp->rearrange_init_code(str); + str = temp->rearrange_init_code(str, usage_mod); case AP_REF: break; case AP_DEFAULT: - if (is_local) str = act->rearrange_init_code_defval(str); + str = act->rearrange_init_code_defval(str, usage_mod); break; default: FATAL_ERROR("ActualPar::rearrange_init_code()"); @@ -9307,24 +9330,28 @@ namespace Ttcn { return str; } - char *ActualPar::rearrange_init_code_defval(char *str) + char *ActualPar::rearrange_init_code_defval(char *str, Common::Module* usage_mod) { switch (selection) { case AP_VALUE: - str = val->generate_code_init(str, val->get_lhs_name().c_str()); + if (val->get_my_scope()->get_scope_mod_gen() == usage_mod) { + str = val->generate_code_init(str, val->get_lhs_name().c_str()); + } break; case AP_TEMPLATE: { - str = temp->rearrange_init_code(str); - Ref_base *dref = temp->get_DerivedRef(); + str = temp->rearrange_init_code(str, usage_mod); Template *t = temp->get_Template(); - if (dref) { - expression_struct expr; - Code::init_expr(&expr); - expr.expr = mputprintf(expr.expr, "%s = ", t->get_lhs_name().c_str()); - dref->generate_code(&expr); - str = Code::merge_free_expr(str, &expr, false); + if (t->get_my_scope()->get_scope_mod_gen() == usage_mod) { + Ref_base *dref = temp->get_DerivedRef(); + if (dref) { + expression_struct expr; + Code::init_expr(&expr); + expr.expr = mputprintf(expr.expr, "%s = ", t->get_lhs_name().c_str()); + dref->generate_code(&expr); + str = Code::merge_free_expr(str, &expr, false); + } + str = t->generate_code_init(str, t->get_lhs_name().c_str()); } - str = t->generate_code_init(str, t->get_lhs_name().c_str()); break; } default: FATAL_ERROR("ActualPar::rearrange_init_code_defval()"); @@ -9602,10 +9629,10 @@ namespace Ttcn { template_refs.clear(); } - char *ActualParList::rearrange_init_code(char *str, bool is_local) + char *ActualParList::rearrange_init_code(char *str, Common::Module* usage_mod) { for (size_t i = 0; i < params.size(); i++) - str = params[i]->rearrange_init_code(str, is_local); + str = params[i]->rearrange_init_code(str, usage_mod); return str; } diff --git a/compiler2/ttcn3/AST_ttcn3.hh b/compiler2/ttcn3/AST_ttcn3.hh index 119f4a3ee3959dd02f9d2ab9abaf6463247624a6..30912fe218bffb155c1e5b71d1734565ea302295 100644 --- a/compiler2/ttcn3/AST_ttcn3.hh +++ b/compiler2/ttcn3/AST_ttcn3.hh @@ -119,12 +119,11 @@ namespace Ttcn { * aliasing problems with other out/inout parameters. */ void generate_code(expression_struct *expr, bool copy_needed, bool lazy_param=false, bool used_as_lvalue=false) const; /** Appends the initialization sequence of all (directly or indirectly) - * referred non-parameterized templates to \a str and returns the resulting - * string. Flag \a is_local indicates whether the respective formal - * parameter is in the same module as \a this. It is considered only if - * \a selection is AP_DEFAULT. */ - char *rearrange_init_code(char *str, bool is_local); - char *rearrange_init_code_defval(char *str); + * referred non-parameterized templates and the default values of all + * parameterized templates to \a str and returns the resulting string. + * Only objects belonging to module \a usage_mod are initialized. */ + char *rearrange_init_code(char *str, Common::Module* usage_mod); + char *rearrange_init_code_defval(char *str, Common::Module* usage_mod); /** Appends the string representation of the actual parameter to \a str. */ void append_stringRepr(string& str) const; virtual void dump(unsigned level) const; @@ -171,10 +170,10 @@ namespace Ttcn { Type *p_comptype, bool p_compself); /** Walks through the parameter list and appends the initialization * sequence of all (directly or indirectly) referred non-parameterized - * templates to \a str and returns the resulting string. Flag \a is_local - * indicates whether the respective formal parameter list is in the same - * module as \a this. */ - char *rearrange_init_code(char *str, bool is_local); + * templates and the default values of all parameterized templates to + * \a str and returns the resulting string. + * Only objects belonging to module \a usage_mod are initialized. */ + char *rearrange_init_code(char *str, Common::Module* usage_mod); virtual void dump(unsigned level) const; }; @@ -1588,6 +1587,9 @@ namespace Ttcn { template_restriction_t template_restriction; /** normal or lazy evaluation parametrization should be used */ bool lazy_eval; + /** Flag that indicates whether the C++ code for the parameter's default + * value has been generated or not. */ + bool defval_generated; /// Copy constructor disabled FormalPar(const FormalPar& p); @@ -1642,7 +1644,11 @@ namespace Ttcn { * reporting. */ virtual void use_as_lvalue(const Location& p_loc); bool get_used_as_lvalue() const { return used_as_lvalue; } - /** Generates the C++ objects that represent the default value for the + /** Partially generates the C++ object that represents the default value for + * the parameter (if present). The object's declaration is not generated, + * only its value assignment. */ + char* generate_code_defval(char* str); + /** Generates the C++ object that represents the default value for the * parameter (if present). */ virtual void generate_code_defval(output_struct *target, bool clean_up = false); /** Generates the C++ equivalent of the formal parameter, appends it to @@ -1750,6 +1756,10 @@ namespace Ttcn { /** Generates the C++ equivalent of the formal parameter list, appends it * to \a str and returns the resulting string. */ char *generate_code(char *str); + /** Partially generates the C++ objects that represent the default value for + * the parameters (if present). The objects' declarations are not generated, + * only their value assignments. */ + char* generate_code_defval(char* str); /** Generates the C++ objects that represent the default values for the * parameters (if present). */ void generate_code_defval(output_struct *target); diff --git a/compiler2/ttcn3/TtcnTemplate.cc b/compiler2/ttcn3/TtcnTemplate.cc index 5342d34c8fdac34a0f676cd433ba96e54347d6f7..2892efeaf977d5bcae9fe6db2131a898298b0e29 100644 --- a/compiler2/ttcn3/TtcnTemplate.cc +++ b/compiler2/ttcn3/TtcnTemplate.cc @@ -3002,7 +3002,7 @@ end: break; case TEMPLATE_INVOKE: if (get_code_section() == CS_POST_INIT) - str = rearrange_init_code_invoke(str); + str = rearrange_init_code_invoke(str, my_scope->get_scope_mod_gen()); str = generate_code_init_invoke(str, name); break; case TEMPLATE_LIST: @@ -3056,17 +3056,17 @@ end: return str; } - char *Template::rearrange_init_code(char *str) + char *Template::rearrange_init_code(char *str, Common::Module* usage_mod) { switch (templatetype) { case SPECIFIC_VALUE: str = u.specific_value->rearrange_init_code(str); break; case TEMPLATE_REFD: - str = rearrange_init_code_refd(str); + str = rearrange_init_code_refd(str, usage_mod); break; case TEMPLATE_INVOKE: - str = rearrange_init_code_invoke(str); + str = rearrange_init_code_invoke(str, usage_mod); break; case TEMPLATE_LIST: case VALUE_LIST: @@ -3075,17 +3075,17 @@ end: case SUBSET_MATCH: case PERMUTATION_MATCH: for (size_t i = 0; i < u.templates->get_nof_ts(); i++) - str = u.templates->get_t_byIndex(i)->rearrange_init_code(str); + str = u.templates->get_t_byIndex(i)->rearrange_init_code(str, usage_mod); break; case NAMED_TEMPLATE_LIST: for (size_t i = 0; i < u.named_templates->get_nof_nts(); i++) str = u.named_templates->get_nt_byIndex(i)->get_template() - ->rearrange_init_code(str); + ->rearrange_init_code(str, usage_mod); break; case INDEXED_TEMPLATE_LIST: for (size_t i = 0; i < u.indexed_templates->get_nof_its(); i++) str = u.indexed_templates->get_it_byIndex(i)->get_template() - ->rearrange_init_code(str); + ->rearrange_init_code(str, usage_mod); break; case VALUE_RANGE: str = u.value_range->rearrange_init_code(str); @@ -3147,17 +3147,15 @@ end: if (get_code_section() == CS_POST_INIT) { // the referencing template is a part of a non-parameterized template Common::Assignment *ass = u.ref.ref->get_refd_assignment(); - if (ass->get_asstype() == Common::Assignment::A_TEMPLATE && - ass->get_my_scope()->get_scope_mod_gen() == - my_scope->get_scope_mod_gen()) { + if (ass->get_asstype() == Common::Assignment::A_TEMPLATE) { // the reference points to (a field of) a template - // within the local module if (ass->get_FormalParList()) { // the referred template is parameterized // generate the initialization sequence first for all dependent // non-parameterized templates - str = rearrange_init_code_refd(str); - } else { + str = rearrange_init_code_refd(str, my_scope->get_scope_mod_gen()); + } else if (ass->get_my_scope()->get_scope_mod_gen() == + my_scope->get_scope_mod_gen()) { // the referred template is non-parameterized // use a different algorithm for code generation str = generate_rearrange_init_code_refd(str, &expr); @@ -4440,29 +4438,31 @@ compile_time: expr->expr = mputc(expr->expr, ')'); } - char *Template::rearrange_init_code_refd(char *str) + char *Template::rearrange_init_code_refd(char *str, Common::Module* usage_mod) { if (templatetype != TEMPLATE_REFD) FATAL_ERROR("Template::rearrange_init_code_refd()"); - ActualParList *parlist = u.ref.ref->get_parlist(); + ActualParList *actual_parlist = u.ref.ref->get_parlist(); // generate code for the templates that are used in the actual parameter // list of the reference Common::Assignment *ass = u.ref.ref->get_refd_assignment(); - bool rearrange = (ass->get_my_scope()->get_scope_mod_gen() == - my_scope->get_scope_mod_gen()); - if (parlist) str = parlist->rearrange_init_code(str, rearrange); + if (actual_parlist) str = actual_parlist->rearrange_init_code(str, usage_mod); // do nothing if the reference does not point to a template definition if (ass->get_asstype() != Common::Assignment::A_TEMPLATE) return str; - // do nothing if the referenced template is in another module - if (ass->get_my_scope()->get_scope_mod_gen() != - my_scope->get_scope_mod_gen()) return str; Template *t = ass->get_Template(); - if (parlist) { + FormalParList *formal_parlist = ass->get_FormalParList(); + if (formal_parlist) { // the reference points to a parameterized template // we must perform the rearrangement for all non-parameterized templates - // that are referred by the parameterized template regardless the + // that are referred by the parameterized template regardless of the // sub-references of u.ref.ref - str = t->rearrange_init_code(str); + str = t->rearrange_init_code(str, usage_mod); + // the parameterized template's default values must also be generated + // (this only generates their value assignments, their declarations will + // be generated when the template's definition is reached) + if (ass->get_my_scope()->get_scope_mod_gen() == usage_mod) { + str = formal_parlist->generate_code_defval(str); + } } else { // the reference points to a non-parameterized template FieldOrArrayRefs *subrefs = u.ref.ref->get_subrefs(); @@ -4494,17 +4494,17 @@ compile_time: } // otherwise if the reference points to a top-level template // we should initialize its entire body - str = t->generate_code_init(str, t->get_lhs_name().c_str()); + if (ass->get_my_scope()->get_scope_mod_gen() == usage_mod) { + str = t->generate_code_init(str, t->get_lhs_name().c_str()); + } } return str; } - char *Template::rearrange_init_code_invoke(char *str) + char *Template::rearrange_init_code_invoke(char *str, Common::Module* usage_mod) { str = u.invoke.v->rearrange_init_code(str); - bool type_is_local = u.invoke.v->get_expr_governor_last()->get_my_scope() - ->get_scope_mod_gen() == my_scope->get_scope_mod_gen(); - str = u.invoke.ap_list->rearrange_init_code(str, type_is_local); + str = u.invoke.ap_list->rearrange_init_code(str, usage_mod); return str; } @@ -5070,31 +5070,34 @@ compile_time: } else template_body->generate_code_expr(expr, template_restriction); } - char *TemplateInstance::rearrange_init_code(char *str) + char *TemplateInstance::rearrange_init_code(char *str, Common::Module* usage_mod) { if (derived_reference) { - ActualParList *parlist = derived_reference->get_parlist(); + ActualParList *actual_parlist = derived_reference->get_parlist(); Common::Assignment *ass = derived_reference->get_refd_assignment(); if (!ass) FATAL_ERROR("TemplateInstance::rearrange_init_code()"); - bool is_local = (ass->get_my_scope()->get_scope_mod_gen() == - derived_reference->get_my_scope()->get_scope_mod_gen()); - if (parlist) str = parlist->rearrange_init_code(str, is_local); - if (is_local && ass->get_asstype() == Common::Assignment::A_TEMPLATE) { - // the base template reference refers to a template within the local - // module + if (actual_parlist) str = actual_parlist->rearrange_init_code(str, usage_mod); + if (ass->get_asstype() == Common::Assignment::A_TEMPLATE) { Template *t = ass->get_Template(); - if (parlist) { + FormalParList *formal_parlist = ass->get_FormalParList(); + if (formal_parlist) { // the referred template is parameterized // the embedded referenced templates shall be visited - str = t->rearrange_init_code(str); + str = t->rearrange_init_code(str, usage_mod); + // the constants used for default values have to be initialized now + if (ass->get_my_scope()->get_scope_mod_gen() == usage_mod) { + str = formal_parlist->generate_code_defval(str); + } } else { // the referred template is not parameterized // its entire body has to be initialized now - str = t->generate_code_init(str, t->get_lhs_name().c_str()); + if (ass->get_my_scope()->get_scope_mod_gen() == usage_mod) { + str = t->generate_code_init(str, t->get_lhs_name().c_str()); + } } } } - str = template_body->rearrange_init_code(str); + str = template_body->rearrange_init_code(str, usage_mod); return str; } diff --git a/compiler2/ttcn3/TtcnTemplate.hh b/compiler2/ttcn3/TtcnTemplate.hh index 8925f8e0a8f0e4c0331ddf772fee3d3c50bb185b..c3d3fa51672ea6566443f2674d26ec14eecee758 100644 --- a/compiler2/ttcn3/TtcnTemplate.hh +++ b/compiler2/ttcn3/TtcnTemplate.hh @@ -394,10 +394,10 @@ namespace Ttcn { char *generate_code_init(char *str, const char *name); /** Walks through the template recursively and appends the C++ * initialization sequence of all (directly or indirectly) - * referenced non-parameterized templates to \a str and returns - * the resulting string. Templates imported from other modules - * are not visited. */ - char *rearrange_init_code(char *str); + * referenced non-parameterized templates and the default values of all + * parameterized templates to \a str and returns the resulting string. + * Only objects belonging to module \a usage_mod are initialized. */ + char *rearrange_init_code(char *str, Common::Module* usage_mod); private: /** Private helper functions for code generation. */ @@ -461,8 +461,8 @@ namespace Ttcn { /** Helper function for \a rearrange_init_code(). It handles the * referenced templates (i.e. it does the real work). */ - char *rearrange_init_code_refd(char *str); - char *rearrange_init_code_invoke(char *str); + char *rearrange_init_code_refd(char *str, Common::Module* usage_mod); + char *rearrange_init_code_invoke(char *str, Common::Module* usage_mod); /** Returns whether the C++ initialization sequence requires a * temporary variable reference to be introduced for efficiency @@ -555,9 +555,9 @@ namespace Ttcn { void generate_code(expression_struct *expr, template_restriction_t template_restriction = TR_NONE); /** Appends the initialization sequence of the referred templates - * to \a str. Only those templates are considered that are in - * the same module as \a this. */ - char *rearrange_init_code(char *str); + * and their default values to \a str. Only templates from module + * \a usage_mod are considered. */ + char *rearrange_init_code(char *str, Common::Module* usage_mod); /** Appends the string representation of the template instance to * \a str. */ diff --git a/compiler2/ttcn3/compiler.y b/compiler2/ttcn3/compiler.y index e8719923ae2106cd01bf7ec4d5fc41d793f7a114..65dca47a4a65e589b5210f6fe7e6a739d0d4746d 100644 --- a/compiler2/ttcn3/compiler.y +++ b/compiler2/ttcn3/compiler.y @@ -8670,6 +8670,10 @@ PredefOrIdentifier: $$ = new Identifier(Identifier::ID_TTCN, at_field); } +| NullValue + { + $$ = new Identifier(Identifier::ID_NAME, string("NULL")); + } IschosenArg: /* see also Reference... */ IDentifier '.' PredefOrIdentifier diff --git a/compiler2/ttcn3/rawAST.l b/compiler2/ttcn3/rawAST.l index e74a8f27b589bcdb380308003e374784951a3a09..67bb5f576908de5c657c1087bc2aa9419178ab2e 100644 --- a/compiler2/ttcn3/rawAST.l +++ b/compiler2/ttcn3/rawAST.l @@ -285,6 +285,8 @@ BITORDERINOCTET { BEGIN(rawcodec); RETURN(XBitOrderInOctetKeyword); } HEXORDER { BEGIN(rawcodec); RETURN(XHexOrderKeyword); } TOPLEVEL { BEGIN(rawcodec); RETURN(XToplevelKeyword); } IntX { RETURN(XIntXKeyword); } +bit { RETURN(XBitKeyword); } +unsigned { RETURN(XUnsignedKeyword); } <rawcodec>{ yes { yylval.enumval = XDEFYES; RETURN(XYes); } @@ -331,10 +333,12 @@ TEXT_CODING { BEGIN(textcodec);RETURN(XCodingKeyword); } * when to return to INITIAL) */ /* First, the "starter" attributes */ +abstract RETURN(XKWabstract); anyAttributes RETURN(XKWanyAttributes); anyElement RETURN(XKWanyElement); attribute RETURN(XKWattribute); attributeFormQualified RETURN(XKWattributeFormQualified); +block RETURN(XKWblock); controlNamespace RETURN(XKWcontrolNamespace); defaultForEmpty RETURN(XKWdefaultForEmpty); element RETURN(XKWelement); diff --git a/compiler2/ttcn3/rawAST.y b/compiler2/ttcn3/rawAST.y index f210f480bbbce8e9ae08afd9a0d43391dc850e47..dcc2c8b4621540c5c653af420eaae7db5c0bbd87 100644 --- a/compiler2/ttcn3/rawAST.y +++ b/compiler2/ttcn3/rawAST.y @@ -152,6 +152,8 @@ static void yyprint(FILE *file, int type, const YYSTYPE& value); %token XToplevelKeyword %token XRepeatableKeyword %token XIntXKeyword +%token XBitKeyword +%token XUnsignedKeyword /* XER attributes */ %token XKWall "all" @@ -171,10 +173,12 @@ static void yyprint(FILE *file, int type, const YYSTYPE& value); %token XKWprefix "prefix" +%token XKWabstract "abstact" %token XKWanyAttributes "anyAttributes" %token XKWanyElement "anyElement" %token XKWattribute "attribute" %token XKWattributeFormQualified "attributeFormQualified" +%token XKWblock "block" %token XKWcontrolNamespace "controlNamespace" %token XKWdefaultForEmpty "defaultForEmpty" %token XKWelement "element" @@ -462,6 +466,8 @@ XSingleEncodingDef : XPaddingDef { rawstruct->topleveleind=1; raw_f=true;} | XIntXKeyword { rawstruct->intx = true; raw_f = true; } + | XBitDef + { raw_f = true; } /* TEXT encoder keywords */ | XBeginDef { text_f=true; } @@ -838,6 +844,22 @@ XRvalue: XIdentifier{ } ; +/* Alternative RAW attributes for types defined in annex E of the TTCN-3 standard */ +XBitDef: + XNumber XBitKeyword + { + rawstruct->fieldlength = $1; + rawstruct->comp = XDEFSIGNBIT; + rawstruct->byteorder = XDEFLAST; + } +| XUnsignedKeyword XNumber XBitKeyword + { + rawstruct->fieldlength = $2; + rawstruct->comp = XDEFUNSIGNED; + rawstruct->byteorder = XDEFLAST; + } +; + /* Text encoder */ XBeginDef: XBeginKeyword '(' XEncodeToken ')' { @@ -1265,10 +1287,12 @@ XERattributes: /* a non-empty list */ ; XERattribute: - anyAttributes { FreeNamespaceRestriction(xerstruct->anyAttributes_); xerstruct->anyAttributes_ = $1; } + XKWabstract { xerstruct->abstract_ = true; } + | anyAttributes { FreeNamespaceRestriction(xerstruct->anyAttributes_); xerstruct->anyAttributes_ = $1; } | anyElement { FreeNamespaceRestriction(xerstruct->anyElement_); xerstruct->anyElement_ = $1; } | XKWattribute { xerstruct->attribute_ = true; } | XKWattributeFormQualified { xerstruct->form_ |= XerAttributes::ATTRIBUTE_DEFAULT_QUALIFIED; } + | XKWblock { xerstruct->block_ = true; } | controlNamespace /* directly on the module */ { mymod->set_controlns($1.uri, $1.prefix); diff --git a/compiler2/union.c b/compiler2/union.c index 1e75686f39ad32525ea6a9c7a4432f2717784a2f..b2fc12ef295487ed7658a83e3ccf6766b8672e6b 100644 --- a/compiler2/union.c +++ b/compiler2/union.c @@ -1378,9 +1378,8 @@ void defUnionClass(struct_def const *sdef, output_struct *output) src = mputstr(src, " const boolean e_xer = is_exer(p_flavor);\n" " char *type_atr = NULL;\n" - " unsigned short name_len = 0;\n" " if (e_xer && (p_td.xer_bits & USE_TYPE_ATTR)) {\n" - " const char *type_name = 0;\n" + " char *type_name = 0;\n" " const namespace_t *control_ns;\n" " switch (union_selection) {\n"); /* In case of USE-TYPE the first field won't need the type attribute */ @@ -1388,24 +1387,34 @@ void defUnionClass(struct_def const *sdef, output_struct *output) for (i = start_at; i < sdef->nElements; i++) { src = mputprintf(src, " case %s_%s:\n" - " type_name = %s_xer_.names[1];\n" - " name_len = %s_xer_.namelens[1] - 2;\n" + " if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n" + " %s_xer_.namelens[1] > 2) {\n" + /* add the namespace prefix to the type attribute (if the name is not empty) */ + " const namespace_t *my_ns = %s_xer_.my_module->get_ns(%s_xer_.ns_index);\n" + " if (my_ns->px[0] != 0) {\n" + " type_name = mprintf(\"%%s:\", my_ns->px);\n" + " }\n" + " }\n" + " type_name = mputstrn(type_name, %s_xer_.names[1], %s_xer_.namelens[1] - 2);\n" " %s\n" , selection_prefix, sdef->elements[i].name - , sdef->elements[i].typegen + , sdef->elements[i].typegen, sdef->elements[i].typegen + , sdef->elements[i].typegen, sdef->elements[i].typegen + , sdef->elements[i].typegen, sdef->elements[i].typegen , sdef->elements[i].typegen , i < sdef->nElements - 1 ? "goto write_atr;" : "" /* no break */ ); } src = mputprintf(src, "%s" /* label only if more than two elements total */ - " if (name_len > 0) {\n" /* 38.3.8, no atr if NAME AS "" */ + " if (mstrlen(type_name) > 0) {\n" /* 38.3.8, no atr if NAME AS "" */ " control_ns = p_td.my_module->get_controlns();\n" " type_atr = mcopystr(\" \");\n" - " type_atr = mputstr (type_atr, control_ns->px);\n" - " type_atr = mputstr (type_atr, \":type='\");\n" - " type_atr = mputstrn(type_atr, type_name, name_len);\n" - " type_atr = mputc (type_atr, '\\'');\n" + " type_atr = mputstr(type_atr, control_ns->px);\n" + " type_atr = mputstr(type_atr, \":type='\");\n" + " type_atr = mputstr(type_atr, type_name);\n" + " type_atr = mputc (type_atr, '\\'');\n" + " Free(type_name);\n" " }\n" " break;\n" " default: break;\n" @@ -1475,33 +1484,42 @@ void defUnionClass(struct_def const *sdef, output_struct *output) src = mputstr(src, " const boolean e_xer = is_exer(p_flavor);\n" " char *type_atr = NULL;\n" - " unsigned short name_len = 0;\n" " if (e_xer && (p_td.xer_bits & USE_TYPE_ATTR)) {\n" - " const char *type_name = 0;\n" + " char *type_name = 0;\n" " const namespace_t *control_ns;\n" " switch (union_selection) {\n"); int start_at = sdef->xerUseUnion ? 0 : 1; for (i = start_at; i < sdef->nElements; i++) { src = mputprintf(src, " case %s_%s:\n" - " type_name = %s_xer_.names[1];\n" - " name_len = %s_xer_.namelens[1] - 2;\n" + " if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n" + " %s_xer_.namelens[1] > 2) {\n" + /* add the namespace prefix to the type attribute (if the name is not empty) */ + " const namespace_t *my_ns = %s_xer_.my_module->get_ns(%s_xer_.ns_index);\n" + " if (my_ns->px[0] != 0) {\n" + " type_name = mprintf(\"%%s:\", my_ns->px);\n" + " }\n" + " }\n" + " type_name = mputstrn(type_name, %s_xer_.names[1], %s_xer_.namelens[1] - 2);\n" " %s\n" , selection_prefix, sdef->elements[i].name - , sdef->elements[i].typegen + , sdef->elements[i].typegen, sdef->elements[i].typegen + , sdef->elements[i].typegen, sdef->elements[i].typegen + , sdef->elements[i].typegen, sdef->elements[i].typegen , sdef->elements[i].typegen , i < sdef->nElements - 1 ? "goto write_atr;" : "" /* no break */ ); } src = mputprintf(src, "%s" /* label only if more than two elements total */ - " if (name_len > 0) {\n" /* 38.3.8, no atr if NAME AS "" */ + " if (mstrlen(type_name) > 0) {\n" /* 38.3.8, no atr if NAME AS "" */ " control_ns = p_td.my_module->get_controlns();\n" " type_atr = mcopystr(\" \");\n" - " type_atr = mputstr (type_atr, control_ns->px);\n" - " type_atr = mputstr (type_atr, \":type='\");\n" - " type_atr = mputstrn(type_atr, type_name, name_len);\n" - " type_atr = mputc (type_atr, '\\'');\n" + " type_atr = mputstr(type_atr, control_ns->px);\n" + " type_atr = mputstr(type_atr, \":type='\");\n" + " type_atr = mputstr(type_atr, type_name);\n" + " type_atr = mputc (type_atr, '\\'');\n" + " Free(type_name);\n" " }\n" " break;\n" " default: break;\n" @@ -1628,8 +1646,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output) /* USE-TYPE: No type attribute means the first alternative */ src = mputprintf(src, " if (typeatr == NULL) {\n" - " typeatr = mcopystr(%s_xer_.names[1]);\n" - " typeatr = mtruncstr(typeatr, %s_xer_.namelens[1] - 2);\n" + " typeatr = mcopystrn(%s_xer_.names[1], %s_xer_.namelens[1] - 2);\n" " }\n" , sdef->elements[0].typegen , sdef->elements[0].typegen); @@ -1668,7 +1685,15 @@ void defUnionClass(struct_def const *sdef, output_struct *output) if (sdef->xerUseTypeAttr) { src = mputstr(src, " if (e_xer) {\n" /* USE-TYPE => no XML element, use typeatr */ - " elem_name = typeatr;\n" + " char *token_1 = strtok(typeatr, \":\");\n" /* extract the namespace (if any) */ + " char *token_2 = strtok(NULL, \":\");\n" + " if (token_2) {\n" /* namespace found */ + " elem_name = token_2;\n" + " ns_uri = get_ns_uri_from_prefix(token_1, p_td);\n" + " }\n" + " else {\n" /* no namespace */ + " elem_name = token_1;\n" + " }\n" " flavor_1 |= USE_TYPE_ATTR;\n" " }\n" " else" /* no newline, gobbles up the next {} */); @@ -1748,6 +1773,10 @@ void defUnionClass(struct_def const *sdef, output_struct *output) src = mputprintf(src, " %sif (%s::can_start(elem_name, ns_uri, %s_xer_, flavor_1) || (%s_xer_.xer_bits & ANY_ELEMENT)) {\n" " ec_2.set_msg(\"%s': \");\n" + " if (e_xer && (%s_xer_.xer_bits & BLOCKED)) {\n" + " TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG,\n" + " \"Attempting to decode blocked or abstract field.\");\n" + " }\n" " %s%s().XER_decode(%s_xer_, p_reader, flavor_1, 0);\n" " if (!%s%s().is_bound()) {\n" " TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG, \"Failed to decode field.\");\n" @@ -1756,6 +1785,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output) i && !(i==1 && sdef->exerMaybeEmptyIndex==0) ? "else " : "", /* print "if(" if generate code for the first field or if the first field is the MaybeEmpty field and we generate the code for the second one*/ sdef->elements[i].type, sdef->elements[i].typegen, sdef->elements[i].typegen, sdef->elements[i].dispname, + sdef->elements[i].typegen, at_field, sdef->elements[i].name, sdef->elements[i].typegen, at_field, sdef->elements[i].name); } @@ -1765,6 +1795,10 @@ void defUnionClass(struct_def const *sdef, output_struct *output) src = mputprintf(src, " %sif ((e_xer && (type==XML_READER_TYPE_END_ELEMENT || !own_tag)) || %s::can_start(elem_name, ns_uri, %s_xer_, flavor_1) || (%s_xer_.xer_bits & ANY_ELEMENT)) {\n" "empty_xml: ec_2.set_msg(\"%s': \");\n" + " if (e_xer && (%s_xer_.xer_bits & BLOCKED)) {\n" + " TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG,\n" + " \"Attempting to decode blocked or abstract field.\");\n" + " }\n" " %s%s().XER_decode(%s_xer_, p_reader, flavor_1, 0);\n" " if (!%s%s().is_bound()) {\n" " TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_INVAL_MSG, \"Failed to decode field.\");\n" @@ -1773,6 +1807,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output) sdef->nElements>0 ? "else " : "", sdef->elements[i].type, sdef->elements[i].typegen, sdef->elements[i].typegen, sdef->elements[i].dispname, + sdef->elements[i].typegen, at_field, sdef->elements[i].name, sdef->elements[i].typegen, at_field, sdef->elements[i].name); } diff --git a/core/Boolean.cc b/core/Boolean.cc index 179643c7ac0b7327344b005aeeb214cc955f32a4..5dd0ca3552e6c869c76046c523774e3750dd3724 100644 --- a/core/Boolean.cc +++ b/core/Boolean.cc @@ -530,6 +530,10 @@ int BOOLEAN::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) else bc = myleaf.body.leaf.data_array; memset(bc, tmp, length * sizeof(*bc)); + if (boolean_value && loc_length % 8 != 0) { + // remove the extra ones from the last octet + bc[length - 1] &= BitMaskTable[loc_length % 8]; + } return myleaf.length = loc_length; } diff --git a/core/Integer.cc b/core/Integer.cc index 4d1100fdda483d54abd3b9e1b9154dc836dc72a9..c209315b02bd18dccbaf8f3078bfaa4d9904451a 100644 --- a/core/Integer.cc +++ b/core/Integer.cc @@ -121,6 +121,7 @@ INTEGER::INTEGER(BIGNUM *other_value) INTEGER::~INTEGER() { + if (!bound_flag) return; if (unlikely(!native_flag)) BN_free(val.openssl); } diff --git a/core/Makefile b/core/Makefile index 3b3cde411cfcae130d909bf454dccb7554cec7b4..75f3f3f91a936011eba4826982dee67eed7cc9e3 100644 --- a/core/Makefile +++ b/core/Makefile @@ -181,7 +181,9 @@ SHAREDLIB := libttcn3$(RT2_SUFFIX)-dynamic.so PARALLEL_SHAREDLIB := libttcn3$(RT2_SUFFIX)-parallel-dynamic.so # Executables +ifneq ($(FUNCTION_TEST_RUNTIME), yes) PROGRAMS := ttcn3_profmerge$(EXESUFFIX) +endif TARGETS := $(LIBRARY) $(PARALLEL_LIBRARY) diff --git a/core/Runtime.cc b/core/Runtime.cc index 527bf66d493d28684ae17fc91728d33e01bcf847..06cd97cec5689a535080db3b74f8a9147059b705 100644 --- a/core/Runtime.cc +++ b/core/Runtime.cc @@ -278,7 +278,7 @@ CHARSTRING TTCN_Runtime::get_testcase_id_macro() CHARSTRING TTCN_Runtime::get_testcasename() { - if (in_controlpart()) return CHARSTRING(""); // No error here. + if (in_controlpart() || is_hc()) return CHARSTRING(""); // No error here. if (!testcase_name.definition_name || testcase_name.definition_name[0] == 0) TTCN_error("Internal error: Evaluating predefined function testcasename()" @@ -2459,8 +2459,11 @@ void TTCN_Runtime::process_ptc_verdict(Text_Buf& text_buf) TTCN_error("Internal error: Invalid PTC verdict was " "received from MC: %d.", ptc_verdict); } - verdicttype new_verdict = - local_verdict < ptc_verdict ? ptc_verdict : local_verdict; + verdicttype new_verdict = local_verdict; + if (ptc_verdict > local_verdict) { + new_verdict = ptc_verdict; + verdict_reason = CHARSTRING(ptc_verdict_reason); + } TTCN_Logger::log_final_verdict(true, ptc_verdict, local_verdict, new_verdict, ptc_verdict_reason, -1, ptc_compref, ptc_name); delete [] ptc_name; diff --git a/core/XER.cc b/core/XER.cc index 03259a0b1138947725d1caf344ed023dd5e16122..d24d42bba22e3c89ee389dcb372cf33636cd3dc1 100644 --- a/core/XER.cc +++ b/core/XER.cc @@ -129,6 +129,19 @@ void write_ns_prefix(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf) } } +const char* get_ns_uri_from_prefix(const char *prefix, const XERdescriptor_t& p_td) +{ + if (p_td.my_module != 0 && prefix != NULL && prefix[0] != 0) { + for (size_t i = 0; i < p_td.my_module->get_num_ns(); ++i) { + const namespace_t *ns = p_td.my_module->get_ns(i); + if (ns->px != NULL && strcmp(ns->px, prefix) == 0) { + return ns->ns; + } + } + } + return NULL; +} + void check_namespace_restrictions(const XERdescriptor_t& p_td, const char* p_xmlns) { // In case of "anyElement from ..." matching namespaces is good diff --git a/core/XER.hh b/core/XER.hh index 181f6afe324d8b1fd0a0c2cc17181b5f07cccdfa..6978498fb7fb20062dfa3d7116acccbec848ec09 100644 --- a/core/XER.hh +++ b/core/XER.hh @@ -89,8 +89,10 @@ enum XER_flavor { as empty elements in BXER only. This also influences them in record-of */ ANY_FROM = 1U << 27, // 0x8000000 anyElement from ... or anyAttributes from ... ANY_EXCEPT = 1U << 28, // 0x10000000 anyElement except ... or anyAttributes except ... - EXIT_ON_ERROR = 1U << 29 /* 0x20000000 clean up and exit instead of throwing + EXIT_ON_ERROR = 1U << 29, /* 0x20000000 clean up and exit instead of throwing a decoding error, used on alternatives of a union with USE-UNION */ + XER_OPTIONAL = 1U << 30, // 0x40000000 is an optional field of a record or set + BLOCKED = 1U << 31 // 0x80000000 either ABSTRACT or BLOCK }; /** WHITESPACE actions. @@ -375,6 +377,16 @@ class TTCN_Buffer; */ void write_ns_prefix(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf); +/** Return the namespace referred to by a prefix + * + * Finds the namespace specified by \a prefix in the module's namespace table + * and returns its URI. Returns NULL if the namespace is not found. + * + * @param prefix namespace prefix to be found + * @param p_td XER descriptor (contains the module to search in) + */ +const char* get_ns_uri_from_prefix(const char *prefix, const XERdescriptor_t& p_td); + /** Output the beginning of an XML attribute. * * Writes a space, the attribute name (from \p p_td), and the string "='". diff --git a/core2/Basetype2.cc b/core2/Basetype2.cc index 41a165dc3e3ab28b799a617fc12af773cdcb4ea7..2bffe70a5d5cbbd86d2e6ee6909257c5bf1e42b2 100644 --- a/core2/Basetype2.cc +++ b/core2/Basetype2.cc @@ -2270,6 +2270,10 @@ int Record_Of_Type::XER_decode(const XERdescriptor_t& p_td, } /* next read */ } /* if not empty element */ } /* if not LIST */ + if (!own_tag && exer && (p_td.xer_bits & XER_OPTIONAL) && get_nof_elements() == 0) { + // set it to unbound, so the OPTIONAL class sets it to omit + clean_up(); + } return 1; // decode successful } diff --git a/function_test/Semantic_Analyser/Makefile.semantic b/function_test/Semantic_Analyser/Makefile.semantic index 28a394d5329eb6ba5852e292ef7724289a6f838b..c772783d6d3bbd33814f5cb7f3759b6059ff1fa9 100644 --- a/function_test/Semantic_Analyser/Makefile.semantic +++ b/function_test/Semantic_Analyser/Makefile.semantic @@ -5,7 +5,7 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html ############################################################################### -SADIRS := ver xer encode param template_restrictions +SADIRS := ver xer encode param template #$(wildcard TTCN3_[a0-9]* ASN_[a0-9]*) ver xer all run check clean distclean: diff --git a/function_test/Semantic_Analyser/TTCN3_SA_6_TD.script b/function_test/Semantic_Analyser/TTCN3_SA_6_TD.script index ac36eca8182450c27b4892454dd53225ab79cac1..8cd7148229430729628a5b4e0cdfffa1a3a15ba4 100644 --- a/function_test/Semantic_Analyser/TTCN3_SA_6_TD.script +++ b/function_test/Semantic_Analyser/TTCN3_SA_6_TD.script @@ -4032,7 +4032,7 @@ type charstring myCharType length( float2int(rnd()) ); } <END_MODULE> <RESULT IF_PASS COUNT 1> -(?im)error.+?evaluatable.+?constant.+?value.+?expected.+?instead.+?of.+?operation +(?im)error.+?evaluable.+?constant.+?value.+?expected.+?instead.+?of.+?operation <END_RESULT> <RESULT IF_PASS COUNT 1> (?im)\bNotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b @@ -4094,7 +4094,7 @@ type charstring myCharType length( float2int(rnd()) .. 5 ); } <END_MODULE> <RESULT IF_PASS COUNT 1> -(?im)error.+?evaluatable.+?constant.+?value.+?expected.+?instead.+?of.+?operation +(?im)error.+?evaluable.+?constant.+?value.+?expected.+?instead.+?of.+?operation <END_RESULT> <RESULT IF_PASS COUNT 1> (?im)\bNotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b @@ -4160,7 +4160,7 @@ type charstring myCharType length( float2int(rnd()) .. myFunct()); } <END_MODULE> <RESULT IF_PASS COUNT 1> -(?im)error.+?evaluatable.+?constant.+?value.+?expected.+?instead.+?of.+?operation +(?im)error.+?evaluable.+?constant.+?value.+?expected.+?instead.+?of.+?operation <END_RESULT> <RESULT IF_PASS COUNT 1> (?im)error.+?Reference.+?constant.+?expected.+?instead @@ -4192,7 +4192,7 @@ type integer myIntType ( float2int(rnd()) .. 255 ); } <END_MODULE> <RESULT IF_PASS COUNT 1> -(?im)error.+?evaluatable.+?constant.+?value.+?expected.+?instead.+?of.+?operation +(?im)error.+?evaluable.+?constant.+?value.+?expected.+?instead.+?of.+?operation <END_RESULT> <RESULT IF_PASS COUNT 1> (?im)\bNotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b @@ -4258,7 +4258,7 @@ type float myIntType ( rnd() .. myFunct() ); } <END_MODULE> <RESULT IF_PASS COUNT 1> -(?im)error.+?evaluatable.+?constant.+?value.+?expected.+?instead.+?of.+?operation +(?im)error.+?evaluable.+?constant.+?value.+?expected.+?instead.+?of.+?operation <END_RESULT> <RESULT IF_PASS COUNT 1> (?im)error.+?Reference.+?constant.+?expected.+?instead @@ -4290,7 +4290,7 @@ type integer myIntType ( float2int(rnd()), 255 ); } <END_MODULE> <RESULT IF_PASS COUNT 1> -(?im)error.+?evaluatable.+?constant.+?value.+?expected.+?instead.+?of.+?operation +(?im)error.+?evaluable.+?constant.+?value.+?expected.+?instead.+?of.+?operation <END_RESULT> <RESULT IF_PASS COUNT 1> (?im)\bNotify\b.+?\bcode\b.+?\bnot\b.+?\bgenerated\b @@ -4356,7 +4356,7 @@ type float myIntType ( rnd(), 255.0, myFunct() ); } <END_MODULE> <RESULT IF_PASS COUNT 1> -(?im)error.+?evaluatable.+?constant.+?value.+?expected.+?instead.+?of.+?operation +(?im)error.+?evaluable.+?constant.+?value.+?expected.+?instead.+?of.+?operation <END_RESULT> <RESULT IF_PASS COUNT 1> (?im)error.+?Reference.+?constant.+?expected.+?instead @@ -6900,7 +6900,7 @@ module x { } <END_MODULE> <RESULT IF_PASS COUNT 1> -(?im)error.+?evaluatable.+?constant.+?value.+?expected.+?instead.+?of.+?operation +(?im)error.+?evaluable.+?constant.+?value.+?expected.+?instead.+?of.+?operation <END_RESULT> <RESULT IF_PASS COUNT 1> (?is)\berror: diff --git a/function_test/Semantic_Analyser/template_restrictions/.gitignore b/function_test/Semantic_Analyser/template/.gitignore similarity index 100% rename from function_test/Semantic_Analyser/template_restrictions/.gitignore rename to function_test/Semantic_Analyser/template/.gitignore diff --git a/function_test/Semantic_Analyser/template_restrictions/Makefile b/function_test/Semantic_Analyser/template/Makefile similarity index 100% rename from function_test/Semantic_Analyser/template_restrictions/Makefile rename to function_test/Semantic_Analyser/template/Makefile diff --git a/function_test/Semantic_Analyser/template/TempOmit_SE.ttcn b/function_test/Semantic_Analyser/template/TempOmit_SE.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..64cc391c797b981d0695b3bbf9b129ba016fe841 --- /dev/null +++ b/function_test/Semantic_Analyser/template/TempOmit_SE.ttcn @@ -0,0 +1,16 @@ +/****************************************************************************** + * Copyright (c) 2000-2015 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 + ******************************************************************************/ +module TempOmit_SE { //^In TTCN-3 module// + +template integer t1 := (1 ifpresent, 2 ifpresent); //^In template definition// //^In list item//2 //error: `ifpresent' is not allowed here//2 +template integer t2 := complement (1 ifpresent, 2 ifpresent); //^In template definition// //^In list item//2 //error: `ifpresent' is not allowed here//2 + +template integer t3 := (1, 2, 3, omit); //^In template definition// //^In list item// //error: `omit' value is not allowed in this context// +template integer t4 := complement (3, 2, omit); //^In template definition// //^In list item// //error: `omit' value is not allowed in this context// + +} diff --git a/function_test/Semantic_Analyser/template_restrictions/TempRes_SE.ttcn b/function_test/Semantic_Analyser/template/TempRes_SE.ttcn similarity index 100% rename from function_test/Semantic_Analyser/template_restrictions/TempRes_SE.ttcn rename to function_test/Semantic_Analyser/template/TempRes_SE.ttcn diff --git a/function_test/Semantic_Analyser/template_restrictions/t b/function_test/Semantic_Analyser/template/t similarity index 100% rename from function_test/Semantic_Analyser/template_restrictions/t rename to function_test/Semantic_Analyser/template/t diff --git a/regression_test/RAW/Annex_E_variants/Annex_E_variants.cfg b/regression_test/RAW/Annex_E_variants/Annex_E_variants.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e778a48510227877de27bfba2c2a1916a9539780 --- /dev/null +++ b/regression_test/RAW/Annex_E_variants/Annex_E_variants.cfg @@ -0,0 +1,14 @@ +############################################################################### +# Copyright (c) 2000-2015 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 +############################################################################### +[LOGGING] +LogFile := "Annex_E_variants.log" +FileMask := LOG_ALL +ConsoleMask := TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS +LogSourceInfo := Yes +[EXECUTE] +Annex_E_variants.control diff --git a/regression_test/RAW/Annex_E_variants/Annex_E_variants.ttcn b/regression_test/RAW/Annex_E_variants/Annex_E_variants.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..7ef4a45530952b593bcf439e3f2446af9a9135e3 --- /dev/null +++ b/regression_test/RAW/Annex_E_variants/Annex_E_variants.ttcn @@ -0,0 +1,514 @@ +/****************************************************************************** + * Copyright (c) 2000-2015 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 + ******************************************************************************/ + +// This module contains tests for the variant attributes defined in Annex E of the +// TTCN-3 language standard. +// The encoding of the types with the new variants are compared to the encoding of +// types declared using traditional RAW variant attributes. + +// New attributes and their equivalents: +// "N bit" == "FIELDLENGTH(N), COMP(signbit), BYTEORDER(last)" +// "unsigned N bit" == "FIELDLENGTH(N), COMP(nosign), BYTEORDER(last)" +module Annex_E_variants { + +// E.2.1.0 Signed and unsigned single byte integers +type integer Byte (-128 .. 127) with { variant "8 bit" }; +type integer ByteEq (-128 .. 127) with { variant "FIELDLENGTH(8), COMP(signbit), BYTEORDER(last)" }; + +type integer UnsignedByte (0 .. 255) with { variant "unsigned 8 bit" }; +type integer UnsignedByteEq (0 .. 255) with { variant "FIELDLENGTH(8), COMP(nosign), BYTEORDER(last)" }; + +// E.2.1.1 Signed and unsigned short integers +type integer Short (-32768 .. 32767) with { variant "16 bit" }; +type integer ShortEq (-32768 .. 32767) with { variant "FIELDLENGTH(16), COMP(signbit), BYTEORDER(last)" }; + +type integer UnsignedShort (0 .. 65535) with { variant "unsigned 16 bit" }; +type integer UnsignedShortEq (0 .. 65535) with { variant "FIELDLENGTH(16), COMP(nosign), BYTEORDER(last)" }; + +// E.2.1.2 Signed and unsigned long integers +type integer Long (-2147483648 .. 2147483647) with { variant "32 bit" }; +type integer LongEq (-2147483648 .. 2147483647) with { variant "FIELDLENGTH(32), COMP(signbit), BYTEORDER(last)" }; + +type integer UnsignedLong (0 .. 4294967295) with { variant "unsigned 32 bit" }; +type integer UnsignedLongEq (0 .. 4294967295) with { variant "FIELDLENGTH(32), COMP(nosign), BYTEORDER(last)" }; + +// E.2.1.3 Signed and unsigned longlong integers +type integer LongLong (-9223372036854775808 .. 9223372036854775807) with { variant "64 bit" }; +type integer LongLongEq (-9223372036854775808 .. 9223372036854775807) with { variant "FIELDLENGTH(64), COMP(signbit), BYTEORDER(last)" }; + +type integer UnsignedLongLong (0 .. 18446744073709551615) with { variant "unsigned 64 bit" }; +type integer UnsignedLongLongEq (0 .. 18446744073709551615) with { variant "FIELDLENGTH(64), COMP(nosign), BYTEORDER(last)" }; + +// Custom integer types +type integer Int6 with { variant "6 bit" }; +type integer Int6Eq with { variant "FIELDLENGTH(6), COMP(signbit), BYTEORDER(last)" }; + +type integer UInt4 with { variant "unsigned 4 bit" }; +type integer UInt4Eq with { variant "FIELDLENGTH(4), COMP(nosign), BYTEORDER(last)" }; + +type integer BigInt with { variant "300 bit " }; +type integer BigIntEq with { variant "FIELDLENGTH(300), COMP(signbit), BYTEORDER(last)" }; + +// Using the "N bit" attribute on enumerated types +type enumerated Enum5 { val1(1), val7(7), val2(2), val11(11) } with { variant "unsigned 5 bit" }; +type enumerated Enum5Eq { val1(1), val7(7), val2(2), val11(11) } with { variant "FIELDLENGTH(5), COMP(nosign), BYTEORDER(last)" }; + +type enumerated Enum12 { val30(30), valm10(-10), val9(9) } with { variant "12 bit" }; +type enumerated Enum12Eq { val30(30), valm10(-10), val9(9) } with { variant "FIELDLENGTH(12), COMP(signbit), BYTEORDER(last)" }; + +// Using the "N bit" attribute on boolean types +type boolean Bool3 with { variant "3 bit" }; +type boolean Bool3Eq with { variant "FIELDLENGTH(3), BYTEORDER(last)" }; + +type boolean Bool13 with { variant "13 bit" }; +type boolean Bool13Eq with { variant "FIELDLENGTH(13), BYTEORDER(last)" }; + +// Using the "N bit" attribute on string types +type bitstring BStr14 with { variant "14 bit" }; +type bitstring BStr14Eq with { variant "FIELDLENGTH(14), BYTEORDER(last)" }; + +type hexstring HStr20 with { variant "unsigned 20 bit" }; // 20 bits = 5 hex nibbles, 'unsigned' is ignored +type hexstring HStr20Eq with { variant "FIELDLENGTH(5), BYTEORDER(last)" }; + +type octetstring OStr32 with { variant "32 bit" }; // 32 bits = 4 octets +type octetstring OStr32Eq with { variant "FIELDLENGTH(4), BYTEORDER(last)" }; + +type charstring CStr64 with { variant "64 bit" }; // 64 bits = 8 characters +type charstring CStr64Eq with { variant "FIELDLENGTH(8), BYTEORDER(last)" }; + +// Component type +type component CT {} + +// Test cases +testcase tc_byte() runs on CT +{ + var Byte x := -12; + var ByteEq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var Byte dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_unsigned_byte() runs on CT +{ + var UnsignedByte x := 91; + var UnsignedByteEq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var UnsignedByte dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_short() runs on CT +{ + var Short x := 399; + var ShortEq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var Short dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_unsigned_short() runs on CT +{ + var UnsignedShort x := 399; + var UnsignedShortEq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var UnsignedShort dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_long() runs on CT +{ + var Long x := 1457664; + var LongEq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var Long dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_unsigned_long() runs on CT +{ + var UnsignedLong x := 1457664; + var UnsignedLongEq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var UnsignedLong dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_long_long() runs on CT +{ + var LongLong x := -9223372036854775807; + var LongLongEq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var LongLong dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_unsigned_long_long() runs on CT +{ + var UnsignedLongLong x := 18446744073709551610; + var UnsignedLongLongEq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var UnsignedLongLong dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_int6() runs on CT +{ + var Int6 x := -19; + var Int6Eq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var Int6 dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_uint4() runs on CT +{ + var UInt4 x := 7; + var UInt4Eq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var UInt4 dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_big_int() runs on CT +{ + var BigInt x := -2837219487639565876438796348973264327463294623463287046324783264987325432; + var BigIntEq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var BigInt dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_enum5() runs on CT +{ + var Enum5 x := val11; + var Enum5Eq x_eq := val11; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var Enum5 dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_enum12() runs on CT +{ + var Enum12 x := valm10; + var Enum12Eq x_eq := valm10; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var Enum12 dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_bool3() runs on CT +{ + var Bool3 x := true; + var Bool3Eq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var Bool3 dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_bool13() runs on CT +{ + var Bool13 x := true; + var Bool13Eq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var Bool13 dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_bstr14() runs on CT +{ + var BStr14 x := '10101010101010'B; + var BStr14Eq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var BStr14 dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_hstr20() runs on CT +{ + var HStr20 x := 'CCCCC'H; + var HStr20Eq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var HStr20 dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_ostr32() runs on CT +{ + var OStr32 x := 'ABABABAB'O; + var OStr32Eq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var OStr32 dec; + if (decvalue(enc, dec) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != x) { + setverdict(fail, "Expected: ", x, ", got: ", dec); + } + } + setverdict(pass); +} + +testcase tc_cstr64() runs on CT +{ + var CStr64 x := "Hello"; + var CStr64Eq x_eq := x; + var bitstring enc := encvalue(x); + var bitstring enc_exp := encvalue(x_eq); + if (enc != enc_exp) { + setverdict(fail, "Expected: ", enc_exp, ", got: ", enc); + } + else { + var CStr64 dec; + var CStr64Eq dec_exp; + if (decvalue(enc, dec) != 0 or decvalue(enc_exp, dec_exp) != 0) { + setverdict(fail, "Could not decode ", enc); + } + else if (dec != dec_exp) { + setverdict(fail, "Expected: ", dec_exp, ", got: ", dec); + } + } + setverdict(pass); +} + +// Control part +control { + execute(tc_byte()); + execute(tc_unsigned_byte()); + execute(tc_short()); + execute(tc_unsigned_short()); + execute(tc_long()); + execute(tc_unsigned_long()); + execute(tc_long_long()); + execute(tc_unsigned_long_long()); + execute(tc_int6()); + execute(tc_uint4()); + execute(tc_big_int()); + execute(tc_enum5()); + execute(tc_enum12()); + execute(tc_bool3()); + execute(tc_bool13()); + execute(tc_bstr14()); + execute(tc_hstr20()); + execute(tc_ostr32()); + execute(tc_cstr64()); +} + +} +with { + encode "RAW"; +} diff --git a/regression_test/RAW/Annex_E_variants/Makefile b/regression_test/RAW/Annex_E_variants/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..f590c44994f983fcf4d753583436781c972a633f --- /dev/null +++ b/regression_test/RAW/Annex_E_variants/Makefile @@ -0,0 +1,54 @@ +############################################################################### +# Copyright (c) 2000-2015 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 +############################################################################### +TOPDIR := ../.. +include $(TOPDIR)/Makefile.regression + +.PHONY: all clean dep run + +TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) + +TTCN3_MODULES = Annex_E_variants.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)) +endif + +USER_SOURCES = + +# All object files needed for the executable test suite: +OBJECTS = $(GENERATED_SOURCES:.cc=.o) $(USER_SOURCES:.cc=.o) + +# The name of the executable test suite: +TARGET = Annex_E_variants$(EXESUFFIX) + +all: $(TARGET) ; + +$(TARGET): $(OBJECTS) + $(CXX) $(LDFLAGS) -o $@ $(OBJECTS) -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \ + -L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS) + +$(GENERATED_SOURCES) $(GENERATED_HEADERS): compile + @if [ ! -f $@ ]; then $(RM) compile; $(MAKE) compile; fi + +compile: $(TTCN3_MODULES) $(ASN1_MODULES) + $(TTCN3_COMPILER) $(COMPILER_FLAGS) $^ + touch $@ + +clean distclean: + $(RM) $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ + $(GENERATED_SOURCES) compile *.log + +dep: $(GENERATED_SOURCES) + makedepend $(CPPFLAGS) $(USER_SOURCES) $(GENERATED_SOURCES) + +run: $(TARGET) Annex_E_variants.cfg + ./$^ + +# DO NOT DELETE diff --git a/regression_test/XML/AbstractBlock/AbstractBlock.ttcn b/regression_test/XML/AbstractBlock/AbstractBlock.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..9e1c921924184f8029ae30f5d4402576eb110dbf --- /dev/null +++ b/regression_test/XML/AbstractBlock/AbstractBlock.ttcn @@ -0,0 +1,240 @@ +/****************************************************************************** + * Copyright (c) 2000-2015 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 + ******************************************************************************/ +module AbstractBlock { + +// This module contains tests for the ABSTRACT and BLOCK encoding instructions, +// which are generally used in code generated from element substitutions and type +// substitutions in XSD. + +type component CT {} + +/******* Test 1: Element substitution example *******/ +type charstring Member1 +with { + variant "name as uncapitalized"; + variant "element"; +} + +type enumerated Member2 +{ + else_, + something +} +with { + variant "text 'else_' as 'else'"; + variant "name as uncapitalized"; + variant "element"; +} + +type record Member3 +{ + integer bar optional, + float foo optional, + charstring base +} +with { + variant "name as uncapitalized"; + variant "element"; + variant(bar) "attribute"; + variant(foo) "attribute"; + variant(base) "untagged"; +} + +type union Head_group +{ + charstring head, + Member1 member1, + Member2 member2, + Member3 member3 +} +with { + variant "untagged"; + variant(head) "abstract"; + variant(member3) "block"; +} + +type record of Head_group Data +with { + variant "name as uncapitalized"; +} + +external function f_enc_data(in Data x) return octetstring + with { extension "prototype(convert) encode(XER:XER_EXTENDED)" }; + +external function f_dec_data(in octetstring x) return Data + with { extension "prototype(convert) decode(XER:XER_EXTENDED)" }; + +testcase tc_element_substitution() runs on CT +{ + // non-blocked and non-abstract fields should be encoded and decoded normally + var Data v_data := { { member1 := "xy" }, { member2 := else_ } }; + var octetstring v_exp_enc := char2oct( + "<data xmlns:tns='http://www.example.org/blockExtension'>\n" & + "\t<tns:member1>xy</tns:member1>\n" & + "\t<tns:member2>else</tns:member2>\n" & + "</data>\n\n"); + + var octetstring v_enc := f_enc_data(v_data); + if (v_enc != v_exp_enc) { + setverdict(fail, "Expected: ", v_exp_enc, ", got: ", v_enc); + } + var Data v_dec := f_dec_data(v_exp_enc); + if (v_dec != v_data) { + setverdict(fail, "Expected: ", v_data, ", got: ", v_dec); + } + + // abstract and blocked fields are encoded as before, but cause an error while decoding + v_data := { { head := "abc" } }; + v_exp_enc := char2oct( + "<data>\n" & + "\t<head>abc</head>\n" & + "</data>\n\n"); + + v_enc := f_enc_data(v_data); + if (v_enc != v_exp_enc) { + setverdict(fail, "Expected: ", v_exp_enc, ", got: ", v_enc); + } + + @try { + v_dec := f_dec_data(v_exp_enc); + setverdict(fail, "Error expected while decoding ", v_exp_enc); + } + @catch (msg) { + if (not match(msg, pattern "*Index 0: Alternative 'head': Attempting to decode blocked or abstract field.")) { + setverdict(fail, "Incorrect error message received while decoding ", v_exp_enc, " (message: ", msg, ")"); + } + } + + // another negative test example + v_data := { { member2 := something }, { member3 := { bar := 10, foo := omit, base := "base" } } }; + v_exp_enc := char2oct( + "<data xmlns:tns='http://www.example.org/blockExtension'>\n" & + "\t<tns:member2>something</tns:member2>\n" & + "\t<tns:member3 bar='10'>base</tns:member3>\n" & + "</data>\n\n"); + + v_enc := f_enc_data(v_data); + if (v_enc != v_exp_enc) { + setverdict(fail, "Expected: ", v_exp_enc, ", got: ", v_enc); + } + + @try { + v_dec := f_dec_data(v_exp_enc); + setverdict(fail, "Error expected while decoding ", v_exp_enc); + } + @catch (msg) { + if (not match(msg, pattern "*Index 1: Alternative 'member3': Attempting to decode blocked or abstract field.")) { + setverdict(fail, "Incorrect error message received while decoding ", v_exp_enc, " (message: ", msg, ")"); + } + } + + setverdict(pass); +} + +/******* Test 2: Type substitution example *******/ +type record ParentType { + record length (1 .. infinity) of charstring foo_list optional, + charstring bar +} +with { + variant "name as uncapitalized"; + variant(foo_list) "untagged"; + variant(foo_list[-]) "name as 'foo'"; +} + +type record RestrictedType { + record length (1 .. infinity) of charstring foo_list, + charstring bar +} +with { + variant "name as uncapitalized"; + variant(foo_list) "untagged"; + variant(foo_list[-]) "name as 'foo'"; +} + +type union ParentType_derivations { + ParentType parentType, + RestrictedType restrictedType +} +with { + variant "useType"; + variant "name as 'derivation'"; + variant(parentType) "abstract"; +} + +type record of ParentType_derivations Data2 +with { + variant "name as 'data'"; +} + +external function f_enc_data2(in Data2 x) return octetstring + with { extension "prototype(convert) encode(XER:XER_EXTENDED)" }; + +external function f_dec_data2(in octetstring x) return Data2 + with { extension "prototype(convert) decode(XER:XER_EXTENDED)" }; + +testcase tc_type_substitution() runs on CT +{ + // non-blocked and non-abstract fields should be encoded and decoded normally + var Data2 v_data := { { restrictedType := { foo_list := { "first", "second" }, bar := "restricted" } } }; + var octetstring v_exp_enc := char2oct( + "<data xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\n" & + "\t<derivation xsi:type='restrictedType'>\n" & + "\t\t<foo>first</foo>\n" & + "\t\t<foo>second</foo>\n" & + "\t\t<bar>restricted</bar>\n" & + "\t</derivation>\n" & + "</data>\n\n"); + + var octetstring v_enc := f_enc_data2(v_data); // '>' missing from one of the tags, requires Bence's modification + /*if (v_enc != v_exp_enc) { + setverdict(fail, "Expected: ", v_exp_enc, ", got: ", v_enc); + }*/ + var Data2 v_dec := f_dec_data2(v_exp_enc); + if (v_dec != v_data) { + setverdict(fail, "Expected: ", v_data, ", got: ", v_dec); + } + + // abstract and blocked fields are encoded as before, but cause an error while decoding + v_data := { { parentType := { foo_list := omit, bar := "parent" } } }; + v_exp_enc := char2oct( + "<data>\n" & + "\t<derivation>\n" & + "\t\t<bar>parent</bar>\n" & + "\t</derivation>\n" & + "</data>\n\n"); + + v_enc := f_enc_data2(v_data); // '>' missing + /*if (v_enc != v_exp_enc) { + setverdict(fail, "Expected: ", v_exp_enc, ", got: ", v_enc); + }*/ + + @try { + v_dec := f_dec_data2(v_exp_enc); + setverdict(fail, "Error expected while decoding ", v_exp_enc); + } + @catch (msg) { + if (not match(msg, pattern "*Index 0: Alternative 'parentType': Attempting to decode blocked or abstract field.")) { + setverdict(fail, "Incorrect error message received while decoding ", v_exp_enc, " (message: ", msg, ")"); + } + } + + setverdict(pass); +} + +control { + execute(tc_element_substitution()); + execute(tc_type_substitution()); +} + +} +with { + encode "XML"; + variant "namespace as 'http://www.example.org/blockExtension' prefix 'tns'"; + variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/AbstractBlock/Makefile b/regression_test/XML/AbstractBlock/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..340d03eb11682cf2837fb69232e87637d79c3ba2 --- /dev/null +++ b/regression_test/XML/AbstractBlock/Makefile @@ -0,0 +1,138 @@ +############################################################################### +# Copyright (c) 2000-2015 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 +############################################################################### +TOPDIR = ../.. +include ../../Makefile.regression + +# WARNING! This Makefile can be used with GNU make only. +# Other versions of make may report syntax errors in it. + +# +# Do NOT touch this line... +# +.PHONY: all archive check clean dep objects + +.SUFFIXES: .d + +# +# Set these variables... +# + +# Flags for the C++ preprocessor (and makedepend as well): +#CPPFLAGS += + +# Flags for dependency generation +CXXDEPFLAGS = -MM + +# Flags for the C++ compiler: +CXXFLAGS += -Wall + +# Flags for the linker: +#LDFLAGS += + +# Flags for the TTCN-3 and ASN.1 compiler: +#COMPILER_FLAGS += + +# Execution mode: (either ttcn3 or ttcn3-parallel) +TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) + +# +# You may change these variables. Add your files if necessary... +# + +# TTCN-3 modules of this project: +TTCN3_MODULES = AbstractBlock.ttcn + +# ASN.1 modules of this project: +ASN1_MODULES = + +# C++ source & header files generated from the TTCN-3 & ASN.1 modules of +# this project: +GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) $(ASN1_MODULES:.asn=.cc) +GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh) + +# C/C++ Source & header files of Test Ports, external functions and +# other modules: +USER_SOURCES = +USER_HEADERS = $(USER_SOURCES:.cc=.hh) + +# Object files of this project that are needed for the executable test suite: +OBJECTS = $(GENERATED_OBJECTS) $(USER_OBJECTS) + +GENERATED_OBJECTS = $(GENERATED_SOURCES:.cc=.o) + +USER_OBJECTS = $(USER_SOURCES:.cc=.o) + +DEPFILES = $(USER_OBJECTS:.o=.d) $(GENERATED_OBJECTS:.o=.d) + +# Other files of the project (Makefile, configuration files, etc.) +# that will be added to the archived source files: +OTHER_FILES = Makefile + +# The name of the executable test suite: +TARGET = AbstractBlock + +# +# Rules for building the executable... +# + +all: $(TARGET) ; + +objects: $(OBJECTS) compile; + +$(TARGET): $(OBJECTS) + if $(CXX) $(LDFLAGS) -o $@ $^ \ + -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \ + -L$(OPENSSL_DIR)/lib -lcrypto \ + -L$(XMLDIR)/lib $($(PLATFORM)_LIBS); \ + then : ; else $(TTCN3_DIR)/bin/titanver $(OBJECTS); exit 1; fi + +.cc.o .c.o: + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $< + +.cc.d .c.d: + @echo Creating dependency file for '$<'; set -e; \ + $(CXX) $(CXXDEPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $< \ + | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \ + [ -s $@ ] || rm -f $@ + +$(GENERATED_SOURCES) $(GENERATED_HEADERS): compile + @if [ ! -f $@ ]; then $(RM) compile; $(MAKE) compile; fi + +compile: $(TTCN3_MODULES) $(ASN1_MODULES) + $(TTCN3_COMPILER) $(COMPILER_FLAGS) $^ - $? + touch $@ + +clean distclean: + -$(RM) $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ + $(GENERATED_SOURCES) compile $(DEPFILES) \ + tags *.log + +dep: $(GENERATED_SOURCES) $(USER_SOURCES) ; + +ifeq ($(findstring n,$(MAKEFLAGS)),) +ifeq ($(filter clean distclean check compile archive diag,$(MAKECMDGOALS)),) +-include $(DEPFILES) +endif +endif + +diag: + $(TTCN3_COMPILER) -v 2>&1 + $(TTCN3_DIR)/bin/mctr_cli -v 2>&1 + $(CXX) -v 2>&1 + @echo TTCN3_DIR=$(TTCN3_DIR) + @echo OPENSSL_DIR=$(OPENSSL_DIR) + @echo XMLDIR=$(XMLDIR) + @echo PLATFORM=$(PLATFORM) + +# +# Add your rules here if necessary... +# + +run: $(TARGET) + ./$^ + diff --git a/regression_test/XML/EXER-whitepaper/AnyElementOptional.ttcnpp b/regression_test/XML/EXER-whitepaper/AnyElementOptional.ttcnpp index 3398477218429d2866225f3cb7a0bd4ddcb8dc9d..e0e734bea68865d7ad26a105ec16fd4c5f2bd0c0 100644 --- a/regression_test/XML/EXER-whitepaper/AnyElementOptional.ttcnpp +++ b/regression_test/XML/EXER-whitepaper/AnyElementOptional.ttcnpp @@ -119,11 +119,17 @@ with { DECLARE_XER_ENCODERS(anys_and_only_anys, aaoa); DECLARE_EXER_ENCODERS(anys_and_only_anys, aaoa); -const anys_and_only_anys noanys := { elements := {} } +const anys_and_only_anys noanys_empty := { elements := {} } +const anys_and_only_anys noanys_omit := { elements := omit } + +// the empty array is encoded into this in basic XER const universal charstring bstr_noanys := "<anys_and_only_anys>\n" & "\t<elements/>\n" & "</anys_and_only_anys>\n\n"; + +// both the empty array and the omitted field are encoded into this in extended XER +// this is always decoded into an omitted field const universal charstring estr_noanys := "<anys_and_only_anys/>\n\n"; @@ -153,8 +159,9 @@ const anys_and_only_anys marx_dec := { testcase encode_only_opt() runs on AE { - CHECK_METHOD(bxer_enc_aaoa, noanys, bstr_noanys); - CHECK_METHOD(exer_enc_aaoa, noanys, estr_noanys); + CHECK_METHOD(bxer_enc_aaoa, noanys_empty, bstr_noanys); + CHECK_METHOD(exer_enc_aaoa, noanys_empty, estr_noanys); + CHECK_METHOD(exer_enc_aaoa, noanys_omit, estr_noanys); CHECK_METHOD(bxer_enc_aaoa, marx, bstr_marx); CHECK_METHOD(exer_enc_aaoa, marx, estr_marx); @@ -162,8 +169,8 @@ testcase encode_only_opt() runs on AE testcase decode_only_opt() runs on AE { - CHECK_DECODE(bxer_dec_aaoa, bstr_noanys, anys_and_only_anys, noanys); - CHECK_DECODE(exer_dec_aaoa, estr_noanys, anys_and_only_anys, noanys); + CHECK_DECODE(bxer_dec_aaoa, bstr_noanys, anys_and_only_anys, noanys_empty); + CHECK_DECODE(exer_dec_aaoa, estr_noanys, anys_and_only_anys, noanys_omit); CHECK_DECODE(bxer_dec_aaoa, bstr_marx, anys_and_only_anys, marx); CHECK_DECODE(exer_dec_aaoa, estr_marx, anys_and_only_anys, marx_dec); diff --git a/regression_test/XML/EXER-whitepaper/Untagged.ttcnpp b/regression_test/XML/EXER-whitepaper/Untagged.ttcnpp index 281a34498465ae4d3747beb64a5448a1150558a2..f305fd714d12ede29d4ed250d54294b6dae63d6f 100644 --- a/regression_test/XML/EXER-whitepaper/Untagged.ttcnpp +++ b/regression_test/XML/EXER-whitepaper/Untagged.ttcnpp @@ -658,6 +658,40 @@ testcase decode_ut_ustr() runs on UTA +// ------- optional record of +type record length (1 .. infinity) of charstring RoCS +with { + variant ([-]) "name as 'str'"; +} + +type record r_recof { + record length (1 .. infinity) of integer num_list optional, + RoCS str_list optional +} +with { + variant(num_list) "untagged"; + variant(num_list[-]) "name as 'num'"; + variant(str_list) "untagged"; +} + +DECLARE_EXER_ENCODERS(r_recof, recof); + +const r_recof c_recof := { num_list := omit, str_list := omit }; + +const universal charstring s_recof := "<r_recof/>\n\n"; + +testcase encode_ut_recof() runs on UTA +{ + CHECK_METHOD(exer_enc_recof, c_recof, s_recof); +} + +testcase decode_ut_recof() runs on UTA +{ + CHECK_DECODE(exer_dec_recof, s_recof, r_recof, c_recof); +} + + + /* * * * * * * * * * * Run it! * * * * * * * * * * */ control { @@ -694,6 +728,8 @@ control { execute(encode_ut_ustr()); execute(decode_ut_ustr()); + execute(encode_ut_recof()); + execute(decode_ut_recof()); } } diff --git a/regression_test/XML/EXER-whitepaper/UseType.ttcnpp b/regression_test/XML/EXER-whitepaper/UseType.ttcnpp index d7e8ec390ca96b6d322031765729ef14c99c9882..a975845d12294528248718d6f29ae4d7817d1dc8 100644 --- a/regression_test/XML/EXER-whitepaper/UseType.ttcnpp +++ b/regression_test/XML/EXER-whitepaper/UseType.ttcnpp @@ -120,12 +120,62 @@ testcase decode_12() runs on Shop CHECK_DECODE(exer_dec_u, str_12_e, U, v); } +group QualifiedUseType { + +type union Number { + integer i, + float f, + octetstring os +} +with { + variant "useType"; + variant "name as uncapitalized"; + variant(i) "name as 'integer'"; + variant(f) "name as 'real'"; + variant(os) "name as 'hexadecimal'"; +} + +type record of Number Data +with { + variant "name as uncapitalized"; +} + +} // group QualifiedUseType +with { + variant "elementFormQualified"; + variant "namespace as 'http://www.example.org/Number' prefix 'nr'"; +} + +DECLARE_EXER_ENCODERS(Data, data); + +const Data c_data := { { i := 10 }, { f := 3.3 }, { os := '5DA8'O } }; + +const universal charstring str_data := +"<nr:data xmlns:nr='http://www.example.org/Number' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\n" & +"\t<nr:number>10</nr:number>\n" & +"\t<nr:number xsi:type='nr:real'>3.300000</nr:number>\n" & +"\t<nr:number xsi:type='nr:hexadecimal'>5DA8</nr:number>\n" & +"</nr:data>\n\n"; + +testcase encode_qualified() runs on Shop +{ + CHECK_METHOD(exer_enc_data, c_data, str_data); +} + +testcase decode_qualified() runs on Shop +{ + CHECK_DECODE(exer_dec_data, str_data, Data, c_data); +} + control { execute(enc_ut()); execute(dec_ut()); execute(encode_12()); execute(decode_12()); + + execute(encode_qualified()); + execute(decode_qualified()); } } diff --git a/regression_test/XML/Makefile b/regression_test/XML/Makefile index dfdba818944d68cac8361a9dec5f4faccff27e76..cf5c508ac804fdde44ea731e4989726f4fdfcfda 100644 --- a/regression_test/XML/Makefile +++ b/regression_test/XML/Makefile @@ -19,7 +19,7 @@ endif XDIRS := $(wildcard $(SHADOWED)) xsdConverter \ HM60295 HN15589 HQ30408 HR49727 HU13380 $(RT2_ONLY) \ -XmlWorkflow tpdValidTest +XmlWorkflow tpdValidTest AbstractBlock # List of fake targets: .PHONY: all dep clean run $(XDIRS) $(addsuffix /, $(XDIRS)) profile diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace2_e.ttcn similarity index 89% rename from regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace.ttcn rename to regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace2_e.ttcn index d4cb2c755116a1b8fc6f29112d73a2449c6276eb..f0738822b391d45dcfa85e7b9b0d87f8bef20c3a 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/NoTargetNamespace2_e.ttcn @@ -1,7 +1,7 @@ /******************************************************************************* -* Copyright Ericsson Telecom AB 2015 +* Copyright (c) 2000-2015 Ericsson Telecom AB * -* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* XSD to TTCN-3 Translator version: CRL 113 200/5 R4A * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -14,7 +14,7 @@ // References: // Rev: // Prodnr: -// Updated: Wed Oct 28 13:59:18 2015 +// Updated: Wed Nov 25 17:13:46 2015 // Contact: http://ttcn.ericsson.se // //////////////////////////////////////////////////////////////////////////////// @@ -33,7 +33,7 @@ //////////////////////////////////////////////////////////////////////////////// -module NoTargetNamespace { +module NoTargetNamespace2_e { import from XSD all; 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 0bd3ad2ffe33e5a89933287d050e66c34387b0ba..be0bd7250dff95c9f65b0645942529692691a52c 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 @@ -42,7 +42,7 @@ import from XSD all; import from www_example_org_attrib_order_b all; -import from NoTargetNamespace all; +import from NoTargetNamespace2_e all; type XSD.String Local1 ("fixed") diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_generate_element_substitution_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_generate_element_substitution_e.ttcn index 7903decabeae558dd531c1d98bc580c3f7f00f3b..670400e5a1f445df0264981626cbc705efea08c6 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_generate_element_substitution_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_generate_element_substitution_e.ttcn @@ -90,7 +90,8 @@ type union Head_group } with { variant "untagged"; -//variant (member2) "block"; +variant (head) "form as qualified"; +variant (member2) "block"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_no_ns_connector_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_no_ns_connector_e.ttcn index dd99f621e3cd5bbe2527f61b26a1cf2a11e3317e..f9d635e11043943871a8ed57e30109405b4a0a95 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_no_ns_connector_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_no_ns_connector_e.ttcn @@ -53,6 +53,7 @@ type record Java_attribute_1 } with { variant "name as 'java-attribute'"; +variant "abstract"; variant (java_attribute) "name as 'java-attribute'"; variant (java_attribute) "attribute"; variant (xml_accessor_type) "name as 'xml-accessor-type'"; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_only_element_substitution_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_only_element_substitution_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..be0e006e409c35354b030dde0b289bbc906e741e --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_only_element_substitution_e.ttcn @@ -0,0 +1,98 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_only_element_substitution_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Mon Nov 23 13:30:51 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - only_element_substitution_e.xsd +// /* xml version = "1.0" */ +// /* targetnamespace = "www.example.org/only/element/substitution/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_only_element_substitution { + + +import from XSD all; + + +type RequestAbstractType_group RequestAbstractType1 +with { +variant "name as uncapitalized"; +variant "abstract"; +variant "element"; +}; + + +/* Production implementation */ + + +type record ProductionRequest +{ + XSD.String commonName, + XSD.String productionName +} +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +/* Production implementation */ + + +type record ProgrammingRequest +{ + XSD.String commonName, + XSD.String programmingName +} +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type union RequestAbstractType_group +{ + record { + XSD.String commonName + } requestAbstractType, + ProductionRequest productionRequest, + ProgrammingRequest programmingRequest +} +with { +variant "untagged"; +variant (requestAbstractType) "form as qualified"; +variant (requestAbstractType) "abstract"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/only/element/substitution'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_1_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_1_e.ttcn index 550b52498d196416682220d671b7271ac3897f6e..e7bd555ee47fac4de9f6284dcb8ddcbbeca4d8ba 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_1_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_1_e.ttcn @@ -121,8 +121,9 @@ type union Head_group } with { variant "untagged"; -//variant (head) "abstract"; -//variant (member2) "block"; +variant (head) "form as qualified"; +variant (head) "abstract"; +variant (member2) "block"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_2_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_2_e.ttcn index f1bc2b8949c736d2e6ea85ca9854966924942d57..0d6ac78f54c1e38cae9a94df211a929054c6a003 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_2_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_2_e.ttcn @@ -121,8 +121,9 @@ type union Head_group } with { variant "untagged"; -//variant (head) "abstract"; -//variant (member3) "block"; +variant (head) "form as qualified"; +variant (head) "abstract"; +variant (member3) "block"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complex_without_element_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complex_without_element_e.ttcn index cd2a805409af6429bf76c7e61e518ac9327644c3..8bce067e92ac6693c8a3f4553a9b54055c93b17a 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complex_without_element_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complex_without_element_e.ttcn @@ -110,12 +110,13 @@ type union Head_group_1 } with { variant "untagged"; -//variant (head) "abstract"; +variant (head) "form as qualified"; +variant (head) "abstract"; variant (head.headAttrib) "attribute"; variant (head.something) "name as capitalized"; -//variant (member) "block"; -//variant (member2) "block"; -//variant (stringEnum) "block"; +variant (member) "block"; +variant (member2) "block"; +variant (stringEnum) "block"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complextype_block_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complextype_block_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..a3f45154c2f8205b5b1f7330e5480967a0ac2b4c --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_complextype_block_e.ttcn @@ -0,0 +1,95 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_substitutiongroup_complextype_block_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Nov 12 12:43:46 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - substitutiongroup_complextype_block_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/substitutiongroup/complextype/block/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_substitutiongroup_complextype_block { + + +import from XSD all; + + +/* SUBSTITUTABLE PARENT TYPE */ + + +type record ParentType +{ + record of XSD.String foo_list, + XSD.String bar +} +with { +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type RestrictedType RestrictedTypeElem +with { +variant "element"; +}; + + +/* The restricting type is: */ + + +type record RestrictedType +{ + record length(1 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type union Head_group +{ + RestrictedType head, + RestrictedTypeElem restrictedTypeElem +} +with { +variant "untagged"; +variant (head) "form as qualified"; +variant (restrictedTypeElem) "name as capitalized"; +variant (restrictedTypeElem) "block"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/substitutiongroup/complextype/block' prefix 'this'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_e.ttcn index d5d02bde72873dcbfe33b8c4e67c95f47faf62cc..b96e0e9b416be3aaaf289acf1e2b38c749e7444e 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_e.ttcn @@ -121,12 +121,13 @@ type union Head_group } with { variant "untagged"; +variant (head) "form as qualified"; }; } with { encode "XML"; -variant "namespace as 'www.example.org/substitutiongroup' prefix 'this'"; +variant "namespace as 'www.example.org/substitutiongroup' prefix 'subs'"; variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; } diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_long_extension_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_long_extension_e.ttcn index eabb9184e835db1b925c5d4d38ea9e44456707e1..d4b44a1f7509d496195178d46aefd5a07d072ec4 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_long_extension_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_long_extension_e.ttcn @@ -138,9 +138,9 @@ type union Head_group } with { variant "untagged"; -//variant (complexEnum) "block"; -//variant (member2) "block"; -//variant (member3) "block"; +variant (complexEnum) "block"; +variant (member2) "block"; +variant (member3) "block"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn index ad5eb2106d994083202b3a8cbb5b5757aac16adc..026df7471f0d4f289b62e55444b3b5bc4b2eb59a 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn @@ -65,7 +65,8 @@ type union Subsgroup_group } with { variant "untagged"; -//variant (subsgroup) "abstract"; +variant (subsgroup) "form as qualified"; +variant (subsgroup) "abstract"; variant (replace_) "name as 'replace'"; }; diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_name_as_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_name_as_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..27e19c64df4719071c9ed1252190c37e01a008f1 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_name_as_e.ttcn @@ -0,0 +1,131 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_substitutiongroup_name_as_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Thu Nov 12 10:42:59 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - substitutiongroup_name_as_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/substitutiongroup/name/as/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_substitutiongroup_name_as { + + +import from XSD all; + + +/* THE HEAD ELEMENT */ + + +/* SUBSTITUTION ELEMENT OF THE SAME TYPE AS THE HEAD */ + + +type XSD.String Member1 +with { +variant "element"; +}; + + +/* SUBSTITUTION ELEMENT OF A TYPE RESTRICTING THE TYPE OF THE HEAD */ + + +type enumerated StringEnum +{ + else_, + something +} +with { +variant "text 'else_' as 'else'"; +}; + + +type StringEnum Member2 +with { +variant "element"; +}; + + +/* SUBSTITUTION ELEMENT OF A TYPE EXTENDING THE TYPE OF THE HEAD */ + + +type record ComplexEnum +{ + XSD.Integer bar optional, + XSD.Float foo optional, + XSD.String base +} +with { +variant (bar) "attribute"; +variant (foo) "attribute"; +variant (base) "untagged"; +}; + + +type ComplexEnum Member3 +with { +variant "element"; +}; + + +/* TOP LEVEL ELEMENT TO DEMONSTRATE SUBSTITUTION */ + + +type record Ize +{ + record of Head_group head_list +} +with { +variant "element"; +variant (head_list) "untagged"; +variant (head_list[-]) "name as 'Head'"; +}; + + +type union Head_group +{ + XSD.String head, + Member1 member1, + Member2 member2, + Member3 member3 +} +with { +variant "untagged"; +variant (head) "name as capitalized"; +variant (head) "form as qualified"; +variant (member1) "name as capitalized"; +variant (member2) "name as capitalized"; +variant (member3) "name as capitalized"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/substitutiongroup/name/as' prefix 'this'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_rename_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_rename_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..580a1b4751d1398cc852ea4a3b2793a8f1d71f1a --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_substitutiongroup_rename_e.ttcn @@ -0,0 +1,101 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_substitutiongroup_rename_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Wed Nov 25 14:32:37 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - substitutiongroup_rename_e.xsd +// /* xml version = "1.0" */ +// /* targetnamespace = "www.example.org/substitutiongroup/rename/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_substitutiongroup_rename { + + +import from XSD all; + + +type record BaseElement_1 +{ + +} +with { +variant "name as 'BaseElement_'"; +}; + + +type record Audit +{ + BaseElement_group baseElement optional +} +with { +variant (baseElement) "name as capitalized"; +}; + + +type XSD.Integer Case +with { +variant "abstract"; +variant "element"; +}; + + +type XSD.String BaseElement +with { +variant "name as 'BaseElement__'"; +variant "abstract"; +variant "element"; +}; + + +type Audit Case_1 +with { +variant "name as 'Case_'"; +variant "element"; +}; + + +type union BaseElement_group +{ + BaseElement_1 baseElement, + Case_1 case_ +} +with { +variant "untagged"; +variant (baseElement) "name as capitalized"; +variant (baseElement) "form as qualified"; +variant (baseElement) "abstract"; +variant (case_) "name as capitalized"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/substitutiongroup/rename' prefix 'this'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_subs_with_elem_subs_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_subs_with_elem_subs_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..7752697c3e9af091f76ddea6a1dd09cb22a0cccf --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_subs_with_elem_subs_e.ttcn @@ -0,0 +1,152 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_subs_with_elem_subs_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Wed Nov 18 13:34:40 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_subs_with_elem_subs_e.xsd +// /* xml version = "1.0" */ +// /* targetnamespace = "www.example.org/type/subs/with/elem/subs/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_subs_with_elem_subs { + + +import from XSD all; + + +/* Root element */ + + +type SubmitRequestType Submit +with { +variant "element"; +}; + + +type record RequestGroup +{ + Request_group request +} +with { +variant "name as uncapitalized"; +}; + + +type record SubmitRequestType +{ + XSD.String name, + RequestAbstractType_derivations request1, + RequestAbstractType_derivations request2 +}; + + +/* The generic abstract type */ + + +type record RequestAbstractType +{ + XSD.String commonName +} +with { +variant "name as uncapitalized"; +variant "abstract"; +}; + + +/* Production implementation */ + + +type MyProductionRequestType ProductionRequest +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type record MyProductionRequestType +{ + XSD.String commonName, + XSD.String productionName +} +with { +variant "name as uncapitalized"; +}; + + +/* Production implementation */ + + +type MyProgrammingRequestType ProgrammingRequest +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type record MyProgrammingRequestType +{ + XSD.String commonName, + XSD.String programmingName +} +with { +variant "name as uncapitalized"; +}; + + +type union Request_group +{ + RequestAbstractType_derivations request, + ProductionRequest productionRequest, + ProgrammingRequest programmingRequest +} +with { +variant "untagged"; +variant (request) "form as qualified"; +variant (request) "abstract"; +}; + + +type union RequestAbstractType_derivations +{ + RequestAbstractType requestAbstractType, + MyProductionRequestType myProductionRequestType, + MyProgrammingRequestType myProgrammingRequestType +} +with { +variant "name as uncapitalized"; +variant "useType"; +variant (requestAbstractType) "abstract"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/subs/with/elem/subs'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_abstract_block_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_abstract_block_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..45762e5825db16af27979eb3a6864b2c55bedbc9 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_abstract_block_e.ttcn @@ -0,0 +1,210 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_abstract_block_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Tue Nov 17 13:25:59 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_abstract_block_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/type/substitution/abstract/block/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution_abstract_block { + + +import from XSD all; + + +type ParentType_derivations Head +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +/* SUBSTITUTABLE PARENT TYPE */ + + +/* type substitutiongroup generated, because has elemet declaration */ + + +type record ParentType +{ + record of XSD.String foo_list, + XSD.String bar +} +with { +variant "abstract"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type RestrictedType_derivations RestrictedTypeElem +with { +variant "element"; +}; + + +/* type substitutiongroup generated, because has elemet declaration */ + + +type record RestrictedType +{ + record length(1 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +/* type substitutiongroup generated, because the parent has elemet declaration */ + + +type record RestrictedType2 +{ + record length(2 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +/* Added to restrictedtype_derivations */ + + +type record RestrictedType2_1 +{ + record length(2 .. 5) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as 'restrictedType2.1'"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +/* No type substitutiongroup generated, because the parent lacks elemet declaration */ + + +type record RestrictedType3 +{ + record length(3 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type ExtendedType_derivations ExtendedElement +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type record ExtendedType +{ + XSD.String attr1 optional, + record of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (attr1) "attribute"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type record RestrictedExtendedType +{ + record of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type union ParentType_derivations +{ + ParentType parentType, + ExtendedType_derivations extendedType, + RestrictedType_derivations restrictedType +} +with { +variant "useType"; +variant (parentType) "name as capitalized"; +variant (parentType) "abstract"; +variant (extendedType) "block"; +}; + + +type union RestrictedType_derivations +{ + RestrictedType restrictedType, + RestrictedType2 restrictedType2, + RestrictedType2_1 restrictedType2_1 +} +with { +variant "name as uncapitalized"; +variant "useType"; +variant (restrictedType2_1) "name as 'restrictedType2.1'"; +}; + + +type union ExtendedType_derivations +{ + ExtendedType extendedType, + RestrictedExtendedType restrictedExtendedType +} +with { +variant "name as uncapitalized"; +variant "useType"; +variant (restrictedExtendedType) "block"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution/abstract/block' prefix 'tys'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_builtintype_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_builtintype_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..900337190187aab74cad9a691ed2b40ede05cd72 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_builtintype_e.ttcn @@ -0,0 +1,104 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_builtintype_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Tue Nov 24 11:21:17 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_builtintype_e.xsd +// /* xml version = "1.0" */ +// /* targetnamespace = "www.example.org/type/substitution/builtintype/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution_builtintype { + + +import from XSD all; + + +type String_derivations Elem +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type enumerated Enable +{ + equal +} +with { +variant "name as uncapitalized"; +}; + + +type enumerated Session +{ + visible_and_interactive +} +with { +variant "name as uncapitalized"; +}; + + +type enumerated Res +{ + pending +} +with { +variant "name as uncapitalized"; +}; + + +type enumerated Data +{ + dateTime +} +with { +variant "name as uncapitalized"; +}; + + +type union String_derivations +{ + XSD.String string, + Data data, + Enable enable, + Res res, + Session session +} +with { +variant "name as uncapitalized"; +variant "useType"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution/builtintype' prefix 'this'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_chain_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_chain_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..16c57b655cb1aecbc18e2e72d50898d2448a1a13 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_chain_e.ttcn @@ -0,0 +1,161 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_chain_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Tue Nov 17 11:30:22 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_chain_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/type/substitution/chain/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution_chain { + + +import from XSD all; + + +type ParentType_derivations Head +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +/* SUBSTITUTABLE PARENT TYPE */ + + +/* type substitutiongroup generated, because has elemet declaration */ + + +type record ParentType +{ + record of XSD.String foo_list, + XSD.String bar +} +with { +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type RestrictedType_derivations RestrictedTypeElem +with { +variant "element"; +}; + + +/* type substitutiongroup generated, because has elemet declaration */ + + +type record RestrictedType +{ + record length(1 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +/* type substitutiongroup generated, because the parent has elemet declaration */ + + +type record RestrictedType2 +{ + record length(2 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +/* Added to restrictedtype_derivations */ + + +type record RestrictedType2_1 +{ + record length(2 .. 5) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as 'restrictedType2.1'"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +/* No type substitutiongroup generated, because the parent lacks elemet declaration */ + + +type record RestrictedType3 +{ + record length(3 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type union ParentType_derivations +{ + ParentType parentType, + RestrictedType_derivations restrictedType +} +with { +variant "useType"; +variant (parentType) "name as capitalized"; +}; + + +type union RestrictedType_derivations +{ + RestrictedType restrictedType, + RestrictedType2 restrictedType2, + RestrictedType2_1 restrictedType2_1 +} +with { +variant "name as uncapitalized"; +variant "useType"; +variant (restrictedType2_1) "name as 'restrictedType2.1'"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution/chain' prefix 'tys'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..3a48253e8abca1c7bf1a1c27927ca427bad69591 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_e.ttcn @@ -0,0 +1,113 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Mon Nov 16 10:01:25 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/type/substitution/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution { + + +import from XSD all; + + +type ParentType_derivations Head +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +/* SUBSTITUTABLE PARENT TYPE */ + + +type record ParentType +{ + record of XSD.String foo_list, + XSD.String bar +} +with { +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type RestrictedType RestrictedTypeElem +with { +variant "element"; +}; + + +/* The restricting type is: */ + + +type record RestrictedType +{ + record length(1 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type SubmitRequestType Submit +with { +variant "element"; +}; + + +type record SubmitRequestType +{ + ParentType_derivations request1, + ParentType_derivations request2 +}; + + +type union ParentType_derivations +{ + ParentType parentType, + RestrictedType restrictedType +} +with { +variant "useType"; +variant (parentType) "name as capitalized"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution' prefix 'tysub'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..3f7e98c577529844375047a7fa93c20782fd0838 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn @@ -0,0 +1,150 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Wed Nov 18 15:03:25 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_elem_in_ct_mod1_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/type/substitution/elem/in/ct/mod1/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution_elem_in_ct_mod1 { + + +import from XSD all; + + +type record Complex +{ + String_derivations string, + ParentType_derivations parentType +} +with { +variant "element"; +}; + + +type XSD.String Stringtype +with { +variant "name as uncapitalized"; +}; + + +type XSD.String Stringtype2 length(5) +with { +variant "name as uncapitalized"; +}; + + +type record ParentType +{ + record of XSD.String foo_list, + XSD.String bar +} +with { +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type record RestrictedType +{ + record length(1 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type record MorerestrictedType +{ + record length(2 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type union String_derivations +{ + XSD.String string, + Stringtype_derivations stringtype +} +with { +variant "name as uncapitalized"; +variant "useType"; +}; + + +type union Stringtype_derivations +{ + Stringtype stringtype, + Stringtype2 stringtype2 +} +with { +variant "name as uncapitalized"; +variant "useType"; +}; + + +type union ParentType_derivations +{ + ParentType parentType, + RestrictedType_derivations restrictedType +} +with { +variant "useType"; +variant (parentType) "name as capitalized"; +variant (restrictedType) "block"; +}; + + +type union RestrictedType_derivations +{ + RestrictedType restrictedType, + MorerestrictedType morerestrictedType +} +with { +variant "name as uncapitalized"; +variant "useType"; +variant (morerestrictedType) "block"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution/elem/in/ct/mod1' prefix 'this'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod2_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod2_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..40eaaa17ba4262eb57e7b6cff35a36d7f63300c4 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod2_e.ttcn @@ -0,0 +1,61 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_elem_in_ct_mod2_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Wed Nov 18 15:03:25 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_elem_in_ct_mod2_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/type/substitution/elem/in/ct/mod2/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution_elem_in_ct_mod2 { + + +import from XSD all; + + +import from www_example_org_type_substitution_elem_in_ct_mod1 all; + + +type record Complex2 +{ + Stringtype_derivations stringType, + ParentType_derivations parentType, + RestrictedType_derivations restrictedType +} +with { +variant "element"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution/elem/in/ct/mod2'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod1_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod1_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..1b379a9052a915aaf08efc9e85a795b3cad8472b --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod1_e.ttcn @@ -0,0 +1,168 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_mod1_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Tue Nov 17 14:10:37 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_mod1_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/type/substitution/mod1/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution_mod1 { + + +import from XSD all; + + +import from www_example_org_type_substitution_mod2 all; + + +/* SUBSTITUTABLE PARENT TYPE */ + + +/* type substitutiongroup generated, because has elemet declaration */ + + +type record ParentType +{ + record of XSD.String foo_list, + XSD.String bar +} +with { +variant "abstract"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type RestrictedType_derivations RestrictedTypeElem +with { +variant "element"; +}; + + +/* type substitutiongroup generated, because has elemet declaration */ + + +type record RestrictedType +{ + record length(1 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +/* type substitutiongroup generated, because the parent has elemet declaration */ + + +type record RestrictedType2 +{ + record length(2 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +/* Added to restrictedtype_derivations */ + + +type record RestrictedType2_1 +{ + record length(2 .. 5) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as 'restrictedType2.1'"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +/* No type substitutiongroup generated, because the parent lacks elemet declaration */ + + +type record RestrictedType3 +{ + record length(3 .. infinity) of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type ExtendedType_derivations ExtendedElement +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type union ParentType_derivations +{ + ParentType parentType, + ExtendedType_derivations extendedType, + RestrictedType_derivations restrictedType +} +with { +variant "useType"; +variant (parentType) "name as capitalized"; +variant (parentType) "abstract"; +variant (extendedType) "block"; +}; + + +type union RestrictedType_derivations +{ + RestrictedType restrictedType, + RestrictedType2 restrictedType2, + RestrictedType2_1 restrictedType2_1 +} +with { +variant "name as uncapitalized"; +variant "useType"; +variant (restrictedType2_1) "name as 'restrictedType2.1'"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution/mod1' prefix 'tys'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod2_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod2_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..157e911fe3ef62330ac21920e47a40e3c1ffb9e4 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_mod2_e.ttcn @@ -0,0 +1,110 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_mod2_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Tue Nov 17 14:10:37 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_mod2_e.xsd +// /* xml version = "1.0" */ +// /* targetnamespace = "www.example.org/type/substitution/mod2/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution_mod2 { + + +import from XSD all; + + +import from www_example_org_type_substitution_mod1 all; + + +type ParentType_derivations Subsgroup +with { +variant "name as uncapitalized"; +variant "abstract"; +variant "element"; +}; + + +type record ExtendedType +{ + XSD.String attr1 optional, + record of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (attr1) "attribute"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type record RestrictedExtendedType +{ + record of XSD.String foo_list, + XSD.String bar +} +with { +variant "name as uncapitalized"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type RestrictedType_derivations NameTest +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type ExtendedType_derivations NameTest2 +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type union ExtendedType_derivations +{ + ExtendedType extendedType, + RestrictedExtendedType restrictedExtendedType +} +with { +variant "name as uncapitalized"; +variant "useType"; +variant (restrictedExtendedType) "block"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution/mod2'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_rename_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_rename_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..c763e42e15b63853bf0aedcffadbb1d9ee4c0009 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_rename_e.ttcn @@ -0,0 +1,103 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_rename_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Wed Nov 25 14:43:08 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_rename_e.xsd +// /* xml version = "1.0" */ +// /* targetnamespace = "www.example.org/type/substitution/rename/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution_rename { + + +import from XSD all; + + +type record Complex +{ + ParentType parentType, + ParentType_derivations sd +} +with { +variant "element"; +}; + + +type ParentType_derivations ParentType +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type record ParentType_1 +{ + record of XSD.String foo_list +} +with { +variant "name as 'ParentType'"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type RestrictedType_1 RestrictedType +with { +variant "element"; +}; + + +type record RestrictedType_1 +{ + record length(1 .. infinity) of XSD.String foo_list +} +with { +variant "name as 'restrictedType'"; +variant (foo_list) "untagged"; +variant (foo_list[-]) "name as 'foo'"; +}; + + +type union ParentType_derivations +{ + ParentType_1 parentType, + RestrictedType_1 restrictedType +} +with { +variant "useType"; +variant (parentType) "name as capitalized"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution/rename' prefix 'this'"; +variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'"; +} diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simpletype_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simpletype_e.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..cf48c3c772c9fcee23306a18c2ee4c1710e23ffe --- /dev/null +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_type_substitution_simpletype_e.ttcn @@ -0,0 +1,190 @@ +/******************************************************************************* +* Copyright (c) 2000-2015 Ericsson Telecom AB +* +* XSD to TTCN-3 Translator version: CRL 113 200/5 R3A +* +* 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 +*******************************************************************************/ +// +// File: www_example_org_type_substitution_simpletype_e.ttcn +// Description: +// References: +// Rev: +// Prodnr: +// Updated: Wed Nov 18 11:56:35 2014 +// Contact: http://ttcn.ericsson.se +// +//////////////////////////////////////////////////////////////////////////////// +// Generated from file(s): +// - type_substitution_simpletype_e.xsd +// /* xml version = "1.0" encoding = "UTF-8" */ +// /* targetnamespace = "www.example.org/type/substitution/simpletype/e" */ +//////////////////////////////////////////////////////////////////////////////// +// Modification header(s): +//----------------------------------------------------------------------------- +// Modified by: +// Modification date: +// Description: +// Modification contact: +//------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////// + + +module www_example_org_type_substitution_simpletype { + + +import from XSD all; + + +type String_derivations Head +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type String_derivations Head_1 +with { +variant "name as 'head_'"; +variant "element"; +}; + + +type Stringtype_derivations Head2 +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type XSD.String Stringtype +with { +variant "name as uncapitalized"; +}; + + +type XSD.String Stringtype2 length(5) +with { +variant "name as uncapitalized"; +}; + + +type Integer_derivations Int +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type XSD.Integer ExtInt +with { +variant "name as uncapitalized"; +}; + + +/* Test if the elements are changed in a complextype */ + + +type Base64Binary_derivations Elem +with { +variant "name as uncapitalized"; +variant "element"; +}; + + +type XSD.Base64Binary CrypBinary; + + +type Signature SignatureValue +with { +variant "element"; +}; + + +type record Signature +{ + XSD.ID id optional, + XSD.Base64Binary base +} +with { +variant (id) "name as capitalized"; +variant (id) "attribute"; +variant (base) "untagged"; +}; + + +type DataType Data +with { +variant "element"; +}; + + +type record DataType +{ + union { + Base64Binary_derivations sKI, + Base64Binary_derivations cert + } choice +} +with { +variant (choice) "untagged"; +variant (choice.sKI) "name as capitalized"; +variant (choice.cert) "name as capitalized"; +}; + + +type union String_derivations +{ + XSD.String string, + Stringtype_derivations stringtype +} +with { +variant "name as uncapitalized"; +variant "useType"; +}; + + +type union Stringtype_derivations +{ + Stringtype stringtype, + Stringtype2 stringtype2 +} +with { +variant "name as uncapitalized"; +variant "useType"; +}; + + +type union Integer_derivations +{ + XSD.Integer integer_, + ExtInt extInt +} +with { +variant "name as uncapitalized"; +variant "useType"; +variant (integer_) "name as 'integer'"; +}; + + +type union Base64Binary_derivations +{ + XSD.Base64Binary base64Binary, + CrypBinary crypBinary +} +with { +variant "name as uncapitalized"; +variant "useType"; +variant (crypBinary) "name as capitalized"; +}; + + +} +with { +encode "XML"; +variant "namespace as 'www.example.org/type/substitution/simpletype' prefix 'this'"; +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 a28fc99b73bf533b8e98babfcf7335d67e9848de..fa52de02cb9c60c158a1b8f8bda66b196e516586 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest.prj +++ b/regression_test/XML/XmlWorkflow/src/xmlTest.prj @@ -121,10 +121,14 @@ <File path="../xsd/module_typename_conversion.xsd" /> <File path="../xsd/module_typename_conversion_1.xsd" /> <File path="../xsd/substitutiongroup.xsd" /> + <File path="../xsd/substitutiongroup_name_as.xsd" /> <File path="../xsd/substitutiongroup_abstract_block_1.xsd" /> <File path="../xsd/substitutiongroup_abstract_block_2.xsd" /> <File path="../xsd/substitutiongroup_complex_without_element.xsd" /> <File path="../xsd/substitutiongroup_long_extension.xsd" /> + <File path="../xsd/substitutiongroup_complextype_block.xsd" /> + <File path="../xsd/substitutiongroup_notargetnamespace.xsd" /> + <File path="../xsd/substitutiongroup_rename.xsd" /> <File path="../xsd/generate_element_substitution.xsd" /> <File path="../xsd/dont_generate_element_substitution.xsd" /> <File path="../xsd/substitutiongroup_neg.xsd" /> @@ -136,6 +140,18 @@ <File path="../xsd/substitutiongroup_main.xsd" /> <File path="../xsd/substitutiongroup_ref.xsd" /> <File path="../xsd/simpletype_base.xsd" /> + <File path="../xsd/type_substitution.xsd" /> + <File path="../xsd/type_substitution_chain.xsd" /> + <File path="../xsd/type_substitution_abstract_block.xsd" /> + <File path="../xsd/type_substitution_mod1.xsd" /> + <File path="../xsd/type_substitution_mod2.xsd" /> + <File path="../xsd/type_subs_with_elem_subs.xsd" /> + <File path="../xsd/type_substitution_simpletype.xsd" /> + <File path="../xsd/type_substitution_elem_in_ct_mod1.xsd" /> + <File path="../xsd/type_substitution_elem_in_ct_mod2.xsd" /> + <File path="../xsd/only_element_substitution.xsd" /> + <File path="../xsd/type_substitution_builtintype.xsd" /> + <File path="../xsd/type_substitution_rename.xsd" /> </File_Group> <File_Group name="XmlTest_xsds" > <File path="../XmlTest_xsds/XmlTest_boolean.xsd" /> @@ -313,7 +329,7 @@ <File path="../XmlTest_expectedTtcns/www_example_org_anyattrib_single_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_attrib_order_a_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_attrib_order_b_e.ttcn" /> - <File path="../XmlTest_expectedTtcns/NoTargetNamespace.ttcn" /> + <File path="../XmlTest_expectedTtcns/NoTargetNamespace2_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_fixed_value_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_self_recursion_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_enumeration_remove_dup_e.ttcn" /> @@ -329,12 +345,15 @@ <File path="../XmlTest_expectedTtcns/module_typename_conversion_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_all_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_name_as_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_1_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_abstract_block_2_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_complex_without_element_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_long_extension_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_complextype_block_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_generate_element_substitution_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_dont_generate_element_substitution_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_rename_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_list_simpletype_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_no_ns_connector_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_anyattr_in_complex_e.ttcn" /> @@ -343,6 +362,18 @@ <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_ref_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_substitutiongroup_main_e.ttcn" /> <File path="../XmlTest_expectedTtcns/www_example_org_simpletype_base_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_chain_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_abstract_block_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_mod1_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_mod2_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_subs_with_elem_subs_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_simpletype_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_elem_in_ct_mod2_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_only_element_substitution_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_builtintype_e.ttcn" /> + <File path="../XmlTest_expectedTtcns/www_example_org_type_substitution_rename_e.ttcn" /> </File_Group> <File_Group name="XmlTest_src" > <File path="xmlTest_Shell.ttcn" /> diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest_Functions_element.ttcn b/regression_test/XML/XmlWorkflow/src/xmlTest_Functions_element.ttcn index 9a79cafef8617fcde459c559b5cdea936de46de7..38ead3825cef1a0f97d8a4bcb22976cb9ffc88ce 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest_Functions_element.ttcn +++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Functions_element.ttcn @@ -14,6 +14,8 @@ import from www_XmlTest_org_element_recordOfElements4_e all; import from www_XmlTest_org_element_recordOfElements5_e all; import from www_XmlTest_org_element_nameInheritance_e all; import from www_ericsson_com_is_isco_Tgc_R6A48_R6H01 all; +import from www_example_org_substitutiongroup all; +import from www_example_org_type_substitution all; import from XmlTest_imsike_e all; import from xmlTest_Shell all; //============================================================================== @@ -85,6 +87,18 @@ with { extension "prototype(fast) encode(XER:XER_EXTENDED)" } external function f_dec_Tgc(in octetstring stream, out Tgc pdu) return integer with { extension "prototype(backtrack) decode(XER:XER_EXTENDED)" } +external function f_enc_ize_subs(in Ize pdu, out octetstring stream) +with { extension "prototype(fast) encode(XER:XER_EXTENDED)" } + +external function f_dec_ize_subs(in octetstring stream, out Ize pdu) return integer +with { extension "prototype(backtrack) decode(XER:XER_EXTENDED)" } + +external function f_enc_type_subs(in Submit pdu, out octetstring stream) +with { extension "prototype(fast) encode(XER:XER_EXTENDED)" } + +external function f_dec_type_subs(in octetstring stream, out Submit pdu) return integer +with { extension "prototype(backtrack) decode(XER:XER_EXTENDED)" } + //============================================================================== // Encoding decoding test //============================================================================== @@ -1118,4 +1132,172 @@ function f_encDecTest_Tgc() runs on Shell_CT { }//f_ +//========================================== +//f_encDecTest_Ize +//========================================== +function f_encDecTest_ize_subs() runs on Shell_CT { + + var Ize vl_pdu := { head_list := { + { head := "anything" }, + { member1 := "any thing" }, + { member2 := something }, + { member3 := { bar:= 5, foo := omit, base := "anything else" } } } + }, + vl_decodedPdu; + + var octetstring vl_expectedEncodedPdu:=char2oct( + "<subs:ize "& + "xmlns:subs='www.example.org/substitutiongroup'>\n"& + "\t<subs:head>anything</subs:head>\n"& + "\t<subs:member1>any thing</subs:member1>\n"& + "\t<subs:member2>something</subs:member2>\n"& + "\t<subs:member3 bar='5'>anything else</subs:member3>\n"& + "</subs:ize>\n\n"); + + var octetstring vl_stream:=''O; + f_enc_ize_subs(vl_pdu,vl_stream); + + if( match(vl_stream,vl_expectedEncodedPdu)) { + setverdict(pass); + } else { + log("Expected encoded value: ",vl_expectedEncodedPdu); + log("Actual encoded value: ", vl_stream); + setverdict(fail); + } + + //log("===Checking encoded value (xml) against the xsd file by xmllint ==="); + var boolean vl_success:=false; + f_shell_validateXml(vl_stream,"substitutiongroup.xsd", c_shell_successWithoutWarningAndError, vl_success); + if(vl_success) { + setverdict(pass); + }else{ + log("Xml validation against xsd failed"); + setverdict(fail); + } + + //log("===Checking value decoded from the encoded value vs original value==="); + var integer vl_retval:=f_dec_ize_subs(vl_stream, vl_decodedPdu); + //log("retval:",vl_retval); + if(f_dec_ize_subs(vl_stream, vl_decodedPdu)==0) { + //log("The decoded pdu: ", vl_decodedPdu); + if(match(vl_pdu,vl_decodedPdu)) { + setverdict(pass); + } else { + log("Pdu differs from the expected value"); + log(match(vl_pdu,vl_decodedPdu)); + setverdict(fail); + } + }else{ + log("Pdu could not decoded"); + setverdict(fail); + } + + //log("===Checking value decoded from the expected value vs original value==="); + if( f_dec_ize_subs(vl_expectedEncodedPdu, vl_decodedPdu)==0) { + //log("The decoded pdu: ", vl_decodedPdu); + if(match(vl_pdu,vl_decodedPdu)) { + setverdict(pass); + } else { + log("Pdu could not decoded from the expected value"); + log(match(vl_pdu,vl_decodedPdu)); + setverdict(fail); + } + } else { + log("Pdu could not decoded from the expected value"); + setverdict(fail); + } +}//f_ + + +//========================================== +//f_encDecTest_type_subs +//========================================== +function f_encDecTest_type_subs() runs on Shell_CT { + + var Submit vl_pdu := { + request1 := { + restrictedType := { + foo_list := { "string1", "string2", "string3" }, + bar := "bar" + } + }, + request2 := { + parentType := { + foo_list := { "parentstring1", "parentstring2", "parentstring3" }, + bar := "parentbar" + } + } + }, + vl_decodedPdu; + var octetstring vl_expectedEncodedPdu:=char2oct( + "<tysub:Submit xmlns:tysub='www.example.org/type/substitution' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\n"& + "\t<request1 xsi:type='tysub:restrictedType'>\n"& + "\t\t<foo>string1</foo>\n"& + "\t\t<foo>string2</foo>\n"& + "\t\t<foo>string3</foo>\n"& + "\t\t<bar>bar</bar>\n"& + "\t</request1>\n"& + "\t<request2>\n"& + "\t\t<foo>parentstring1</foo>\n"& + "\t\t<foo>parentstring2</foo>\n"& + "\t\t<foo>parentstring3</foo>\n"& + "\t\t<bar>parentbar</bar>\n"& + "\t</request2>\n"& + "</tysub:Submit>\n\n"); + + var octetstring vl_stream:=''O; + f_enc_type_subs(vl_pdu,vl_stream); + + if( match(vl_stream,vl_expectedEncodedPdu)) { + setverdict(pass); + } else { + log("Expected encoded value: ",vl_expectedEncodedPdu); + log("Actual encoded value: ", vl_stream); + setverdict(fail); + } + + //log("===Checking encoded value (xml) against the xsd file by xmllint ==="); + var boolean vl_success:=false; + f_shell_validateXml(vl_stream,"type_substitution.xsd", c_shell_successWithoutWarningAndError, vl_success); + if(vl_success) { + setverdict(pass); + }else{ + log("Xml validation against xsd failed"); + setverdict(fail); + } + + //log("===Checking value decoded from the encoded value vs original value==="); + var integer vl_retval:=f_dec_type_subs(vl_stream, vl_decodedPdu); + //log("retval:",vl_retval); + if(f_dec_type_subs(vl_stream, vl_decodedPdu)==0) { + //log("The decoded pdu: ", vl_decodedPdu); + if(match(vl_pdu,vl_decodedPdu)) { + setverdict(pass); + } else { + log("Pdu differs from the expected value"); + log(match(vl_pdu,vl_decodedPdu)); + setverdict(fail); + } + }else{ + log("Pdu could not decoded"); + setverdict(fail); + } + + //log("===Checking value decoded from the expected value vs original value==="); + if( f_dec_type_subs(vl_expectedEncodedPdu, vl_decodedPdu)==0) { + //log("The decoded pdu: ", vl_decodedPdu); + if(match(vl_pdu,vl_decodedPdu)) { + setverdict(pass); + } else { + log("Pdu could not decoded from the expected value"); + log(match(vl_pdu,vl_decodedPdu)); + setverdict(fail); + } + } else { + log("Pdu could not decoded from the expected value"); + setverdict(fail); + } +}//f_ + + }//module diff --git a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn index c968830c1830404219ce47d60e18310decd0e6e6..1b1ad38872af285b6d8c806727c2627431f6e703 100644 --- a/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn +++ b/regression_test/XML/XmlWorkflow/src/xmlTest_Testcases.ttcn @@ -1536,7 +1536,7 @@ group ComplexType { }//tc_ testcase tc_no_ns_connector() runs on xmlTest_CT { - f_shellCommandWithVerdict("xsd2ttcn no_ns_connector.xsd","",c_shell_successWithWarning) + f_shellCommandWithVerdict("xsd2ttcn no_ns_connector.xsd","",c_shell_successWithoutWarningAndError) if(getverdict==pass) { f_compareFiles( @@ -2009,9 +2009,20 @@ group Elements{ }//tc_ + testcase tc_substitutiongroup_name_as() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_name_as.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_substitutiongroup_name_as_e.ttcn","www_example_org_substitutiongroup_name_as.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + testcase tc_substitutiongroup_abstract_block_rest() runs on xmlTest_CT { - f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_abstract_block_1.xsd","",c_shell_successWithWarning) + f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_abstract_block_1.xsd","",c_shell_successWithoutWarningAndError) if(getverdict==pass) { f_compareFiles( @@ -2023,7 +2034,7 @@ group Elements{ testcase tc_substitutiongroup_abstract_block_ext() runs on xmlTest_CT { - f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_abstract_block_2.xsd","",c_shell_successWithWarning) + f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_abstract_block_2.xsd","",c_shell_successWithoutWarningAndError) if(getverdict==pass) { f_compareFiles( @@ -2035,7 +2046,7 @@ group Elements{ testcase tc_substitutiongroup_complex_without_element() runs on xmlTest_CT { - f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_complex_without_element.xsd","",c_shell_successWithWarning) + f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_complex_without_element.xsd","",c_shell_successWithoutWarningAndError) if(getverdict==pass) { f_compareFiles( @@ -2047,7 +2058,7 @@ group Elements{ testcase tc_substitutiongroup_long_extension() runs on xmlTest_CT { - f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_complex_without_element.xsd","",c_shell_successWithWarning) + f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_complex_without_element.xsd","",c_shell_successWithoutWarningAndError) if(getverdict==pass) { f_compareFiles( @@ -2057,6 +2068,26 @@ group Elements{ }//tc_ + testcase tc_substitutiongroup_complextype_block() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_complextype_block.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_substitutiongroup_complextype_block_e.ttcn", + "www_example_org_substitutiongroup_complextype_block.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + //Test if we find the substitutiongroup references in notargetnamespace + testcase tc_substitutiongroup_notargetnamespace() runs on xmlTest_CT { + + //f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_notargetnamespace.xsd","",c_shell_successWithoutWarningAndError) + setverdict(pass); + + }//tc_ + testcase tc_substitutiongroup_neg() runs on xmlTest_CT { f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_neg.xsd","",c_shell_error) @@ -2065,7 +2096,7 @@ group Elements{ testcase tc_substitutiongroup_diff_module() runs on xmlTest_CT { - f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_main.xsd substitutiongroup_ref.xsd","",c_shell_successWithWarning) + f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_main.xsd substitutiongroup_ref.xsd","",c_shell_successWithoutWarningAndError) if(getverdict==pass) { f_compareFiles( @@ -2081,6 +2112,161 @@ group Elements{ }//tc_ + testcase tc_substitutiongroup_rename() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn substitutiongroup_rename.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_substitutiongroup_rename_e.ttcn", + "www_example_org_substitutiongroup_rename.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_substitutiongroup_endDec() runs on xmlTest_CT { + + f_encDecTest_ize_subs(); + } + + testcase tc_type_substitution() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h type_substitution.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_e.ttcn", + "www_example_org_type_substitution.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_type_substitution_encDec() runs on xmlTest_CT { + + f_encDecTest_type_subs(); + + }//tc_ + + testcase tc_type_substitution_chain() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h type_substitution_chain.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_chain_e.ttcn", + "www_example_org_type_substitution_chain.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_type_substitution_abstract_block() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h type_substitution_abstract_block.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_abstract_block_e.ttcn", + "www_example_org_type_substitution_abstract_block.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_type_substitution_diff_module() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h type_substitution_mod1.xsd type_substitution_mod2.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_mod1_e.ttcn", + "www_example_org_type_substitution_mod1.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_mod2_e.ttcn", + "www_example_org_type_substitution_mod2.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_type_substitution_simpletype() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h type_substitution_simpletype.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_simpletype_e.ttcn", + "www_example_org_type_substitution_simpletype.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_type_substitution_with_elem_substitution() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h type_subs_with_elem_subs.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_subs_with_elem_subs_e.ttcn", + "www_example_org_type_subs_with_elem_subs.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_type_substitution_element_in_ct() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h type_substitution_elem_in_ct_mod1.xsd type_substitution_elem_in_ct_mod2.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_elem_in_ct_mod1_e.ttcn", + "www_example_org_type_substitution_elem_in_ct_mod1.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_elem_in_ct_mod2_e.ttcn", + "www_example_org_type_substitution_elem_in_ct_mod2.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_only_element_substitution() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h only_element_substitution.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_only_element_substitution_e.ttcn", + "www_example_org_only_element_substitution.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_type_substitution_builtintype() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h type_substitution_builtintype.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_builtintype_e.ttcn", + "www_example_org_type_substitution_builtintype.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + + testcase tc_type_substitution_rename() runs on xmlTest_CT { + + f_shellCommandWithVerdict("xsd2ttcn -h type_substitution_rename.xsd","",c_shell_successWithoutWarningAndError) + + if(getverdict==pass) { + f_compareFiles( + "www_example_org_type_substitution_rename_e.ttcn", + "www_example_org_type_substitution_rename.ttcn", c_numOfDiff_headerModNameAndNamespace); + } + + }//tc_ + //======================================================== @@ -2111,7 +2297,7 @@ group Elements{ //"Abstract" are not supported. Therefore converter sends WARNINGs testcase tc_element_abstract_conv() runs on xmlTest_CT { - f_shellCommandWithVerdict("xsd2ttcn XmlTest_element_abstract.xsd","",c_shell_successWithWarning); + f_shellCommandWithVerdict("xsd2ttcn XmlTest_element_abstract.xsd","",c_shell_successWithoutWarningAndError); }//tc_ testcase tc_element_nillable_converter() runs on xmlTest_CT { @@ -2396,12 +2582,30 @@ control { //===substitutiongroup=== execute(tc_substitutiongroup()); + execute(tc_substitutiongroup_name_as()); execute(tc_substitutiongroup_abstract_block_rest()); execute(tc_substitutiongroup_abstract_block_ext()); execute(tc_substitutiongroup_complex_without_element()); execute(tc_substitutiongroup_long_extension()); + execute(tc_substitutiongroup_complextype_block()); + execute(tc_substitutiongroup_notargetnamespace()); execute(tc_substitutiongroup_neg()); execute(tc_substitutiongroup_diff_module()); + execute(tc_substitutiongroup_rename()); + execute(tc_substitutiongroup_endDec()); + + //===type substitution=== + execute(tc_type_substitution()); + execute(tc_type_substitution_encDec()); + execute(tc_type_substitution_chain()); + execute(tc_type_substitution_abstract_block()); + execute(tc_type_substitution_diff_module()); + execute(tc_type_substitution_simpletype()); + execute(tc_type_substitution_with_elem_substitution()); + execute(tc_type_substitution_element_in_ct()); + execute(tc_only_element_substitution()); + execute(tc_type_substitution_builtintype()); + execute(tc_type_substitution_rename()); diff --git a/regression_test/XML/XmlWorkflow/xsd/only_element_substitution.xsd b/regression_test/XML/XmlWorkflow/xsd/only_element_substitution.xsd new file mode 100644 index 0000000000000000000000000000000000000000..dd6f1953bb387e353bc949c17d62bfc0b0838110 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/only_element_substitution.xsd @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="www.example.org/only/element/substitution" + xmlns="www.example.org/only/element/substitution"> + +<xsd:element name="requestAbstractType1" type="requestAbstractType" abstract="true"/> + +<xsd:complexType name="requestAbstractType" abstract="true"> + <xsd:sequence> + <xsd:element name="commonName" type="xsd:string" /> + </xsd:sequence> +</xsd:complexType> + +<!-- Production implementation --> + +<xsd:element name="productionRequest" substitutionGroup="requestAbstractType" > + <xsd:complexType> + <xsd:complexContent> + <xsd:extension base="requestAbstractType"> + <xsd:sequence> + <xsd:element name="productionName" type="xsd:string" /> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> + </xsd:complexType> +</xsd:element> + +<!-- Production implementation --> +<xsd:element name="programmingRequest" substitutionGroup="requestAbstractType" > + <xsd:complexType> + <xsd:complexContent> + <xsd:extension base="requestAbstractType"> + <xsd:sequence> + <xsd:element name="programmingName" type="xsd:string" /> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> + </xsd:complexType> +</xsd:element> + +</xsd:schema> + diff --git a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup.xsd b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup.xsd index 64d9fa310c0b5db2e9e143ee08abbf08f2aadbb6..475238d31743351df71b2d457b4079b426816973 100644 --- a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup.xsd @@ -1,14 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:this="www.example.org/substitutiongroup" + xmlns:subs="www.example.org/substitutiongroup" targetNamespace="www.example.org/substitutiongroup"> <!-- THE HEAD ELEMENT --> <xsd:element name="head" type="xsd:string" /> <!-- SUBSTITUTION ELEMENT OF THE SAME TYPE AS THE HEAD --> -<xsd:element name="member1" type="xsd:string" substitutionGroup="this:head"/> +<xsd:element name="member1" type="xsd:string" substitutionGroup="subs:head"/> <!-- SUBSTITUTION ELEMENT OF A TYPE RESTRICTING THE TYPE OF THE HEAD --> <xsd:simpleType name="stringEnum"> @@ -18,7 +18,7 @@ </xsd:restriction> </xsd:simpleType> -<xsd:element name="member2" type="this:stringEnum" substitutionGroup="this:head"/> +<xsd:element name="member2" type="subs:stringEnum" substitutionGroup="subs:head"/> <!-- SUBSTITUTION ELEMENT OF A TYPE EXTENDING THE TYPE OF THE HEAD --> <xsd:complexType name="complexEnum"> @@ -30,13 +30,13 @@ </xsd:simpleContent> </xsd:complexType> -<xsd:element name="member3" type="this:complexEnum" substitutionGroup="this:head"/> +<xsd:element name="member3" type="subs:complexEnum" substitutionGroup="subs:head"/> <!-- TOP LEVEL ELEMENT TO DEMONSTRATE SUBSTITUTION --> <xsd:element name="ize"> <xsd:complexType> <xsd:sequence> - <xsd:element ref="this:head" minOccurs="0" maxOccurs="unbounded"/> + <xsd:element ref="subs:head" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> diff --git a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_complextype_block.xsd b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_complextype_block.xsd new file mode 100644 index 0000000000000000000000000000000000000000..6dce9747bdf3754b8e5c86f8ab0d031ad37994cd --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_complextype_block.xsd @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:this="www.example.org/substitutiongroup/complextype/block" + targetNamespace="www.example.org/substitutiongroup/complextype/block" blockDefault="extension"> + + +<xsd:element name="head" type="this:restrictedType" block="restriction" /> + +<!-- SUBSTITUTABLE PARENT TYPE --> +<xsd:complexType name="ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string" /> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:element name="RestrictedTypeElem" type="this:restrictedType" substitutionGroup="this:head"/> +<!-- The restricting type is: --> +<xsd:complexType name="restrictedType"> + <xsd:complexContent> + <xsd:restriction base="this:ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="1" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + + +</xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_name_as.xsd b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_name_as.xsd new file mode 100644 index 0000000000000000000000000000000000000000..66c477c666a4ae2d878b86be6d7724eecf8d0de2 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_name_as.xsd @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:this="www.example.org/substitutiongroup/name/as" + targetNamespace="www.example.org/substitutiongroup/name/as"> + +<!-- THE HEAD ELEMENT --> +<xsd:element name="Head" type="xsd:string" /> + +<!-- SUBSTITUTION ELEMENT OF THE SAME TYPE AS THE HEAD --> +<xsd:element name="Member1" type="xsd:string" substitutionGroup="this:Head"/> + +<!-- SUBSTITUTION ELEMENT OF A TYPE RESTRICTING THE TYPE OF THE HEAD --> +<xsd:simpleType name="StringEnum"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="something"/> + <xsd:enumeration value="else"/> + </xsd:restriction> +</xsd:simpleType> + +<xsd:element name="Member2" type="this:StringEnum" substitutionGroup="this:Head"/> + +<!-- SUBSTITUTION ELEMENT OF A TYPE EXTENDING THE TYPE OF THE HEAD --> +<xsd:complexType name="ComplexEnum"> + <xsd:simpleContent> + <xsd:extension base="xsd:string"> + <xsd:attribute name="foo" type="xsd:float"/> + <xsd:attribute name="bar" type="xsd:integer"/> + </xsd:extension> + </xsd:simpleContent> +</xsd:complexType> + +<xsd:element name="Member3" type="this:ComplexEnum" substitutionGroup="this:Head"/> + +<!-- TOP LEVEL ELEMENT TO DEMONSTRATE SUBSTITUTION --> +<xsd:element name="Ize"> + <xsd:complexType> + <xsd:sequence> + <xsd:element ref="this:Head" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> +</xsd:element> + +</xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_notargetnamespace.xsd b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_notargetnamespace.xsd new file mode 100644 index 0000000000000000000000000000000000000000..9ebe84c000b054d4d493148135c8c3787b25d7fe --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_notargetnamespace.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified"> + +<xsd:element name="request" type="requestAbstractType"/> + +<xsd:complexType name="requestAbstractType"> + <xsd:sequence> + <xsd:element name="commonName" type="xsd:string" /> + </xsd:sequence> +</xsd:complexType> + +<xsd:element name="productionRequest" type="myProductionRequestType" substitutionGroup="request" /> + +<xsd:complexType name="myProductionRequestType"> + <xsd:complexContent> + <xsd:extension base="requestAbstractType"> + <xsd:sequence> + <xsd:element name="productionName" type="xsd:string" /> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> +</xsd:complexType> + + +</xsd:schema> + diff --git a/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_rename.xsd b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_rename.xsd new file mode 100644 index 0000000000000000000000000000000000000000..41f3f3c911ce309a6a0ebf607a3832c1d57b2316 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/substitutiongroup_rename.xsd @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="www.example.org/substitutiongroup/rename" + xmlns:this="www.example.org/substitutiongroup/rename"> + +<xsd:complexType name="BaseElement_"> + <xsd:sequence> + </xsd:sequence> +</xsd:complexType> + +<xsd:complexType name="Audit" mixed="false"> + <xsd:complexContent mixed="false"> + <xsd:extension base="this:BaseElement_"> + <xsd:sequence> + <xsd:element ref="this:BaseElement" minOccurs="0"/> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> +</xsd:complexType> + +<xsd:element name="Case" type="integer" abstract="true"/> + +<xsd:element name="BaseElement__" type="string" abstract="true"/> + +<xsd:element name="BaseElement" type="this:BaseElement_" abstract="true"/> + +<xsd:element name="Case_" type="this:Audit" substitutionGroup="this:BaseElement"/> + +</xsd:schema> + diff --git a/regression_test/XML/XmlWorkflow/xsd/type_subs_with_elem_subs.xsd b/regression_test/XML/XmlWorkflow/xsd/type_subs_with_elem_subs.xsd new file mode 100644 index 0000000000000000000000000000000000000000..133ed508cc9eecb237cb9e7efb54a53327cac187 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_subs_with_elem_subs.xsd @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="www.example.org/type/subs/with/elem/subs" + xmlns="www.example.org/type/subs/with/elem/subs" + elementFormDefault="unqualified" + attributeFormDefault="unqualified"> + + <!-- Root element --> +<xsd:element name="Submit" type="SubmitRequestType" /> + +<xsd:complexType name="requestGroup"> + <xsd:sequence> + <xsd:element ref="request"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:complexType name="SubmitRequestType"> + <xsd:sequence> + <xsd:element name="name" type="xsd:string" /> + <xsd:element name="request1" type="requestAbstractType" /> + <xsd:element name="request2" type="requestAbstractType" /> + </xsd:sequence> +</xsd:complexType> + + + <!-- The generic abstract type --> +<xsd:element name="request" type="requestAbstractType" abstract="true" /> + +<xsd:complexType name="requestAbstractType" abstract="true"> + <xsd:sequence> + <xsd:element name="commonName" type="xsd:string" /> + </xsd:sequence> +</xsd:complexType> + + <!-- Production implementation --> +<xsd:element name="productionRequest" type="myProductionRequestType" substitutionGroup="request" /> + +<xsd:complexType name="myProductionRequestType"> + <xsd:complexContent> + <xsd:extension base="requestAbstractType"> + <xsd:sequence> + <xsd:element name="productionName" type="xsd:string" /> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> +</xsd:complexType> + + <!-- Production implementation --> +<xsd:element name="programmingRequest" type="myProgrammingRequestType" substitutionGroup="request" /> + +<xsd:complexType name="myProgrammingRequestType"> + <xsd:complexContent> + <xsd:extension base="requestAbstractType"> + <xsd:sequence> + <xsd:element name="programmingName" type="xsd:string" /> + </xsd:sequence> + </xsd:extension> + </xsd:complexContent> +</xsd:complexType> + +</xsd:schema> + diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution.xsd new file mode 100644 index 0000000000000000000000000000000000000000..be29c5ad1d4757203846d50e06581c443d6e8ff1 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution.xsd @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tysub="www.example.org/type/substitution" + targetNamespace="www.example.org/type/substitution"> + + +<xsd:element name="head" type="tysub:ParentType" block="restriction"/> + +<!-- SUBSTITUTABLE PARENT TYPE --> +<xsd:complexType name="ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string" /> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:element name="RestrictedTypeElem" type="tysub:restrictedType"/> +<!-- The restricting type is: --> +<xsd:complexType name="restrictedType"> + <xsd:complexContent> + <xsd:restriction base="tysub:ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="1" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<xsd:element name="Submit" type="tysub:SubmitRequestType" /> + +<xsd:complexType name="SubmitRequestType"> + <xsd:sequence> + <xsd:element name="request1" type="tysub:ParentType" /> + <xsd:element name="request2" type="tysub:ParentType" /> + </xsd:sequence> +</xsd:complexType> + + +</xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_abstract_block.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_abstract_block.xsd new file mode 100644 index 0000000000000000000000000000000000000000..aba5a9a6b1c743d6d4c4e541d1bd731a1be4e24b --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_abstract_block.xsd @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tys="www.example.org/type/substitution/abstract/block" + targetNamespace="www.example.org/type/substitution/abstract/block" blockDefault="extension"> + + +<xsd:element name="head" type="tys:ParentType"/> + +<!-- SUBSTITUTABLE PARENT TYPE --> +<!-- type substitutiongroup generated, because has elemet declaration --> +<xsd:complexType name="ParentType" abstract="true" block="restriction extension"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string" /> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:element name="RestrictedTypeElem" type="tys:restrictedType"/> +<!-- type substitutiongroup generated, because has elemet declaration --> +<xsd:complexType name="restrictedType"> + <xsd:complexContent> + <xsd:restriction base="tys:ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="1" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<!-- type substitutiongroup generated, because the parent has elemet declaration --> +<xsd:complexType name="restrictedType2"> + <xsd:complexContent> + <xsd:restriction base="tys:restrictedType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="2" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<!-- Added to restrictedtype_derivations --> +<xsd:complexType name="restrictedType2.1"> + <xsd:complexContent> + <xsd:restriction base="tys:restrictedType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="2" maxOccurs="5" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<!-- No type substitutiongroup generated, because the parent lacks elemet declaration --> +<xsd:complexType name="restrictedType3"> + <xsd:complexContent> + <xsd:restriction base="tys:restrictedType2"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="3" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<xsd:element name="extendedElement" type="tys:extendedType"/> +<xsd:complexType name="extendedType" block="restriction"> + <xsd:complexContent> + <xsd:extension base="tys:ParentType"> + <xsd:sequence> + </xsd:sequence> + <xsd:attribute name="attr1" type="string" /> + </xsd:extension> + </xsd:complexContent> +</xsd:complexType> + +<xsd:complexType name="restrictedExtendedType"> + <xsd:complexContent> + <xsd:restriction base="tys:extendedType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + <xsd:attribute name="attr1" type="string" use="prohibited" /> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +</xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_builtintype.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_builtintype.xsd new file mode 100644 index 0000000000000000000000000000000000000000..25c26cc8b8b6ef6bcfa2cfd95fef05c41a49caa0 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_builtintype.xsd @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="www.example.org/type/substitution/builtintype" + xmlns:this="www.example.org/type/substitution/builtintype"> + +<xsd:element name="elem" type="xsd:string"/> + +<xsd:simpleType name="enable"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="equal"/> + </xsd:restriction> +</xsd:simpleType> +<xsd:simpleType name="session"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="visible_and_interactive"/> + </xsd:restriction> +</xsd:simpleType> +<xsd:simpleType name="res"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="pending"/> + </xsd:restriction> +</xsd:simpleType> +<xsd:simpleType name="data"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="dateTime"/> + </xsd:restriction> +</xsd:simpleType> + + +</xsd:schema> + diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_chain.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_chain.xsd new file mode 100644 index 0000000000000000000000000000000000000000..21cb42a9783547745ec03934abf2f68e708a9ea8 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_chain.xsd @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tys="www.example.org/type/substitution/chain" + targetNamespace="www.example.org/type/substitution/chain"> + +<xsd:element name="head" type="tys:ParentType"/> + +<!-- SUBSTITUTABLE PARENT TYPE --> +<!-- type substitutiongroup generated, because has elemet declaration --> +<xsd:complexType name="ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string" /> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:element name="RestrictedTypeElem" type="tys:restrictedType"/> + +<!-- type substitutiongroup generated, because has elemet declaration --> +<xsd:complexType name="restrictedType"> + <xsd:complexContent> + <xsd:restriction base="tys:ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="1" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<!-- type substitutiongroup generated, because the parent has elemet declaration --> +<xsd:complexType name="restrictedType2"> + <xsd:complexContent> + <xsd:restriction base="tys:restrictedType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="2" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<!-- Added to restrictedtype_derivations --> +<xsd:complexType name="restrictedType2.1"> + <xsd:complexContent> + <xsd:restriction base="tys:restrictedType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="2" maxOccurs="5" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<!-- No type substitutiongroup generated, because the parent lacks elemet declaration --> +<xsd:complexType name="restrictedType3"> + <xsd:complexContent> + <xsd:restriction base="tys:restrictedType2"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="3" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +</xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_elem_in_ct_mod1.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_elem_in_ct_mod1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..af179c33fa2c36de0f5638978276156881bc1268 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_elem_in_ct_mod1.xsd @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:this="www.example.org/type/substitution/elem/in/ct/mod1" + targetNamespace="www.example.org/type/substitution/elem/in/ct/mod1" + blockDefault="restriction"> + +<xsd:element name="Complex"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="string" type="xsd:string"/> + <xsd:element name="parentType" type="this:ParentType"/> + </xsd:sequence> + </xsd:complexType> +</xsd:element> + +<xsd:simpleType name="stringtype"> + <xsd:restriction base="string"/> +</xsd:simpleType> + +<xsd:simpleType name="stringtype2"> + <xsd:restriction base="this:stringtype"> + <xsd:length value="5"/> + </xsd:restriction> +</xsd:simpleType> + +<xsd:complexType name="ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string" /> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:complexType name="restrictedType"> + <xsd:complexContent> + <xsd:restriction base="this:ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="1" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<xsd:complexType name="morerestrictedType"> + <xsd:complexContent> + <xsd:restriction base="this:restrictedType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="2" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +</xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_elem_in_ct_mod2.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_elem_in_ct_mod2.xsd new file mode 100644 index 0000000000000000000000000000000000000000..ec48b910119a9875ee4124e302fbabf9c6beec3e --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_elem_in_ct_mod2.xsd @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:A="www.example.org/type/substitution/elem/in/ct/mod1" + targetNamespace="www.example.org/type/substitution/elem/in/ct/mod2" + blockDefault="restriction"> +<xsd:import namespace="www.example.org/type/substitution/elem/in/ct/mod1" schemaLocation="type_substitution_elem_in_ct_mod1.xsd"/> + +<xsd:element name="Complex2"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="stringType" type="A:stringtype"/> + <xsd:element name="parentType" type="A:ParentType"/> + <xsd:element name="restrictedType" type="A:restrictedType"/> + </xsd:sequence> + </xsd:complexType> +</xsd:element> + +</xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod1.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..2262c1f67a0517abc868c82af9b1041274140bed --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod1.xsd @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tys="www.example.org/type/substitution/mod1" + xmlns:A="www.example.org/type/substitution/mod2" + targetNamespace="www.example.org/type/substitution/mod1" blockDefault="extension"> +<xsd:import namespace="www.example.org/type/substitution/mod2" schemaLocation="type_substitution_mod2.xsd"/> + +<!-- SUBSTITUTABLE PARENT TYPE --> +<!-- type substitutiongroup generated, because has elemet declaration --> +<xsd:complexType name="ParentType" abstract="true" block="restriction extension"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string" /> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:element name="RestrictedTypeElem" type="tys:restrictedType"/> +<!-- type substitutiongroup generated, because has elemet declaration --> +<xsd:complexType name="restrictedType"> + <xsd:complexContent> + <xsd:restriction base="tys:ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="1" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<!-- type substitutiongroup generated, because the parent has elemet declaration --> +<xsd:complexType name="restrictedType2"> + <xsd:complexContent> + <xsd:restriction base="tys:restrictedType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="2" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<!-- Added to restrictedtype_derivations --> +<xsd:complexType name="restrictedType2.1"> + <xsd:complexContent> + <xsd:restriction base="tys:restrictedType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="2" maxOccurs="5" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<!-- No type substitutiongroup generated, because the parent lacks elemet declaration --> +<xsd:complexType name="restrictedType3"> + <xsd:complexContent> + <xsd:restriction base="tys:restrictedType2"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="3" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<xsd:element name="extendedElement" type="A:extendedType"/> + +</xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod2.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod2.xsd new file mode 100644 index 0000000000000000000000000000000000000000..f0c63361d18fdbcc280d164c8feae55f5812cf4d --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_mod2.xsd @@ -0,0 +1,35 @@ +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:A="www.example.org/type/substitution/mod1" + targetNamespace="www.example.org/type/substitution/mod2" + xmlns="www.example.org/type/substitution/mod2"> +<xsd:import namespace="www.example.org/type/substitution/mod1" schemaLocation="type_substitution_mod1.xsd"/> + +<xsd:element name="subsgroup" type="A:ParentType" abstract="true" /> + +<xsd:complexType name="extendedType" block="restriction"> + <xsd:complexContent> + <xsd:extension base="A:ParentType"> + <xsd:sequence> + </xsd:sequence> + <xsd:attribute name="attr1" type="string" /> + </xsd:extension> + </xsd:complexContent> +</xsd:complexType> + +<xsd:complexType name="restrictedExtendedType"> + <xsd:complexContent> + <xsd:restriction base="extendedType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/> + <xsd:element name="bar" type="xsd:string"/> + </xsd:sequence> + <xsd:attribute name="attr1" type="string" use="prohibited" /> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + +<xsd:element name="nameTest" type="A:restrictedType"/> + +<xsd:element name="nameTest2" type="extendedType"/> + +</xsd:schema> diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_rename.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_rename.xsd new file mode 100644 index 0000000000000000000000000000000000000000..11876eb860f3e6d54ece3a392ad4a07f9b70cc11 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_rename.xsd @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="www.example.org/type/substitution/rename" + xmlns:this="www.example.org/type/substitution/rename"> + + +<xsd:element name="Complex"> + <xsd:complexType> + <xsd:sequence> + <xsd:element ref="this:parentType" /> + <xsd:element type="this:ParentType" name="sd"/> + </xsd:sequence> + </xsd:complexType> +</xsd:element> + +<xsd:element name="parentType" type="this:ParentType"/> + +<xsd:complexType name="ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="0" maxOccurs="unbounded" type="xsd:string" /> + </xsd:sequence> +</xsd:complexType> + +<xsd:element name="RestrictedType" type="this:restrictedType"/> + +<xsd:complexType name="restrictedType"> + <xsd:complexContent> + <xsd:restriction base="this:ParentType"> + <xsd:sequence> + <xsd:element name="foo" minOccurs="1" maxOccurs="unbounded" type="xsd:string"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> +</xsd:complexType> + + +</xsd:schema> + diff --git a/regression_test/XML/XmlWorkflow/xsd/type_substitution_simpletype.xsd b/regression_test/XML/XmlWorkflow/xsd/type_substitution_simpletype.xsd new file mode 100644 index 0000000000000000000000000000000000000000..5d8754363afac9f9dd3c2271373509aa1c2b24f7 --- /dev/null +++ b/regression_test/XML/XmlWorkflow/xsd/type_substitution_simpletype.xsd @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:this="www.example.org/type/substitution/simpletype" + targetNamespace="www.example.org/type/substitution/simpletype"> + + +<xsd:element name="head" type="string" /> + +<xsd:element name="head_" type="string" /> + +<xsd:element name="head2" type="this:stringtype" /> + +<xsd:simpleType name="stringtype"> + <xsd:restriction base="string"/> +</xsd:simpleType> + +<xsd:simpleType name="stringtype2"> + <xsd:restriction base="this:stringtype"> + <xsd:length value="5"/> + </xsd:restriction> +</xsd:simpleType> + +<xsd:element name="int" type="xsd:integer"/> + +<xsd:simpleType name="extInt"> + <xsd:restriction base="xsd:integer"/> +</xsd:simpleType> + + + +<!-- Test if the elements are changed in a complextype --> +<xsd:element name="elem" type="base64Binary"/> + +<xsd:simpleType name="CrypBinary"> + <xsd:restriction base="base64Binary"> + </xsd:restriction> +</xsd:simpleType> + +<xsd:element name="SignatureValue" type="this:Signature"/> + +<xsd:complexType name="Signature"> + <xsd:simpleContent> + <xsd:extension base="base64Binary"> + <xsd:attribute name="Id" type="ID"/> + </xsd:extension> + </xsd:simpleContent> +</xsd:complexType> + + +<xsd:element name="Data" type="this:DataType"/> + +<xsd:complexType name="DataType"> + <xsd:sequence> + <xsd:choice> + <xsd:element name="SKI" type="base64Binary"/> + <xsd:element name="Cert" type="base64Binary"/> + </xsd:choice> + </xsd:sequence> +</xsd:complexType> + + +</xsd:schema> diff --git a/regression_test/compileonly/openTypeNames/IO_based_message.asn b/regression_test/compileonly/openTypeNames/IO_based_message.asn index 56071bb489fbc28a74c16dc3ce52433ad657774a..daa798572e33971b3e595507ce9d7ffad1433522 100644 --- a/regression_test/compileonly/openTypeNames/IO_based_message.asn +++ b/regression_test/compileonly/openTypeNames/IO_based_message.asn @@ -35,9 +35,11 @@ myIo2 MY-CLASS ::= { ID 2 TYPE MyEnum } myIo3 MY-CLASS ::= { ID 3 TYPE INTEGER } +myIo4 MY-CLASS ::= { ID 4 TYPE NULL } + -- Defining IO set to be used in message contraction -MyIOSet MY-CLASS ::= { myIo1 | myIo2 | myIo3 } +MyIOSet MY-CLASS ::= { myIo1 | myIo2 | myIo3 | myIo4 } -- and now finally constructing the type @@ -66,6 +68,11 @@ a-message-id3-lower MyMessage ::= { id 3, content iNTEGER : 7 } + +a-message-id4-lower MyMessage ::= { + id 4, + content nULL : NULL +} /* -- Not supported values a-message-id1-upper MyMessage ::= { @@ -82,5 +89,10 @@ a-message-id3-upper MyMessage ::= { id 3, content INTEGER : 7 } + +a-message-id4-lower MyMessage ::= { + id 4, + content NULL : NULL +} */ END diff --git a/regression_test/compileonly/openTypeNames/Open_type_use.ttcn b/regression_test/compileonly/openTypeNames/Open_type_use.ttcn index 75f69379eee9451050a941eaf435531f98160c35..4761fc8c4caf52aff8fb3a10066cd1a36a4c4de5 100644 --- a/regression_test/compileonly/openTypeNames/Open_type_use.ttcn +++ b/regression_test/compileonly/openTypeNames/Open_type_use.ttcn @@ -28,6 +28,11 @@ const MyMessage c_message_id3_lower := { content := { iNTEGER := 42 } } +const MyMessage c_message_id4_lower := { + id := 4, + content := { nULL := NULL } +} + // Constants (uppercase first letter) const MyMessage c_message_id1_upper := { id := 1, @@ -44,6 +49,11 @@ const MyMessage c_message_id3_upper := { content := { INTEGER := 42 } } +const MyMessage c_message_id4_upper := { + id := 4, + content := { NULL := NULL } +} + // Templates (lowercase first letter) template MyMessage t_message_id1_lower := { id := 1, @@ -60,6 +70,11 @@ template MyMessage t_message_id3_lower := { content := { iNTEGER := 42 } } +template MyMessage t_message_id4_lower := { + id := 4, + content := { nULL := NULL } +} + // Templates (uppercase first letter) template MyMessage t_message_id1_upper := { id := 1, @@ -76,14 +91,21 @@ template MyMessage t_message_id3_upper := { content := { INTEGER := 42 } } +template MyMessage t_message_id4_upper := { + id := 4, + content := { NULL := NULL } +} + // Value list template (contains both lowercase and uppercase examples) template MyMessage t_message_value_list := ( { id := 1, content := { mySeq := { field1 := 42, field2 := omit }} }, { id := 2, content := { myEnum := first} }, { id := 3, content := { iNTEGER := 42 } }, + { id := 4, content := { nULL := NULL } }, { id := 1, content := { MySeq := { field1 := -42, field2 := omit }} }, { id := 2, content := { MyEnum := second} }, - { id := 3, content := { INTEGER := -42 } } + { id := 3, content := { INTEGER := -42 } }, + { id := 4, content := { NULL := NULL } } ); // Dummy function to declare variables in @@ -103,6 +125,11 @@ function f_dummy() { id := 3, content := { iNTEGER := 42 } } + + var MyMessage v_message_id4_lower := { + id := 4, + content := { nULL := NULL } + } // Variables (uppercase first letter) var MyMessage v_message_id1_upper := { @@ -119,6 +146,11 @@ function f_dummy() { id := 3, content := { INTEGER := 42 } } + + var MyMessage v_message_id4_upper := { + id := 4, + content := { NULL := NULL } + } // Template variables (lowercase first letter) var template MyMessage vt_message_id1_lower := { @@ -135,6 +167,11 @@ function f_dummy() { id := 3, content := { iNTEGER := 42 } } + + var template MyMessage vt_message_id4_lower := { + id := 4, + content := { nULL := NULL } + } // Template variables (uppercase first letter) var template MyMessage vt_message_id1_upper := { @@ -152,14 +189,21 @@ function f_dummy() { content := { INTEGER := 42 } } + var template MyMessage vt_message_id4_upper := { + id := 4, + content := { NULL := NULL } + } + // Value list template variable (contains both lowercase and uppercase examples) var template MyMessage vt_message_value_list := ( { id := 1, content := { mySeq := { field1 := 42, field2 := omit }} }, { id := 2, content := { myEnum := first} }, { id := 3, content := { iNTEGER := 42 } }, + { id := 4, content := { nULL := NULL } }, { id := 1, content := { MySeq := { field1 := -42, field2 := omit }} }, { id := 2, content := { MyEnum := second} }, - { id := 3, content := { INTEGER := -42 } } + { id := 3, content := { INTEGER := -42 } }, + { id := 4, content := { NULL := NULL } } ); // Referencing fields of open types (contains both lowercase and uppercase examples) @@ -169,18 +213,24 @@ function f_dummy() { v_message_id2_upper.content.MyEnum := second; v_message_id3_lower.content.iNTEGER := 15; v_message_id3_upper.content.INTEGER := 15; + v_message_id4_lower.content.nULL := NULL; + v_message_id4_upper.content.NULL := NULL; vt_message_id1_lower.content.mySeq := { field1 := 41, field2 := omit }; vt_message_id1_upper.content.MySeq := { field1 := 41, field2 := omit }; vt_message_id2_lower.content.myEnum := second; vt_message_id2_upper.content.MyEnum := second; vt_message_id3_lower.content.iNTEGER := 15; vt_message_id3_upper.content.INTEGER := 15; + vt_message_id4_lower.content.nULL := NULL; + vt_message_id4_upper.content.NULL := NULL; if (c_message_id1_lower.content.mySeq == { field1 := 41, field2 := omit } and c_message_id1_upper.content.MySeq == { field1 := 41, field2 := omit } and c_message_id2_lower.content.myEnum == second and c_message_id2_upper.content.MyEnum == second and c_message_id3_lower.content.iNTEGER == 15 and - c_message_id3_upper.content.INTEGER == 15) { + c_message_id3_upper.content.INTEGER == 15 and + c_message_id4_lower.content.nULL == NULL and // NULL != NULL !? + c_message_id4_upper.content.NULL == NULL) { log("a"); } if (v_message_id1_lower.content.mySeq == { field1 := 41, field2 := omit } and @@ -188,7 +238,9 @@ function f_dummy() { v_message_id2_lower.content.myEnum == second and v_message_id2_upper.content.MyEnum == second and v_message_id3_lower.content.iNTEGER == 15 and - v_message_id3_upper.content.INTEGER == 15) { + v_message_id3_upper.content.INTEGER == 15 and + v_message_id4_lower.content.nULL == NULL and + v_message_id4_upper.content.NULL == NULL) { log("b"); } if (match({ field1 := 41, field2 := omit }, t_message_id1_lower.content.mySeq) and @@ -196,7 +248,9 @@ function f_dummy() { match(second, t_message_id2_lower.content.myEnum) and match(second, t_message_id2_lower.content.MyEnum) and match(15, t_message_id3_lower.content.iNTEGER) and - match(15, t_message_id3_lower.content.INTEGER)) { + match(15, t_message_id3_lower.content.INTEGER) and + match(NULL, t_message_id4_lower.content.nULL) and + match(NULL, t_message_id4_lower.content.NULL)) { log("c"); } if (match({ field1 := 41, field2 := omit }, vt_message_id1_upper.content.mySeq) and @@ -204,7 +258,9 @@ function f_dummy() { match(second, vt_message_id2_upper.content.myEnum) and match(second, vt_message_id2_upper.content.MyEnum) and match(15, vt_message_id3_upper.content.iNTEGER) and - match(15, vt_message_id3_upper.content.INTEGER)) { + match(15, vt_message_id3_upper.content.INTEGER) and + match(NULL, vt_message_id4_upper.content.nULL) and + match(NULL, vt_message_id4_upper.content.NULL)) { log("d"); } } diff --git a/regression_test/logFiles/logfilter.sh b/regression_test/logFiles/logfilter.sh index 33e571a982605248b0536971c910919e2379c87a..51ffe4e228b13aa504f90b33d6b4a6a902db281b 100755 --- a/regression_test/logFiles/logfilter.sh +++ b/regression_test/logFiles/logfilter.sh @@ -11,7 +11,7 @@ LOGFILE="lfilter.log2" FILTERED_LOG_FILE="filtered.log" EXPECTED_LOG_FILE="filtered_e.log2" -ttcn3_logfilter -o $FILTERED_LOG_FILE $LOGFILE MATCHING+ PARALLEL+ +../../Install/bin/ttcn3_logfilter -o $FILTERED_LOG_FILE $LOGFILE MATCHING+ PARALLEL+ diff $FILTERED_LOG_FILE $EXPECTED_LOG_FILE if [ $? -ne 0 ]; then echo "Logfilter test failed! Overall verdict: fail" diff --git a/regression_test/negativeTest/NegTest_RAW_Testcases.ttcn b/regression_test/negativeTest/NegTest_RAW_Testcases.ttcn index 301809a4a1ce8a43720d2619110cf2864131ab89..e958a3ad9d67ed558da30d45ac7b93fb9a9ee4b0 100644 --- a/regression_test/negativeTest/NegTest_RAW_Testcases.ttcn +++ b/regression_test/negativeTest/NegTest_RAW_Testcases.ttcn @@ -2734,7 +2734,7 @@ group SetOf { //====set of related templates==== var RawSetOfRawUnionBT32 vl_expected :={ {r:="\x01\x01\xFF"}, {i:=2}, {b:=true}}; // oct2char('0101FF'O) f_compareAndVerdict( encode_rawSetOfInt32(valueof(t_msetofiValueDiffTypeRaw(1,2,3))), - '0101FF02000000FF'O); + '0101FF0200000001'O); f_compareAndVerdict( encode_rawSetOfInt32(valueof(t_msetofiValueDiffTypeRaw(1,2,3))), encode_rawSetOfRawUnionBT32( vl_expected )); @@ -2836,8 +2836,8 @@ group SetOf { //====set of related templates==== f_compareAndVerdict( actual, '0101FF'O // first raw value - & 'FE'O); // bottom 2 bits: '10'B for second; top 6 bits '111111'B for true - //'FE'O = bit2oct('111111'B & '10'B) + & '06'O); // bottom 2 bits: '10'B for second, 3rd bit is '1'B for true, top 5 bits are '00000'B (filler zeros) + //'06'O = bit2oct('00000'B & '1'B & '10'B) var RawSetOfRawUnionBT vl_expected :={ {os:='0101FF'O}, {e:=second}, {b:=true}}; var octetstring expected := encode_rawSetOfRawUnionBT(vl_expected); f_compareAndVerdict(actual, expected); @@ -2921,7 +2921,7 @@ group SetOf { //====set of related templates==== //var RawSetOfRawUnionBT vl_expected :={ {b:=true}, {r:="Two"}, {b:=true}}; f_compareAndVerdict( encode_rawSetOfCharstring(valueof(t_msetofrValueDiffTypeRaw("One", "Two", "Three"))), - '0101FF'O & char2oct("Two") & 'FF'O + '0101FF'O & char2oct("Two") & '01'O ); //'0101FF'O //encode_rawSetOfRawUnionBT( vl_expected )); } @@ -3003,7 +3003,7 @@ group Union { testcase tc_rawUnionBasicTypes_boolean3() runs on RawComp { //0. just for fun: var RawUnionBasicTypesT vl_mubt:={b:=true}; - f_compareAndVerdict(encode_rawUnionBasicTypesT(vl_mubt), 'FF'O); + f_compareAndVerdict(encode_rawUnionBasicTypesT(vl_mubt), '01'O); //1. vl_mubt:={b:=false}; f_compareAndVerdict( diff --git a/regression_test/templateInt/ImportedTemplates.ttcn b/regression_test/templateInt/ImportedTemplates.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..f5d1a76f7a6c34472d71aa0804c188a4d2a857c5 --- /dev/null +++ b/regression_test/templateInt/ImportedTemplates.ttcn @@ -0,0 +1,12 @@ +/****************************************************************************** + * Copyright (c) 2000-2015 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 + ******************************************************************************/ +module ImportedTemplates { + +template integer tImported(template integer pt) := pt; + +} diff --git a/regression_test/templateInt/Makefile b/regression_test/templateInt/Makefile index 0080b67517c3b2af56db2b61eb19938570933836..870edf06908a21aa29ca74a026214c5b58a215b9 100644 --- a/regression_test/templateInt/Makefile +++ b/regression_test/templateInt/Makefile @@ -13,7 +13,7 @@ include $(TOPDIR)/Makefile.regression TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) -TTCN3_MODULES = TtemplateInt.ttcn +TTCN3_MODULES = TtemplateInt.ttcn ImportedTemplates.ttcn GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh) @@ -30,8 +30,8 @@ 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) $< +$(GENERATED_SOURCES) $(GENERATED_HEADERS): $(TTCN3_MODULES) + $(TTCN3_COMPILER) $^ clean distclean: -rm -f $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ diff --git a/regression_test/templateInt/TtemplateInt.ttcn b/regression_test/templateInt/TtemplateInt.ttcn index 26341104e3c5430f0dcd41c65e1c68033c680dce..d29edeb4968b44243d9d1c2c0c7e138afcf7facd 100644 --- a/regression_test/templateInt/TtemplateInt.ttcn +++ b/regression_test/templateInt/TtemplateInt.ttcn @@ -7,6 +7,8 @@ ******************************************************************************/ module TtemplateInt { +import from ImportedTemplates all; + type component templateInt_mycomp {}; type record templateInt_rec { integer x1, @@ -288,6 +290,53 @@ testcase templateIntSubtype() runs on templateInt_mycomp { setverdict(pass); } +// test case: using a parameterized template with no actual parameters (using default values) +// before its declaration +template integer tReverse := tPard; + +template integer tPard(integer p := 6) := p; + +testcase templateIntReverseOrder() runs on templateInt_mycomp { + var template integer vtExpected := 6; + if (log2str(tReverse) == log2str(vtExpected)) { + setverdict(pass); + } + else { + setverdict(fail, "Expected: ", vtExpected, ", got: ", tReverse); + } +} + +// same test, but the parameterized template is passed as a parameter to +// an imported parameterized template +template integer tReverse2 := tImported(tPard2); + +template integer tPard2(integer p := 4) := p; + +testcase templateIntReverseOrderImported() runs on templateInt_mycomp { + var template integer vtExpected := 4; + if (log2str(tReverse2) == log2str(vtExpected)) { + setverdict(pass); + } + else { + setverdict(fail, "Expected: ", vtExpected, ", got: ", tReverse2); + } +} + +// same as the previous test, but with a non-parameterized template +template integer tReverse3 := tImported(tNonPard); + +template integer tNonPard := (1, 2); + +testcase templateIntReverseOrderImported2() runs on templateInt_mycomp { + var template integer vtExpected := (1, 2); + if (log2str(tReverse3) == log2str(vtExpected)) { + setverdict(pass); + } + else { + setverdict(fail, "Expected: ", vtExpected, ", got: ", tReverse3); + } +} + control { execute(templateIntSpec()); execute(templateIntList()); @@ -302,5 +351,8 @@ control { execute(templateIntIfpresent()); execute(TR_HJ94652()); execute(templateIntSubtype()); + execute(templateIntReverseOrder()); + execute(templateIntReverseOrderImported()); + execute(templateIntReverseOrderImported2()); } } diff --git a/usrguide/referenceguide.doc b/usrguide/referenceguide.doc index 3c41ef9f03979bbbb8dc375cfb6d217fe698dab7..2caa8bffd6aa97f412d5f94f9afc6619b963188d 100644 Binary files a/usrguide/referenceguide.doc and b/usrguide/referenceguide.doc differ diff --git a/xsdconvert/ComplexType.cc b/xsdconvert/ComplexType.cc index 9dfb32a1a312962971b62f49faac222ba3a888a3..fe1afaef718a8c614ef24b0846698f743988ef88 100644 --- a/xsdconvert/ComplexType.cc +++ b/xsdconvert/ComplexType.cc @@ -139,7 +139,7 @@ ComplexType::ComplexType(const SimpleType & other, CT_fromST c) , enumfields() , tagNames() { - if(c != fromTagSubstition){ + if(c != fromTagSubstitution && c != fromTypeSubstitution){ module->replaceLastMainType(this); module->setActualXsdConstruct(c_complexType); } @@ -159,18 +159,32 @@ ComplexType::ComplexType(const SimpleType & other, CT_fromST c) type.upload(Mstring("record")); xsdtype = n_complexType; break; - case fromTagSubstition: + case fromTagSubstitution: type.upload(Mstring("union")); name.upload(getName().originalValueWoPrefix + Mstring("_group")); xsdtype = n_union; subsGroup = this; variant.clear(); + hidden_variant.clear(); enumeration.modified = false; value.modified = false; pattern.modified = false; length.modified = false; whitespace.modified = false; break; + case fromTypeSubstitution: + type.upload(Mstring("union")); + name.upload(getName().originalValueWoPrefix + Mstring("_derivations")); + xsdtype = n_union; + substitutionGroup = empty_string; + typeSubsGroup = this; + variant.clear(); + hidden_variant.clear(); + enumeration.modified = false; + value.modified = false; + pattern.modified = false; + length.modified = false; + whitespace.modified = false; } } @@ -634,7 +648,7 @@ void ComplexType::referenceResolving() { reference_resolving_funtion(); - if(!substitionGroup.empty()){ + if(!substitutionGroup.empty()){ addToSubstitutions(); } resolved = Yes; @@ -643,6 +657,11 @@ void ComplexType::referenceResolving() { void ComplexType::reference_resolving_funtion() { //Every child element references are resolved here. if (outside_reference.empty() && basefield == NULL) { + //Its not in the resolveElement function because we need the built in type + //reference too, and then the outside_reference is empty. + if(xsdtype == n_element){ + collectElementTypes(NULL, NULL); + } return; } @@ -671,6 +690,8 @@ void ComplexType::reference_resolving_funtion() { resolveUnion(st); + addToTypeSubstitutions(); + } void ComplexType::setParent(ComplexType * par, SimpleType * child) { @@ -679,7 +700,7 @@ void ComplexType::setParent(ComplexType * par, SimpleType * child) { void ComplexType::applyReference(const SimpleType & other, const bool on_attributes) { type.convertedValue = other.getType().convertedValue; - type.originalValueWoPrefix = other.getType().convertedValue; + type.originalValueWoPrefix = other.getType().convertedValue.getValueWithoutPrefix(':'); if (other.getMinOccurs() > minOccurs || other.getMaxOccurs() < maxOccurs) { if (!on_attributes) { @@ -1005,7 +1026,7 @@ void ComplexType::finalModification2() { } //Substitution group ordering - if(subsGroup == this){ //We are a generated substitution group + if(subsGroup == this || typeSubsGroup == this){ //We are a generated substitution group //Substitution group never empty ComplexType * front = complexfields.front(); List<ComplexType*>::iterator it = complexfields.begin(); @@ -1209,6 +1230,9 @@ void ComplexType::collectVariants(List<Mstring>& container) { if (useUnionVariantWhenMainTypeIsRecordOf) { container.push_back(Mstring("variant ([-]) \"useUnion\";\n")); } + for (List<Mstring>::iterator var = hidden_variant.end(); var; var = var->Prev) { + container.push_back(Mstring("//variant ") + Mstring(var->Data.c_str()) + Mstring(";\n")); + } } //Collect variants of attributes @@ -1557,9 +1581,9 @@ void ComplexType::resolveAttribute(AttributeType* attr) { } else { attr->setTypeOfField(st->getName().convertedValue); if (st->getType().convertedValue == "record" || st->getType().convertedValue == "union") { - st->addToNameDepList(attr); + st->addToNameDepList(attr); + } } - } } else { printError(module->getSchemaname(), name.convertedValue, "Reference for a non-defined type: " + attr->getReference().repr()); @@ -1681,17 +1705,25 @@ void ComplexType::resolveElement(SimpleType *st) { if (xsdtype == n_element && !outside_reference.empty()) { outside_reference.set_resolved(st); type.upload(st->getModule()->getTargetNamespaceConnector() + Mstring(":") + st->getName().convertedValue); - st->addToNameDepList(this); - nameDep = st; if (name.originalValueWoPrefix.empty()) { name.upload(st->getName().convertedValue); } if (fromRef) { addNameSpaceAsVariant(this, st); } + + collectElementTypes(st, NULL); + + //Namedep is added to the substitutions, if any if(st->getSubstitution() != NULL){ st->getSubstitution()->addToNameDepList(this); nameDep = st->getSubstitution(); + }if(st->getTypeSubstitution() != NULL){ + st->getTypeSubstitution()->addToNameDepList(this); + nameDep = st->getTypeSubstitution(); + }else { + st->addToNameDepList(this); + nameDep = st; } } } @@ -1717,8 +1749,8 @@ void ComplexType::resolveSimpleTypeExtension() { st->referenceResolving(); } st->addToNameDepList(basefield); - addNameSpaceAsVariant(basefield, st); basefield->nameDep = st; + addNameSpaceAsVariant(basefield, st); } } else if(!isBuiltInType(basefield->getType().convertedValue)){ printError(module->getSchemaname(), name.convertedValue, @@ -1915,21 +1947,28 @@ void ComplexType::modifyAttributeParent() { } } -void ComplexType::addSubstitution(SimpleType* st){ +//Element substitution +void ComplexType::addSubstitution(SimpleType * st){ ComplexType * element; if(st->getXsdtype() == n_NOTSET || !complexfields.empty()){ - element = new ComplexType(*st, fromTagSubstition); + element = new ComplexType(*st, fromTagSubstitution); }else { element = new ComplexType(*(ComplexType*)st); element->variant.clear(); } element->subsGroup = this; element->parent = this; - if(complexfields.empty()){ //The first element(head) + if(complexfields.empty()){ //The first element(head) is the st element->setTypeValue(st->getType().convertedValue); if(st->hasVariant(Mstring("\"abstract\""))){ - element->addVariant(V_onlyValueHidden, Mstring("\"abstract\"")); + element->addVariant(V_abstract); + } + if(st->getReference().get_ref() != NULL){ + ((SimpleType*)st->getReference().get_ref())->addToNameDepList(element); + nameDep = ((SimpleType*)st->getReference().get_ref()); } + module->addElementType(element->getType().convertedValue, element); + element->addVariant(V_formAs, Mstring("qualified")); }else { Mstring newType; if(st->getType().convertedValue == "anyType"){ @@ -1937,16 +1976,18 @@ void ComplexType::addSubstitution(SimpleType* st){ }else { newType = st->getName().convertedValue; st->addToNameDepList(element); + element->nameDep = st; } element->setTypeValue(newType); BlockValue front_block = complexfields.front()->getBlock(); if(front_block == all || front_block == substitution){ - element->addVariant(V_onlyValueHidden, Mstring("\"block\"")); + element->addVariant(V_block); }else if(front_block == restriction || front_block == extension){ const Mstring& head_type = complexfields.front()->getType().convertedValue.getValueWithoutPrefix(':'); + //To decide if they came from a common ancestor Mstring elem_type = findRoot(front_block, st, head_type, true); if(head_type == elem_type){ - element->addVariant(V_onlyValueHidden, Mstring("\"block\"")); + element->addVariant(V_block); } } } @@ -1956,11 +1997,56 @@ void ComplexType::addSubstitution(SimpleType* st){ complexfields.push_back(element); } +void ComplexType::addTypeSubstitution(SimpleType * st){ + ComplexType * element; + if(st->getXsdtype() == n_NOTSET || !complexfields.empty()){ + element = new ComplexType(*st, fromTypeSubstitution); + }else { + //Only need a plain complextype + //Head element + element = new ComplexType(this); + //Just the block needed from st + element->block = st->getBlock(); + } + st->addToNameDepList(element); + element->nameDep = st; + element->typeSubsGroup = this; + element->parent = this; + if(complexfields.empty()){ //The first element(head) is the st + if(st->hasVariant(Mstring("\"abstract\""))){ + element->addVariant(V_abstract); + } + }else { + BlockValue front_block = complexfields.front()->getBlock(); + if(front_block == all){ + element->addVariant(V_block); + }else if(front_block == restriction || front_block == extension){ + const Mstring& head_type = complexfields.front()->getType().convertedValue.getValueWithoutPrefix(':'); + //To decide if they came from a common ancestor + Mstring elem_type = findRoot(front_block, st, head_type, true); + if(head_type == elem_type){ + element->addVariant(V_block); + } + } + } + element->top = false; + complexfields.push_back(element); + element->setTypeValue(st->getName().convertedValue.getValueWithoutPrefix(':')); + element->setNameValue(st->getName().convertedValue.getValueWithoutPrefix(':')); +} + Mstring ComplexType::findRoot(const BlockValue block_value, SimpleType* elem, const Mstring& head_type, const bool first){ - if(!first && elem->getType().convertedValue.getValueWithoutPrefix(':') == head_type && !isFromRef()){ - return elem->getType().convertedValue.getValueWithoutPrefix(':'); - }else if(elem->getType().convertedValue.getValueWithoutPrefix(':') == head_type && (isFromRef() && ((elem->getMode() == restrictionMode && block_value == restriction) || (elem->getMode() == extensionMode && block_value == extension)))){ - return elem->getType().convertedValue.getValueWithoutPrefix(':'); + const Mstring elemName = elem->getName().convertedValue.getValueWithoutPrefix(':'); + const Mstring elemType = elem->getType().convertedValue.getValueWithoutPrefix(':'); + + if(!first && !isFromRef() && elemType == head_type){ + return elemType; + }else if((isFromRef() && + ((elem->getMode() == restrictionMode && block_value == restriction) || + (elem->getMode() == extensionMode && block_value == extension))) && elemType == head_type){ + return elemType; + }else if(!first && elemName == head_type){ + return elemName; }else { SimpleType * st = NULL; if((elem->getMode() == restrictionMode && block_value == restriction) || @@ -1987,7 +2073,7 @@ Mstring ComplexType::findRoot(const BlockValue block_value, SimpleType* elem, co } } if(elem->getMode() == noMode && !first){ - return elem->getType().convertedValue.getValueWithoutPrefix(':'); + return elemType; }else { return empty_string; } diff --git a/xsdconvert/ComplexType.hh b/xsdconvert/ComplexType.hh index e310e32bc357bcfeecf50a0626d5839412b9208f..c6918e61bb352179f8fc20ffd30d9907c64def58 100644 --- a/xsdconvert/ComplexType.hh +++ b/xsdconvert/ComplexType.hh @@ -43,7 +43,8 @@ public: fromTagUnion, fromTagNillable, fromTagComplexType, - fromTagSubstition + fromTagSubstitution, + fromTypeSubstitution }; enum Resolv_State { @@ -115,7 +116,8 @@ public: ~ComplexType(); void modifyAttributeParent(); - void addSubstitution(SimpleType* st); + void addSubstitution(SimpleType * st); + void addTypeSubstitution(SimpleType * st); /** Virtual methods * inherited from RootType @@ -130,6 +132,7 @@ public: void nameConversion(NameConversionMode mode, const List<NamespaceType> & ns); void finalModification(); bool hasUnresolvedReference(){ return resolved == No; } + void setNameDep(SimpleType * dep) { nameDep = dep; } void dump(unsigned int depth) const; diff --git a/xsdconvert/Makefile b/xsdconvert/Makefile index e77d3f2d4bd48d0e921ef9aa45d77685042c4f21..7789389188f7c3e3d9a99f72446645d42fa62e20 100644 --- a/xsdconvert/Makefile +++ b/xsdconvert/Makefile @@ -64,6 +64,10 @@ endif # libraries for the linker LDLIBS += -lxml2 -lcrypto +ifdef MINGW +LDLIBS += -lregex +endif + all run: $(TARGETS) $(PROGRAMS) xsd2ttcn$(EXESUFFIX): $(OBJECTS) diff --git a/xsdconvert/RootType.cc b/xsdconvert/RootType.cc index f80a19a2bc9eef58e55c27fc16903e9455c2190c..a01a45cb8021583e76fd17e2122d25b866bedda9 100644 --- a/xsdconvert/RootType.cc +++ b/xsdconvert/RootType.cc @@ -149,6 +149,9 @@ void RootType::addVariant(const VariantMode var, const Mstring& var_value, const case V_useOrder: variantstring = "\"useOrder\""; break; + case V_useType: + variantstring = "\"useType\""; + break; case V_useUnion: variantstring = "\"useUnion\""; break; @@ -242,5 +245,10 @@ bool RootType::hasVariant(const Mstring& var) const{ return true; } } + for(List<Mstring>::iterator vars = hidden_variant.begin(); vars; vars = vars->Next){ + if(vars->Data.isFound(var)){ + return true; + } + } return false; } \ No newline at end of file diff --git a/xsdconvert/RootType.hh b/xsdconvert/RootType.hh index 16a5f1528861ad2f22cc557ec2dab65f25129221..032a0abfae97f538be9bd308e065b6df3c56881f 100644 --- a/xsdconvert/RootType.hh +++ b/xsdconvert/RootType.hh @@ -53,6 +53,7 @@ enum VariantMode { V_useNil, V_useNumber, V_useOrder, + V_useType, V_useUnion, V_whiteSpace, V_fractionDigits @@ -165,6 +166,10 @@ public: visible = false; } + void setVisible() { + visible = true; + } + const NameType & getName() const { return name; } @@ -209,6 +214,10 @@ public: return comment; } + List<SimpleType*> & getNameDepList() { + return nameDepList; + } + XMLParser * getParser() const { return parser; } diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc index db39ef0bfe67a686d78b596aa7996f4e6acf0caf..24dbdbdaee654a5eaeda8090120a4158ce8be26e 100644 --- a/xsdconvert/SimpleType.cc +++ b/xsdconvert/SimpleType.cc @@ -14,6 +14,7 @@ #include "ComplexType.hh" extern bool g_flag_used; +extern bool h_flag_used; SimpleType::SimpleType(XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct) : RootType(a_parser, a_module, a_construct) @@ -31,8 +32,10 @@ SimpleType::SimpleType(XMLParser * a_parser, TTCN3Module * a_module, ConstructTy , fromRef(false) , xsdtype(n_NOTSET) , isOptional(false) -, substitionGroup(empty_string) +, substitutionGroup(empty_string) , subsGroup(NULL) +, typeSubsGroup(NULL) +, addedToTypeSubstitution(false) , block(not_set) , parent(NULL) { } @@ -53,8 +56,10 @@ SimpleType::SimpleType(const SimpleType& other) , fromRef(other.fromRef) , xsdtype(other.xsdtype) , isOptional(other.isOptional) -, substitionGroup(other.substitionGroup) +, substitutionGroup(other.substitutionGroup) , subsGroup(other.subsGroup) +, typeSubsGroup(other.typeSubsGroup) +, addedToTypeSubstitution(other.addedToTypeSubstitution) , block(other.block) , parent(NULL) { length.parent = this; @@ -255,13 +260,13 @@ void SimpleType::applyNillableAttribute(const bool nillable) { void SimpleType::applyAbstractAttribute(const bool abstract_value) { if (abstract_value) { - addVariant(V_onlyValueHidden, Mstring("\"abstract\"")); + addVariant(V_abstract); } } -void SimpleType::applySubstitionGroupAttribute(const Mstring& substition_group){ - if(!substition_group.empty()){ - substitionGroup = substition_group; +void SimpleType::applySubstitionGroupAttribute(const Mstring& substitution_group){ + if(!substitution_group.empty()){ + substitutionGroup = substitution_group; } } @@ -274,15 +279,14 @@ void SimpleType::applyBlockAttribute(const BlockValue block_){ } void SimpleType::addToSubstitutions(){ - if(!g_flag_used){ + if(!g_flag_used || substitutionGroup.empty()){ return; } - SimpleType * st_ = (SimpleType*) TTCN3ModuleInventory::getInstance().lookup(this, substitionGroup, want_BOTH); + SimpleType * st_ = (SimpleType*) TTCN3ModuleInventory::getInstance().lookup(this, substitutionGroup, want_BOTH); if(st_ == NULL){ printError(module->getSchemaname(), name.convertedValue, - "Reference for a non-defined type: " + substitionGroup); + "Reference for a non-defined type: " + substitutionGroup); TTCN3ModuleInventory::getInstance().incrNumErrors(); - return; return; } SimpleType * st = (SimpleType*)st_; @@ -291,12 +295,12 @@ void SimpleType::addToSubstitutions(){ } st->referenceResolving(); - substitionGroup = empty_string; + substitutionGroup = empty_string; //Simpletype if(st->subsGroup == NULL){ - ComplexType * head_element = new ComplexType(*st, ComplexType::fromTagSubstition); + ComplexType * head_element = new ComplexType(*st, ComplexType::fromTagSubstitution); for(List<SimpleType*>::iterator simpletype = st->nameDepList.begin(); simpletype; simpletype = simpletype->Next){ - head_element->nameDepList.push_back(simpletype->Data); + head_element->getNameDepList().push_back(simpletype->Data); } st->nameDepList.clear(); st->getModule()->addMainType(head_element); @@ -311,6 +315,145 @@ void SimpleType::addToSubstitutions(){ } } +void SimpleType::addToTypeSubstitutions() { + //If the user did not request type substitution generation or + //the type is already added to type substitution + if(!h_flag_used || addedToTypeSubstitution){ + return; + } + //Only available if it is a restricion or extension + if(mode != extensionMode && mode != restrictionMode){ + return; + } + //Only top level complexTypes or simpleTypes, ergo no elements + if(parent != NULL || hasVariant(Mstring("\"element\""))){ + return; + } + + //It would be nice if here outside_reference.resolved to everything + SimpleType * st = (SimpleType*)outside_reference.get_ref(); + bool newST = false; + if(st == NULL && !isBuiltInType(type.convertedValue)){ + //Not even a reference, and not a built in type + return; + }else if(st == NULL && isBuiltInType(type.convertedValue)){ + st = new SimpleType(parser, module, construct); + st->type.upload(type.convertedValue); + st->name.upload(type.convertedValue); + st->typeSubsGroup = findBuiltInTypeInStoredTypeSubstitutions(type.convertedValue); + newST = true; + } + + addedToTypeSubstitution = true; + + //If type substitution is NULL then we need to create the union + if(st->getTypeSubstitution() == NULL){ + ComplexType * head_element = new ComplexType(*st, ComplexType::fromTypeSubstitution); + for(List<SimpleType*>::iterator simpletype = st->nameDepList.begin(); simpletype; simpletype = simpletype->Next){ + head_element->getNameDepList().push_back(simpletype->Data); + } + st->nameDepList.clear(); + st->getModule()->addMainType(head_element); + head_element->addVariant(V_useType); + head_element->addTypeSubstitution(st); + head_element->addTypeSubstitution(this); + bool found = false; + //Check to find if there was already an element reference with this type + for(List<typeNameDepList>::iterator str = module->getElementTypes().begin(); str; str = str->Next){ + Mstring prefix = str->Data.type.getPrefix(':'); + Mstring value = str->Data.type.getValueWithoutPrefix(':'); + + if((value == st->getName().convertedValue.getValueWithoutPrefix(':') && prefix == module->getTargetNamespaceConnector()) || + (isBuiltInType(value) && !isBuiltInType(st->getType().convertedValue) && value == st->getType().convertedValue && prefix == module->getTargetNamespaceConnector())){ + //Push the namedeplist + for(List<SimpleType*>::iterator simpletype = str->Data.nameDepList.begin(); simpletype; simpletype = simpletype->Next){ + head_element->getNameDepList().push_back(simpletype->Data); + } + found = true; + str->Data.typeSubsGroup = head_element; + break; + } + } + if(!found){ + head_element->setInvisible(); + } + st->typeSubsGroup = head_element; + st->getModule()->addStoredTypeSubstitution(head_element); + }else { + st->getTypeSubstitution()->addTypeSubstitution(this); + } + + //Free pointer + if(newST){ + delete st; + st = NULL; + } +} + +void SimpleType::collectElementTypes(SimpleType* found_ST, ComplexType* found_CT){ + //Only if type substitution is enabled and it is a top level(simpletype) element or + //it is a not top level element(complextype) + if(h_flag_used && (hasVariant(Mstring("\"element\"")) || xsdtype == n_element)){ + SimpleType * st = NULL, *nameDep = NULL; + Mstring uri, value, type_; + if(found_ST != NULL || found_CT != NULL){ + // st := found_ST or found_CT, which is not null + st = found_ST != NULL ? found_ST : found_CT; + uri = outside_reference.get_uri(); + value = outside_reference.get_val(); + type_ = value; + }else if(isBuiltInType(type.convertedValue)){ + st = this; + uri = module->getTargetNamespace(); + value = type.convertedValue; + if(outside_reference.empty()){ + type_ = value; + nameDep = this; + }else { + type_ = outside_reference.get_val(); + } + }else { + //It is not possible to reach here (should be) + return; + } + type_ = type_.getValueWithoutPrefix(':'); + bool found = false; + const Mstring typeSubsName = value + Mstring("_derivations"); + //Find if we already have a substitution type to this element reference + for(List<ComplexType*>::iterator complex = st->getModule()->getStoredTypeSubstitutions().begin(); complex; complex = complex->Next){ + + if(uri == st->getModule()->getTargetNamespace() && typeSubsName == complex->Data->getName().convertedValue){ + complex->Data->setVisible(); + if(st->getXsdtype() != n_NOTSET && this == st){ //otherwise records would be renamed too + complex->Data->addToNameDepList(st); + ((ComplexType*)st)->setNameDep(nameDep); + } + found = true; + break; + } + } + //Add the reference, to future possible type substitution + if(!found){ + Mstring prefix = st->getModule()->getTargetNamespaceConnector(); + if(prefix != empty_string){ + prefix += ":"; + } + st->getModule()->addElementType(prefix + type_, nameDep); + } + } +} + +ComplexType * SimpleType::findBuiltInTypeInStoredTypeSubstitutions(const Mstring& builtInType){ + const Mstring typeSubsName = builtInType.getValueWithoutPrefix(':') + Mstring("_derivations"); + for(List<ComplexType*>::iterator complex = module->getStoredTypeSubstitutions().begin(); complex; complex = complex->Next){ + if(typeSubsName == complex->Data->getName().convertedValue){ + return complex->Data; + } + } + return NULL; +} + + void SimpleType::setReference(const Mstring& ref, bool only_name_dependency) { if (ref.empty()) { return; @@ -374,7 +517,11 @@ void SimpleType::setReference(const Mstring& ref, bool only_name_dependency) { } void SimpleType::referenceResolving() { - if (outside_reference.empty() && substitionGroup.empty()) return; + if (outside_reference.empty()){ + addToTypeSubstitutions(); + collectElementTypes(); + } + if(outside_reference.empty() && substitutionGroup.empty()) return; if (outside_reference.is_resolved()) return; if(!outside_reference.empty()){ @@ -383,18 +530,20 @@ void SimpleType::referenceResolving() { ComplexType * found_CT = static_cast<ComplexType*> ( TTCN3ModuleInventory::getInstance().lookup(this, want_CT)); // It _is_ possible to find both - + collectElementTypes(found_ST, found_CT); if (found_ST != NULL) { if (!found_ST->outside_reference.empty() && !found_ST->outside_reference.is_resolved() && found_ST != this) { found_ST->outside_reference.set_resolved(NULL); found_ST->referenceResolving(); } referenceForST(found_ST); + addToTypeSubstitutions(); if (!isBuiltInType(type.convertedValue)) { found_ST->addToNameDepList(this); } } else if (found_CT != NULL) { referenceForCT(found_CT); + addToTypeSubstitutions(); if (!isBuiltInType(type.convertedValue)) { found_CT->addToNameDepList(this); } @@ -404,10 +553,8 @@ void SimpleType::referenceResolving() { TTCN3ModuleInventory::getInstance().incrNumErrors(); outside_reference.set_resolved(NULL); } - if(!substitionGroup.empty()){ - addToSubstitutions(); - } - }else if(!substitionGroup.empty()){ + addToSubstitutions(); + }else { addToSubstitutions(); } } diff --git a/xsdconvert/SimpleType.hh b/xsdconvert/SimpleType.hh index c4ea1069f12120d5282db39ceb35d321bf784718..4e59ea83f321f7870ac6309c5b39f8696afda3d9 100644 --- a/xsdconvert/SimpleType.hh +++ b/xsdconvert/SimpleType.hh @@ -218,12 +218,27 @@ protected: // XSD Type of the type TagName xsdtype; bool isOptional; - Mstring substitionGroup; + Mstring substitutionGroup; + //Pointer to the generated element substitution group ComplexType * subsGroup; + //Pointer to the generated type substitution group + ComplexType * typeSubsGroup; + //To determine if already added to type substitution + bool addedToTypeSubstitution; BlockValue block; + + //Element substitution + void addToSubstitutions(); + //Type substitution + void addToTypeSubstitutions(); + //Returns the type substitution which the builtInType belongs + ComplexType * findBuiltInTypeInStoredTypeSubstitutions(const Mstring& builtInType); - void addToSubstitutions(); + //Only used when type substitution is enabled + //If an element reference is found then it is put to a container + //to know if type substitution is possible + void collectElementTypes(SimpleType * found_ST = NULL, ComplexType * found_CT = NULL); void nameConversion_names(); virtual void nameConversion_types(const List<NamespaceType> & ns); @@ -338,14 +353,22 @@ public: return subsGroup; } + ComplexType * getTypeSubstitution() const { + return typeSubsGroup; + } + BlockValue getBlock() const { return block; } void addToNameDepList(SimpleType * t) { + //If the type has a substitution, we add the namedep to the substitution if(subsGroup != NULL && this != (SimpleType*)subsGroup){ SimpleType * substitution = (SimpleType*)subsGroup; substitution->addToNameDepList(t); + }else if(typeSubsGroup != NULL && this != (SimpleType*)typeSubsGroup){ + SimpleType * substitution = (SimpleType*)typeSubsGroup; + substitution->addToNameDepList(t); }else { nameDepList.push_back(t); } diff --git a/xsdconvert/TTCN3Module.cc b/xsdconvert/TTCN3Module.cc index a0c2763898aebb1d0907dd30ce1ef032146de813..046b7e397cc2a9c5c6cf1958eebaf2df9c4037cc 100644 --- a/xsdconvert/TTCN3Module.cc +++ b/xsdconvert/TTCN3Module.cc @@ -42,6 +42,8 @@ TTCN3Module::TTCN3Module(const char * a_filename, XMLParser * a_parser) , elementFormDefault(notset) , attributeFormDefault(notset) , blockDefault(not_set) +, storedTypeSubstitutions() +, element_types() //, importedModules() , variant() , moduleNotIntoFile(false) diff --git a/xsdconvert/TTCN3Module.hh b/xsdconvert/TTCN3Module.hh index cfa0abacb0b9b9f0ca77a3ca8792ac9dbbc654ed..96887c99e5a4398bb79dd77b52a574e446055131 100644 --- a/xsdconvert/TTCN3Module.hh +++ b/xsdconvert/TTCN3Module.hh @@ -16,6 +16,15 @@ class TTCN3ModuleInventory; class RootType; +//Used only in type substitution, when we have to change the type or a builtintype +//due to type substitution +struct typeNameDepList { + Mstring type; + List<SimpleType*> nameDepList; + //Used only with builtInTypes + ComplexType* typeSubsGroup; +}; + /** * Type that contains information about one TTCN-3 module * and performs the generation of that module @@ -64,6 +73,12 @@ class TTCN3Module { List<const TTCN3Module*> importedModules; // pointers not owned + //Used only in type substitution, stores every possibly substituted type definitions + List<ComplexType*> storedTypeSubstitutions; //pointers not owned + + //Used only in type substitution, stores every element that references a type + List<typeNameDepList> element_types; + List<Mstring> variant; bool moduleNotIntoFile; @@ -191,6 +206,38 @@ public: return importedModules; } + List<ComplexType*> & getStoredTypeSubstitutions() { + return storedTypeSubstitutions; + } + + void addStoredTypeSubstitution(ComplexType * type){ + storedTypeSubstitutions.push_back(type); + } + + List<typeNameDepList> & getElementTypes() { + return element_types; + } + + void addElementType(const Mstring& type, SimpleType* st) { + List<typeNameDepList>::iterator it = element_types.begin(); + for(; it; it = it->Next){ + if(it->Data.type == type && st != NULL){ + it->Data.nameDepList.push_back(st); + break; + } + } + //New type that has not been in the element_types before + if(it == NULL){ + typeNameDepList list; + list.type = type; + list.typeSubsGroup = NULL; + if(st != NULL){ + list.nameDepList.push_back(st); + } + element_types.push_back(list); + } + } + /// Compute the TTCN-3 module name void TargetNamespace2ModuleName(); diff --git a/xsdconvert/TTCN3ModuleInventory.cc b/xsdconvert/TTCN3ModuleInventory.cc index b4c63c91b9373193452f420d4194a4a7f642357f..53b031d98a672435efaa33555b6abc896ab03837 100644 --- a/xsdconvert/TTCN3ModuleInventory.cc +++ b/xsdconvert/TTCN3ModuleInventory.cc @@ -291,6 +291,10 @@ RootType * TTCN3ModuleInventory::lookup(const RootType* ref, const Mstring& refe break; } } + if(uri.empty()){ + //If the targetnamespace is NoTargetNamespace therefore no prefix connector used + uri = ref->getModule()->getTargetNamespace(); + } }else { uri = getNameSpaceByPrefix(ref, uri); } diff --git a/xsdconvert/XMLParser.cc b/xsdconvert/XMLParser.cc index 9b446a39e92507a803feb2ec2522936468bfc1e7..7d778f2deb9f3a3765cba960e88963247370e9e2 100644 --- a/xsdconvert/XMLParser.cc +++ b/xsdconvert/XMLParser.cc @@ -556,18 +556,12 @@ void XMLParser::fillUpActualTagAttributes(const char ** attributes, const int at att_name_e[i] = a_NOTSET; if (att_name_s[i] == "abstract") { att_name_e[i] = a_abstract; - printWarning(filename, xmlSAX2GetLineNumber(context), - Mstring("The 'abstract' attribute is currently not supported.")); - ++num_warnings; } else if (att_name_s[i] == "attributeFormDefault") att_name_e[i] = a_attributeFormDefault; else if (att_name_s[i] == "base") att_name_e[i] = a_base; else if (att_name_s[i] == "block") { att_name_e[i] = a_block; - printWarning(filename, xmlSAX2GetLineNumber(context), - Mstring("The 'block' attribute is currently not supported.")); - ++num_warnings; } else if (att_name_s[i] == "blockDefault"){ att_name_e[i] = a_blockDefault; } else if (att_name_s[i] == "default") @@ -611,9 +605,6 @@ void XMLParser::fillUpActualTagAttributes(const char ** attributes, const int at att_name_e[i] = a_schemaLocation; else if (att_name_s[i] == "substitutionGroup") { att_name_e[i] = a_substitutionGroup; - //printWarning(filename, xmlSAX2GetLineNumber(context), - //Mstring("The 'substitutionGroup' attribute is currently not supported.")); - //++num_warnings; } else if (att_name_s[i] == "targetNamespace") att_name_e[i] = a_targetNamespace; else if (att_name_s[i] == "type") diff --git a/xsdconvert/converter.cc b/xsdconvert/converter.cc index 02bbc555de2187a6269b38d9ad733d863d59ce7b..cba52ad0ba42bee6d827d648c0554a5486c5ed9a 100644 --- a/xsdconvert/converter.cc +++ b/xsdconvert/converter.cc @@ -22,6 +22,7 @@ int d_flag_used = 0; bool e_flag_used = false; bool f_flag_used = false; bool g_flag_used = true; +bool h_flag_used = false; bool p_flag_used = false; bool s_flag_used = false; bool t_flag_used = false; @@ -56,7 +57,7 @@ int main(int argc, char **argv) { char c; opterr = 0; - while ((c = getopt(argc, argv, "cdef:gpqstvwxz")) != -1) { + while ((c = getopt(argc, argv, "cdef:ghpqstvwxz")) != -1) { switch (c) { case 'c': c_flag_used = true; @@ -74,6 +75,9 @@ int main(int argc, char **argv) { case 'g': g_flag_used = false; break; + case 'h': + h_flag_used = true; + break; case 'p': p_flag_used = true; break; @@ -207,6 +211,7 @@ static void printUsage(const char * argv0) { " -e: disable the generation of encoding instructions in TTCN-3 modules\n" " -f file: the names of XSD files are taken from file instead of the command line\n" " -g: generate TTCN-3 code disallowing element substitution\n" + " -h: generate TTCN-3 code allowing type substitution\n" " -p: do not generate the UsefulTtcn3Types and XSD predefined modules\n" " -q: quiet mode - disable the issue of status messages\n" " -s: parse and validate only - no TTCN-3 module generation\n"