Debugger - Stage 2 (artf511247)
[deliverable/titan.core.git] / core / ASN_External.cc
index 65e7e3dd031367555f19db8d251a2b4c5affdec7..19e189520d06f05da8803a39aa97cb0748a19955 100644 (file)
@@ -1,10 +1,24 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright (c) 2000-2014 Ericsson Telecom AB
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// which accompanies this distribution, and is available at
-// http://www.eclipse.org/legal/epl-v10.html
-///////////////////////////////////////////////////////////////////////////////
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Balasko, Jeno
+ *   Baranyi, Botond
+ *   Beres, Szabolcs
+ *   Delic, Adam
+ *   Forstner, Matyas
+ *   Kovacs, Ferenc
+ *   Raduly, Csaba
+ *   Szabados, Kristof
+ *   Szabo, Bence Janos
+ *   Szabo, Janos Zoltan – initial implementation
+ *   Szalai, Gabor
+ *
+ ******************************************************************************/
 #include <string.h>
 
 #include "ASN_External.hh"
@@ -91,6 +105,7 @@ namespace { /* anonymous namespace */
     inline union_selection_type get_selection() const { return union_selection; }
 #ifdef TITAN_RUNTIME_2
     void set_param(Module_Param& /*param*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::set_param() called."); }
+    Module_Param* get_param(Module_Param_Name& param_name) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::get_param() called."); }
     void encode_text(Text_Buf& /*text_buf*/) const { TTCN_error("Internal error: EXTERNALtransfer_encoding::encode_text() called."); }
     void decode_text(Text_Buf& /*text_buf*/) { TTCN_error("Internal error: EXTERNALtransfer_encoding::decode_text() called."); }
     boolean is_bound() const { return union_selection!=UNBOUND_VALUE; }
@@ -104,7 +119,7 @@ namespace { /* anonymous namespace */
     int XER_encode(const XERdescriptor_t& p_td,
                    TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const;
     int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
-                   unsigned int flavor, embed_values_dec_struct_t*);
+                   unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*);
   private:
     boolean BER_decode_set_selection(const ASN_BER_TLV_t& p_tlv);
   public:
@@ -146,6 +161,7 @@ namespace { /* anonymous namespace */
     {return field_encoding;}
 #ifdef TITAN_RUNTIME_2
     void set_param(Module_Param& /*param*/) { TTCN_error("Internal error: EXTERNALtransfer::set_param() called."); }
+    Module_Param* get_param(Module_Param_Name& param_name) const { TTCN_error("Internal error: EXTERNALtransfer::get_param() called."); }
     void encode_text(Text_Buf& /*text_buf*/) const { TTCN_error("Internal error: EXTERNALtransfer::encode_text() called."); }
     void decode_text(Text_Buf& /*text_buf*/) { TTCN_error("Internal error: EXTERNALtransfer::decode_text() called."); }
     boolean is_bound() const { TTCN_error("Internal error: EXTERNALtransfer::is_bound() called."); }
@@ -161,7 +177,7 @@ namespace { /* anonymous namespace */
     int XER_encode(const XERdescriptor_t& p_td,
                    TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const;
     int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
-                   unsigned int flavor, embed_values_dec_struct_t*);
+                   unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*);
   };
 
   /** Transform the information from the visible format to the encoding format
@@ -197,19 +213,19 @@ namespace { /* anonymous namespace */
     field_encoding.octet__aligned()=ex.data__value();
   }
 
