Commit 8ecd6580 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

XER dec: changed 'anyElement' fix in record of record (bug 539956)



Change-Id: Ie5e57b155fa05e628f53c2ddcb8ed3714289bbe5
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 468b295f
......@@ -1961,6 +1961,17 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
/* The last component with which it can begin is the first non-optional.
* Does that sentence makes sense to you ? */
}
for (i = 0; i < sdef->nElements; i++) {
if (strcmp(sdef->elements[i].type, "UNIVERSAL_CHARSTRING") == 0 &&
!sdef->elements[i].xerAttribute) {
src = mputprintf(src,
" else if (%s_xer_.xer_bits & ANY_ELEMENT) return TRUE;\n"
, sdef->elements[i].typegen);
}
if (!sdef->elements[i].isOptional && !sdef->elements[i].xerAttribute) {
break;
}
}
src = mputstr(src, " return FALSE;\n}\n\n");
/* * * * * * * * * * XER_encode * * * * * * * * * * * * * * */
......@@ -7731,6 +7742,20 @@ check_generate_end:
src = mputprintf(src,
" else if (%s::can_start(p_name, p_uri, %s_xer_, p_flavor, p_flavor2)) return TRUE;\n"
, sdef->elements[i].type, sdef->elements[i].typegen);
if (!sdef->elements[i].isOptional) {
break;
}
}
for (i = 0; i < sdef->nElements; i++) {
if (strcmp(sdef->elements[i].type, "UNIVERSAL_CHARSTRING") == 0 &&
!sdef->elements[i].xerAttribute) {
src = mputprintf(src,
" else if (%s_xer_.xer_bits & ANY_ELEMENT) return TRUE;\n"
, sdef->elements[i].typegen);
}
if (!sdef->elements[i].isOptional && !sdef->elements[i].xerAttribute) {
break;
}
}
src = mputstr(src,
" return FALSE;\n"
......
......@@ -891,15 +891,6 @@ void UNIVERSAL_CHARSTRING::dump() const
}
}
boolean UNIVERSAL_CHARSTRING::can_start(const char *name, const char *uri,
XERdescriptor_t const& xd, unsigned int flavor, unsigned int flavor2)
{
if (is_exer(flavor) && (xd.xer_bits & ANY_ELEMENT)) {
return TRUE;
}
return Base_Type::can_start(name, uri, xd, flavor, flavor2);
}
void UNIVERSAL_CHARSTRING::log() const
{
if (charstring) {
......
......@@ -271,9 +271,6 @@ public:
CHARSTRING get_stringRepr_for_pattern() const;
void dump() const;
static boolean can_start(const char *name, const char *uri,
XERdescriptor_t const& xd, unsigned int flavor, unsigned int flavor2);
private:
// convert this string to character string for pattern matching: ([A-P]{8})*
......
......@@ -5820,15 +5820,21 @@ int Record_Type::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
else {
// In case the field is an optional anyElement -> check if it should be omitted
boolean optional_any_elem_check = TRUE;
if (get_at(i)->is_optional() && (xer_descr(i)->xer_bits & ANY_ELEMENT)) {
// The "anyElement" coding instruction can only be applied to a universal charstring field
OPTIONAL<UNIVERSAL_CHARSTRING>* opt_field = dynamic_cast<OPTIONAL<UNIVERSAL_CHARSTRING>*>(get_at(i));
if (opt_field) {
const char* next_field_name = NULL;
if (i < field_cnt - 1) {
next_field_name = fld_name(i + 1);
if (xer_descr(i)->xer_bits & ANY_ELEMENT) {
if (get_at(i)->is_optional()) {
// The "anyElement" coding instruction can only be applied to a universal charstring field
OPTIONAL<UNIVERSAL_CHARSTRING>* opt_field = dynamic_cast<OPTIONAL<UNIVERSAL_CHARSTRING>*>(get_at(i));
if (opt_field) {
const char* next_field_name = NULL;
if (i < field_cnt - 1) {
next_field_name = fld_name(i + 1);
}
optional_any_elem_check = opt_field->XER_check_any_elem(reader, next_field_name, tag_closed);
}
optional_any_elem_check = opt_field->XER_check_any_elem(reader, next_field_name, tag_closed);
}
else if (tag_closed) {
// If the record is emptyElement, there's no way it will have an anyElement field
reader.Read();
}
}
if (optional_any_elem_check && !already_processed) {
......
......@@ -166,5 +166,5 @@ RUN :=
endif
run: $(TARGET) run.cfg
if $(RUN) ./$^; then ./indent.pl neg.log; else ./indent.pl neg.log; exit 1; fi
$(RUN) ./$^
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