Commit f78bd1dd authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

XER: RT2 fixes



Change-Id: Iadc6731e6af081e3f18af8b22047f4212f81185c
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent 727ab6e0
...@@ -1846,9 +1846,9 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc) ...@@ -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"); "char **collect_ns(const XERdescriptor_t& p_td, size_t& num_ns, bool& def_ns, unsigned int flavor = 0) const;\n");
src = mputprintf(src, 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" " 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. */ /* The above might throw but then nothing was allocated. */
, name); , name);
...@@ -1860,7 +1860,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc) ...@@ -1860,7 +1860,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
" boolean def_ns_1 = FALSE;\n"); " boolean def_ns_1 = FALSE;\n");
for (i = start_at; i < sdef->nElements; ++i) { for (i = start_at; i < sdef->nElements; ++i) {
src = mputprintf(src, 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" " merge_ns(collected_ns, num_collected, new_ns, num_new);\n"
" def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */ " def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */
, sdef->elements[i].name, sdef->elements[i].typegen , sdef->elements[i].name, sdef->elements[i].typegen
...@@ -1939,12 +1939,12 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc) ...@@ -1939,12 +1939,12 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
" boolean def_ns = FALSE;\n" " boolean def_ns = FALSE;\n"
" if (e_xer) {\n" " if (e_xer) {\n"
" if (p_indent == 0) {\n" /* top-level */ " 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" " }\n"
" else if ((p_flavor & DEF_NS_SQUASHED) && p_td.my_module && p_td.ns_index != -1){\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" " const namespace_t * ns = p_td.my_module->get_ns((size_t)p_td.ns_index);\n"
" if (*ns->px == '\\0') {\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" " }\n"
" }\n" " }\n"
......
...@@ -1085,16 +1085,16 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1085,16 +1085,16 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
); );
src = mputprintf(src, 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" " 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. */ /* The above may throw but then nothing was allocated. */
" if (val_ptr) try {\n" " if (val_ptr) try {\n"
" char **new_ns;\n" " char **new_ns;\n"
" size_t num_new;\n" " size_t num_new;\n"
" for (int i = 0; i < val_ptr->n_elements; ++i) {\n" " for (int i = 0; i < val_ptr->n_elements; ++i) {\n"
" boolean def_ns_1 = FALSE;\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" " merge_ns(collected_ns, num_collected, new_ns, num_new);\n"
" def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */ " def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */
" }\n" " }\n"
...@@ -1150,7 +1150,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1150,7 +1150,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" size_t num_collected = 0;\n" " size_t num_collected = 0;\n"
" char **collected_ns = NULL;\n" " char **collected_ns = NULL;\n"
" boolean def_ns = FALSE;\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" " 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" " p_buf.put_s(strlen(collected_ns[cur_coll]), (cbyte*)collected_ns[cur_coll]);\n"
" Free(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) ...@@ -1273,7 +1273,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" size_t num_collected = 0;\n" " size_t num_collected = 0;\n"
" char **collected_ns = NULL;\n" " char **collected_ns = NULL;\n"
" boolean def_ns = FALSE;\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" " 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" " p_buf.put_s(strlen(collected_ns[cur_coll]), (cbyte*)collected_ns[cur_coll]);\n"
" Free(collected_ns[cur_coll]);\n" " Free(collected_ns[cur_coll]);\n"
...@@ -2553,16 +2553,16 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -2553,16 +2553,16 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
); );
src = mputprintf(src, 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" " 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. */ /* The above may throw but then nothing was allocated. */
" if (n_elements!=-1) try {\n" " if (n_elements!=-1) try {\n"
" char **new_ns;\n" " char **new_ns;\n"
" size_t num_new;\n" " size_t num_new;\n"
" for (int i = 0; i < n_elements; ++i) {\n" " for (int i = 0; i < n_elements; ++i) {\n"
" boolean def_ns_1 = FALSE;\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" " merge_ns(collected_ns, num_collected, new_ns, num_new);\n"
" def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */ " def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */
" }\n" " }\n"
...@@ -2618,7 +2618,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -2618,7 +2618,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" size_t num_collected = 0;\n" " size_t num_collected = 0;\n"
" char **collected_ns = NULL;\n" " char **collected_ns = NULL;\n"
" boolean def_ns = FALSE;\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" " 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" " p_buf.put_s(strlen(collected_ns[cur_coll]), (cbyte*)collected_ns[cur_coll]);\n"
" Free(collected_ns[cur_coll]);\n" " Free(collected_ns[cur_coll]);\n"
...@@ -2736,7 +2736,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -2736,7 +2736,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" size_t num_collected = 0;\n" " size_t num_collected = 0;\n"
" char **collected_ns = NULL;\n" " char **collected_ns = NULL;\n"
" boolean def_ns = FALSE;\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" " 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" " p_buf.put_s(strlen(collected_ns[cur_coll]), (cbyte*)collected_ns[cur_coll]);\n"
" Free(collected_ns[cur_coll]);\n" " Free(collected_ns[cur_coll]);\n"
......
...@@ -1129,14 +1129,14 @@ finished: ...@@ -1129,14 +1129,14 @@ finished:
} }
template<typename T_type> 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 #ifdef TITAN_RUNTIME_2
switch (get_selection()) { switch (get_selection()) {
#else #else
switch (optional_selection) { switch (optional_selection) {
#endif #endif
case OPTIONAL_PRESENT: 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: case OPTIONAL_OMIT:
def_ns = FALSE; def_ns = FALSE;
num = 0; num = 0;
......
...@@ -1775,12 +1775,12 @@ void Record_Of_Type::decode(const TTCN_Typedescriptor_t& p_td, ...@@ -1775,12 +1775,12 @@ void Record_Of_Type::decode(const TTCN_Typedescriptor_t& p_td,
va_end(pvar); 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; size_t num_collected = 0;
// First, our own namespace. Sets num_collected to 0 or 1. // First, our own namespace. Sets num_collected to 0 or 1.
// If it throws, nothing was allocated. // 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 // Then the embedded type
try { try {
...@@ -1788,7 +1788,7 @@ char **Record_Of_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool ...@@ -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) { if (val_ptr) for (int i = 0; i < get_nof_elements(); ++i) {
size_t num_new = 0; size_t num_new = 0;
char **new_namespaces = get_at(i)->collect_ns( 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); merge_ns(collected_ns, num_collected, new_namespaces, num_new);
def_ns = def_ns || def_ns_1; // alas, no ||= def_ns = def_ns || def_ns_1; // alas, no ||=
} }
...@@ -4057,7 +4057,7 @@ const XERdescriptor_t* Record_Type::xer_descr(int /*field_index*/) const ...@@ -4057,7 +4057,7 @@ const XERdescriptor_t* Record_Type::xer_descr(int /*field_index*/) const
return NULL; 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(); const int field_cnt = get_count();
// The USE-ORDER member is first, unless preempted by EMBED-VALUES // 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& ...@@ -4068,7 +4068,7 @@ char ** Record_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool&
size_t num_collected = 0; size_t num_collected = 0;
// First, our own namespace. Sets num_collected to 0 or 1. // First, our own namespace. Sets num_collected to 0 or 1.
// If it throws, nothing was allocated. // 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{ try{
// If the nil attribute will be written, add the control namespace // 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& ...@@ -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) { for (int a = start_at; a < field_cnt; ++a) {
size_t num_new = 0; size_t num_new = 0;
boolean def_ns_1 = FALSE; 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); merge_ns(collected_ns, num_collected, new_namespaces, num_new);
def_ns = def_ns || def_ns_1; def_ns = def_ns || def_ns_1;
// merge_ns freed new_namespaces // merge_ns freed new_namespaces
...@@ -4165,14 +4165,14 @@ int Record_Type::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf, ...@@ -4165,14 +4165,14 @@ int Record_Type::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
boolean def_ns = FALSE; boolean def_ns = FALSE;
if (exer) { if (exer) {
if (indent == 0) { // top-level type 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) { 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); const namespace_t * ns = p_td.my_module->get_ns((size_t)p_td.ns_index);
// The default namespace has been squashed. // The default namespace has been squashed.
// If we are in the default namespace, restore it. // If we are in the default namespace, restore it.
if (*ns->px == '\0') { 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, ...@@ -4609,14 +4609,14 @@ int Record_Type::XER_encode_negtest(const Erroneous_descriptor_t* p_err_descr,
boolean def_ns = FALSE; boolean def_ns = FALSE;
if (exer) { if (exer) {
if (indent == 0) { // top-level type 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) { 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); const namespace_t * ns = p_td.my_module->get_ns((size_t)p_td.ns_index);
// The default namespace has been squashed. // The default namespace has been squashed.
// If we are in the default namespace, restore it. // If we are in the default namespace, restore it.
if (*ns->px == '\0') { 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, ...@@ -5319,15 +5319,12 @@ int Record_Type::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
break; break;
} // type has USE-NIL } // type has USE-NIL
if (parent_tag) {
const char *prefix = (const char*)reader.Prefix(); const char *prefix = (const char*)reader.Prefix();
// prefix may be NULL, control_ns->px is never NULL or empty // prefix may be NULL
if (prefix && !strcmp(prefix, control_ns->px) if (prefix && !strcmp((const char*)reader.LocalName(), "type")) {
&& !strcmp((const char*)reader.LocalName(), "type")) {
continue; // xsi:type has been processed by the parent continue; // xsi:type has been processed by the parent
} }
}
if (aa_index >= 0) { if (aa_index >= 0) {
ec_1.set_msg("%s': ", fld_name(aa_index)); ec_1.set_msg("%s': ", fld_name(aa_index));
TTCN_EncDec_ErrorContext ec_2("Attribute %d: ", num_aa); TTCN_EncDec_ErrorContext ec_2("Attribute %d: ", num_aa);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment