Sync with 5.3.0
[deliverable/titan.core.git] / compiler2 / record_of.c
index b820722e988d8c3bb1fe6cf705b62500ba558375..5f97b3d90634d15e4cd15670fef550ce496c0f74 100644 (file)
@@ -39,11 +39,11 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
   char *def = NULL, *src = NULL;
   const char *name = sdef->name, *dispname = sdef->dispname;
   const char *type = sdef->type;
-  boolean ber_needed = sdef->isASN1 && enable_ber();
-  boolean raw_needed = sdef->hasRaw && enable_raw();
-  boolean text_needed = sdef->hasText && enable_text();
-  boolean xer_needed = sdef->hasXer && enable_xer();
-  boolean json_needed = sdef->hasJson && enable_json();
+  boolean ber_needed = force_gen_seof || (sdef->isASN1 && enable_ber());
+  boolean raw_needed = force_gen_seof || (sdef->hasRaw && enable_raw());
+  boolean text_needed = force_gen_seof || (sdef->hasText && enable_text());
+  boolean xer_needed = force_gen_seof || (sdef->hasXer && enable_xer());
+  boolean json_needed = force_gen_seof || (sdef->hasJson && enable_json());
 
   /* Class definition and private data members */
   def = mputprintf(def,
@@ -723,7 +723,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "    p_buf.put_cs(*p_td.text->separator_encode);\n"
       "    encoded_length+=p_td.text->separator_encode->lengthof();\n"
       "   }\n"
-      "   encoded_length+=(*this)[a].TEXT_encode(%s_descr_,p_buf);\n"
+      "   encoded_length+=(*this)[a].TEXT_encode(*p_td.oftype_descr,p_buf);\n"
       "  }\n"
       "  if(p_td.text->end_encode){\n"
       "    p_buf.put_cs(*p_td.text->end_encode);\n"
@@ -731,7 +731,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "  }\n"
       "  return encoded_length;\n"
       "}\n"
-      ,name,sdef->oftypedescrname
+      ,name
       );
     src = mputprintf(src,
       "int %s::TEXT_decode(const TTCN_Typedescriptor_t& p_td,"
@@ -774,7 +774,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "  while(TRUE){\n"
       "    %s *val=new %s;\n"
       "    pos=p_buf.get_pos();\n"
-      "    int len=val->TEXT_decode(%s_descr_,p_buf,limit,TRUE);\n"
+      "    int len=val->TEXT_decode(*p_td.oftype_descr,p_buf,limit,TRUE);\n"
       "    if(len==-1 || (len==0 && !limit.has_token())){\n"
       "      p_buf.set_pos(pos);\n"
       "      delete val;\n"
@@ -816,7 +816,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "      }\n"
       "    }\n"
       "  }\n"
-      ,name,type,type,sdef->oftypedescrname,type
+      ,name,type,type,type
      );
     src = mputstr(src,
       "   limit.remove_tokens(ml);\n"
@@ -871,7 +871,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
        "    for(int elem_i=0; elem_i<val_ptr->n_elements; elem_i++) {\n"
        "      ec.set_msg(\"Component #%%d: \", elem_i);\n"
        "      new_tlv->add_TLV((*this)[elem_i].BER_encode_TLV"
-       "(%s_descr_, p_coding));\n"
+       "(*p_td.oftype_descr, p_coding));\n"
        "    }\n"
        "%s"
        "  }\n"
@@ -905,16 +905,16 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
        "val_ptr->n_elements + 1);\n"
        "    val_ptr->n_elements++;\n"
        "    val_ptr->value_elements[val_ptr->n_elements - 1] = new %s;\n"
-       "    val_ptr->value_elements[val_ptr->n_elements - 1]->BER_decode_TLV(%s_descr_, tmp_tlv, "
+       "    val_ptr->value_elements[val_ptr->n_elements - 1]->BER_decode_TLV(*p_td.oftype_descr, tmp_tlv, "
        "L_form);\n"
        "    ec_2.set_msg(\"%%d: \", val_ptr->n_elements);\n"
        "  }\n"
        "  return TRUE;\n"
        "}\n"
        "\n"
-       , name, sdef->oftypedescrname
+       , name
        , sdef->kind==SET_OF?"    new_tlv->sort_tlvs();\n":""
-       , name, type, type, sdef->oftypedescrname
+       , name, type, type
        );
 
     if(sdef->has_opentypes) {
@@ -966,7 +966,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
     "    int a=0;\n"
     "    if(sel_field==-1) sel_field=p_td.raw->fieldlength;\n"
     "    for(a=0;a<sel_field;a++){\n"
-    "      decoded_field_length=(*this)[a+start_field].RAW_decode(%s_descr_,"
+    "      decoded_field_length=(*this)[a+start_field].RAW_decode(*p_td.oftype_descr,"
     "p_buf,limit,top_bit_ord,TRUE);\n"
     "      if(decoded_field_length < 0) return decoded_field_length;\n"
     "      decoded_length+=decoded_field_length;\n"
@@ -983,7 +983,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
     "    }\n"
     "    while(limit>0){\n"
     "      start_of_field=p_buf.get_pos_bit();\n"
-    "      decoded_field_length=(*this)[a].RAW_decode(%s_descr_,p_buf,limit,"
+    "      decoded_field_length=(*this)[a].RAW_decode(*p_td.oftype_descr,p_buf,limit,"
     "top_bit_ord,TRUE);\n"
     "      if(decoded_field_length < 0){\n"
     "        delete &(*this)[a];\n"
@@ -997,13 +997,16 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
     "      decoded_length+=decoded_field_length;\n"
     "      limit-=decoded_field_length;\n"
     "      a++;\n"
-    ,name,sdef->oftypedescrname,sdef->oftypedescrname
+    ,name
     );
-    if(sdef->raw.extension_bit!=XDEFNO && sdef->raw.extension_bit!=XDEFDEFAULT){
+    if (force_gen_seof || (sdef->raw.extension_bit!=XDEFNO && sdef->raw.extension_bit!=XDEFDEFAULT)){
       src=mputprintf(src,
-    "      if (%sp_buf.get_last_bit())\n"
+    "      if (%s%sp_buf.get_last_bit()%s)\n"
     "        return decoded_length+p_buf.increase_pos_padd(p_td.raw->padding)"
-    "+prepaddlength;\n", sdef->raw.extension_bit == XDEFYES ? "" : "!");
+    "+prepaddlength;\n"
+    , force_gen_seof ? "EXT_BIT_NO != p_td.raw->extension_bit && ((EXT_BIT_YES != p_td.raw->extension_bit) ^ " : ""
+    , (force_gen_seof || sdef->raw.extension_bit == XDEFYES) ? "" : "!"
+    , force_gen_seof ? ")" : "");
     }
       src=mputprintf(src,
     "    }\n"
@@ -1023,12 +1026,12 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
     "  myleaf.body.node.nodes=init_nodes_of_enc_tree(encoded_num_of_records);\n"
     "  for(int a=0;a<encoded_num_of_records;a++){\n"
     "    myleaf.body.node.nodes[a]=new RAW_enc_tree(TRUE,&myleaf,"
-    "&(myleaf.curr_pos),a,%s_descr_.raw);\n"
-    "    encoded_length+=(*this)[a].RAW_encode(%s_descr_,"
+    "&(myleaf.curr_pos),a,p_td.oftype_descr->raw);\n"
+    "    encoded_length+=(*this)[a].RAW_encode(*p_td.oftype_descr,"
     "*myleaf.body.node.nodes[a]);\n"
     "  }\n"
     " return myleaf.length=encoded_length;\n}\n\n"
-    , name, sdef->oftypedescrname, sdef->oftypedescrname
+    , name
     );
   }
 
@@ -1042,10 +1045,12 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "boolean %s::can_start(const char *name, const char *uri, "
       "XERdescriptor_t const& xd, unsigned int flavor) {\n"
       "  boolean e_xer = is_exer(flavor);\n"
-      "  if (e_xer && (xd.xer_bits & ANY_ELEMENT)) "
+      "  if ((!e_xer || !(xd.xer_bits & UNTAGGED)) && !(flavor & XER_RECOF)) return "
+      "check_name(name, xd, e_xer) && (!e_xer || check_namespace(uri, xd));\n"
+      "  if (e_xer && (xd.oftype_descr->xer_bits & ANY_ELEMENT)) "
       , name
       );
-    if (sdef->nFollowers) {
+    if (!force_gen_seof && sdef->nFollowers) {
       /* If there are optional fields following the record-of, then seeing
        * {any XML tag that belongs to those fields} where the record-of may be
        * means that the record-of is empty. */
@@ -1065,12 +1070,9 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
     else src = mputstr(src, "return TRUE;\n");
 
     src = mputprintf(src,
-      "  if ((!e_xer || !(xd.xer_bits & UNTAGGED)) && !(flavor & XER_RECOF)) return "
-      "check_name(name, xd, e_xer) && (!e_xer || check_namespace(uri, xd));\n"
-      "  else return %s::can_start(name, uri, %s_xer_, flavor | XER_RECOF);\n"
+      "  return %s::can_start(name, uri, *xd.oftype_descr, flavor | XER_RECOF);\n"
       "}\n\n"
       , sdef->type
-      , sdef->oftypedescrname
       );
 
     src = mputprintf(src,
@@ -1083,7 +1085,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "    size_t num_new;\n"
       "    for (int i = 0; i < val_ptr->n_elements; ++i) {\n"
       "      bool def_ns_1 = false;"
-      "      new_ns = (*this)[i].collect_ns(%s_xer_, num_new, def_ns_1);\n"
+      "      new_ns = (*this)[i].collect_ns(*p_td.oftype_descr, num_new, def_ns_1);\n"
       "      merge_ns(collected_ns, num_collected, new_ns, num_new);\n"
       "      def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */
       "    }\n"
@@ -1098,7 +1100,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "  num = num_collected;\n"
       "  return collected_ns;\n"
       "}\n\n"
-      , name, sdef->oftypedescrname);
+      , name);
 
     src=mputprintf(src,
       "int %s::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf, "
@@ -1112,16 +1114,18 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "%s" /* Factor out p_indent if not attribute */
       "  if (val_ptr->n_elements==0) {\n" /* Empty record of */
       , name
-      , sdef->xerAttribute ? "" : "  if (indenting) do_indent(p_buf, p_indent);\n"
+      , force_gen_seof ? "  if (indenting && !(p_td.xer_bits & XER_ATTRIBUTE)) do_indent(p_buf, p_indent);\n"
+      : (sdef->xerAttribute ? "" : "  if (indenting) do_indent(p_buf, p_indent);\n")
       );
-    if (sdef->xerAttribute) {
-      src=mputstr(src,
-        "    if (e_xer) {\n" /* Empty attribute. */
+    if (force_gen_seof || sdef->xerAttribute) {
+      src=mputprintf(src,
+        "    if (e_xer%s) {\n" /* Empty attribute. */
         "      begin_attribute(p_td, p_buf);\n"
         "      p_buf.put_c('\\'');\n"
-        "    } else\n");
+        "    } else\n"
+        , force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
     }
-    else {
+    if (force_gen_seof || !sdef->xerAttribute) {
       src = mputstr(src,
         "    if (own_tag)");
     }
@@ -1149,7 +1153,8 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "    }\n"
       "  }\n"
       "  else {\n" /* Not empty record of. Start tag or attribute */
-      , sdef->xerAttribute ? "      if (indenting) do_indent(p_buf, p_indent);\n" : ""
+      , force_gen_seof ? "      if (indenting && (p_td.xer_bits & XER_ATTRIBUTE)) do_indent(p_buf, p_indent);\n"
+      : (sdef->xerAttribute ? "      if (indenting) do_indent(p_buf, p_indent);\n" : "")
       );
     if (sdef->xerAnyAttrElem) {
       src = mputstr(src,
@@ -1236,11 +1241,12 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
         "      p_buf.put_s(shorter, saved);\n" /* restore the '>' and anything after */
         "    } else {\n");
     }
-    if (sdef->xerAttribute) {
-      src=mputstr(src,
-        "    if (e_xer) {\n"
+    if (force_gen_seof || sdef->xerAttribute) {
+      src=mputprintf(src,
+        "    if (e_xer%s) {\n"
         "      begin_attribute(p_td, p_buf);\n"
-        "    } else\n");
+        "    } else\n"
+        , force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
     }
     src=mputprintf(src,
       "    if (own_tag) {\n"
@@ -1266,7 +1272,8 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "        Free(collected_ns);\n"
       "        p_buf.put_s(1 + keep_newline, (cbyte*)\">\\n\");\n"
       "      }\n"
-      , sdef->xerAttribute ? "      if (indenting) do_indent(p_buf, p_indent);\n" : ""
+      , force_gen_seof ? "      if (indenting && (p_td.xer_bits & XER_ATTRIBUTE)) do_indent(p_buf, p_indent);\n"
+      : (sdef->xerAttribute ? "      if (indenting) do_indent(p_buf, p_indent);\n" : "")
       );
     if (sdef->xmlValueList) {
       src=mputstr(src, "      if (indenting && !e_xer) do_indent(p_buf, p_indent+1);\n"); /* !e_xer or GDMO */
@@ -1277,20 +1284,26 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "    TTCN_EncDec_ErrorContext ec_0(\"Index \");\n"
       "    TTCN_EncDec_ErrorContext ec_1;\n"
       );
-    src=mputprintf(src,
+    src=mputstr(src,
       "    for (int i = 0; i < val_ptr->n_elements; ++i) {\n"
-      /*"      if (i > 0 && !own_tag && 0 != emb_val &&\n"
-      "          emb_val->embval_index < emb_val->embval_size) {\n"
-      "        emb_val->embval_array->get_embedded_value(emb_val->embval_index).XER_encode(\n"
-      "          UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
+      "      if (i > 0 && !own_tag && 0 != emb_val &&\n"
+      "          emb_val->embval_index < (0 != emb_val->embval_array_reg ?\n"
+      "          emb_val->embval_array_reg->size_of() : emb_val->embval_array_opt->size_of())) {\n"
+      "        if (0 != emb_val->embval_array_reg) {\n"
+      "          (*emb_val->embval_array_reg)[emb_val->embval_index].XER_encode(\n"
+      "            UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
+      "        }\n"
+      "        else {\n"
+      "          (*emb_val->embval_array_opt)[emb_val->embval_index].XER_encode(\n"
+      "            UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
+      "        }\n"
       "        ++emb_val->embval_index;\n"
-      "      }\n" - temporarily removed in RT1 */
-      "      ec_1.set_msg(\"%%d: \", i);\n"
+      "      }\n"
+      "      ec_1.set_msg(\"%d: \", i);\n"
       "      if (e_xer && (p_td.xer_bits & XER_LIST) && i>0) p_buf.put_c(' ');\n"
-      "      (*this)[i].XER_encode(%s_xer_, p_buf, p_flavor, p_indent+own_tag, emb_val);\n"
+      "      (*this)[i].XER_encode(*p_td.oftype_descr, p_buf, p_flavor, p_indent+own_tag, emb_val);\n"
       "    }\n"
-      "    if (indenting && !is_exerlist(p_flavor)) {\n",
-      sdef->oftypedescrname
+      "    if (indenting && !is_exerlist(p_flavor)) {\n"
     );
     if (sdef->xmlValueList) {
       src=mputstr(src, "      if (!e_xer) p_buf.put_c('\\n');\n"); /* !e_xer or GDMO */
@@ -1298,10 +1311,11 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
     src=mputstr(src,
       "      do_indent(p_buf, p_indent);\n"
       "    }\n");
-    if (sdef->xerAttribute) {
-      src=mputstr(src,
-        "    if (e_xer) p_buf.put_c('\\'');\n"
-        "    else\n");
+    if (force_gen_seof || sdef->xerAttribute) {
+      src=mputprintf(src,
+        "    if (e_xer%s) p_buf.put_c('\\'');\n"
+        "    else\n"
+        , force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
     }
     src=mputstr(src,
       "    if (own_tag){\n"
@@ -1357,13 +1371,15 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "  }\n" /* next read */
       "  else xml_depth = p_reader.Depth();\n"
       "  p_flavor |= XER_RECOF;\n"
+      "  TTCN_EncDec_ErrorContext ec_0(\"Index \");\n"
+      "  TTCN_EncDec_ErrorContext ec_1;\n"
 #ifndef NDEBUG
       , __FUNCTION__, __LINE__
 #endif
       , name
       );
 
-    src = mputprintf(src,
+    src = mputstr(src,
       "  if (e_xer && (p_td.xer_bits & XER_LIST)) {\n" /* LIST decoding*/
       "    char *x_val = (char*)p_reader.NewValue();\n" /* we own it */
       "    size_t x_pos = 0;\n"
@@ -1377,13 +1393,13 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "      x_pos += strlen(str) + 1;\n"
       "      TTCN_Buffer buf_2;\n"
       "      buf_2.put_c('<');\n"
-      "      write_ns_prefix(%s_xer_, buf_2);\n"
-      "      const char * const exer_name = %s_xer_.names[1];\n"
-      "      boolean i_can_has_ns = %s_xer_.my_module != 0 && %s_xer_.ns_index != -1;\n"
+      "      write_ns_prefix(*p_td.oftype_descr, buf_2);\n"
+      "      const char * const exer_name = p_td.oftype_descr->names[1];\n"
+      "      boolean i_can_has_ns = p_td.oftype_descr->my_module != 0 && p_td.oftype_descr->ns_index != -1;\n"
       /* If it has a namespace, chop off the '>' from the end */
-      "      buf_2.put_s((size_t)%s_xer_.namelens[1]-1-i_can_has_ns, (cbyte*)exer_name);\n"
+      "      buf_2.put_s((size_t)p_td.oftype_descr->namelens[1]-1-i_can_has_ns, (cbyte*)exer_name);\n"
       "      if (i_can_has_ns) {\n"
-      "        const namespace_t * const pns = %s_xer_.my_module->get_ns(%s_xer_.ns_index);\n"
+      "        const namespace_t * const pns = p_td.oftype_descr->my_module->get_ns(p_td.oftype_descr->ns_index);\n"
       "        buf_2.put_s(7 - (*pns->px == 0), (cbyte*)\" xmlns:\");\n"
       "        buf_2.put_s(strlen(pns->px), (cbyte*)pns->px);\n"
       "        buf_2.put_s(2, (cbyte*)\"='\");\n"
@@ -1394,14 +1410,15 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "      buf_2.put_s(strlen(str), (cbyte*)str);\n"
       "      buf_2.put_c('<');\n"
       "      buf_2.put_c('/');\n"
-      "      write_ns_prefix(%s_xer_, buf_2);\n"
-      "      buf_2.put_s((size_t)%s_xer_.namelens[1], (cbyte*)exer_name);\n"
+      "      write_ns_prefix(*p_td.oftype_descr, buf_2);\n"
+      "      buf_2.put_s((size_t)p_td.oftype_descr->namelens[1], (cbyte*)exer_name);\n"
       "      XmlReaderWrap reader_2(buf_2);\n"
       "      rd_ok = reader_2.Read();\n" /* Move to the start element. */
+      "      ec_1.set_msg(\"%d: \", val_ptr->n_elements);\n"
       /* Don't move to the #text, that's the callee's responsibility. */
       /* The call to the non-const operator[] creates a new element object,
        * then we call its XER_decode with the temporary XML reader. */
-      "      (*this)[val_ptr->n_elements].XER_decode(%s_xer_, reader_2, p_flavor, 0);\n"
+      "      (*this)[val_ptr->n_elements].XER_decode(*p_td.oftype_descr, reader_2, p_flavor, 0);\n"
       "      if (p_flavor & EXIT_ON_ERROR && !(*this)[val_ptr->n_elements - 1].is_bound()) {\n"
       "        if (1 == val_ptr->n_elements) {\n"
       // Failed to decode even the first element
@@ -1423,11 +1440,6 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "      p_reader.Read();\n" /* past it */
       "    }\n"
       "  }\n"
-      , sdef->oftypedescrname, sdef->oftypedescrname
-      , sdef->oftypedescrname, sdef->oftypedescrname
-      , sdef->oftypedescrname, sdef->oftypedescrname
-      , sdef->oftypedescrname, sdef->oftypedescrname
-      , sdef->oftypedescrname, sdef->oftypedescrname
     );
 
     src = mputprintf(src,
@@ -1457,17 +1469,18 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
         "            if (p_reader.NodeType() != XML_READER_TYPE_ELEMENT) rd_ok = p_reader.Read();\n"
         "          } else");
     }
-    src = mputprintf(src,
+    src = mputstr(src,
       "          {\n"
       /* An untagged record-of ends if it encounters an element with a name
        * that doesn't match its component */
       "            if (!own_tag && !can_start((const char*)p_reader.LocalName(), "
-      "(const char*)p_reader.NamespaceUri(), %s_xer_, p_flavor)) {\n"
+      "(const char*)p_reader.NamespaceUri(), p_td, p_flavor)) {\n"
       "              for (; rd_ok == 1 && p_reader.Depth() > xml_depth; rd_ok = p_reader.Read()) ;\n"
       "              break;\n"
       "            }\n"
+      "            ec_1.set_msg(\"%d: \", val_ptr->n_elements);\n"
       /* The call to the non-const operator[] creates the element */
-      "            (*this)[val_ptr->n_elements].XER_decode(%s_xer_, p_reader, p_flavor, emb_val);\n"
+      "            (*this)[val_ptr->n_elements].XER_decode(*p_td.oftype_descr, p_reader, p_flavor, emb_val);\n"
       "            if (0 != emb_val && !own_tag && val_ptr->n_elements > 1) {\n"
       "              ++emb_val->embval_index;\n"
       "            }\n"      
@@ -1481,11 +1494,16 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "          }\n"
       "          break;\n"
       "        }\n"
-      /*"        else if (XML_READER_TYPE_TEXT == type && 0 != emb_val && !own_tag && get_nof_elements() > 0) {\n"
+      "        else if (XML_READER_TYPE_TEXT == type && 0 != emb_val && !own_tag && val_ptr->n_elements > 0) {\n"
       "          UNIVERSAL_CHARSTRING emb_ustr((const char*)p_reader.Value());\n"
-      "          emb_val->embval_array->set_embedded_value(emb_val->embval_index, emb_ustr);\n"
+      "          if (0 != emb_val->embval_array_reg) {\n"
+      "            (*emb_val->embval_array_reg)[emb_val->embval_index] = emb_ustr;\n"
+      "          }\n"
+      "          else {\n"
+      "            (*emb_val->embval_array_opt)[emb_val->embval_index] = emb_ustr;\n"
+      "          }\n"
       "          rd_ok = p_reader.Read();\n"
-      "        }\n" - temporarily removed in RT1 */
+      "        }\n"
       "        else {\n"
       "          rd_ok = p_reader.Read();\n"
       "        }\n"
@@ -1494,13 +1512,12 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "  }\n" /* if not LIST */
       "  return 1;\n"
       "}\n\n"
-      , sdef->oftypedescrname, sdef->oftypedescrname
     );
   }
   if (json_needed) {
     // JSON encode, RT1
     src = mputprintf(src,
-      "int %s::JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok) const\n"
+      "int %s::JSON_encode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok) const\n"
       "{\n"
       "  if (!is_bound()) {\n"
       "    TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND,\n"
@@ -1509,18 +1526,18 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "  }\n\n"
       "  int enc_len = p_tok.put_next_token(JSON_TOKEN_ARRAY_START, NULL);\n"
       "  for(int i = 0; i < val_ptr->n_elements; ++i) {\n"
-      "    int ret_val = (*this)[i].JSON_encode(%s_descr_, p_tok);\n"
+      "    int ret_val = (*this)[i].JSON_encode(*p_td.oftype_descr, p_tok);\n"
       "    if (0 > ret_val) break;\n"
       "    enc_len += ret_val;\n"
       "  }\n"
       "  enc_len += p_tok.put_next_token(JSON_TOKEN_ARRAY_END, NULL);\n"
       "  return enc_len;\n"
       "}\n\n"
-      , name, dispname, sdef->oftypedescrname);
+      , name, dispname);
     
     // JSON decode, RT1
     src = mputprintf(src,
-      "int %s::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent)\n"
+      "int %s::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)\n"
       "{\n"
       "  json_token_t token = JSON_TOKEN_NONE;\n"
       "  int dec_len = p_tok.get_next_token(&token, NULL, NULL);\n"
@@ -1535,7 +1552,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "  while (true) {\n"
       "    size_t buf_pos = p_tok.get_buf_pos();\n"
       "    %s* val = new %s;\n"
-      "    int ret_val = val->JSON_decode(%s_descr_, p_tok, p_silent);\n"
+      "    int ret_val = val->JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n"
       "    if (JSON_ERROR_INVALID_TOKEN == ret_val) {\n"
       "      p_tok.set_buf_pos(buf_pos);\n"
       "      delete val;\n"
@@ -1564,7 +1581,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
       "  }\n\n"
       "  return dec_len;\n"
       "}\n\n"
-      , name, type, type, sdef->oftypedescrname, type);
+      , name, type, type, type);
   }
   /* end of class */
   def = mputstr(def, "};\n\n");
@@ -1604,11 +1621,11 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
   char *def = NULL, *src = NULL;
   const char *name = sdef->name, *dispname = sdef->dispname;
   const char *type = sdef->type;
-  boolean ber_needed = sdef->isASN1 && enable_ber();
-  boolean raw_needed = sdef->hasRaw && enable_raw();
-  boolean text_needed = sdef->hasText && enable_text();
-  boolean xer_needed = sdef->hasXer && enable_xer();
-  boolean json_needed = sdef->hasJson && enable_json();
+  boolean ber_needed = force_gen_seof || (sdef->isASN1 && enable_ber());
+  boolean raw_needed = force_gen_seof || (sdef->hasRaw && enable_raw());
+  boolean text_needed = force_gen_seof || (sdef->hasText && enable_text());
+  boolean xer_needed = force_gen_seof || (sdef->hasXer && enable_xer());
+  boolean json_needed = force_gen_seof || (sdef->hasJson && enable_json());
 
   /* Class definition and private data members */
   def = mputprintf(def,
@@ -1684,7 +1701,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
   /* constructors */
   def = mputprintf(def, "%s(): n_elements(-1), value_elements(NULL) {}\n", name);
 
-  def = mputprintf(def, "%s(null_type other_value): n_elements(0), value_elements(NULL) {}\n", name);
+  def = mputprintf(def, "%s(null_type): n_elements(0), value_elements(NULL) {}\n", name);
 
   /* copy constructor */
   def = mputprintf(def, "%s(const %s& other_value) { copy_value(other_value); }\n", name, name);
@@ -2176,7 +2193,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "    p_buf.put_cs(*p_td.text->separator_encode);\n"
       "    encoded_length+=p_td.text->separator_encode->lengthof();\n"
       "   }\n"
-      "   encoded_length+=value_elements[a].TEXT_encode(%s_descr_,p_buf);\n"
+      "   encoded_length+=value_elements[a].TEXT_encode(*p_td.oftype_descr,p_buf);\n"
       "  }\n"
       "  if(p_td.text->end_encode){\n"
       "    p_buf.put_cs(*p_td.text->end_encode);\n"
@@ -2184,7 +2201,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "  }\n"
       "  return encoded_length;\n"
       "}\n"
-      ,name,sdef->oftypedescrname
+      ,name
       );
     src = mputprintf(src,
       "int %s::TEXT_decode(const TTCN_Typedescriptor_t& p_td,"
@@ -2223,7 +2240,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "  while(TRUE){\n"
       "    %s val;\n"
       "    pos=p_buf.get_pos();\n"
-      "    int len=val.TEXT_decode(%s_descr_,p_buf,limit,TRUE);\n"
+      "    int len=val.TEXT_decode(*p_td.oftype_descr,p_buf,limit,TRUE);\n"
       "    if(len==-1 || (len==0 && !limit.has_token())){\n"
       "      p_buf.set_pos(pos);\n"
       "      if(sep_found){\n"
@@ -2261,7 +2278,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "      }\n"
       "    }\n"
       "  }\n"
-      ,name,type,sdef->oftypedescrname
+      ,name,type
      );
     src = mputstr(src,
       "   limit.remove_tokens(ml);\n"
@@ -2315,7 +2332,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
        "    for(int elem_i=0; elem_i<n_elements; elem_i++) {\n"
        "      ec.set_msg(\"Component #%%d: \", elem_i);\n"
        "      new_tlv->add_TLV(value_elements[elem_i].BER_encode_TLV"
-       "(%s_descr_, p_coding));\n"
+       "(*p_td.oftype_descr, p_coding));\n"
        "    }\n"
        "%s"
        "  }\n"
@@ -2341,16 +2358,16 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
        "  while(BER_decode_constdTLV_next(stripped_tlv, V_pos, L_form, "
        "tmp_tlv)) {\n"
        "  set_size(n_elements+1);\n"
-       "  value_elements[n_elements-1].BER_decode_TLV(%s_descr_, tmp_tlv, "
+       "  value_elements[n_elements-1].BER_decode_TLV(*p_td.oftype_descr, tmp_tlv, "
          "L_form);\n"
        "  ec_2.set_msg(\"%%d: \", n_elements);\n"
        "  }\n"
        "  return TRUE;\n"
        "}\n"
        "\n"
-       , name, sdef->oftypedescrname
+       , name
        , sdef->kind==SET_OF?"    new_tlv->sort_tlvs();\n":""
-       , name, sdef->oftypedescrname
+       , name
        );
 
     if(sdef->has_opentypes) {
@@ -2396,7 +2413,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
     "    int a=0;\n"
     "    if(sel_field==-1) sel_field=p_td.raw->fieldlength;\n"
     "    for(a=0;a<sel_field;a++){\n"
-    "      decoded_field_length=(*this)[a+start_field].RAW_decode(%s_descr_,"
+    "      decoded_field_length=(*this)[a+start_field].RAW_decode(*p_td.oftype_descr,"
     "p_buf,limit,top_bit_ord,TRUE);\n"
     "      if(decoded_field_length < 0) return decoded_field_length;\n"
     "      decoded_length+=decoded_field_length;\n"
@@ -2413,7 +2430,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
     "    }\n"
     "    while(limit>0){\n"
     "      start_of_field=p_buf.get_pos_bit();\n"
-    "      decoded_field_length=(*this)[a].RAW_decode(%s_descr_,p_buf,limit,"
+    "      decoded_field_length=(*this)[a].RAW_decode(*p_td.oftype_descr,p_buf,limit,"
     "top_bit_ord,TRUE);\n"
     "      if(decoded_field_length < 0){\n"
     /*"        delete &(*this)[a];\n"*/
@@ -2427,7 +2444,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
     "      decoded_length+=decoded_field_length;\n"
     "      limit-=decoded_field_length;\n"
     "      a++;\n"
-    ,name,sdef->oftypedescrname,sdef->oftypedescrname
+    ,name
     );
     if(sdef->raw.extension_bit!=XDEFNO && sdef->raw.extension_bit!=XDEFDEFAULT){
       src=mputprintf(src,
@@ -2452,12 +2469,12 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
     "  myleaf.body.node.nodes=init_nodes_of_enc_tree(encoded_num_of_records);\n"
     "  for(int a=0;a<encoded_num_of_records;a++){\n"
     "    myleaf.body.node.nodes[a]=new RAW_enc_tree(TRUE,&myleaf,"
-    "&(myleaf.curr_pos),a,%s_descr_.raw);\n"
-    "    encoded_length+=(*this)[a].RAW_encode(%s_descr_,"
+    "&(myleaf.curr_pos),a,p_td.oftype_descr->raw);\n"
+    "    encoded_length+=(*this)[a].RAW_encode(*p_td.oftype_descr,"
     "*myleaf.body.node.nodes[a]);\n"
     "  }\n"
     " return myleaf.length=encoded_length;\n}\n\n"
-    , name, sdef->oftypedescrname, sdef->oftypedescrname
+    , name
     );
   }
 
@@ -2471,10 +2488,12 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "boolean %s::can_start(const char *name, const char *uri, "
       "XERdescriptor_t const& xd, unsigned int flavor) {\n"
       "  boolean e_xer = is_exer(flavor);\n"
-      "  if (e_xer && (xd.xer_bits & ANY_ELEMENT)) "
+      "  if ((!e_xer || !(xd.xer_bits & UNTAGGED)) && !(flavor & XER_RECOF)) return "
+      "check_name(name, xd, e_xer) && (!e_xer || check_namespace(uri, xd));\n"
+      "  if (e_xer && (xd.oftype_descr->xer_bits & ANY_ELEMENT)) "
       , name
       );
-    if (sdef->nFollowers) {
+    if (!force_gen_seof && sdef->nFollowers) {
       /* If there are optional fields following the record-of, then seeing
        * {any XML tag that belongs to those fields} where the record-of may be
        * means that the record-of is empty. */
@@ -2494,12 +2513,9 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
     else src = mputstr(src, "return TRUE;\n");
 
     src = mputprintf(src,
-      "  if ((!e_xer || !(xd.xer_bits & UNTAGGED)) && !(flavor & XER_RECOF)) return "
-      "check_name(name, xd, e_xer) && (!e_xer || check_namespace(uri, xd));\n"
-      "  else return %s::can_start(name, uri, %s_xer_, flavor | XER_RECOF);\n"
+      "  return %s::can_start(name, uri, *xd.oftype_descr, flavor | XER_RECOF);\n"
       "}\n\n"
       , sdef->type
-      , sdef->oftypedescrname
       );
 
     src = mputprintf(src,
@@ -2512,7 +2528,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "    size_t num_new;\n"
       "    for (int i = 0; i < n_elements; ++i) {\n"
       "      bool def_ns_1 = false;"
-      "      new_ns = value_elements[i].collect_ns(%s_xer_, num_new, def_ns_1);\n"
+      "      new_ns = value_elements[i].collect_ns(*p_td.oftype_descr, num_new, def_ns_1);\n"
       "      merge_ns(collected_ns, num_collected, new_ns, num_new);\n"
       "      def_ns = def_ns || def_ns_1;\n" /* alas, no ||= */
       "    }\n"
@@ -2527,7 +2543,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "  num = num_collected;\n"
       "  return collected_ns;\n"
       "}\n\n"
-      , name, sdef->oftypedescrname);
+      , name);
 
     src=mputprintf(src,
       "int %s::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf, "
@@ -2541,16 +2557,18 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "%s" /* Factor out p_indent if not attribute */
       "  if (n_elements==0) {\n" /* Empty record of */
       , name
-      , sdef->xerAttribute ? "" : "  if (indenting) do_indent(p_buf, p_indent);\n"
+      , force_gen_seof ? "  if (indenting && !(p_td.xer_bits & XER_ATTRIBUTE)) do_indent(p_buf, p_indent);\n"
+      : (sdef->xerAttribute ? "" : "  if (indenting) do_indent(p_buf, p_indent);\n")
       );
-    if (sdef->xerAttribute) {
-      src=mputstr(src,
-        "    if (e_xer) {\n" /* Empty attribute. */
+    if (force_gen_seof || sdef->xerAttribute) {
+      src=mputprintf(src,
+        "    if (e_xer%s) {\n" /* Empty attribute. */
         "      begin_attribute(p_td, p_buf);\n"
         "      p_buf.put_c('\\'');\n"
-        "    } else\n");
+        "    } else\n"
+        , force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
     }
-    else {
+    if (force_gen_seof || !sdef->xerAttribute) {
       src = mputstr(src,
         "    if (own_tag)");
     }
@@ -2578,7 +2596,8 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "    }\n"
       "  }\n"
       "  else {\n" /* Not empty record of. Start tag or attribute */
-      , sdef->xerAttribute ? "      if (indenting) do_indent(p_buf, p_indent);\n" : ""
+      , force_gen_seof ? "  if (indenting && !(p_td.xer_bits & XER_ATTRIBUTE)) do_indent(p_buf, p_indent);\n"
+      : (sdef->xerAttribute ? "" : "  if (indenting) do_indent(p_buf, p_indent);\n")
       );
     if (sdef->xerAnyAttrElem) {
       src = mputstr(src,
@@ -2660,11 +2679,12 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
         "      p_buf.put_s(shorter, saved);\n" /* restore the '>' and anything after */
         "    } else {\n");
     }
-    if (sdef->xerAttribute) {
-      src=mputstr(src,
-        "    if (e_xer) {\n"
+    if (force_gen_seof || sdef->xerAttribute) {
+      src=mputprintf(src,
+        "    if (e_xer%s) {\n"
         "      begin_attribute(p_td, p_buf);\n"
-        "    } else\n");
+        "    } else\n"
+        , force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
     }
     src=mputprintf(src,
       "    if (own_tag) {\n"
@@ -2690,7 +2710,8 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "        Free(collected_ns);\n"
       "        p_buf.put_s(1 + keep_newline, (cbyte*)\">\\n\");\n"
       "      }\n"
-      , sdef->xerAttribute ? "      if (indenting) do_indent(p_buf, p_indent);\n" : ""
+      , force_gen_seof ? "      if (indenting && (p_td.xer_bits & XER_ATTRIBUTE)) do_indent(p_buf, p_indent);\n"
+      : (sdef->xerAttribute ? "      if (indenting) do_indent(p_buf, p_indent);\n" : "")
       );
     if (sdef->xmlValueList) {
       src=mputstr(src, "      if (indenting && !e_xer) do_indent(p_buf, p_indent+1);\n"); /* !e_xer or GDMO */
@@ -2701,20 +2722,26 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "    TTCN_EncDec_ErrorContext ec_0(\"Index \");\n"
       "    TTCN_EncDec_ErrorContext ec_1;\n"
       );
-    src=mputprintf(src,
+    src=mputstr(src,
       "    for (int i = 0; i < n_elements; ++i) {\n"
-      /*"      if (i > 0 && !own_tag && 0 != emb_val &&\n"
-      "          emb_val->embval_index < emb_val->embval_size) {\n"
-      "        emb_val->embval_array->get_embedded_value(emb_val->embval_index).XER_encode(\n"
-      "          UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
+      "      if (i > 0 && !own_tag && 0 != emb_val &&\n"
+      "          emb_val->embval_index < (0 != emb_val->embval_array_reg ?\n"
+      "          emb_val->embval_array_reg->size_of() : emb_val->embval_array_opt->size_of())) {\n"
+      "        if (0 != emb_val->embval_array_reg) {\n"
+      "          (*emb_val->embval_array_reg)[emb_val->embval_index].XER_encode(\n"
+      "            UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
+      "        }\n"
+      "        else {\n"
+      "          (*emb_val->embval_array_opt)[emb_val->embval_index].XER_encode(\n"
+      "            UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
+      "        }\n"
       "        ++emb_val->embval_index;\n"
-      "      }\n" - temporarily removed in RT1 */
-      "      ec_1.set_msg(\"%%d: \", i);\n"
+      "      }\n"
+      "      ec_1.set_msg(\"%d: \", i);\n"
       "      if (e_xer && (p_td.xer_bits & XER_LIST) && i>0) p_buf.put_c(' ');\n"
-      "      value_elements[i].XER_encode(%s_xer_, p_buf, p_flavor, p_indent+own_tag, emb_val);\n"
+      "      value_elements[i].XER_encode(*p_td.oftype_descr, p_buf, p_flavor, p_indent+own_tag, emb_val);\n"
       "    }\n"
-      "    if (indenting && !is_exerlist(p_flavor)) {\n",
-      sdef->oftypedescrname
+      "    if (indenting && !is_exerlist(p_flavor)) {\n"
     );
     if (sdef->xmlValueList) {
       src=mputstr(src, "      if (!e_xer) p_buf.put_c('\\n');\n"); /* !e_xer or GDMO */
@@ -2722,10 +2749,11 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
     src=mputstr(src,
       "      do_indent(p_buf, p_indent);\n"
       "    }\n");
-    if (sdef->xerAttribute) {
-      src=mputstr(src,
-        "    if (e_xer) p_buf.put_c('\\'');\n"
-        "    else\n");
+    if (force_gen_seof || sdef->xerAttribute) {
+      src=mputprintf(src,
+        "    if (e_xer%s) p_buf.put_c('\\'');\n"
+        "    else\n"
+        , force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
     }
     src=mputstr(src,
       "    if (own_tag){\n"
@@ -2787,7 +2815,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       , name
       );
 
-    src = mputprintf(src,
+    src = mputstr(src,
       "  if (e_xer && (p_td.xer_bits & XER_LIST)) {\n" /* LIST decoding*/
       "    char *x_val = (char*)p_reader.NewValue();\n" /* we own it */
       "    size_t x_pos = 0;\n"
@@ -2801,13 +2829,13 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "      x_pos += strlen(str) + 1;\n"
       "      TTCN_Buffer buf_2;\n"
       "      buf_2.put_c('<');\n"
-      "      write_ns_prefix(%s_xer_, buf_2);\n"
-      "      const char * const exer_name = %s_xer_.names[1];\n"
-      "      boolean i_can_has_ns = %s_xer_.my_module != 0 && %s_xer_.ns_index != -1;\n"
+      "      write_ns_prefix(*p_td.oftype_descr, buf_2);\n"
+      "      const char * const exer_name = p_td.oftype_descr->names[1];\n"
+      "      boolean i_can_has_ns = p_td.oftype_descr->my_module != 0 && p_td.oftype_descr->ns_index != -1;\n"
       /* If it has a namespace, chop off the '>' from the end */
-      "      buf_2.put_s((size_t)%s_xer_.namelens[1]-1-i_can_has_ns, (cbyte*)exer_name);\n"
+      "      buf_2.put_s((size_t)p_td.oftype_descr->namelens[1]-1-i_can_has_ns, (cbyte*)exer_name);\n"
       "      if (i_can_has_ns) {\n"
-      "        const namespace_t * const pns = %s_xer_.my_module->get_ns(%s_xer_.ns_index);\n"
+      "        const namespace_t * const pns = p_td.oftype_descr->my_module->get_ns(p_td.oftype_descr->ns_index);\n"
       "        buf_2.put_s(7 - (*pns->px == 0), (cbyte*)\" xmlns:\");\n"
       "        buf_2.put_s(strlen(pns->px), (cbyte*)pns->px);\n"
       "        buf_2.put_s(2, (cbyte*)\"='\");\n"
@@ -2818,14 +2846,14 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "      buf_2.put_s(strlen(str), (cbyte*)str);\n"
       "      buf_2.put_c('<');\n"
       "      buf_2.put_c('/');\n"
-      "      write_ns_prefix(%s_xer_, buf_2);\n"
-      "      buf_2.put_s((size_t)%s_xer_.namelens[1], (cbyte*)exer_name);\n"
+      "      write_ns_prefix(*p_td.oftype_descr, buf_2);\n"
+      "      buf_2.put_s((size_t)p_td.oftype_descr->namelens[1], (cbyte*)exer_name);\n"
       "      XmlReaderWrap reader_2(buf_2);\n"
       "      rd_ok = reader_2.Read();\n" /* Move to the start element. */
       /* Don't move to the #text, that's the callee's responsibility. */
       /* The call to the non-const operator[] creates a new element object,
        * then we call its XER_decode with the temporary XML reader. */
-      "      (*this)[n_elements].XER_decode(%s_xer_, reader_2, p_flavor, 0);\n"
+      "      (*this)[n_elements].XER_decode(*p_td.oftype_descr, reader_2, p_flavor, 0);\n"
       "      if (p_flavor & EXIT_ON_ERROR && !(*this)[n_elements - 1].is_bound()) {\n"
       "        if (1 == n_elements) {\n"
       // Failed to decode even the first element
@@ -2847,11 +2875,6 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "      p_reader.Read();\n" /* past it */
       "    }\n"
       "  }\n"
-      , sdef->oftypedescrname, sdef->oftypedescrname
-      , sdef->oftypedescrname, sdef->oftypedescrname
-      , sdef->oftypedescrname, sdef->oftypedescrname
-      , sdef->oftypedescrname, sdef->oftypedescrname
-      , sdef->oftypedescrname, sdef->oftypedescrname
     );
 
     src = mputprintf(src,
@@ -2881,17 +2904,17 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
         "            if (p_reader.NodeType() != XML_READER_TYPE_ELEMENT) rd_ok = p_reader.Read();\n"
         "          } else");
     }
-    src = mputprintf(src,
+    src = mputstr(src,
       "          {\n"
       /* An untagged record-of ends if it encounters an element with a name
        * that doesn't match its component */
       "            if (!own_tag && !can_start((const char*)p_reader.LocalName(), "
-      "(const char*)p_reader.NamespaceUri(), %s_xer_, p_flavor)) {\n"
+      "(const char*)p_reader.NamespaceUri(), p_td, p_flavor)) {\n"
       "              for (; rd_ok == 1 && p_reader.Depth() > xml_depth; rd_ok = p_reader.Read()) ;\n"
       "              break;\n"
       "            }\n"
       /* The call to the non-const operator[] creates the element */
-      "            operator [](n_elements).XER_decode(%s_xer_, p_reader, p_flavor, emb_val);\n"
+      "            operator [](n_elements).XER_decode(*p_td.oftype_descr, p_reader, p_flavor, emb_val);\n"
       "            if (0 != emb_val && !own_tag && n_elements > 1) {\n"
       "              ++emb_val->embval_index;\n"
       "            }\n"
@@ -2905,11 +2928,16 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "          }\n"
       "          break;\n"
       "        }\n"
-      /*"        else if (XML_READER_TYPE_TEXT == type && 0 != emb_val && !own_tag && n_elements > 0) {\n"
+      "        else if (XML_READER_TYPE_TEXT == type && 0 != emb_val && !own_tag && n_elements > 0) {\n"
       "          UNIVERSAL_CHARSTRING emb_ustr((const char*)p_reader.Value());\n"
-      "          emb_val->embval_array->set_embedded_value(emb_val->embval_index, emb_ustr);\n"
+      "          if (0 != emb_val->embval_array_reg) {\n"
+      "            (*emb_val->embval_array_reg)[emb_val->embval_index] = emb_ustr;\n"
+      "          }\n"
+      "          else {\n"
+      "            (*emb_val->embval_array_opt)[emb_val->embval_index] = emb_ustr;\n"
+      "          }\n"
       "          rd_ok = p_reader.Read();\n"
-      "        }\n" - temporarily removed in RT1 */
+      "        }\n"
       "        else {\n"
       "          rd_ok = p_reader.Read();\n"
       "        }\n"
@@ -2918,13 +2946,12 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "  }\n" /* if not LIST */
       "  return 1;\n"
       "}\n\n"
-      , sdef->oftypedescrname, sdef->oftypedescrname
     );
   }
   if (json_needed) {
     // JSON encode, RT1, mem. alloc. optimised
     src = mputprintf(src,
-      "int %s::JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok) const\n"
+      "int %s::JSON_encode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok) const\n"
       "{\n"
       "  if (!is_bound()) {\n"
       "    TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND,\n"
@@ -2933,18 +2960,18 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "  }\n\n"
       "  int enc_len = p_tok.put_next_token(JSON_TOKEN_ARRAY_START, NULL);\n"
       "  for(int i = 0; i < n_elements; ++i) {\n"
-      "    int ret_val = value_elements[i].JSON_encode(%s_descr_, p_tok);\n"
+      "    int ret_val = value_elements[i].JSON_encode(*p_td.oftype_descr, p_tok);\n"
       "    if (0 > ret_val) break;\n"
       "    enc_len += ret_val;\n"
       "  }\n"
       "  enc_len += p_tok.put_next_token(JSON_TOKEN_ARRAY_END, NULL);\n"
       "  return enc_len;\n"
       "}\n\n"
-      , name, dispname, sdef->oftypedescrname);
+      , name, dispname);
     
     // JSON decode, RT1, mem. alloc. optimised
     src = mputprintf(src,
-      "int %s::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent)\n"
+      "int %s::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)\n"
       "{\n"
       "  json_token_t token = JSON_TOKEN_NONE;\n"
       "  int dec_len = p_tok.get_next_token(&token, NULL, NULL);\n"
@@ -2959,7 +2986,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "  while (true) {\n"
       "    size_t buf_pos = p_tok.get_buf_pos();\n"
       "    %s val;\n"
-      "    int ret_val = val.JSON_decode(%s_descr_, p_tok, p_silent);\n"
+      "    int ret_val = val.JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n"
       "    if (JSON_ERROR_INVALID_TOKEN == ret_val) {\n"
       "      p_tok.set_buf_pos(buf_pos);\n"
       "      break;\n"
@@ -2984,7 +3011,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
       "  }\n\n"
       "  return dec_len;\n"
       "}\n\n"
-      , name, type, sdef->oftypedescrname);
+      , name, type);
   }
   /* end of class */
   def = mputstr(def, "};\n\n");
@@ -3024,8 +3051,8 @@ void defRecordOfClass2(const struct_of_def *sdef, output_struct *output)
   char *def = NULL, *src = NULL;
   const char *name = sdef->name;
   const char *type = sdef->type;
-  boolean raw_needed = sdef->hasRaw && enable_raw();
-  boolean xer_needed = sdef->hasXer && enable_xer();
+  boolean raw_needed = force_gen_seof || (sdef->hasRaw && enable_raw());
+  boolean xer_needed = force_gen_seof || (sdef->hasXer && enable_xer());
 
   /* Class definition */
   def = mputprintf(def,
@@ -3164,12 +3191,10 @@ void defRecordOfClass2(const struct_of_def *sdef, output_struct *output)
   src = mputprintf(src,
     "Base_Type* %s::create_elem() const { return new %s; }\n"
     "const Base_Type* %s::get_unbound_elem() const { return &UNBOUND_ELEM; }\n"
-    "const TTCN_Typedescriptor_t* %s::get_descriptor() const { return &%s_descr_; }\n"
-    "const TTCN_Typedescriptor_t* %s::get_elem_descr() const { return &%s_descr_; }\n\n",
+    "const TTCN_Typedescriptor_t* %s::get_descriptor() const { return &%s_descr_; }\n",
     name, type,
     name,
-    name, name,
-    name, sdef->oftypedescrname);
+    name, name);
 
   /* helper functions called by enc/dec members of the ancestor class */
   if (raw_needed) {
@@ -3194,13 +3219,20 @@ void defRecordOfClass2(const struct_of_def *sdef, output_struct *output)
       "boolean %s::can_start(const char *name, const char *uri, "
       "XERdescriptor_t const& xd, unsigned int flavor) {\n"
       "  boolean e_xer = is_exer(flavor);\n"
+      /* if EXER and UNTAGGED, it can begin with the tag of the element,
+       * otherwise it must be the tag of the type itself,
+       * specified in the supplied parameter.
+       * If flavor contains UNTAGGED, that's a signal to go directly
+       * to the embedded type. */
+      "  if (!e_xer || !((xd.xer_bits|flavor) & UNTAGGED)) return "
+      "check_name(name, xd, e_xer) && (!e_xer || check_namespace(uri, xd));\n"
       /* a record-of with ANY-ELEMENT can start with any tag
        * :-( with some exceptions )-: */
-      "  if (e_xer && (xd.xer_bits & ANY_ELEMENT)) "
+      "  if (e_xer && (xd.oftype_descr->xer_bits & ANY_ELEMENT)) "
       , name, name
       );
 
-    if (sdef->nFollowers) {
+    if (!force_gen_seof && sdef->nFollowers) {
       size_t f;
       src = mputstr(src, "{\n");
       for (f = 0; f < sdef->nFollowers; ++f) {
@@ -3218,15 +3250,8 @@ void defRecordOfClass2(const struct_of_def *sdef, output_struct *output)
       src = mputstr(src, "return TRUE;\n");
     }
     src = mputprintf(src,
-      /* if EXER and UNTAGGED, it can begin with the tag of the element,
-       * otherwise it must be the tag of the type itself,
-       * specified in the supplied parameter.
-       * If flavor contains UNTAGGED, that's a signal to go directly
-       * to the embedded type. */
-      "  if (!e_xer || !((xd.xer_bits|flavor) & UNTAGGED)) return "
-      "check_name(name, xd, e_xer) && (!e_xer || check_namespace(uri, xd));\n"
-      "  else return %s::can_start(name, uri, %s_xer_, flavor | XER_RECOF);\n"
-      "}\n\n", sdef->type, sdef->oftypedescrname);
+      "  return %s::can_start(name, uri, *xd.oftype_descr, flavor | XER_RECOF);\n"
+      "}\n\n", sdef->type);
     def = mputprintf(def, "boolean isXmlValueList() const { return %s; }\n\n",
       sdef->xmlValueList ? "TRUE" : "FALSE");
   }
This page took 0.041009 seconds and 5 git commands to generate.