Commit 48006c2f authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

XER: XER attributes now inherited when used in a self recursive type (Bug 526507)



Change-Id: Ic53e58db83dd7e5d545b600dc09a922f4efadd8e
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent aeb2e5bb
......@@ -590,6 +590,7 @@ namespace Common {
raw_parsed = false;
raw_checked = false;
xer_checked = false;
variants_checked = false;
raw_length_calculated = false;
has_opentypes = false;
opentype_outermost = false;
......
......@@ -343,6 +343,7 @@ namespace Common {
bool raw_parsed;
bool raw_checked;
bool xer_checked;
bool variants_checked;
bool raw_length_calculated;
bool has_opentypes;
bool opentype_outermost;
......
......@@ -211,7 +211,7 @@ void Type::chk()
* components.
*/
if (!parent_type) chk_table_constraints();
if (legacy_codec_handling) {
chk_coding_attribs();
}
......@@ -227,6 +227,9 @@ void Type::chk()
void Type::chk_coding_attribs()
{
if (!legacy_codec_handling && !variants_checked) {
return;
}
if (typetype == T_SEQ_T || typetype == T_SET_T || typetype == T_CHOICE_T) {
// If this record/set/union type has no attributes but one of its fields does,
// create an empty attribute structure.
......@@ -262,28 +265,39 @@ void Type::chk_coding_attribs()
chk_xer();
if (!legacy_codec_handling) {
switch (typetype) {
case T_SEQ_T:
case T_SEQ_A:
case T_SET_T:
case T_SET_A:
case T_CHOICE_T:
case T_CHOICE_A:
case T_ANYTYPE:
case T_OPENTYPE:
for (size_t i = 0; i < get_nof_comps(); ++i) {
get_comp_byIndex(i)->get_type()->chk_coding_attribs();
}
break;
if (RecursionTracker::is_happening(this)) {
return;
}
RecursionTracker tracker(this);
if (is_ref()) {
get_type_refd()->chk_coding_attribs();
}
else {
switch (typetype) {
case T_SEQ_T:
case T_SEQ_A:
case T_SET_T:
case T_SET_A:
case T_CHOICE_T:
case T_CHOICE_A:
case T_ANYTYPE:
case T_OPENTYPE:
for (size_t i = 0; i < get_nof_comps(); ++i) {
get_comp_byIndex(i)->get_type()->chk_coding_attribs();
}
break;
case T_ARRAY:
case T_SEQOF:
case T_SETOF:
get_ofType()->chk_coding_attribs();
break;
case T_ARRAY:
case T_SEQOF:
case T_SETOF:
get_ofType()->chk_coding_attribs();
break;
default:
break;
default:
break;
}
}
}
}
......@@ -873,6 +887,7 @@ void Type::chk_variants()
if (legacy_codec_handling) {
FATAL_ERROR("Type::chk_encodings");
}
variants_checked = true;
if (is_asn1() || ownertype != OT_TYPE_DEF) {
return;
}
......@@ -2578,14 +2593,17 @@ void Type::chk_xer() { // XERSTUFF semantic check
||ownertype==OT_COMP_FIELD
||ownertype==OT_RECORD_OF) {
if (is_ref()) {
// Merge XER attributes from the referenced type.
// This implements X.693amd1 clause 15.1.2
XerAttributes * newx = new XerAttributes;
Type *t1 = get_type_refd();
// chk_refd() (called by chk() for T_REFD) does not check
// the referenced type; do it now. This makes it fully recursive.
t1->chk();
if (!legacy_codec_handling && !t1->xer_checked) {
xer_checked = false;
return;
}
// Merge XER attributes from the referenced type.
// This implements X.693amd1 clause 15.1.2
XerAttributes * newx = new XerAttributes;
size_t old_text = 0;
if (t1->xerattrib && !t1->xerattrib->empty()) {
old_text = t1->xerattrib->num_text_;
......
......@@ -314,6 +314,66 @@ testcase decode_emb_array_opt2() runs on EMB
CHECK_DECODE(exer_dec_emb_outer3, str_emb_array_w_holes, Outer3, c_emb_array_w_holes3);
}
type record Item
{
record of universal charstring embed_values,
Rule_expansion rule_expansion,
integer i
}
with {
variant "embedValues";
};
type union Rule_expansion
{
One_of one_of
}
type record One_of
{
record of record {
Item item
} sequence_list
}
DECLARE_EXER_ENCODERS(One_of, oneof);
const One_of c_emb_oneof :=
{
sequence_list := {
{
item := {
embed_values := {"","",""},
rule_expansion := {
one_of := {sequence_list := {}}
},
i := 3
}
}
}
}
const universal charstring str_emb_oneof :=
"<One_of>\n"&
"\t<sequence_list>\n"&
"\t\t<SEQUENCE>\n"&
"<item><rule_expansion><one_of><sequence_list/></one_of></rule_expansion><i>3</i></item>"&
"\t\t</SEQUENCE>\n"&
"\t</sequence_list>\n"&
"</One_of>\n\n";
testcase encode_emb_oneof() runs on EMB
{
CHECK_METHOD(exer_enc_oneof, c_emb_oneof, str_emb_oneof);
}
testcase decode_emb_oneof() runs on EMB
{
CHECK_DECODE(exer_dec_oneof, str_emb_oneof, One_of, c_emb_oneof);
}
control {
execute(encode_emb());
execute(decode_emb());
......@@ -327,6 +387,8 @@ control {
execute(decode_emb_array_opt());
execute(encode_emb_array_opt2());
execute(decode_emb_array_opt2());
execute(encode_emb_oneof());
execute(decode_emb_oneof());
}
}
......
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