-  static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_descr_ = { "EXTERNALtransfer.encoding", &CHOICE_ber_, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
+  static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_descr_ = { "EXTERNALtransfer.encoding", &CHOICE_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
 
   static const ASN_Tag_t EXTERNALtransfer_encoding_single__ASN1__type_tag_[] = { { ASN_TAG_CONT, 0u } };
   static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_single__ASN1__type_ber_ = { 1u, EXTERNALtransfer_encoding_single__ASN1__type_tag_ };
-  static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_single__ASN1__type_descr_ = { "EXTERNALtransfer.encoding.single-ASN1-type", &EXTERNALtransfer_encoding_single__ASN1__type_ber_, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
+  static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_single__ASN1__type_descr_ = { "EXTERNALtransfer.encoding.single-ASN1-type", &EXTERNALtransfer_encoding_single__ASN1__type_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
 
   static const ASN_Tag_t EXTERNALtransfer_encoding_octet__aligned_tag_[] = { { ASN_TAG_CONT, 1u } };
   static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_octet__aligned_ber_ = { 1u, EXTERNALtransfer_encoding_octet__aligned_tag_ };
-  static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_octet__aligned_descr_ = { "EXTERNALtransfer.encoding.octet-aligned", &EXTERNALtransfer_encoding_octet__aligned_ber_, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
+  static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_octet__aligned_descr_ = { "EXTERNALtransfer.encoding.octet-aligned", &EXTERNALtransfer_encoding_octet__aligned_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
 
   static const ASN_Tag_t EXTERNALtransfer_encoding_arbitrary_tag_[] = { { ASN_TAG_CONT, 2u } };
   static const ASN_BERdescriptor_t EXTERNALtransfer_encoding_arbitrary_ber_ = { 1u, EXTERNALtransfer_encoding_arbitrary_tag_ };
-  static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_arbitrary_descr_ = { "EXTERNALtransfer.encoding.arbitrary", &EXTERNALtransfer_encoding_arbitrary_ber_, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
+  static const TTCN_Typedescriptor_t EXTERNALtransfer_encoding_arbitrary_descr_ = { "EXTERNALtransfer.encoding.arbitrary", &EXTERNALtransfer_encoding_arbitrary_ber_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
 
   /* Member functions of C++ classes */
 
@@ -438,7 +454,7 @@ namespace { /* anonymous namespace */
   }
 
   int EXTERNALtransfer_encoding::XER_decode(const XERdescriptor_t& p_td,
-    XmlReaderWrap& reader, unsigned int flavor, embed_values_dec_struct_t*)
+    XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
   {
     int exer  = is_exer(flavor);
     int  success = reader.Ok(), type, depth = -1;
@@ -461,15 +477,15 @@ namespace { /* anonymous namespace */
 
     switch (*name) {
     case 's': // single-ASN1-type
-      single__ASN1__type().XER_decode(EXTERNAL_encoding_singleASN_xer_, reader, flavor, 0);
+      single__ASN1__type().XER_decode(EXTERNAL_encoding_singleASN_xer_, reader, flavor, flavor2, 0);
       break;
 
     case 'o': // octet-aligned
-      octet__aligned().XER_decode(EXTERNAL_encoding_octet_aligned_xer_, reader, flavor, 0);
+      octet__aligned().XER_decode(EXTERNAL_encoding_octet_aligned_xer_, reader, flavor, flavor2, 0);
       break;
 
     case 'a': // arbitrary
-      arbitrary().XER_decode(EXTERNAL_encoding_arbitrary_xer_, reader, flavor, 0);
+      arbitrary().XER_decode(EXTERNAL_encoding_arbitrary_xer_, reader, flavor, flavor2, 0);
       break;
 
     default:
@@ -580,7 +596,7 @@ namespace { /* anonymous namespace */
   }
 
   int EXTERNALtransfer::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
-                                   unsigned int flavor, embed_values_dec_struct_t*)
+                                   unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
   {
     int exer  = is_exer(flavor);
     int success = reader.Ok(), depth = -1;
@@ -594,10 +610,10 @@ namespace { /* anonymous namespace */
       }
     }
 
-    field_direct__reference      .XER_decode(EXTERNAL_direct_reference_xer_     , reader, flavor, 0);
-    field_indirect__reference    .XER_decode(EXTERNAL_indirect_reference_xer_   , reader, flavor, 0);
-    field_data__value__descriptor.XER_decode(EXTERNAL_data_value_descriptor_xer_, reader, flavor, 0);
-    field_encoding               .XER_decode(EXTERNAL_encoding_xer_             , reader, flavor, 0);
+    field_direct__reference      .XER_decode(EXTERNAL_direct_reference_xer_     , reader, flavor, flavor2, 0);
+    field_indirect__reference    .XER_decode(EXTERNAL_indirect_reference_xer_   , reader, flavor, flavor2, 0);
+    field_data__value__descriptor.XER_decode(EXTERNAL_data_value_descriptor_xer_, reader, flavor, flavor2, 0);
+    field_encoding               .XER_decode(EXTERNAL_encoding_xer_             , reader, flavor, flavor2, 0);
 
     for (success = reader.Read(); success == 1; success = reader.Read()) {
       int type = reader.NodeType();
@@ -707,10 +723,10 @@ int EXTERNAL::XER_encode(const XERdescriptor_t& p_td,
 }
 
 int EXTERNAL::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
-  unsigned int flavor, embed_values_dec_struct_t*)
+  unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
 {
   EXTERNALtransfer xfer;
-  xfer.XER_decode(p_td, reader, flavor, 0);
+  xfer.XER_decode(p_td, reader, flavor, flavor2, 0);
   transfer(&xfer);
   return 1; // decode successful
 }
@@ -983,11 +999,15 @@ void EXTERNAL_identification::log() const
 
 void EXTERNAL_identification::set_param(Module_Param& param) {
   param.basic_check(Module_Param::BC_VALUE, "union value");
-  if (param.get_type()==Module_Param::MP_Value_List && param.get_size()==0) return;
-  if (param.get_type()!=Module_Param::MP_Assignment_List) {
+  Module_Param_Ptr mp = &param;
+  if (param.get_type() == Module_Param::MP_Reference) {
+    mp = param.get_referenced_param();
+  }
+  if (mp->get_type()==Module_Param::MP_Value_List && mp->get_size()==0) return;
+  if (mp->get_type()!=Module_Param::MP_Assignment_List) {
     param.error("union value with field name was expected");
   }
-  Module_Param* mp_last = param.get_elem(param.get_size()-1);
+  Module_Param* mp_last = mp->get_elem(mp->get_size()-1);
   if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) {
     syntaxes().set_param(*mp_last);
     return;
@@ -1015,10 +1035,54 @@ void EXTERNAL_identification::set_param(Module_Param& param) {
   mp_last->error("Field %s does not exist in type EXTERNAL.identification.", mp_last->get_id()->get_name());
 }
 
+Module_Param* EXTERNAL_identification::get_param(Module_Param_Name& param_name) const
+{
+  if (!is_bound()) {
+    return new Module_Param_Unbound();
+  }
+  Module_Param* mp_field = NULL;
+  
+  switch(get_selection()) {
+  case ALT_syntaxes:
+    mp_field = field_syntaxes->get_param(param_name);
+    mp_field->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
+    break;
+  case ALT_syntax:
+    mp_field = field_syntax->get_param(param_name);
+    mp_field->set_id(new Module_Param_FieldName(mcopystr("syntax")));
+    break;
+  case ALT_presentation__context__id:
+    mp_field = field_presentation__context__id->get_param(param_name);
+    mp_field->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
+    break;
+  case ALT_context__negotiation:
+    mp_field = field_context__negotiation->get_param(param_name);
+    mp_field->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
+    break;
+  case ALT_transfer__syntax:
+    mp_field = field_transfer__syntax->get_param(param_name);
+    mp_field->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
+    break;
+  case ALT_fixed:
+    mp_field = field_fixed->get_param(param_name);
+    mp_field->set_id(new Module_Param_FieldName(mcopystr("fixed")));
+    break;
+  default:
+    break;
+  }
+  Module_Param_Assignment_List* mp = new Module_Param_Assignment_List();
+  mp->add_elem(mp_field);
+  return mp;
+}
+
 void EXTERNAL_identification_template::set_param(Module_Param& param)
 {
   param.basic_check(Module_Param::BC_TEMPLATE, "union template");
-  switch (param.get_type()) {
+  Module_Param_Ptr mp = &param;
+  if (param.get_type() == Module_Param::MP_Reference) {
+    mp = param.get_referenced_param();
+  }
+  switch (mp->get_type()) {
   case Module_Param::MP_Omit:
     *this = OMIT_VALUE;
     break;
@@ -1029,18 +1093,21 @@ void EXTERNAL_identification_template::set_param(Module_Param& param)
     *this = ANY_OR_OMIT;
     break;
   case Module_Param::MP_List_Template:
-  case Module_Param::MP_ComplementList_Template:
-    set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, param.get_size());
-    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
-      list_item(p_i).set_param(*param.get_elem(p_i));
-    }
-    break;
+  case Module_Param::MP_ComplementList_Template: {
+    EXTERNAL_identification_template temp;
+    temp.set_type(mp->get_type() == Module_Param::MP_List_Template ?
+      VALUE_LIST : COMPLEMENTED_LIST, mp->get_size());
+    for (size_t i=0; i<mp->get_size(); i++) {
+      temp.list_item(i).set_param(*mp->get_elem(i));
+    }
+    *this = temp;
+    break; }
   case Module_Param::MP_Value_List:
-    if (param.get_size()==0) break;
+    if (mp->get_size()==0) break;
     param.type_error("union template", "EXTERNAL.identification");
     break;
   case Module_Param::MP_Assignment_List: {
-    Module_Param* mp_last = param.get_elem(param.get_size()-1);
+    Module_Param* mp_last = mp->get_elem(mp->get_size()-1);
     if (!strcmp(mp_last->get_id()->get_name(), "syntaxes")) {
       syntaxes().set_param(*mp_last);
       break;
@@ -1070,7 +1137,77 @@ void EXTERNAL_identification_template::set_param(Module_Param& param)
   default:
     param.type_error("union template", "EXTERNAL.identification");
   }
-  is_ifpresent = param.get_ifpresent();
+  is_ifpresent = param.get_ifpresent() || mp->get_ifpresent();
+}
+
+Module_Param* EXTERNAL_identification_template::get_param(Module_Param_Name& param_name) const
+{
+  Module_Param* mp = NULL;
+  switch (template_selection) {
+  case UNINITIALIZED_TEMPLATE:
+    mp = new Module_Param_Unbound();
+    break;
+  case OMIT_VALUE:
+    mp = new Module_Param_Omit();
+    break;
+  case ANY_VALUE:
+    mp = new Module_Param_Any();
+    break;
+  case ANY_OR_OMIT:
+    mp = new Module_Param_AnyOrNone();
+    break;
+  case SPECIFIC_VALUE: {
+    Module_Param* mp_field = NULL;
+    switch(single_value.union_selection) {
+    case EXTERNAL_identification::ALT_syntaxes:
+      mp_field = single_value.field_syntaxes->get_param(param_name);
+      mp_field->set_id(new Module_Param_FieldName(mcopystr("syntaxes")));
+      break;
+    case EXTERNAL_identification::ALT_syntax:
+      mp_field = single_value.field_syntax->get_param(param_name);
+      mp_field->set_id(new Module_Param_FieldName(mcopystr("syntax")));
+      break;
+    case EXTERNAL_identification::ALT_presentation__context__id:
+      mp_field = single_value.field_presentation__context__id->get_param(param_name);
+      mp_field->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
+      break;
+    case EXTERNAL_identification::ALT_context__negotiation:
+      mp_field = single_value.field_context__negotiation->get_param(param_name);
+      mp_field->set_id(new Module_Param_FieldName(mcopystr("context_negotiation")));
+      break;
+    case EXTERNAL_identification::ALT_transfer__syntax:
+      mp_field = single_value.field_transfer__syntax->get_param(param_name);
+      mp_field->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
+      break;
+    case EXTERNAL_identification::ALT_fixed:
+      mp_field = single_value.field_fixed->get_param(param_name);
+      mp_field->set_id(new Module_Param_FieldName(mcopystr("fixed")));
+      break;
+    default:
+      break;
+    }
+    mp = new Module_Param_Assignment_List();
+    mp->add_elem(mp_field);
+    break; }
+  case VALUE_LIST:
+  case COMPLEMENTED_LIST: {
+    if (template_selection == VALUE_LIST) {
+      mp = new Module_Param_List_Template();
+    }
+    else {
+      mp = new Module_Param_ComplementList_Template();
+    }
+    for (size_t i = 0; i < value_list.n_values; ++i) {
+      mp->add_elem(value_list.list_value[i].get_param(param_name));
+    }
+    break; }
+  default:
+    break;
+  }
+  if (is_ifpresent) {
+    mp->set_ifpresent();
+  }
+  return mp;
 }
 
 void EXTERNAL_identification::encode_text(Text_Buf& text_buf) const
@@ -1317,7 +1454,8 @@ EXTERNAL_identification_template& EXTERNAL_identification_template::operator=(co
   return *this;
 }
 
-boolean EXTERNAL_identification_template::match(const EXTERNAL_identification& other_value) const
+boolean EXTERNAL_identification_template::match(const EXTERNAL_identification& other_value,
+                                                boolean /* legacy */) const
 {
   switch (template_selection) {
   case ANY_VALUE:
@@ -1615,7 +1753,8 @@ void EXTERNAL_identification_template::log() const
   log_ifpresent();
 }
 
-void EXTERNAL_identification_template::log_match(const EXTERNAL_identification& match_value) const
+void EXTERNAL_identification_template::log_match(const EXTERNAL_identification& match_value,
+                                                 boolean /* legacy */) const
 {
   if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
     if(match(match_value)){
@@ -1801,13 +1940,13 @@ void EXTERNAL_identification_template::decode_text(Text_Buf& text_buf)
   }
 }
 
-boolean EXTERNAL_identification_template::is_present() const
+boolean EXTERNAL_identification_template::is_present(boolean legacy /* = FALSE */) const
 {
   if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
-  return !match_omit();
+  return !match_omit(legacy);
 }
 
-boolean EXTERNAL_identification_template::match_omit() const
+boolean EXTERNAL_identification_template::match_omit(boolean legacy /* = FALSE */) const
 {
   if (is_ifpresent) return TRUE;
   switch (template_selection) {
@@ -1816,10 +1955,12 @@ boolean EXTERNAL_identification_template::match_omit() const
     return TRUE;
   case VALUE_LIST:
   case COMPLEMENTED_LIST:
-    for (unsigned int i=0; i<value_list.n_values; i++)
-      if (value_list.list_value[i].match_omit())
-        return template_selection==VALUE_LIST;
-    return template_selection==COMPLEMENTED_LIST;
+    if (legacy) {
+      for (unsigned int i=0; i<value_list.n_values; i++)
+        if (value_list.list_value[i].match_omit())
+          return template_selection==VALUE_LIST;
+      return template_selection==COMPLEMENTED_LIST;
+    } // else fall through
   default:
     return FALSE;
   }
@@ -1827,7 +1968,8 @@ boolean EXTERNAL_identification_template::match_omit() const
 }
 
 #ifndef TITAN_RUNTIME_2
-void EXTERNAL_identification_template::check_restriction(template_res t_res, const char* t_name) const
+void EXTERNAL_identification_template::check_restriction(template_res t_res, const char* t_name,
+                                                         boolean legacy /* = FALSE */) const
 {
   if (template_selection==UNINITIALIZED_TEMPLATE) return;
   switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
@@ -1839,7 +1981,7 @@ void EXTERNAL_identification_template::check_restriction(template_res t_res, con
         template_selection==SPECIFIC_VALUE)) return;
     break;
   case TR_PRESENT:
-    if (!match_omit()) return;
+    if (!match_omit(legacy)) return;
     break;
   default:
     return;
@@ -1904,34 +2046,38 @@ void EXTERNAL_identification_syntaxes::clean_up()
 void EXTERNAL_identification_syntaxes::set_param(Module_Param& param)
 {
   param.basic_check(Module_Param::BC_VALUE, "record value");
-  switch (param.get_type()) {
+  Module_Param_Ptr mp = &param;
+  if (param.get_type() == Module_Param::MP_Reference) {
+    mp = param.get_referenced_param();
+  }
+  switch (mp->get_type()) {
   case Module_Param::MP_Value_List:
-    if (param.get_size()==0) return;
-    if (2!=param.get_size()) {
-      param.error("record value of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)param.get_size());
+    if (mp->get_size()==0) return;
+    if (2!=mp->get_size()) {
+      param.error("record value of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)mp->get_size());
     }
-    if (param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) abstract().set_param(*param.get_elem(0));
-    if (param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer().set_param(*param.get_elem(1));
+    if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) abstract().set_param(*mp->get_elem(0));
+    if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer().set_param(*mp->get_elem(1));
     break;
   case Module_Param::MP_Assignment_List: {
-    Vector<bool> value_used(param.get_size());
-    value_used.resize(param.get_size(), false);
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    Vector<bool> value_used(mp->get_size());
+    value_used.resize(mp->get_size(), false);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "abstract")) {
         abstract().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "transfer")) {
         transfer().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
-      param.get_elem(val_idx)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", param.get_elem(val_idx)->get_id()->get_name());
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) {
+      mp->get_elem(val_idx)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", mp->get_elem(val_idx)->get_id()->get_name());
       break;
     }
   } break;
@@ -1940,10 +2086,46 @@ void EXTERNAL_identification_syntaxes::set_param(Module_Param& param)
   }
 }
 
+Module_Param* EXTERNAL_identification_syntaxes::get_param(Module_Param_Name& param_name) const
+{
+  if (!is_bound()) {
+    return new Module_Param_Unbound();
+  }
+  Module_Param* mp_field_abstract = field_abstract.get_param(param_name);
+  mp_field_abstract->set_id(new Module_Param_FieldName(mcopystr("abstract")));
+  Module_Param* mp_field_transfer = field_transfer.get_param(param_name);
+  mp_field_transfer->set_id(new Module_Param_FieldName(mcopystr("transfer")));
+  Module_Param_Assignment_List* mp = new Module_Param_Assignment_List();
+  mp->add_elem(mp_field_abstract);
+  mp->add_elem(mp_field_transfer);
+  return mp;
+}
+
+void EXTERNAL_identification_syntaxes::encode_text(Text_Buf& text_buf) const
+{
+  field_abstract.encode_text(text_buf);
+  field_transfer.encode_text(text_buf);
+}
+
+void EXTERNAL_identification_syntaxes::decode_text(Text_Buf& text_buf)
+{
+  field_abstract.decode_text(text_buf);
+  field_transfer.decode_text(text_buf);
+}
+
+struct EXTERNAL_identification_syntaxes_template::single_value_struct {
+  OBJID_template field_abstract;
+  OBJID_template field_transfer;
+};
+
 void EXTERNAL_identification_syntaxes_template::set_param(Module_Param& param)
 {
   param.basic_check(Module_Param::BC_TEMPLATE, "record template");
-  switch (param.get_type()) {
+  Module_Param_Ptr mp = &param;
+  if (param.get_type() == Module_Param::MP_Reference) {
+    mp = param.get_referenced_param();
+  }
+  switch (mp->get_type()) {
   case Module_Param::MP_Omit:
     *this = OMIT_VALUE;
     break;
@@ -1954,65 +2136,97 @@ void EXTERNAL_identification_syntaxes_template::set_param(Module_Param& param)
     *this = ANY_OR_OMIT;
     break;
   case Module_Param::MP_List_Template:
-  case Module_Param::MP_ComplementList_Template:
-    set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, param.get_size());
-    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
-      list_item(p_i).set_param(*param.get_elem(p_i));
-    }
-    break;
+  case Module_Param::MP_ComplementList_Template: {
+    EXTERNAL_identification_syntaxes_template temp;
+    temp.set_type(mp->get_type() == Module_Param::MP_List_Template ?
+      VALUE_LIST : COMPLEMENTED_LIST, mp->get_size());
+    for (size_t i=0; i<mp->get_size(); i++) {
+      temp.list_item(i).set_param(*mp->get_elem(i));
+    }
+    *this = temp;
+    break; }
   case Module_Param::MP_Value_List:
-    if (param.get_size()==0) break;
-    if (2!=param.get_size()) {
-      param.error("record template of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)param.get_size());
+    if (mp->get_size()==0) break;
+    if (2!=mp->get_size()) {
+      param.error("record template of type EXTERNAL.identification.syntaxes has 2 fields but list value has %d fields", (int)mp->get_size());
     }
-    if (param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) abstract().set_param(*param.get_elem(0));
-    if (param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer().set_param(*param.get_elem(1));
+    if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) abstract().set_param(*mp->get_elem(0));
+    if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer().set_param(*mp->get_elem(1));
     break;
   case Module_Param::MP_Assignment_List: {
-    Vector<bool> value_used(param.get_size());
-    value_used.resize(param.get_size(), false);
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    Vector<bool> value_used(mp->get_size());
+    value_used.resize(mp->get_size(), false);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "abstract")) {
         abstract().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "transfer")) {
         transfer().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
-      param.get_elem(val_idx)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", param.get_elem(val_idx)->get_id()->get_name());
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) {
+      mp->get_elem(val_idx)->error("Non existent field name in type EXTERNAL.identification.syntaxes: %s", mp->get_elem(val_idx)->get_id()->get_name());
       break;
     }
   } break;
   default:
     param.type_error("record template", "EXTERNAL.identification.syntaxes");
   }
-  is_ifpresent = param.get_ifpresent();
+  is_ifpresent = param.get_ifpresent() || mp->get_ifpresent();
 }
 
-void EXTERNAL_identification_syntaxes::encode_text(Text_Buf& text_buf) const
+Module_Param* EXTERNAL_identification_syntaxes_template::get_param(Module_Param_Name& param_name) const
 {
-  field_abstract.encode_text(text_buf);
-  field_transfer.encode_text(text_buf);
-}
-
-void EXTERNAL_identification_syntaxes::decode_text(Text_Buf& text_buf)
-{
-  field_abstract.decode_text(text_buf);
-  field_transfer.decode_text(text_buf);
+  Module_Param* mp = NULL;
+  switch (template_selection) {
+  case UNINITIALIZED_TEMPLATE:
+    mp = new Module_Param_Unbound();
+    break;
+  case OMIT_VALUE:
+    mp = new Module_Param_Omit();
+    break;
+  case ANY_VALUE:
+    mp = new Module_Param_Any();
+    break;
+  case ANY_OR_OMIT:
+    mp = new Module_Param_AnyOrNone();
+    break;
+  case SPECIFIC_VALUE: {
+    Module_Param* mp_field_abstract = single_value->field_abstract.get_param(param_name);
+    mp_field_abstract->set_id(new Module_Param_FieldName(mcopystr("abstract")));
+    Module_Param* mp_field_transfer = single_value->field_transfer.get_param(param_name);
+    mp_field_transfer->set_id(new Module_Param_FieldName(mcopystr("transfer")));
+    mp = new Module_Param_Assignment_List();
+    mp->add_elem(mp_field_abstract);
+    mp->add_elem(mp_field_transfer);
+    break; }
+  case VALUE_LIST:
+  case COMPLEMENTED_LIST: {
+    if (template_selection == VALUE_LIST) {
+      mp = new Module_Param_List_Template();
+    }
+    else {
+      mp = new Module_Param_ComplementList_Template();
+    }
+    for (size_t i = 0; i < value_list.n_values; ++i) {
+      mp->add_elem(value_list.list_value[i].get_param(param_name));
+    }
+    break; }
+  default:
+    break;
+  }
+  if (is_ifpresent) {
+    mp->set_ifpresent();
+  }
+  return mp;
 }
 
-struct EXTERNAL_identification_syntaxes_template::single_value_struct {
-  OBJID_template field_abstract;
-  OBJID_template field_transfer;
-};
-
 void EXTERNAL_identification_syntaxes_template::clean_up()
 {
   switch (template_selection) {
@@ -2154,7 +2368,8 @@ EXTERNAL_identification_syntaxes_template& EXTERNAL_identification_syntaxes_temp
   return *this;
 }
 
-boolean EXTERNAL_identification_syntaxes_template::match(const EXTERNAL_identification_syntaxes& other_value) const
+boolean EXTERNAL_identification_syntaxes_template::match(const EXTERNAL_identification_syntaxes& other_value,
+                                                         boolean /* legacy */) const
 {
   switch (template_selection) {
   case ANY_VALUE:
@@ -2296,7 +2511,8 @@ void EXTERNAL_identification_syntaxes_template::log() const
   log_ifpresent();
 }
 
-void EXTERNAL_identification_syntaxes_template::log_match(const EXTERNAL_identification_syntaxes& match_value) const
+void EXTERNAL_identification_syntaxes_template::log_match(const EXTERNAL_identification_syntaxes& match_value,
+                                                          boolean /* legacy */) const
 {
   if (template_selection == SPECIFIC_VALUE) {
     TTCN_Logger::log_event_str("{ abstract := ");
@@ -2362,13 +2578,13 @@ void EXTERNAL_identification_syntaxes_template::decode_text(Text_Buf& text_buf)
   }
 }
 
-boolean EXTERNAL_identification_syntaxes_template::is_present() const
+boolean EXTERNAL_identification_syntaxes_template::is_present(boolean legacy /* = FALSE */) const
 {
   if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
-  return !match_omit();
+  return !match_omit(legacy);
 }
 
-boolean EXTERNAL_identification_syntaxes_template::match_omit() const
+boolean EXTERNAL_identification_syntaxes_template::match_omit(boolean legacy /* = FALSE */) const
 {
   if (is_ifpresent) return TRUE;
   switch (template_selection) {
@@ -2377,10 +2593,12 @@ boolean EXTERNAL_identification_syntaxes_template::match_omit() const
     return TRUE;
   case VALUE_LIST:
   case COMPLEMENTED_LIST:
-    for (unsigned int i=0; i<value_list.n_values; i++)
-      if (value_list.list_value[i].match_omit())
-        return template_selection==VALUE_LIST;
-    return template_selection==COMPLEMENTED_LIST;
+    if (legacy) {
+      for (unsigned int i=0; i<value_list.n_values; i++)
+        if (value_list.list_value[i].match_omit())
+          return template_selection==VALUE_LIST;
+      return template_selection==COMPLEMENTED_LIST;
+    } // else fall through
   default:
     return FALSE;
   }
@@ -2388,7 +2606,8 @@ boolean EXTERNAL_identification_syntaxes_template::match_omit() const
 }
 
 #ifndef TITAN_RUNTIME_2
-void EXTERNAL_identification_syntaxes_template::check_restriction(template_res t_res, const char* t_name) const
+void EXTERNAL_identification_syntaxes_template::check_restriction(template_res t_res, const char* t_name,
+                                                                  boolean legacy /* = FALSE */) const
 {
   if (template_selection==UNINITIALIZED_TEMPLATE) return;
   switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
@@ -2400,7 +2619,7 @@ void EXTERNAL_identification_syntaxes_template::check_restriction(template_res t
         template_selection==SPECIFIC_VALUE)) return;
     break;
   case TR_PRESENT:
-    if (!match_omit()) return;
+    if (!match_omit(legacy)) return;
     break;
   default:
     return;
@@ -2465,34 +2684,38 @@ void EXTERNAL_identification_context__negotiation::clean_up()
 void EXTERNAL_identification_context__negotiation::set_param(Module_Param& param)
 {
   param.basic_check(Module_Param::BC_VALUE, "record value");
-  switch (param.get_type()) {
+  Module_Param_Ptr mp = &param;
+  if (param.get_type() == Module_Param::MP_Reference) {
+    mp = param.get_referenced_param();
+  }
+  switch (mp->get_type()) {
   case Module_Param::MP_Value_List:
-    if (param.get_size()==0) return;
-    if (2!=param.get_size()) {
-      param.error("record value of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)param.get_size());
+    if (mp->get_size()==0) return;
+    if (2!=mp->get_size()) {
+      param.error("record value of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp->get_size());
     }
-    if (param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) presentation__context__id().set_param(*param.get_elem(0));
-    if (param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer__syntax().set_param(*param.get_elem(1));
+    if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) presentation__context__id().set_param(*mp->get_elem(0));
+    if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer__syntax().set_param(*mp->get_elem(1));
     break;
   case Module_Param::MP_Assignment_List: {
-    Vector<bool> value_used(param.get_size());
-    value_used.resize(param.get_size(), false);
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    Vector<bool> value_used(mp->get_size());
+    value_used.resize(mp->get_size(), false);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "presentation_context_id")) {
         presentation__context__id().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "transfer_syntax")) {
         transfer__syntax().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
-      param.get_elem(val_idx)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", param.get_elem(val_idx)->get_id()->get_name());
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) {
+      mp->get_elem(val_idx)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", mp->get_elem(val_idx)->get_id()->get_name());
       break;
     }
   } break;
@@ -2501,10 +2724,46 @@ void EXTERNAL_identification_context__negotiation::set_param(Module_Param& param
   }
 }
 
+Module_Param* EXTERNAL_identification_context__negotiation::get_param(Module_Param_Name& param_name) const
+{
+  if (!is_bound()) {
+    return new Module_Param_Unbound();
+  }
+  Module_Param* mp_field_presentation_context_id = field_presentation__context__id.get_param(param_name);
+  mp_field_presentation_context_id->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
+  Module_Param* mp_field_transfer_syntax = field_transfer__syntax.get_param(param_name);
+  mp_field_transfer_syntax->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
+  Module_Param_Assignment_List* mp = new Module_Param_Assignment_List();
+  mp->add_elem(mp_field_presentation_context_id);
+  mp->add_elem(mp_field_transfer_syntax);
+  return mp;
+}
+
+void EXTERNAL_identification_context__negotiation::encode_text(Text_Buf& text_buf) const
+{
+  field_presentation__context__id.encode_text(text_buf);
+  field_transfer__syntax.encode_text(text_buf);
+}
+
+void EXTERNAL_identification_context__negotiation::decode_text(Text_Buf& text_buf)
+{
+  field_presentation__context__id.decode_text(text_buf);
+  field_transfer__syntax.decode_text(text_buf);
+}
+
+struct EXTERNAL_identification_context__negotiation_template::single_value_struct {
+  INTEGER_template field_presentation__context__id;
+  OBJID_template field_transfer__syntax;
+};
+
 void EXTERNAL_identification_context__negotiation_template::set_param(Module_Param& param)
 {
   param.basic_check(Module_Param::BC_TEMPLATE, "record template");
-  switch (param.get_type()) {
+  Module_Param_Ptr mp = &param;
+  if (param.get_type() == Module_Param::MP_Reference) {
+    mp = param.get_referenced_param();
+  }
+  switch (mp->get_type()) {
   case Module_Param::MP_Omit:
     *this = OMIT_VALUE;
     break;
@@ -2515,65 +2774,97 @@ void EXTERNAL_identification_context__negotiation_template::set_param(Module_Par
     *this = ANY_OR_OMIT;
     break;
   case Module_Param::MP_List_Template:
-  case Module_Param::MP_ComplementList_Template:
-    set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, param.get_size());
-    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
-      list_item(p_i).set_param(*param.get_elem(p_i));
-    }
-    break;
+  case Module_Param::MP_ComplementList_Template: {
+    EXTERNAL_identification_context__negotiation_template temp;
+    temp.set_type(mp->get_type() == Module_Param::MP_List_Template ?
+      VALUE_LIST : COMPLEMENTED_LIST, mp->get_size());
+    for (size_t i=0; i<mp->get_size(); i++) {
+      temp.list_item(i).set_param(*mp->get_elem(i));
+    }
+    *this = temp;
+    break; }
   case Module_Param::MP_Value_List:
-    if (param.get_size()==0) break;
-    if (2!=param.get_size()) {
-      param.error("record template of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)param.get_size());
+    if (mp->get_size()==0) break;
+    if (2!=mp->get_size()) {
+      param.error("record template of type EXTERNAL.identification.context-negotiation has 2 fields but list value has %d fields", (int)mp->get_size());
     }
-    if (param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) presentation__context__id().set_param(*param.get_elem(0));
-    if (param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer__syntax().set_param(*param.get_elem(1));
+    if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) presentation__context__id().set_param(*mp->get_elem(0));
+    if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) transfer__syntax().set_param(*mp->get_elem(1));
     break;
   case Module_Param::MP_Assignment_List: {
-    Vector<bool> value_used(param.get_size());
-    value_used.resize(param.get_size(), false);
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    Vector<bool> value_used(mp->get_size());
+    value_used.resize(mp->get_size(), false);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "presentation_context_id")) {
         presentation__context__id().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "transfer_syntax")) {
         transfer__syntax().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
-      param.get_elem(val_idx)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", param.get_elem(val_idx)->get_id()->get_name());
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) {
+      mp->get_elem(val_idx)->error("Non existent field name in type EXTERNAL.identification.context-negotiation: %s", mp->get_elem(val_idx)->get_id()->get_name());
       break;
     }
   } break;
   default:
     param.type_error("record template", "EXTERNAL.identification.context-negotiation");
   }
-  is_ifpresent = param.get_ifpresent();
+  is_ifpresent = param.get_ifpresent() || mp->get_ifpresent();
 }
 
-void EXTERNAL_identification_context__negotiation::encode_text(Text_Buf& text_buf) const
+Module_Param* EXTERNAL_identification_context__negotiation_template::get_param(Module_Param_Name& param_name) const
 {
-  field_presentation__context__id.encode_text(text_buf);
-  field_transfer__syntax.encode_text(text_buf);
-}
-
-void EXTERNAL_identification_context__negotiation::decode_text(Text_Buf& text_buf)
-{
-  field_presentation__context__id.decode_text(text_buf);
-  field_transfer__syntax.decode_text(text_buf);
+  Module_Param* mp = NULL;
+  switch (template_selection) {
+  case UNINITIALIZED_TEMPLATE:
+    mp = new Module_Param_Unbound();
+    break;
+  case OMIT_VALUE:
+    mp = new Module_Param_Omit();
+    break;
+  case ANY_VALUE:
+    mp = new Module_Param_Any();
+    break;
+  case ANY_OR_OMIT:
+    mp = new Module_Param_AnyOrNone();
+    break;
+  case SPECIFIC_VALUE: {
+    Module_Param* mp_field_presentation_context_id = single_value->field_presentation__context__id.get_param(param_name);
+    mp_field_presentation_context_id->set_id(new Module_Param_FieldName(mcopystr("presentation_context_id")));
+    Module_Param* mp_field_transfer_syntax = single_value->field_transfer__syntax.get_param(param_name);
+    mp_field_transfer_syntax->set_id(new Module_Param_FieldName(mcopystr("transfer_syntax")));
+    mp = new Module_Param_Assignment_List();
+    mp->add_elem(mp_field_presentation_context_id);
+    mp->add_elem(mp_field_transfer_syntax);
+    break; }
+  case VALUE_LIST:
+  case COMPLEMENTED_LIST: {
+    if (template_selection == VALUE_LIST) {
+      mp = new Module_Param_List_Template();
+    }
+    else {
+      mp = new Module_Param_ComplementList_Template();
+    }
+    for (size_t i = 0; i < value_list.n_values; ++i) {
+      mp->add_elem(value_list.list_value[i].get_param(param_name));
+    }
+    break; }
+  default:
+    break;
+  }
+  if (is_ifpresent) {
+    mp->set_ifpresent();
+  }
+  return mp;
 }
 
-struct EXTERNAL_identification_context__negotiation_template::single_value_struct {
-  INTEGER_template field_presentation__context__id;
-  OBJID_template field_transfer__syntax;
-};
-
 void EXTERNAL_identification_context__negotiation_template::clean_up()
 {
   switch (template_selection) {
@@ -2715,7 +3006,8 @@ EXTERNAL_identification_context__negotiation_template& EXTERNAL_identification_c
   return *this;
 }
 
-boolean EXTERNAL_identification_context__negotiation_template::match(const EXTERNAL_identification_context__negotiation& other_value) const
+boolean EXTERNAL_identification_context__negotiation_template::match(const EXTERNAL_identification_context__negotiation& other_value,
+                                                                     boolean /* legacy */) const
 {
   switch (template_selection) {
   case ANY_VALUE:
@@ -2857,7 +3149,8 @@ void EXTERNAL_identification_context__negotiation_template::log() const
   log_ifpresent();
 }
 
-void EXTERNAL_identification_context__negotiation_template::log_match(const EXTERNAL_identification_context__negotiation& match_value) const
+void EXTERNAL_identification_context__negotiation_template::log_match(const EXTERNAL_identification_context__negotiation& match_value,
+                                                                      boolean /* legacy */) const
 {
   if (template_selection == SPECIFIC_VALUE) {
     TTCN_Logger::log_event_str("{ presentation_context_id := ");
@@ -2923,13 +3216,13 @@ void EXTERNAL_identification_context__negotiation_template::decode_text(Text_Buf
   }
 }
 
-boolean EXTERNAL_identification_context__negotiation_template::is_present() const
+boolean EXTERNAL_identification_context__negotiation_template::is_present(boolean legacy /* = FALSE */) const
 {
   if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
-  return !match_omit();
+  return !match_omit(legacy);
 }
 
-boolean EXTERNAL_identification_context__negotiation_template::match_omit() const
+boolean EXTERNAL_identification_context__negotiation_template::match_omit(boolean legacy /* = FALSE */) const
 {
   if (is_ifpresent) return TRUE;
   switch (template_selection) {
@@ -2938,10 +3231,12 @@ boolean EXTERNAL_identification_context__negotiation_template::match_omit() cons
     return TRUE;
   case VALUE_LIST:
   case COMPLEMENTED_LIST:
-    for (unsigned int i=0; i<value_list.n_values; i++)
-      if (value_list.list_value[i].match_omit())
-        return template_selection==VALUE_LIST;
-    return template_selection==COMPLEMENTED_LIST;
+    if (legacy) {
+      for (unsigned int i=0; i<value_list.n_values; i++)
+        if (value_list.list_value[i].match_omit())
+          return template_selection==VALUE_LIST;
+      return template_selection==COMPLEMENTED_LIST;
+    } // else fall through
   default:
     return FALSE;
   }
@@ -2949,7 +3244,8 @@ boolean EXTERNAL_identification_context__negotiation_template::match_omit() cons
 }
 
 #ifndef TITAN_RUNTIME_2
-void EXTERNAL_identification_context__negotiation_template::check_restriction(template_res t_res, const char* t_name) const
+void EXTERNAL_identification_context__negotiation_template::check_restriction(template_res t_res, const char* t_name,
+                                                                              boolean legacy /* = FALSE */) const
 {
   if (template_selection==UNINITIALIZED_TEMPLATE) return;
   switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
@@ -2961,7 +3257,7 @@ void EXTERNAL_identification_context__negotiation_template::check_restriction(te
         template_selection==SPECIFIC_VALUE)) return;
     break;
   case TR_PRESENT:
-    if (!match_omit()) return;
+    if (!match_omit(legacy)) return;
     break;
   default:
     return;
@@ -3035,42 +3331,46 @@ void EXTERNAL::clean_up()
 void EXTERNAL::set_param(Module_Param& param)
 {
   param.basic_check(Module_Param::BC_VALUE, "record value");
-  switch (param.get_type()) {
+  Module_Param_Ptr mp = &param;
+  if (param.get_type() == Module_Param::MP_Reference) {
+    mp = param.get_referenced_param();
+  }
+  switch (mp->get_type()) {
   case Module_Param::MP_Value_List:
-    if (param.get_size()==0) return;
-    if (3!=param.get_size()) {
-      param.error("record value of type EXTERNAL has 3 fields but list value has %d fields", (int)param.get_size());
+    if (mp->get_size()==0) return;
+    if (3!=mp->get_size()) {
+      param.error("record value of type EXTERNAL has 3 fields but list value has %d fields", (int)mp->get_size());
     }
-    if (param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) identification().set_param(*param.get_elem(0));
-    if (param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) data__value__descriptor().set_param(*param.get_elem(1));
-    if (param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) data__value().set_param(*param.get_elem(2));
+    if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) identification().set_param(*mp->get_elem(0));
+    if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) data__value__descriptor().set_param(*mp->get_elem(1));
+    if (mp->get_elem(2)->get_type()!=Module_Param::MP_NotUsed) data__value().set_param(*mp->get_elem(2));
     break;
   case Module_Param::MP_Assignment_List: {
-    Vector<bool> value_used(param.get_size());
-    value_used.resize(param.get_size(), false);
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    Vector<bool> value_used(mp->get_size());
+    value_used.resize(mp->get_size(), false);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "identification")) {
         identification().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "data_value_descriptor")) {
         data__value__descriptor().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
       if (!strcmp(curr_param->get_id()->get_name(), "data_value")) {
         data__value().set_param(*curr_param);
         value_used[val_idx]=true;
       }
     }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
-      param.get_elem(val_idx)->error("Non existent field name in type EXTERNAL: %s", param.get_elem(val_idx)->get_id()->get_name());
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) {
+      mp->get_elem(val_idx)->error("Non existent field name in type EXTERNAL: %s", mp->get_elem(val_idx)->get_id()->get_name());
       break;
     }
   } break;
@@ -3079,68 +3379,22 @@ void EXTERNAL::set_param(Module_Param& param)
   }
 }
 
-void EXTERNAL_template::set_param(Module_Param& param)
+Module_Param* EXTERNAL::get_param(Module_Param_Name& param_name) const
 {
-  param.basic_check(Module_Param::BC_TEMPLATE, "record template");
-  switch (param.get_type()) {
-  case Module_Param::MP_Omit:
-    *this = OMIT_VALUE;
-    break;
-  case Module_Param::MP_Any:
-    *this = ANY_VALUE;
-    break;
-  case Module_Param::MP_AnyOrNone:
-    *this = ANY_OR_OMIT;
-    break;
-  case Module_Param::MP_List_Template:
-  case Module_Param::MP_ComplementList_Template:
-    set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, param.get_size());
-    for (size_t p_i=0; p_i<param.get_size(); p_i++) {
-      list_item(p_i).set_param(*param.get_elem(p_i));
-    }
-    break;
-  case Module_Param::MP_Value_List:
-    if (param.get_size()==0) break;
-    if (3!=param.get_size()) {
-      param.error("record template of type EXTERNAL has 3 fields but list value has %d fields", (int)param.get_size());
-    }
-    if (param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) identification().set_param(*param.get_elem(0));
-    if (param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) data__value__descriptor().set_param(*param.get_elem(1));
-    if (param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) data__value().set_param(*param.get_elem(2));
-    break;
-  case Module_Param::MP_Assignment_List: {
-    Vector<bool> value_used(param.get_size());
-    value_used.resize(param.get_size(), false);
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
-      if (!strcmp(curr_param->get_id()->get_name(), "identification")) {
-        identification().set_param(*curr_param);
-        value_used[val_idx]=true;
-      }
-    }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
-      if (!strcmp(curr_param->get_id()->get_name(), "data_value_descriptor")) {
-        data__value__descriptor().set_param(*curr_param);
-        value_used[val_idx]=true;
-      }
-    }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
-      Module_Param* const curr_param = param.get_elem(val_idx);
-      if (!strcmp(curr_param->get_id()->get_name(), "data_value")) {
-        data__value().set_param(*curr_param);
-        value_used[val_idx]=true;
-      }
-    }
-    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
-      param.get_elem(val_idx)->error("Non existent field name in type EXTERNAL: %s", param.get_elem(val_idx)->get_id()->get_name());
-      break;
-    }
-  } break;
-  default:
-    param.type_error("record template", "EXTERNAL");
+  if (!is_bound()) {
+    return new Module_Param_Unbound();
   }
-  is_ifpresent = param.get_ifpresent();
+  Module_Param* mp_field_identification = field_identification.get_param(param_name);
+  mp_field_identification->set_id(new Module_Param_FieldName(mcopystr("identification")));
+  Module_Param* mp_field_data_value_descriptor = field_data__value__descriptor.get_param(param_name);
+  mp_field_data_value_descriptor->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
+  Module_Param* mp_field_data_value = field_data__value.get_param(param_name);
+  mp_field_data_value->set_id(new Module_Param_FieldName(mcopystr("data_value")));
+  Module_Param_Assignment_List* mp = new Module_Param_Assignment_List();
+  mp->add_elem(mp_field_identification);
+  mp->add_elem(mp_field_data_value_descriptor);
+  mp->add_elem(mp_field_data_value);
+  return mp;
 }
 
 void EXTERNAL::encode_text(Text_Buf& text_buf) const
@@ -3229,7 +3483,7 @@ void EXTERNAL::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTC
       if (type==XML_READER_TYPE_ELEMENT)
        break;
     }
-    XER_decode(*p_td.xer, reader, XER_coding, 0);
+    XER_decode(*p_td.xer, reader, XER_coding, XER_NONE, 0);
     size_t bytes = reader.ByteConsumed();
     p_buf.set_pos(bytes);
     break;}
@@ -3250,6 +3504,126 @@ struct EXTERNAL_template::single_value_struct {
   OCTETSTRING_template field_data__value;
 };
 
+void EXTERNAL_template::set_param(Module_Param& param)
+{
+  param.basic_check(Module_Param::BC_TEMPLATE, "record template");
+  Module_Param_Ptr mp = &param;
+  if (param.get_type() == Module_Param::MP_Reference) {
+    mp = param.get_referenced_param();
+  }
+  switch (mp->get_type()) {
+  case Module_Param::MP_Omit:
+    *this = OMIT_VALUE;
+    break;
+  case Module_Param::MP_Any:
+    *this = ANY_VALUE;
+    break;
+  case Module_Param::MP_AnyOrNone:
+    *this = ANY_OR_OMIT;
+    break;
+  case Module_Param::MP_List_Template:
+  case Module_Param::MP_ComplementList_Template: {
+    EXTERNAL_template temp;
+    temp.set_type(mp->get_type() == Module_Param::MP_List_Template ?
+      VALUE_LIST : COMPLEMENTED_LIST, mp->get_size());
+    for (size_t i=0; i<mp->get_size(); i++) {
+      temp.list_item(i).set_param(*mp->get_elem(i));
+    }
+    *this = temp;
+    break; }
+  case Module_Param::MP_Value_List:
+    if (mp->get_size()==0) break;
+    if (3!=mp->get_size()) {
+      param.error("record template of type EXTERNAL has 3 fields but list value has %d fields", (int)mp->get_size());
+    }
+    if (mp->get_elem(0)->get_type()!=Module_Param::MP_NotUsed) identification().set_param(*mp->get_elem(0));
+    if (mp->get_elem(1)->get_type()!=Module_Param::MP_NotUsed) data__value__descriptor().set_param(*mp->get_elem(1));
+    if (mp->get_elem(2)->get_type()!=Module_Param::MP_NotUsed) data__value().set_param(*mp->get_elem(2));
+    break;
+  case Module_Param::MP_Assignment_List: {
+    Vector<bool> value_used(mp->get_size());
+    value_used.resize(mp->get_size(), false);
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
+      if (!strcmp(curr_param->get_id()->get_name(), "identification")) {
+        identification().set_param(*curr_param);
+        value_used[val_idx]=true;
+      }
+    }
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
+      if (!strcmp(curr_param->get_id()->get_name(), "data_value_descriptor")) {
+        data__value__descriptor().set_param(*curr_param);
+        value_used[val_idx]=true;
+      }
+    }
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) {
+      Module_Param* const curr_param = mp->get_elem(val_idx);
+      if (!strcmp(curr_param->get_id()->get_name(), "data_value")) {
+        data__value().set_param(*curr_param);
+        value_used[val_idx]=true;
+      }
+    }
+    for (size_t val_idx=0; val_idx<mp->get_size(); val_idx++) if (!value_used[val_idx]) {
+      mp->get_elem(val_idx)->error("Non existent field name in type EXTERNAL: %s", mp->get_elem(val_idx)->get_id()->get_name());
+      break;
+    }
+  } break;
+  default:
+    param.type_error("record template", "EXTERNAL");
+  }
+  is_ifpresent = param.get_ifpresent() || mp->get_ifpresent();
+}
+
+Module_Param* EXTERNAL_template::get_param(Module_Param_Name& param_name) const
+{
+  Module_Param* mp = NULL;
+  switch (template_selection) {
+  case UNINITIALIZED_TEMPLATE:
+    mp = new Module_Param_Unbound();
+    break;
+  case OMIT_VALUE:
+    mp = new Module_Param_Omit();
+    break;
+  case ANY_VALUE:
+    mp = new Module_Param_Any();
+    break;
+  case ANY_OR_OMIT:
+    mp = new Module_Param_AnyOrNone();
+    break;
+  case SPECIFIC_VALUE: {
+    Module_Param* mp_field_identification = single_value->field_identification.get_param(param_name);
+    mp_field_identification->set_id(new Module_Param_FieldName(mcopystr("identification")));
+    Module_Param* mp_field_data_value_descriptor = single_value->field_data__value__descriptor.get_param(param_name);
+    mp_field_data_value_descriptor->set_id(new Module_Param_FieldName(mcopystr("data_value_descriptor")));
+    Module_Param* mp_field_string_value = single_value->field_data__value.get_param(param_name);
+    mp_field_string_value->set_id(new Module_Param_FieldName(mcopystr("data_value")));
+    mp = new Module_Param_Assignment_List();
+    mp->add_elem(mp_field_identification);
+    mp->add_elem(mp_field_data_value_descriptor);
+    mp->add_elem(mp_field_string_value);
+    break; }
+  case VALUE_LIST:
+  case COMPLEMENTED_LIST: {
+    if (template_selection == VALUE_LIST) {
+      mp = new Module_Param_List_Template();
+    }
+    else {
+      mp = new Module_Param_ComplementList_Template();
+    }
+    for (size_t i = 0; i < value_list.n_values; ++i) {
+      mp->add_elem(value_list.list_value[i].get_param(param_name));
+    }
+    break; }
+  default:
+    break;
+  }
+  if (is_ifpresent) {
+    mp->set_ifpresent();
+  }
+  return mp;
+}
+
 void EXTERNAL_template::clean_up()
 {
   switch (template_selection) {
@@ -3394,7 +3768,8 @@ EXTERNAL_template& EXTERNAL_template::operator=(const EXTERNAL_template& other_v
   return *this;
 }
 
-boolean EXTERNAL_template::match(const EXTERNAL& other_value) const
+boolean EXTERNAL_template::match(const EXTERNAL& other_value,
+                                 boolean /* legacy */) const
 {
   switch (template_selection) {
   case ANY_VALUE:
@@ -3556,7 +3931,8 @@ void EXTERNAL_template::log() const
   log_ifpresent();
 }
 
-void EXTERNAL_template::log_match(const EXTERNAL& match_value) const
+void EXTERNAL_template::log_match(const EXTERNAL& match_value,
+                                  boolean /* legacy */) const
 {
   if (template_selection == SPECIFIC_VALUE) {
     TTCN_Logger::log_event_str("{ identification := ");
@@ -3631,13 +4007,13 @@ void EXTERNAL_template::decode_text(Text_Buf& text_buf)
   }
 }
 
-boolean EXTERNAL_template::is_present() const
+boolean EXTERNAL_template::is_present(boolean legacy /* = FALSE */) const
 {
   if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
-  return !match_omit();
+  return !match_omit(legacy);
 }
 
-boolean EXTERNAL_template::match_omit() const
+boolean EXTERNAL_template::match_omit(boolean legacy /* = FALSE */) const
 {
   if (is_ifpresent) return TRUE;
   switch (template_selection) {
@@ -3646,10 +4022,14 @@ boolean EXTERNAL_template::match_omit() const
     return TRUE;
   case VALUE_LIST:
   case COMPLEMENTED_LIST:
-    for (unsigned int i=0; i<value_list.n_values; i++)
-      if (value_list.list_value[i].match_omit())
-        return template_selection==VALUE_LIST;
-    return template_selection==COMPLEMENTED_LIST;
+    if (legacy) {
+      // legacy behavior: 'omit' can appear in the value/complement list
+      for (unsigned int i=0; i<value_list.n_values; i++)
+        if (value_list.list_value[i].match_omit())
+          return template_selection==VALUE_LIST;
+      return template_selection==COMPLEMENTED_LIST;
+    }
+    // else fall through
   default:
     return FALSE;
   }
@@ -3657,7 +4037,8 @@ boolean EXTERNAL_template::match_omit() const
 }
 
 #ifndef TITAN_RUNTIME_2
-void EXTERNAL_template::check_restriction(template_res t_res, const char* t_name) const
+void EXTERNAL_template::check_restriction(template_res t_res, const char* t_name,
+                                          boolean legacy /* = FALSE */) const
 {
   if (template_selection==UNINITIALIZED_TEMPLATE) return;
   switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) {
@@ -3669,7 +4050,7 @@ void EXTERNAL_template::check_restriction(template_res t_res, const char* t_name
         template_selection==SPECIFIC_VALUE)) return;
     break;
   case TR_PRESENT:
-    if (!match_omit()) return;
+    if (!match_omit(legacy)) return;
     break;
   default:
     return;
This page took 0.041272 seconds and 5 git commands to generate.