Commit e353db54 authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

xsd2ttcn: defaultForEmpty variants are generated with constants for the value (artf190392)



Change-Id: Ib54f4e6672adc7eb83b4d72d875790632d0c2eee
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent 0797da7c
......@@ -828,7 +828,12 @@ Value *Type::new_value_for_dfe(Type *last, const char *dfe_str, Common::Referenc
if (is_ref_dfe) {
Value* v = new Value(Value::V_REFD, ref->clone());
v->set_my_scope(get_my_scope()->get_scope_mod());
if (!is_compatible_tt_tt(last->typetype, v->get_expr_governor_last()->typetype, last->is_asn1(), v->get_expr_governor_last()->is_asn1())) {
Type * t = v->get_expr_governor_last();
if (t == NULL) {
delete v;
return 0;
}
if (!is_compatible_tt_tt(last->typetype, v->get_expr_governor_last()->typetype, last->is_asn1(), t->is_asn1())) {
v->get_reference()->error("Incompatible types were given to defaultForEmpty variant: `%s' instead of `%s'.\n",
v->get_expr_governor_last()->get_typename().c_str(), last->get_typename().c_str());
delete v;
......
......@@ -292,7 +292,8 @@ other.print("other");
defaultForEmptyIsRef_ = other.defaultForEmptyIsRef_;
}
if (other.defaultForEmptyIsRef_ && other.defaultForEmptyRef_ != 0) {
defaultForEmptyIsRef_ |= other.defaultForEmptyIsRef_;
if (other.defaultForEmptyRef_ != 0) {
Free(defaultForEmptyRef_);
defaultForEmptyRef_ = other.defaultForEmptyRef_->clone();
}
......
......@@ -18,7 +18,8 @@ type record DFEConst { //^In type definition//
universal charstring us, //^In record field \`us\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_us//
integer i, //^In record field \`i\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_i//
float f, //^In record field \`f\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_f//
boolean b //^In record field \`b\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_b//
boolean b, //^In record field \`b\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_b//
charstring csmissing //^In record field \`csmissing\'\:// //^error: DEFAULT\-FOR\-EMPTY not supported for character\-encodable type DFEConst_csmissing//
}
with {
variant "element";
......@@ -27,6 +28,7 @@ with {
variant (i) "defaultForEmpty as c_oct"; //^error: Incompatible types were given to defaultForEmpty variant\: \`octetstring\' instead of \`integer\'\.//
variant (f) "defaultForEmpty as c_oct"; //^error: Incompatible types were given to defaultForEmpty variant\: \`octetstring\' instead of \`float\'\.//
variant (b) "defaultForEmpty as c_oct"; //^error: Incompatible types were given to defaultForEmpty variant\: \`octetstring\' instead of \`boolean\'\.//
variant (csmissing) "defaultForEmpty as c_missing"; //^error\: There is no local or imported definition with name \`c_missing\'//
}
}
......
......@@ -45,6 +45,9 @@ module http_www_XmlTest_org_po {
import from XSD all;
const XSD.NMTOKEN c_defaultForEmpty_1 := "US";
/* Purchase order schema for Example.com.
Copyright 2000 Example.com. All rights reserved. */
......@@ -78,7 +81,7 @@ with {
type record USAddress
{
XSD.NMTOKEN country ("US") optional,
XSD.NMTOKEN country (c_defaultForEmpty_1) optional,
XSD.String name,
XSD.String street,
XSD.String city,
......@@ -86,7 +89,7 @@ type record USAddress
XSD.Decimal zip
}
with {
variant (country) "defaultForEmpty as 'US'";
variant (country) "defaultForEmpty as c_defaultForEmpty_1";
variant (country) "attribute";
};
......
......@@ -46,6 +46,9 @@ module urn_ietf_params_xml_ns_conference_info {
import from XSD all;
const State_type c_defaultForEmpty_1 := full;
/* CONFERENCE ELEMENT */
......@@ -77,7 +80,7 @@ with {
variant "name as 'conference-type'";
variant (attr) "attribute";
variant (entity) "attribute";
variant (state) "defaultForEmpty as 'full'";
variant (state) "defaultForEmpty as c_defaultForEmpty_1";
variant (state) "attribute";
variant (attr_1) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'";
variant (attr_1) "name as 'attr'";
......@@ -231,7 +234,7 @@ type record Uris_type
}
with {
variant "name as 'uris-type'";
variant (state) "defaultForEmpty as 'full'";
variant (state) "defaultForEmpty as c_defaultForEmpty_1";
variant (state) "attribute";
variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'";
variant (entry_list) "untagged";
......@@ -282,7 +285,7 @@ type record Users_type
}
with {
variant "name as 'users-type'";
variant (state) "defaultForEmpty as 'full'";
variant (state) "defaultForEmpty as c_defaultForEmpty_1";
variant (state) "attribute";
variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'";
variant (user_list) "untagged";
......@@ -311,7 +314,7 @@ type record User_type
with {
variant "name as 'user-type'";
variant (entity) "attribute";
variant (state) "defaultForEmpty as 'full'";
variant (state) "defaultForEmpty as c_defaultForEmpty_1";
variant (state) "attribute";
variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'";
variant (display_text) "name as 'display-text'";
......@@ -372,7 +375,7 @@ type record Endpoint_type
with {
variant "name as 'endpoint-type'";
variant (entity) "attribute";
variant (state) "defaultForEmpty as 'full'";
variant (state) "defaultForEmpty as c_defaultForEmpty_1";
variant (state) "attribute";
variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'";
variant (display_text) "name as 'display-text'";
......@@ -557,7 +560,7 @@ type record Sidebars_by_val_type
}
with {
variant "name as 'sidebars-by-val-type'";
variant (state) "defaultForEmpty as 'full'";
variant (state) "defaultForEmpty as c_defaultForEmpty_1";
variant (state) "attribute";
variant (attr) "anyAttributes except unqualified, 'urn:ietf:params:xml:ns:conference-info'";
variant (entry_list) "untagged";
......
......@@ -46,6 +46,12 @@ module www_XmlTest_org_element_recordOfElements {
import from XSD all;
const XSD.String c_defaultForEmpty_1 := "Msc";
const XSD.String c_defaultForEmpty_2 := "American";
/* This documentum tests based on
XML Schema Part 1: Structures Second Edition */
......@@ -58,7 +64,7 @@ type record PersonInfo1
XSD.String degree optional
}
with {
variant (degree) "defaultForEmpty as 'Msc'";
variant (degree) "defaultForEmpty as c_defaultForEmpty_1";
};
......@@ -71,7 +77,7 @@ type record PersonInfo2
XSD.Integer age optional
}
with {
variant (nationality) "defaultForEmpty as 'American'";
variant (nationality) "defaultForEmpty as c_defaultForEmpty_2";
variant (nationality) "attribute";
variant (title) "attribute";
};
......
......@@ -50,10 +50,13 @@ import from www_example_org_attrib_order_b all;
import from NoTargetNamespace2 all;
type XSD.String Local1 ("fixed")
const XSD.String c_defaultForEmpty_1 := "fixed";
type XSD.String Local1 (c_defaultForEmpty_1)
with {
variant "defaultForEmpty as c_defaultForEmpty_1";
variant "name as uncapitalized";
variant "defaultForEmpty as 'fixed'";
variant "attribute";
};
......
......@@ -44,16 +44,19 @@ module www_example_org_attribgroup_ingroup {
import from XSD all;
const XSD.String c_defaultForEmpty_1 := "simple";
type record AttrGroupinGroup
{
RemoteSchema remoteSchema optional,
XSD.String type_ ("simple") optional
XSD.String type_ (c_defaultForEmpty_1) optional
}
with {
variant (remoteSchema) "attribute";
variant (type_) "defaultForEmpty as c_defaultForEmpty_1";
variant (type_) "form as qualified";
variant (type_) "name as 'type'";
variant (type_) "defaultForEmpty as 'simple'";
variant (type_) "attribute";
};
......
......@@ -43,6 +43,9 @@ module www_example_org_complextype_aliases {
import from XSD all;
const XSD.Integer c_defaultForEmpty_1 := 2;
/* Theese types needed to force the nameconversion */
......@@ -245,7 +248,7 @@ type record ComplexTypeRestrictionNotAlias5
{
XSD.String attr optional,
record length(0 .. 2) of record {
XSD.Integer elem (2) optional,
XSD.Integer elem (c_defaultForEmpty_1) optional,
record length(1 .. 2) of XSD.Integer elem1_list
} sequence_list
}
......@@ -253,7 +256,7 @@ with {
variant (attr) "attribute";
variant (sequence_list) "untagged";
variant (sequence_list[-]) "untagged";
variant (sequence_list[-].elem) "defaultForEmpty as '2'";
variant (sequence_list[-].elem) "defaultForEmpty as c_defaultForEmpty_1";
variant (sequence_list[-].elem1_list) "untagged";
variant (sequence_list[-].elem1_list[-]) "name as 'elem1'";
};
......@@ -266,14 +269,14 @@ type record ComplexTypeRestrictionNotAlias6
{
XSD.String attr optional,
record length(0 .. 2) of record {
XSD.Integer elem (2)
XSD.Integer elem (c_defaultForEmpty_1)
} sequence_list
}
with {
variant (attr) "attribute";
variant (sequence_list) "untagged";
variant (sequence_list[-]) "untagged";
variant (sequence_list[-].elem) "defaultForEmpty as '2'";
variant (sequence_list[-].elem) "defaultForEmpty as c_defaultForEmpty_1";
};
......
/*******************************************************************************
* Copyright (c) 2000-2017 Ericsson Telecom AB
*
* XSD to TTCN-3 Translator
*
* 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:
* Szabo, Bence Janos
*
*******************************************************************************/
//
// File: www_example_org_defaultforempty.ttcn
// Description:
// References:
// Rev:
// Prodnr:
// Updated: Thu Jan 19 13:08:35 2017
// Contact: http://ttcn.ericsson.se
//
////////////////////////////////////////////////////////////////////////////////
// Generated from file(s):
// - defaultforempty.xsd
// /* xml version = "1.0" encoding = "UTF-8" */
// /* targetnamespace = "www.example.org/defaultforempty" */
////////////////////////////////////////////////////////////////////////////////
// Modification header(s):
//-----------------------------------------------------------------------------
// Modified by:
// Modification date:
// Description:
// Modification contact:
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
module www_example_org_defaultforempty {
import from XSD all;
const XSD.String c_defaultForEmpty_1 := "defaultValue";
const XSD.String c_defaultForEmpty_2 := "fixedValue";
const XSD.Date c_defaultForEmpty_3 := "1999-11-11";
const XSD.Integer c_defaultForEmpty_4 := 3;
const XSD.Float c_defaultForEmpty_5 := 3.0;
const XSD.Float c_defaultForEmpty_6 := infinity;
const XSD.Float c_defaultForEmpty_7 := -infinity;
const XSD.Float c_defaultForEmpty_8 := not_a_number;
const XSD.Boolean c_defaultForEmpty_9 := true;
const XSD.Boolean c_defaultForEmpty_10 := false;
const MyString_1 c_defaultForEmpty_11 := "fix";
const MyString2_1 c_defaultForEmpty_12 := "fix";
const EnumString c_defaultForEmpty_13 := a;
const EnumDate c_defaultForEmpty_14 := x1888_01_01;
const EnumFloat c_defaultForEmpty_15 := infinity;
const EnumFloat c_defaultForEmpty_16 := not_a_number;
const EnumFloat c_defaultForEmpty_17 := 1.0;
const EnumInteger c_defaultForEmpty_18 := int3;
const EnumInteger c_defaultForEmpty_19 := int_3;
/* Basic defaultForEmpty */
type XSD.String StringDefault
with {
variant "defaultForEmpty as c_defaultForEmpty_1";
variant "element";
};
type XSD.String StringFixed (c_defaultForEmpty_2)
with {
variant "defaultForEmpty as c_defaultForEmpty_2";
variant "element";
};
type XSD.Date DateDefault
with {
variant "defaultForEmpty as c_defaultForEmpty_3";
variant "element";
};
type XSD.Date DateFixed (c_defaultForEmpty_3)
with {
variant "defaultForEmpty as c_defaultForEmpty_3";
variant "element";
};
type XSD.Integer IntegerDefault
with {
variant "defaultForEmpty as c_defaultForEmpty_4";
variant "element";
};
type XSD.Integer IntegerFixed (c_defaultForEmpty_4)
with {
variant "defaultForEmpty as c_defaultForEmpty_4";
variant "element";
};
type XSD.Float FloatDefault
with {
variant "defaultForEmpty as c_defaultForEmpty_5";
variant "element";
};
type XSD.Float FloatFixed (c_defaultForEmpty_5)
with {
variant "defaultForEmpty as c_defaultForEmpty_5";
variant "element";
};
type XSD.Float FloatDefault2
with {
variant "defaultForEmpty as c_defaultForEmpty_5";
variant "element";
};
type XSD.Float FloatFixed2 (c_defaultForEmpty_5)
with {
variant "defaultForEmpty as c_defaultForEmpty_5";
variant "element";
};
type XSD.Float FloatDefault3
with {
variant "defaultForEmpty as c_defaultForEmpty_6";
variant "element";
};
type XSD.Float FloatFixed3 (c_defaultForEmpty_6)
with {
variant "defaultForEmpty as c_defaultForEmpty_6";
variant "element";
};
type XSD.Float FloatDefault4
with {
variant "defaultForEmpty as c_defaultForEmpty_7";
variant "element";
};
type XSD.Float FloatFixed4 (c_defaultForEmpty_7)
with {
variant "defaultForEmpty as c_defaultForEmpty_7";
variant "element";
};
type XSD.Float FloatDefault5
with {
variant "defaultForEmpty as c_defaultForEmpty_8";
variant "element";
};
type XSD.Float FloatFixed5 (c_defaultForEmpty_8)
with {
variant "defaultForEmpty as c_defaultForEmpty_8";
variant "element";
};
type XSD.Boolean BooleanDefault
with {
variant "defaultForEmpty as c_defaultForEmpty_9";
variant "element";
//variant "text 'true' as '1'";
//variant "text 'false' as '0'";
};
type XSD.Boolean BooleanFixed (c_defaultForEmpty_9)
with {
variant "defaultForEmpty as c_defaultForEmpty_9";
variant "element";
//variant "text 'true' as '1'";
//variant "text 'false' as '0'";
};
type XSD.Boolean BooleanDefault2
with {
variant "defaultForEmpty as c_defaultForEmpty_9";
variant "element";
//variant "text 'true' as '1'";
//variant "text 'false' as '0'";
};
type XSD.Boolean BooleanFixed2 (c_defaultForEmpty_9)
with {
variant "defaultForEmpty as c_defaultForEmpty_9";
variant "element";
//variant "text 'true' as '1'";
//variant "text 'false' as '0'";
};
type XSD.Boolean BooleanDefault3
with {
variant "defaultForEmpty as c_defaultForEmpty_10";
variant "element";
//variant "text 'true' as '1'";
//variant "text 'false' as '0'";
};
type XSD.Boolean BooleanFixed3 (c_defaultForEmpty_10)
with {
variant "defaultForEmpty as c_defaultForEmpty_10";
variant "element";
//variant "text 'true' as '1'";
//variant "text 'false' as '0'";
};
/* Check if the name conversion follows to the constants too */
type XSD.AnyType AttrfixedMyString3
with {
variant "name as 'AttrfixedMyString3_'";
variant "element";
};
type XSD.AnyType MyString
with {
variant "name as 'MyString_'";
variant "element";
};
type XSD.AnyType MyString2
with {
variant "name as 'MyString2_'";
variant "element";
};
type XSD.String MyString_1 (pattern "fix")
with {
variant "name as 'MyString'";
};
type MyString_1 MyStringFixed (c_defaultForEmpty_11)
with {
variant "defaultForEmpty as c_defaultForEmpty_11";
variant "element";
};
type XSD.String MyString2_1
with {
variant "name as 'MyString2'";
};
type MyString2_1 MyStringFixed2 (c_defaultForEmpty_12)
with {
variant "defaultForEmpty as c_defaultForEmpty_12";
variant "element";
};
type MyString_1 AttrfixedMyString3_1 (c_defaultForEmpty_11)
with {
variant "defaultForEmpty as c_defaultForEmpty_11";
variant "name as 'AttrfixedMyString3'";
variant "attribute";
};
type record Complex
{