-///////////////////////////////////////////////////////////////////////////////
-// 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
+ * Tatarka, Gabor
+ *
+ ******************************************************************************/
#include "Objid.hh"
#include "../common/dbgnew.hh"
void OBJID::set_param(Module_Param& param) {
param.basic_check(Module_Param::BC_VALUE, "objid value");
- if (param.get_type()!=Module_Param::MP_Objid) param.type_error("objid value");
+ Module_Param_Ptr mp = ¶m;
+ if (param.get_type() == Module_Param::MP_Reference) {
+ mp = param.get_referenced_param();
+ }
+ if (mp->get_type()!=Module_Param::MP_Objid) param.type_error("objid value");
if (sizeof(objid_element)!=sizeof(int)) TTCN_error("Internal error: OBJID::set_param()");
clean_up();
- init_struct(param.get_string_size());
- memcpy(val_ptr->components_ptr, param.get_string_data(), val_ptr->n_components * sizeof(objid_element));
+ init_struct(mp->get_string_size());
+ memcpy(val_ptr->components_ptr, mp->get_string_data(), val_ptr->n_components * sizeof(objid_element));
+}
+
+Module_Param* OBJID::get_param(Module_Param_Name& /* param_name */) const
+{
+ if (!is_bound()) {
+ return new Module_Param_Unbound();
+ }
+ int* val_cpy = (int *)Malloc(val_ptr->n_components);
+ memcpy(val_cpy, val_ptr->components_ptr, val_ptr->n_components * sizeof(int));
+ return new Module_Param_Objid(val_ptr->n_components, val_cpy);
}
void OBJID::encode_text(Text_Buf& text_buf) const
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;}
}
int OBJID::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;
return *this;
}
-boolean OBJID_template::match(const OBJID& other_value) const
+boolean OBJID_template::match(const OBJID& other_value, boolean /* legacy */) const
{
if (!other_value.is_bound()) return FALSE;
switch (template_selection) {
log_ifpresent();
}
-void OBJID_template::log_match(const OBJID& match_value) const
+void OBJID_template::log_match(const OBJID& match_value,
+ boolean /* legacy */) const
{
if (TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()
&& TTCN_Logger::get_logmatch_buffer_len() != 0) {
void OBJID_template::set_param(Module_Param& param) {
param.basic_check(Module_Param::BC_TEMPLATE, "objid template");
- switch (param.get_type()) {
+ Module_Param_Ptr mp = ¶m;
+ 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;
*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 i=0; i<param.get_size(); i++) {
- list_item(i).set_param(*param.get_elem(i));
+ case Module_Param::MP_ComplementList_Template: {
+ OBJID_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));
}
- break;
+ *this = temp;
+ break; }
case Module_Param::MP_Objid:
if (sizeof(OBJID::objid_element)!=sizeof(int)) TTCN_error("Internal error: OBJID_template::set_param()");
- *this = OBJID(param.get_string_size(), (OBJID::objid_element*)param.get_string_data());
+ *this = OBJID(mp->get_string_size(), (OBJID::objid_element*)mp->get_string_data());
break;
//case Module_Param::MP_Objid_Template:
// TODO
default:
param.type_error("objid template");
}
- is_ifpresent = param.get_ifpresent();
+ is_ifpresent = param.get_ifpresent() || mp->get_ifpresent();
+}
+
+Module_Param* OBJID_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:
+ mp = single_value.get_param(param_name);
+ 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 OBJID_template::encode_text(Text_Buf& text_buf) const
}
}
-boolean OBJID_template::is_present() const
+boolean OBJID_template::is_present(boolean legacy /* = FALSE */) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
- return !match_omit();
+ return !match_omit(legacy);
}
-boolean OBJID_template::match_omit() const
+boolean OBJID_template::match_omit(boolean legacy /* = FALSE */) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
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;
}
}
#ifndef TITAN_RUNTIME_2
-void OBJID_template::check_restriction(template_res t_res, const char* t_name) const
+void OBJID_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) {
template_selection==SPECIFIC_VALUE)) return;
break;
case TR_PRESENT:
- if (!match_omit()) return;
+ if (!match_omit(legacy)) return;
break;
default:
return;