Commit ab0736ad authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

OER coding fixes



Change-Id: I52fff0a33732784caf38e86115e515181e303e5d
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent 012d72e5
...@@ -3084,14 +3084,8 @@ void Type::chk_oer() { ...@@ -3084,14 +3084,8 @@ void Type::chk_oer() {
if (t->get_sub_type()) { if (t->get_sub_type()) {
oerattrib->extendable = t->get_sub_type()->is_extendable(); oerattrib->extendable = t->get_sub_type()->is_extendable();
} }
for (size_t i = 0; i < t->get_nof_comps(); i++) {
t->get_comp_byIndex(i)->get_type()->chk();
}
break; } break; }
case T_SEQOF: { case T_SEQOF:
t->get_ofType()->chk();
break;
}
case T_BOOL: case T_BOOL:
case T_ENUM_A: case T_ENUM_A:
case T_UTF8STRING: case T_UTF8STRING:
......
...@@ -4746,7 +4746,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output) ...@@ -4746,7 +4746,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
, sdef->elements[i].typedescrname); , sdef->elements[i].typedescrname);
} }
} }
if (sdef->has_opentypes) { if (sdef->opentype_outermost) {
src = mputstr(src, src = mputstr(src,
" TTCN_EncDec_ErrorContext ec_1(\"While decoding opentypes: \");" " TTCN_EncDec_ErrorContext ec_1(\"While decoding opentypes: \");"
" TTCN_Type_list p_typelist;\n" " TTCN_Type_list p_typelist;\n"
......
...@@ -1680,9 +1680,9 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1680,9 +1680,9 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" p_typelist.push(this);\n" " p_typelist.push(this);\n"
" TTCN_EncDec_ErrorContext ec_0(\"Component #\");\n" " TTCN_EncDec_ErrorContext ec_0(\"Component #\");\n"
" TTCN_EncDec_ErrorContext ec_1;\n" " TTCN_EncDec_ErrorContext ec_1;\n"
" for(int elem_i=0; elem_i<n_elements; elem_i++) {\n" " for(int elem_i=0; elem_i<val_ptr->n_elements; elem_i++) {\n"
" ec_1.set_msg(\"%%d: \", elem_i);\n" " ec_1.set_msg(\"%%d: \", elem_i);\n"
" value_elements[elem_i].OER_decode_opentypes(p_typelist," " (*this)[elem_i].OER_decode_opentypes(p_typelist,"
" p_buf, p_oer);\n" " p_buf, p_oer);\n"
" }\n" " }\n"
" p_typelist.pop();\n" " p_typelist.pop();\n"
......
...@@ -397,7 +397,7 @@ public: ...@@ -397,7 +397,7 @@ public:
virtual int encode_raw(TTCN_Buffer& p_buf) const; virtual int encode_raw(TTCN_Buffer& p_buf) const;
virtual int RAW_encode_negtest_raw(RAW_enc_tree& p_myleaf) const; virtual int RAW_encode_negtest_raw(RAW_enc_tree& p_myleaf) const;
virtual int JSON_encode_negtest_raw(JSON_Tokenizer&) const; virtual int JSON_encode_negtest_raw(JSON_Tokenizer&) const;
virtual int OER_encode_negtest_raw(JSON_Tokenizer&) const; //TODO virtual int OER_encode_negtest_raw(TTCN_Buffer&) const; //TODO
#endif #endif
/** Examines whether this message corresponds the tags in the /** Examines whether this message corresponds the tags in the
......
...@@ -22,7 +22,7 @@ void encode_oer_length(size_t num_bytes, TTCN_Buffer& buf, boolean seof) { ...@@ -22,7 +22,7 @@ void encode_oer_length(size_t num_bytes, TTCN_Buffer& buf, boolean seof) {
buf.put_c(num_bytes); buf.put_c(num_bytes);
} else { } else {
size_t bytes = num_bytes; size_t bytes = num_bytes;
// Encode length in maybe more than 1 bytes // Encode length in maybe more than 1 byte
size_t needed_bytes = 0; size_t needed_bytes = 0;
while (bytes != 0) { while (bytes != 0) {
bytes >>= 8; bytes >>= 8;
......
...@@ -197,7 +197,7 @@ int Base_Type::JSON_encode_negtest_raw(JSON_Tokenizer&) const ...@@ -197,7 +197,7 @@ int Base_Type::JSON_encode_negtest_raw(JSON_Tokenizer&) const
return 0; return 0;
} }
int Base_Type::OER_encode_negtest_raw(JSON_Tokenizer&) const int Base_Type::OER_encode_negtest_raw(TTCN_Buffer&) const
{ {
TTCN_error("A value of type %s cannot be used as erroneous raw value for OER encoding.", TTCN_error("A value of type %s cannot be used as erroneous raw value for OER encoding.",
get_descriptor()->name); get_descriptor()->name);
......
...@@ -2753,6 +2753,12 @@ ...@@ -2753,6 +2753,12 @@
with { extension "prototype (convert) encode(OER)" } with { extension "prototype (convert) encode(OER)" }
external function dec_Item(in octetstring stream) return Item external function dec_Item(in octetstring stream) return Item
with { extension "prototype (convert) decode(OER)" }
external function enc_ErrorReturn(in ErrorReturn pdu) return octetstring
with { extension "prototype (convert) encode(OER)" }
external function dec_ErrorReturn(in octetstring stream) return ErrorReturn
with { extension "prototype (convert) decode(OER)" } with { extension "prototype (convert) decode(OER)" }
testcase tc_opentype() runs on EmptyCT { testcase tc_opentype() runs on EmptyCT {
...@@ -2775,6 +2781,33 @@ ...@@ -2775,6 +2781,33 @@
setverdict(fail, "tc_opentype: ", match(pf, pfres)); setverdict(fail, "tc_opentype: ", match(pf, pfres));
} }
var ErrorReturn er, erres;
er := {
errorCategory := "A",
errors := {
{
errorCode := 1,
errorInfo := {errorSet_1_Type := 365}
},
{
errorCode := 2,
errorInfo := {errorSet_2_Type := "If U can decode this, U can be happy. Smile! :-)"}
}
}
}
os := enc_ErrorReturn(er);
if (os != 'C041010201010302016D01023130496620552063616E206465636F646520746869732C20552063616E2062652068617070792E20536D696C6521203A2D29'O) {
setverdict(fail, "tc_opentype: ", match('C041010201010302016D01023130496620552063616E206465636F646520746869732C20552063616E2062652068617070792E20536D696C6521203A2D29'O, os));
}
erres := dec_ErrorReturn(os);
if (er != erres) {
setverdict(fail, "tc_opentype: ", match(er, erres));
}
setverdict(pass); setverdict(pass);
} }
......
...@@ -371,4 +371,39 @@ dateOfBirth "19571111"}, ...@@ -371,4 +371,39 @@ dateOfBirth "19571111"},
dateOfBirth "19590717"}}} dateOfBirth "19590717"}}}
ERROR-CLASS ::= CLASS
{
&category PrintableString(SIZE(1)),
&code INTEGER,
&Type DEFAULT INTEGER
}
WITH SYNTAX {&category &code [&Type]}
ErrorSet ERROR-CLASS ::=
{
{"A" 1 [1] INTEGER} |
{"A" 2 [1] VisibleString} |
{"B" 1 [1] PrintableString} |
{"B" 2 [1] BOOLEAN} |
oneErrorObject
}
oneErrorObject ERROR-CLASS ::= { "C" 3 ENUMERATED{foobar} }
ErrorReturn ::= SEQUENCE
{
errorCategory ERROR-CLASS.&category ({ErrorSet}) OPTIONAL,
errors SEQUENCE OF SEQUENCE
{
errorCode ERROR-CLASS.&code({ErrorSet}{@errorCategory}),
errorInfo [99] ERROR-CLASS.&Type({ErrorSet}{@errorCategory,@.errorCode})
} OPTIONAL
}
END END
\ No newline at end of file
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