diff --git a/compiler2/record.c b/compiler2/record.c index ef06ff3df1e665b635dade0153733bed25426c4d..c1a2e0f19b77f3491bf955e5b5bf230981f1b33f 100644 --- a/compiler2/record.c +++ b/compiler2/record.c @@ -1846,9 +1846,9 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc) "char **collect_ns(const XERdescriptor_t& p_td, size_t& num_ns, bool& def_ns, unsigned int flavor = 0) const;\n"); src = mputprintf(src, - "char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num_ns, bool& def_ns, unsigned int) const {\n" + "char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num_ns, bool& def_ns, unsigned int flavor) const {\n" " size_t num_collected;\n" - " char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns);\n" + " char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns, flavor);\n" /* The above might throw but then nothing was allocated. */ , name); @@ -1860,7 +1860,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc) " boolean def_ns_1 = FALSE;\n"); for (i = start_at; i < sdef->nElements; ++i) { src = mputprintf(src, - " new_ns = field_%s.collect_ns(%s_xer_, num_new, def_ns);\n" + " new_ns = field_%s.collect_ns(%s_xer_, num_new, def_ns, flavor);\n" " merge_ns(collected_ns, num_collected, new_ns, num_new);\n" " def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */ , sdef->elements[i].name, sdef->elements[i].typegen @@ -1939,12 +1939,12 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc) " boolean def_ns = FALSE;\n" " if (e_xer) {\n" " if (p_indent == 0) {\n" /* top-level */ - " collected_ns = collect_ns(p_td, num_collected, def_ns);\n" /* our own ns */ + " collected_ns = collect_ns(p_td, num_collected, def_ns, p_flavor2);\n" /* our own ns */ " }\n" " else if ((p_flavor & DEF_NS_SQUASHED) && p_td.my_module && p_td.ns_index != -1){\n" " const namespace_t * ns = p_td.my_module->get_ns((size_t)p_td.ns_index);\n" " if (*ns->px == '\\0') {\n" - " collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns);\n" + " collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns, p_flavor2);\n" " }\n" " }\n" " }\n" diff --git a/compiler2/record_of.c b/compiler2/record_of.c index 555a05d6517a23400be1d07cba5f4f9c8ad96555..cfd6bdffd3a5571bd01a1d26fd75ad3adac5cea3 100644 --- a/compiler2/record_of.c +++ b/compiler2/record_of.c @@ -1085,16 +1085,16 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ); src = mputprintf(src, - "char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int) const {\n" + "char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int flavor) const {\n" " size_t num_collected;\n" - " char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns);\n" + " char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns, flavor);\n" /* The above may throw but then nothing was allocated. */ " if (val_ptr) try {\n" " char **new_ns;\n" " size_t num_new;\n" " for (int i = 0; i < val_ptr->n_elements; ++i) {\n" " boolean def_ns_1 = FALSE;\n" - " new_ns = (*this)[i].collect_ns(*p_td.oftype_descr, num_new, def_ns_1);\n" + " new_ns = (*this)[i].collect_ns(*p_td.oftype_descr, num_new, def_ns_1, flavor);\n" " merge_ns(collected_ns, num_collected, new_ns, num_new);\n" " def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */ " }\n" @@ -1150,7 +1150,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) " size_t num_collected = 0;\n" " char **collected_ns = NULL;\n" " boolean def_ns = FALSE;\n" - " collected_ns = collect_ns(p_td, num_collected, def_ns);\n" + " collected_ns = collect_ns(p_td, num_collected, def_ns, p_flavor2);\n" " for (size_t cur_coll = 0; cur_coll < num_collected; ++cur_coll) {\n" " p_buf.put_s(strlen(collected_ns[cur_coll]), (cbyte*)collected_ns[cur_coll]);\n" " Free(collected_ns[cur_coll]);\n" @@ -1273,7 +1273,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) " size_t num_collected = 0;\n" " char **collected_ns = NULL;\n" " boolean def_ns = FALSE;\n" - " collected_ns = collect_ns(p_td, num_collected, def_ns);\n" + " collected_ns = collect_ns(p_td, num_collected, def_ns, p_flavor2);\n" " for (size_t cur_coll = 0; cur_coll < num_collected; ++cur_coll) {\n" " p_buf.put_s(strlen(collected_ns[cur_coll]), (cbyte*)collected_ns[cur_coll]);\n" " Free(collected_ns[cur_coll]);\n" @@ -2553,16 +2553,16 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ); src = mputprintf(src, - "char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int) const {\n" + "char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int flavor) const {\n" " size_t num_collected;\n" - " char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns);\n" + " char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns, flavor);\n" /* The above may throw but then nothing was allocated. */ " if (n_elements!=-1) try {\n" " char **new_ns;\n" " size_t num_new;\n" " for (int i = 0; i < n_elements; ++i) {\n" " boolean def_ns_1 = FALSE;\n" - " new_ns = value_elements[i].collect_ns(*p_td.oftype_descr, num_new, def_ns_1);\n" + " new_ns = value_elements[i].collect_ns(*p_td.oftype_descr, num_new, def_ns_1, flavor);\n" " merge_ns(collected_ns, num_collected, new_ns, num_new);\n" " def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */ " }\n" @@ -2618,7 +2618,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct " size_t num_collected = 0;\n" " char **collected_ns = NULL;\n" " boolean def_ns = FALSE;\n" - " collected_ns = collect_ns(p_td, num_collected, def_ns);\n" + " collected_ns = collect_ns(p_td, num_collected, def_ns, p_flavor2);\n" " for (size_t cur_coll = 0; cur_coll < num_collected; ++cur_coll) {\n" " p_buf.put_s(strlen(collected_ns[cur_coll]), (cbyte*)collected_ns[cur_coll]);\n" " Free(collected_ns[cur_coll]);\n" @@ -2736,7 +2736,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct " size_t num_collected = 0;\n" " char **collected_ns = NULL;\n" " boolean def_ns = FALSE;\n" - " collected_ns = collect_ns(p_td, num_collected, def_ns);\n" + " collected_ns = collect_ns(p_td, num_collected, def_ns, p_flavor2);\n" " for (size_t cur_coll = 0; cur_coll < num_collected; ++cur_coll) {\n" " p_buf.put_s(strlen(collected_ns[cur_coll]), (cbyte*)collected_ns[cur_coll]);\n" " Free(collected_ns[cur_coll]);\n" diff --git a/core/Optional.hh b/core/Optional.hh index e3b35f052898b48504b933662e1289b44a04181c..b964f91741152814fd35c52b14d6acbfa8ac2d7a 100644 --- a/core/Optional.hh +++ b/core/Optional.hh @@ -1129,14 +1129,14 @@ finished: } template<typename T_type> -char ** OPTIONAL<T_type>::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int /*flavor*/) const { +char ** OPTIONAL<T_type>::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int flavor) const { #ifdef TITAN_RUNTIME_2 switch (get_selection()) { #else switch (optional_selection) { #endif case OPTIONAL_PRESENT: - return optional_value->collect_ns(p_td, num, def_ns); + return optional_value->collect_ns(p_td, num, def_ns, flavor); case OPTIONAL_OMIT: def_ns = FALSE; num = 0; diff --git a/core2/Basetype2.cc b/core2/Basetype2.cc index d82e04657b86d687ac2edf95374ceeb0a501259c..ad572542af51a6c082350ce3f22ad82cba377a87 100644 --- a/core2/Basetype2.cc +++ b/core2/Basetype2.cc @@ -1775,12 +1775,12 @@ void Record_Of_Type::decode(const TTCN_Typedescriptor_t& p_td, va_end(pvar); } -char **Record_Of_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int /*flavor*/) const +char **Record_Of_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int flavor) const { size_t num_collected = 0; // First, our own namespace. Sets num_collected to 0 or 1. // If it throws, nothing was allocated. - char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns); + char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns, flavor); // Then the embedded type try { @@ -1788,7 +1788,7 @@ char **Record_Of_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool if (val_ptr) for (int i = 0; i < get_nof_elements(); ++i) { size_t num_new = 0; char **new_namespaces = get_at(i)->collect_ns( - *p_td.oftype_descr, num_new, def_ns_1); + *p_td.oftype_descr, num_new, def_ns_1, flavor); merge_ns(collected_ns, num_collected, new_namespaces, num_new); def_ns = def_ns || def_ns_1; // alas, no ||= } @@ -4057,7 +4057,7 @@ const XERdescriptor_t* Record_Type::xer_descr(int /*field_index*/) const return NULL; } -char ** Record_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int /*flavor*/) const +char ** Record_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int flavor) const { const int field_cnt = get_count(); // The USE-ORDER member is first, unless preempted by EMBED-VALUES @@ -4068,7 +4068,7 @@ char ** Record_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& size_t num_collected = 0; // First, our own namespace. Sets num_collected to 0 or 1. // If it throws, nothing was allocated. - char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns); + char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns, flavor); try{ // If the nil attribute will be written, add the control namespace @@ -4088,7 +4088,7 @@ char ** Record_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& for (int a = start_at; a < field_cnt; ++a) { size_t num_new = 0; boolean def_ns_1 = FALSE; - char **new_namespaces = get_at(a)->collect_ns(*xer_descr(a), num_new, def_ns_1); + char **new_namespaces = get_at(a)->collect_ns(*xer_descr(a), num_new, def_ns_1, flavor); merge_ns(collected_ns, num_collected, new_namespaces, num_new); def_ns = def_ns || def_ns_1; // merge_ns freed new_namespaces @@ -4165,14 +4165,14 @@ int Record_Type::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf, boolean def_ns = FALSE; if (exer) { if (indent == 0) { // top-level type - collected_ns = collect_ns(p_td, num_collected, def_ns); + collected_ns = collect_ns(p_td, num_collected, def_ns, flavor2); } else if ((flavor & DEF_NS_SQUASHED) && p_td.my_module && p_td.ns_index != -1) { const namespace_t * ns = p_td.my_module->get_ns((size_t)p_td.ns_index); // The default namespace has been squashed. // If we are in the default namespace, restore it. if (*ns->px == '\0') { - collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns); + collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns, flavor2); } } } @@ -4609,14 +4609,14 @@ int Record_Type::XER_encode_negtest(const Erroneous_descriptor_t* p_err_descr, boolean def_ns = FALSE; if (exer) { if (indent == 0) { // top-level type - collected_ns = collect_ns(p_td, num_collected, def_ns); + collected_ns = collect_ns(p_td, num_collected, def_ns, flavor2); } else if ((flavor & DEF_NS_SQUASHED) && p_td.my_module && p_td.ns_index != -1) { const namespace_t * ns = p_td.my_module->get_ns((size_t)p_td.ns_index); // The default namespace has been squashed. // If we are in the default namespace, restore it. if (*ns->px == '\0') { - collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns); + collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns, flavor2); } } } @@ -5319,15 +5319,12 @@ int Record_Type::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, break; } // type has USE-NIL - if (parent_tag) { const char *prefix = (const char*)reader.Prefix(); - // prefix may be NULL, control_ns->px is never NULL or empty - if (prefix && !strcmp(prefix, control_ns->px) - && !strcmp((const char*)reader.LocalName(), "type")) { + // prefix may be NULL + if (prefix && !strcmp((const char*)reader.LocalName(), "type")) { continue; // xsi:type has been processed by the parent } - } - + if (aa_index >= 0) { ec_1.set_msg("%s': ", fld_name(aa_index)); TTCN_EncDec_ErrorContext ec_2("Attribute %d: ", num_aa);