Commit 0118409e authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Implemented RAW coding instruction 'FORCEOMIT' (bug 537389)



Change-Id: I686082cdc4914dd301bb39ee83233da00d28acfd
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent d6a11d06
......@@ -2487,6 +2487,33 @@ namespace Common {
}
}
}
for (int j = 0; j < rawpar->forceomit.nElements; ++j) { // FORCEOMIT
Type* t = field_type_last;
bool erroneous = false;
for (int k = 0; k < rawpar->forceomit.lists[j]->nElements; ++k) {
Identifier* idf = rawpar->forceomit.lists[j]->names[k];
t = t->get_type_refd_last();
if (!t->is_secho()) {
error("Invalid field type in RAW parameter FORCEOMIT for "
"field %s.", field_id.get_dispname().c_str());
erroneous = true;
break;
}
if (!t->has_comp_withName(*idf)) {
error("Invalid field name '%s' in RAW parameter FORCEOMIT for "
"field %s",
rawpar->forceomit.lists[j]->names[k]->get_dispname().c_str(),
field_id.get_dispname().c_str());
erroneous = true;
break;
}
t = t->get_comp_byName(*idf)->get_type();
}
if (!erroneous && !t->is_optional_field()) {
error("RAW parameter FORCEOMIT for field %s does not refer to an "
"optional field.", field_id.get_dispname().c_str());
}
}
for(int c=0;c<rawpar->crosstaglist.nElements;c++) { // CROSSTAG
Identifier *idf=rawpar->crosstaglist.tag[c].fieldName;
if(!field_type_last->is_secho()){
......
......@@ -751,9 +751,41 @@ void Type::generate_code_rawdescriptor(output_struct *target)
->add_padding_pattern(string(rawattrib->padding_pattern)).c_str());
else str = mputstr(str, "NULL,");
str = mputprintf(str, "%d,", rawattrib->length_restrition);
str = mputprintf(str, "CharCoding::%s};\n",
str = mputprintf(str, "CharCoding::%s,",
rawattrib->stringformat == CharCoding::UTF_8 ? "UTF_8" :
(rawattrib->stringformat == CharCoding::UTF16 ? "UTF16" : "UNKNOWN"));
if (rawattrib->forceomit.nElements > 0) {
char* force_omit_str = mprintf("const RAW_Field_List* "
"%s_raw_force_omit_lists[] = {\n ", gennameown_str);
for (int i = 0; i < rawattrib->forceomit.nElements; ++i) {
if (i > 0) {
force_omit_str = mputstr(force_omit_str, ",\n ");
}
Type* t = get_type_refd_last();
for (int j = 0; j < rawattrib->forceomit.lists[i]->nElements; ++j) {
Identifier* name = rawattrib->forceomit.lists[i]->names[j];
force_omit_str = mputprintf(force_omit_str, "new RAW_Field_List(%d, ",
static_cast<int>(t->get_comp_index_byName(*name)));
t = t->get_comp_byName(*name)->get_type()->get_type_refd_last();
}
force_omit_str = mputstr(force_omit_str, "NULL");
for (int j = 0; j < rawattrib->forceomit.lists[i]->nElements; ++j) {
force_omit_str = mputc(force_omit_str, ')');
}
}
force_omit_str = mputprintf(force_omit_str,
"\n};\n"
"const RAW_Force_Omit %s_raw_force_omit(%d, %s_raw_force_omit_lists);\n",
gennameown_str, rawattrib->forceomit.nElements, gennameown_str);
target->source.global_vars = mputstr(target->source.global_vars, force_omit_str);
Free(force_omit_str);
str = mputprintf(str, "&%s_raw_force_omit", gennameown_str);
}
else {
str = mputstr(str, "NULL");
}
str = mputstr(str, "};\n");
target->source.global_vars = mputstr(target->source.global_vars, str);
Free(str);
if (dummy_raw) {
......
......@@ -50,7 +50,8 @@ void def_encdec(const char *p_classname,
"int RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree&) const;\n"
"int RAW_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&,"
" int, raw_order_t, boolean no_err=FALSE,"
"int sel_field=-1, boolean first_call=TRUE);\n"
"int sel_field=-1, boolean first_call=TRUE, "
"const RAW_Force_Omit* force_omit = NULL);\n"
);
if(text)
def=mputprintf(def,
......
......@@ -619,7 +619,8 @@ void defEnumClass(const enum_def *edef, output_struct *output)
}
src = mputprintf(src,
"int %s::RAW_decode(const TTCN_Typedescriptor_t& p_td,TTCN_Buffer& p_buf,"
"int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean)\n"
"int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, "
"const RAW_Force_Omit*)\n"
"{\n"
" int decoded_value = 0;\n"
" int decoded_length = RAW_decode_enum_type(p_td, p_buf, limit, "
......
......@@ -207,7 +207,7 @@ char* generate_raw_coding(char* src,
}
src = mputprintf(src, "int %s::RAW_decode(const TTCN_Typedescriptor_t& "
"p_td, TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, "
"boolean, int, boolean)\n"
"boolean, int, boolean, const RAW_Force_Omit* force_omit)\n"
"{\n"
"int prepaddlength = p_buf.increase_pos_padd(p_td.raw->prepadding);\n"
"limit -= prepaddlength;\n"
......@@ -249,8 +249,12 @@ char* generate_raw_coding(char* src,
}
if (has_fixed && has_variable) break;
}
src = mputprintf(src, "if (field_map[%lu] == 0) {\n",
src = mputprintf(src, "if (field_map[%lu] == 0",
(unsigned long) i);
if (sdef->elements[i].isOptional) {
src = mputprintf(src, " && (force_omit == NULL || !(*force_omit)(%d))", i);
}
src = mputstr(src, ") {\n");
if (flag_needed)
src = mputstr(src, "boolean already_failed = FALSE;\n");
if (has_fixed) {
......@@ -281,16 +285,19 @@ char* generate_raw_coding(char* src,
"p_buf, limit, temporal_top_order, TRUE);\n"
"p_buf.set_pos_bit(fl_start_pos);\n"
"if (temporal_decoded_length > 0 && temporal_%lu == %s) {\n"
"RAW_Force_Omit field_%d_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
"int decoded_field_length = field_%s%s.RAW_decode(%s_descr_, "
"p_buf, limit, local_top_order, TRUE);\n"
"p_buf, limit, local_top_order, TRUE, -1, TRUE, &field_%d_force_omit);\n"
"if (decoded_field_length %s 0 && (",
cur_field_list->fields[cur_field_list->nElements - 1].type,
(unsigned long) j, cur_field_list->start_pos, (unsigned long) j,
cur_field_list->fields[cur_field_list->nElements - 1].typedescr,
(unsigned long) j, cur_field_list->value,
i, i, sdef->elements[i].typedescrname,
sdef->elements[i].name,
sdef->elements[i].isOptional ? "()" : "",
sdef->elements[i].typedescrname,
sdef->elements[i].typedescrname, i,
sdef->elements[i].isOptional ? ">" : ">=");
src = genRawFieldChecker(src, cur_choice, TRUE);
src = mputstr(src, ")) {\n"
......@@ -318,12 +325,16 @@ char* generate_raw_coding(char* src,
* than we have to decode it.
*/
if (flag_needed) src = mputstr(src, "if (!already_failed) {\n");
src = mputprintf(src, "int decoded_field_length = "
src = mputprintf(src,
"RAW_Force_Omit field_%d_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
"int decoded_field_length = "
"field_%s%s.RAW_decode(%s_descr_, p_buf, limit, "
"local_top_order, TRUE);\n"
"local_top_order, TRUE, -1, TRUE, &field_%d_force_omit);\n"
"if (decoded_field_length %s 0 && (",
sdef->elements[i].name, sdef->elements[i].isOptional ? "()" : "",
sdef->elements[i].typedescrname,
i, i, sdef->elements[i].typedescrname,
sdef->elements[i].name, sdef->elements[i].isOptional ? "()" : "",
sdef->elements[i].typedescrname, i,
sdef->elements[i].isOptional ? ">" : ">=");
src = genRawFieldChecker(src, cur_choice, TRUE);
src = mputstr(src, ")) {\n"
......@@ -349,25 +360,40 @@ char* generate_raw_coding(char* src,
if (!raw_options[i].tag_type) {
boolean repeatable;
if (sdef->elements[i].of_type && sdef->elements[i].hasRaw &&
sdef->elements[i].raw.repeatable == XDEFYES) repeatable = TRUE;
sdef->elements[i].raw.repeatable == XDEFYES) {
repeatable = TRUE;
if (sdef->elements[i].isOptional) {
src = mputprintf(src, "if (force_omit == NULL || !(*force_omit)(%d)) ", i);
}
}
else {
repeatable = FALSE;
src = mputprintf(src, "if (field_map[%lu] == 0) ",
(unsigned long) i);
src = mputprintf(src, "if (field_map[%lu] == 0",
(unsigned long) i);
if (sdef->elements[i].isOptional) {
src = mputprintf(src, " && (force_omit == NULL || !(*force_omit)(%d))", i);
}
src = mputstr(src, ") ");
}
src = mputprintf(src, "{\n"
"RAW_Force_Omit field_%d_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
"int decoded_field_length = field_%s%s.RAW_decode(%s_descr_, "
"p_buf, limit, local_top_order, TRUE",
"p_buf, limit, local_top_order, TRUE, -1, ",
i, i, sdef->elements[i].typedescrname,
sdef->elements[i].name, sdef->elements[i].isOptional ? "()" : "",
sdef->elements[i].typedescrname);
if (repeatable)
src = mputprintf(src, ", -1, field_map[%lu] == 0",
src = mputprintf(src, "field_map[%lu] == 0",
(unsigned long) i);
src = mputprintf(src, ");\n"
else {
src = mputstr(src, "TRUE");
}
src = mputprintf(src, ", &field_%d_force_omit);\n"
"if (decoded_field_length %s 0) {\n"
"decoded_length += decoded_field_length;\n"
"limit -= decoded_field_length;\n",
sdef->elements[i].isOptional ? ">" : ">=");
i, sdef->elements[i].isOptional ? ">" : ">=");
if (repeatable) {
if (!sdef->elements[i].isOptional) src = mputprintf(src,
"if (field_map[%lu] == 0) nof_mand_fields++;\n",
......@@ -396,14 +422,21 @@ char* generate_raw_coding(char* src,
/* decoding fields with tag OTHERWISE */
if (raw_options[i].tag_type &&
sdef->raw.taglist.list[raw_options[i].tag_type-1].nElements == 0) {
src = mputprintf(src, "if (field_map[%lu] == 0) {\n"
src = mputprintf(src, "if (field_map[%lu] == 0", (unsigned long) i);
if (sdef->elements[i].isOptional) {
src = mputprintf(src, " && (force_omit == NULL || !(*force_omit)(%d))", i);
}
src = mputprintf(src, ") {\n"
"RAW_Force_Omit field_%d_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
"int decoded_field_length = field_%s%s.RAW_decode(%s_descr_, "
"p_buf, limit, local_top_order, TRUE);\n"
"p_buf, limit, local_top_order, TRUE, -1, TRUE, &field_%d_force_omit);\n"
"if (decoded_field_length %s 0) {\n"
"decoded_length += decoded_field_length;\n"
"limit -= decoded_field_length;\n", (unsigned long) i,
"limit -= decoded_field_length;\n",
i, i, sdef->elements[i].typedescrname,
sdef->elements[i].name, sdef->elements[i].isOptional ? "()" : "",
sdef->elements[i].typedescrname,
sdef->elements[i].typedescrname, i,
sdef->elements[i].isOptional ? ">" : ">=");
if (!sdef->elements[i].isOptional)
src = mputstr(src, "nof_mand_fields++;\n");
......@@ -437,7 +470,7 @@ char* generate_raw_coding(char* src,
src = mputprintf(src,
"int %s::RAW_decode(const TTCN_Typedescriptor_t& p_td, "
"TTCN_Buffer& p_buf, int limit, raw_order_t top_bit_ord, boolean no_err, "
"int, boolean)\n"
"int, boolean, const RAW_Force_Omit* force_omit)\n"
"{ (void)no_err;\n"
" int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);\n"
" limit-=prepaddlength;\n"
......@@ -5335,10 +5368,20 @@ static char *genRawDecodeRecordField(char *src, const struct_def *sdef,
);
}
/* decoding of normal field */
if (sdef->elements[i].isOptional) src = mputstr(src,
" size_t fl_start_pos = p_buf.get_pos_bit();\n");
if (sdef->elements[i].isOptional) {
src = mputprintf(src,
" if (force_omit != NULL && (*force_omit)(%d)) {\n"
" field_%s = OMIT_VALUE;\n"
" }\n"
" else {\n"
" size_t fl_start_pos = p_buf.get_pos_bit();\n",
i, sdef->elements[i].name);
}
src = mputprintf(src,
" RAW_Force_Omit field_%d_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
" decoded_field_length = field_%s%s.RAW_decode(%s_descr_, p_buf, ",
i, i, sdef->elements[i].typedescrname,
sdef->elements[i].name, sdef->elements[i].isOptional ? "()" : "",
sdef->elements[i].typedescrname);
if (delayed_decode) {
......@@ -5352,15 +5395,21 @@ static char *genRawDecodeRecordField(char *src, const struct_def *sdef,
if (sdef->elements[i].hasRaw &&
sdef->elements[i].raw.crosstaglist.nElements > 0)
src = mputstr(src, ", selected_field");
else src = mputstr(src, ", -1");
boolean lengthof_found = FALSE;
for (a = 0; a < raw_options[i].lengthof; a++) {
int field_index = raw_options[i].lengthoffield[a];
/* number of elements in 'record of' or 'set of' */
if (sdef->elements[field_index].raw.unit == -1) {
src = mputprintf(src, ", value_of_length_field%d", field_index);
lengthof_found = TRUE;
break;
}
}
src = mputstr(src, ");\n");
if (!lengthof_found) {
src = mputstr(src, ", TRUE");
}
src = mputprintf(src, ", &field_%d_force_omit);\n", i);
if (delayed_decode) {
src = mputprintf(src, " if (decoded_field_length != %d) return -1;\n",
sdef->elements[i].raw.length);
......@@ -5494,7 +5543,7 @@ static char *genRawDecodeRecordField(char *src, const struct_def *sdef,
}
if(sdef->elements[i].isOptional){
src=mputprintf(src,
" }\n }\n%s"
" }\n }\n }\n%s"
" else field_%s=OMIT_VALUE;\n"
,raw_options[i].tag_type?" }\n":"",sdef->elements[i].name
);
......@@ -6584,7 +6633,8 @@ static void defEmptyRecordClass(const struct_def *sdef,
src = mputprintf(src,
"int %s::RAW_decode(const TTCN_Typedescriptor_t& p_td, "
"TTCN_Buffer& p_buf, int, raw_order_t, boolean, int, boolean)\n"
"TTCN_Buffer& p_buf, int, raw_order_t, boolean, int, boolean, "
"const RAW_Force_Omit*)\n"
"{\n"
"bound_flag = TRUE;\n"
"return p_buf.increase_pos_padd(p_td.raw->prepadding) + "
......@@ -7539,7 +7589,7 @@ check_generate_end:
"virtual int RAW_encode_negtest(const Erroneous_descriptor_t *, const TTCN_Typedescriptor_t&, RAW_enc_tree&) const;\n"
"int RAW_decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, "
"int, raw_order_t, boolean no_err = FALSE, "
"int sel_field = -1, boolean first_call = TRUE);\n");
"int sel_field = -1, boolean first_call = TRUE, const RAW_Force_Omit* force_omit = NULL);\n");
src = generate_raw_coding(src, sdef, raw_options, haspointer,
hascrosstag, has_ext_bit);
} else { /* generate helper functions for the default RAW enc/dec */
......
......@@ -960,7 +960,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
src=mputprintf(src,
"int %s::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, "
"int limit, raw_order_t top_bit_ord, boolean /*no_err*/, int sel_field"
", boolean first_call){\n"
", boolean first_call, const RAW_Force_Omit*){\n"
" int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);\n"
" limit-=prepaddlength;\n"
" int decoded_length=0;\n"
......@@ -2504,7 +2504,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
src=mputprintf(src,
"int %s::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, "
"int limit, raw_order_t top_bit_ord, boolean /*no_err*/, int sel_field"
", boolean first_call){\n"
", boolean first_call, const RAW_Force_Omit*){\n"
" int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);\n"
" limit-=prepaddlength;\n"
" int decoded_length=0;\n"
......
......@@ -62,6 +62,8 @@ RawAST::RawAST(RawAST *other, int default_length){
presence.fieldName=NULL;
presence.nElements=0;
presence.keyList=NULL;
forceomit.nElements = 0;
forceomit.lists = NULL;
topleveleind=other->topleveleind;
toplevel.bitorder=other->toplevel.bitorder;
length_restrition=other->length_restrition;
......@@ -105,6 +107,8 @@ void RawAST::init_rawast(int default_length){
presence.fieldName=NULL;
presence.nElements=0;
presence.keyList=NULL;
forceomit.nElements = 0;
forceomit.lists = NULL;
topleveleind=0;
intx = false;
stringformat = CharCoding::UNKNOWN;
......@@ -121,6 +125,10 @@ RawAST::~RawAST(){
free_rawAST_tag_list(&taglist);
free_rawAST_tag_list(&crosstaglist);
free_rawAST_single_tag(&presence);
for (int i = 0; i < forceomit.nElements; ++i) {
free_rawAST_field_list(forceomit.lists[i]);
}
Free(forceomit.lists);
if(lengthindex!=NULL) {
for(int a=0;a<lengthindex->nElements;a++) delete lengthindex->names[a];
Free(lengthindex->names);
......@@ -160,6 +168,14 @@ void RawAST::print_RawAST(){
}
printf("\n\r");
}
printf("forceomit:\n\r");
for (int i = 0; i < forceomit.nElements; ++i) {
for (int j = 0; j < forceomit.lists[i]->nElements; ++j) {
printf("%s%s", j > 0 ? "." : " ",
forceomit.lists[i]->names[j]->get_name().c_str());
}
printf("\n\r");
}
printf("crosstag:\n\r");
printf(" nElements:%d \n\r",crosstaglist.nElements);
for(int a=0;a<crosstaglist.nElements;a++){
......
......@@ -50,6 +50,11 @@ typedef struct {
Common::Value *v_value;
} rawAST_tag_field_value;
typedef struct {
int nElements;
rawAST_field_list** lists;
} rawAST_force_omit;
typedef struct {
Common::Identifier* fieldName; // NULL == omit
int nElements;
......@@ -115,6 +120,8 @@ public:
multiple tagValues may be specified */
rawAST_single_tag presence; /**< Presence indicator expressions for an
optional field */
rawAST_force_omit forceomit; /**< forces lower level optional fields to
be omitted */
int topleveleind;
rawAST_toplevel toplevel; /**< Toplevel attributes */
int length_restrition;
......
......@@ -289,6 +289,7 @@ LENGTHINDEX { BEGIN(rawcodec); RETURN(XLengthIndexKeyword); }
TAG { BEGIN(rawcodec); RETURN(XTagKeyword); }
CROSSTAG { BEGIN(rawcodec); RETURN(XCrossTagKeyword); }
PRESENCE { BEGIN(rawcodec); RETURN(XPresenceKeyword); }
FORCEOMIT { BEGIN(rawcodec); RETURN(XForceOmitKeyword); }
FIELDLENGTH { BEGIN(rawcodec); RETURN(XFieldLengthKeyword); }
FORMAT { BEGIN(rawcodec); RETURN(XFieldLengthKeyword); }
ALIGN { BEGIN(rawcodec); RETURN(XAlignKeyword); }
......
......@@ -73,6 +73,7 @@ static void yyprint(FILE *file, int type, const YYSTYPE& value);
Common::Value::verdict_t verdictval;
Common::Identifier *identifier;
rawAST_field_list *fieldlist;
rawAST_force_omit forceomit;
rawAST_tag_list taglist;
rawAST_tag_field_value keyid;
rawAST_single_tag singletag;
......@@ -149,6 +150,7 @@ static void yyprint(FILE *file, int type, const YYSTYPE& value);
%token XTagKeyword
%token XCrossTagKeyword
%token XPresenceKeyword
%token XForceOmitKeyword
%token XFieldLengthKeyword
%token XAlignKeyword
%token <enumval> XLeft
......@@ -308,6 +310,9 @@ static void yyprint(FILE *file, int type, const YYSTYPE& value);
%type <fieldlist>
XLengthIndexDef XStructFieldRefOrEmpty XStructFieldRef
%type <forceomit>
XStructFieldRefList
%type <str>
XEncodeToken XmatchDef XAliasToken XJsonValueSegment XJsonValueCore XJsonValue
XJsonAlias
......@@ -382,6 +387,14 @@ XLengthIndexDef
XStructFieldRef
XStructFieldRefOrEmpty
%destructor {
for (int i = 0; i < $$.nElements; ++i) {
free_rawAST_field_list($$.lists[i]);
}
Free($$.lists);
}
XStructFieldRefList
%destructor { free_rawAST_tag_list(&$$); }
XAssocList
......@@ -478,6 +491,8 @@ XSingleEncodingDef : XPaddingDef
{raw_f=true; }
| XPresenceDef
{ raw_f=true;}
| XForceOmitDef
{ raw_f = true; }
| XFieldLengthDef
{ rawstruct->fieldlength = $1*length_multiplier; raw_f=true;}
| XPtrOffsetDef
......@@ -747,6 +762,42 @@ XPresenceDef : XPresenceKeyword '(' XKeyIdList XoptSemiColon ')'
{ free_rawAST_single_tag(&(rawstruct->presence));
link_rawAST_single_tag(&(rawstruct->presence), &$3);};
/* ForceOmit */
XForceOmitDef:
XForceOmitKeyword '(' XStructFieldRefList ')'
{
if (rawstruct->forceomit.nElements == 0) {
rawstruct->forceomit = $3;
}
else {
rawstruct->forceomit.lists = static_cast<rawAST_field_list**>(
Realloc(rawstruct->forceomit.lists,
(rawstruct->forceomit.nElements + $3.nElements) *
sizeof(rawAST_field_list*)));
memcpy(rawstruct->forceomit.lists + rawstruct->forceomit.nElements,
$3.lists, $3.nElements * sizeof(rawAST_field_list*));
rawstruct->forceomit.nElements += $3.nElements;
Free($3.lists);
}
}
;
XStructFieldRefList:
XStructFieldRef
{
$$.nElements = 1;
$$.lists = static_cast<rawAST_field_list**>(
Malloc(sizeof(rawAST_field_list*)) );
$$.lists[0] = $1;
}
| XStructFieldRefList ',' XStructFieldRef
{
$$.nElements = $1.nElements + 1;
$$.lists = static_cast<rawAST_field_list**>(
Realloc($1.lists, $$.nElements * sizeof(rawAST_field_list*)) );
$$.lists[$1.nElements] = $3;
}
;
/* FieldLength */
XFieldLengthDef : XFieldLengthKeyword '(' XNumber ')'
......
......@@ -839,7 +839,8 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
}
src = mputprintf(src, "int %s::RAW_decode(\n"
"const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit, \n"
"raw_order_t top_bit_ord, boolean no_err, int sel_field, boolean)\n"
"raw_order_t top_bit_ord, boolean no_err, int sel_field, boolean, "
"const RAW_Force_Omit* force_omit)\n"
"{\n"
" int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);\n"
" limit-=prepaddlength;\n"
......@@ -849,10 +850,13 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
" switch(sel_field){\n", name);
for (i = 0; i < sdef->nElements; i++) {
src = mputprintf(src,
" case %lu:\n"
" case %lu: {\n"
" RAW_Force_Omit field_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
" decoded_length = %s().RAW_decode(%s_descr_, p_buf, limit, "
"top_bit_ord, no_err);\n"
" break;\n", (unsigned long) i, sdef->elements[i].name,
"top_bit_ord, no_err, -1, TRUE, &field_force_omit);\n"
" break; }\n", (unsigned long) i, (int) i,
sdef->elements[i].typedescrname, sdef->elements[i].name,
sdef->elements[i].typedescrname);
}
src = mputstr(src, " default: break;\n"
......@@ -966,10 +970,13 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
}
src = mputprintf(src, ") {\n"
" p_buf.set_pos_bit(starting_pos);\n"
" RAW_Force_Omit field_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
" decoded_length = %s().RAW_decode(%s_descr_, p_buf, "
"limit, top_bit_ord, TRUE);\n"
" if (decoded_length > 0) {\n", sdef->elements[i].name,
sdef->elements[i].typedescrname);
"limit, top_bit_ord, TRUE, -1, TRUE, &field_force_omit);\n"
" if (decoded_length > 0) {\n",
(int) i, sdef->elements[i].typedescrname,
sdef->elements[i].name, sdef->elements[i].typedescrname);
src = mputstr(src, " if (");
src = genRawFieldChecker(src, cur_choice, TRUE);
src = mputstr(src, ") {\n"
......@@ -991,10 +998,13 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
if (cur_choice->fields[j].start_pos < 0) {
src = mputprintf(src, " if (already_failed) {\n"
" p_buf.set_pos_bit(starting_pos);\n"
" RAW_Force_Omit field_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
" decoded_length = %s().RAW_decode(%s_descr_, p_buf, limit, "
"top_bit_ord, TRUE);\n"
" if (decoded_length > 0) {\n", sdef->elements[i].name,
sdef->elements[i].typedescrname);
"top_bit_ord, TRUE, -1, TRUE, &field_force_omit);\n"
" if (decoded_length > 0) {\n",
(int) i, sdef->elements[i].typedescrname,
sdef->elements[i].name, sdef->elements[i].typedescrname);
src = mputstr(src, " if (");
src = genRawFieldChecker(src, cur_choice, TRUE);
src = mputstr(src, ") {\n"
......@@ -1015,10 +1025,13 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
rawAST_coding_taglist* cur_choice = sdef->raw.taglist.list
- tag_type[i] - 1;
src = mputprintf(src, " p_buf.set_pos_bit(starting_pos);\n"
" RAW_Force_Omit field_%d_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
" decoded_length = %s().RAW_decode(%s_descr_, p_buf, limit, "
"top_bit_ord, TRUE);\n"
" if (decoded_length >= 0) {\n", sdef->elements[i].name,
sdef->elements[i].typedescrname);
"top_bit_ord, TRUE, -1, TRUE, &field_%d_force_omit);\n"
" if (decoded_length >= 0) {\n",
(int) i, (int) i, sdef->elements[i].typedescrname,
sdef->elements[i].name, sdef->elements[i].typedescrname, (int) i);
src = mputstr(src, " if (");
src = genRawFieldChecker(src, cur_choice, TRUE);
src = mputstr(src, ") {\n"
......@@ -1031,10 +1044,13 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
for (i = 0; i < sdef->nElements; i++) { /* fields without tag */
if (!tag_type[i]) {
src = mputprintf(src, " p_buf.set_pos_bit(starting_pos);\n"
" RAW_Force_Omit field_%d_force_omit(%d, force_omit, "
"%s_descr_.raw->forceomit);\n"
" decoded_length = %s().RAW_decode(%s_descr_, p_buf, limit, "
"top_bit_ord, TRUE);\n"
" if (decoded_length >= 0) {\n", sdef->elements[i].name,
sdef->elements[i].typedescrname);
"top_bit_ord, TRUE, -1, TRUE, &field_%d_force_omit);\n"
" if (decoded_length >= 0) {\n",
(int) i, (int) i, sdef->elements[i].typedescrname,
sdef->elements[i].name, sdef->elements[i].typedescrname, (int) i);
src = mputstr(src, " return decoded_length + "
"p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;\n"
" }\n");
......
......@@ -997,7 +997,8 @@ int Base_Type::TEXT_decode(const TTCN_Typedescriptor_t& p_td,
int Base_Type::RAW_decode(const TTCN_Typedescriptor_t& p_td,
TTCN_Buffer&, int /* limit */, raw_order_t /* top_bit_ord */,
boolean /* no_error */, int /* sel_field */, boolean /* first_call */ )
boolean /* no_error */, int /* sel_field */, boolean /* first_call */,
const RAW_Force_Omit* /* force_omit */ )
{
TTCN_error("RAW decoding requested for type '%s'"
" which has no RAW decoding method.",p_td.name);
......
......@@ -51,6 +51,7 @@ class Module_Param_Name;
struct embed_values_enc_struct_t;