diff --git a/compiler2/Type.cc b/compiler2/Type.cc index 7510963c1103359ae74d24f5ac9574699638ef19..1ae3e9f889cb382339e7b07ca8e6798da9861287 100644 --- a/compiler2/Type.cc +++ b/compiler2/Type.cc @@ -6219,7 +6219,8 @@ namespace Common { else if (rawattrib && enable_raw()) return false; else if (textattrib && enable_text()) return false; else if (enable_xer()) return false; - else if (jsonattrib && enable_json()) return false; + else if ((jsonattrib || (!is_asn1() && + hasEncodeAttr(get_encoding_name(CT_JSON)))) && enable_json()) return false; else return true; default: return false; @@ -6635,7 +6636,7 @@ namespace Common { * descriptor. */ if (t->is_tagged() || t->rawattrib || t->textattrib || t->jsonattrib || - (!is_asn1() && t->hasEncodeAttr(get_encoding_name(CT_JSON))) || + (!t->is_asn1() && t->hasEncodeAttr(get_encoding_name(CT_JSON))) || (t->xerattrib && !t->xerattrib->empty() )) { return t->get_genname_own(p_scope); diff --git a/compiler2/Type_codegen.cc b/compiler2/Type_codegen.cc index 295f0cf2590ec6e0f6164a43f48182fd666df032..c830a5a4a38cf0a83c4c335384a9d331a28f55e0 100644 --- a/compiler2/Type_codegen.cc +++ b/compiler2/Type_codegen.cc @@ -2098,12 +2098,16 @@ void Type::generate_code_Array(output_struct *target) if (has_encoding(CT_JSON)) { target->header.class_decls = mputprintf(target->header.class_decls, "class %s;\n", own_name); + string base_name = u.array.dimension->get_value_type(u.array.element_type, my_scope); target->header.class_defs = mputprintf(target->header.class_defs, "class %s : public %s {\n" "const TTCN_Typedescriptor_t* get_elem_descr() const;\n" + "public:\n" + "%s(): %s() {}\n" + "%s(const %s& p): %s(p) {}\n" "};\n\n", - own_name, - u.array.dimension->get_value_type(u.array.element_type, my_scope).c_str()); + own_name, base_name.c_str(), own_name, base_name.c_str(), + own_name, base_name.c_str(), base_name.c_str()); target->source.methods = mputprintf(target->source.methods, "const TTCN_Typedescriptor_t* %s::get_elem_descr() const { return &%s_descr_; }\n\n", own_name, u.array.element_type->get_genname_typedescriptor(my_scope).c_str()); diff --git a/regression_test/compileonly/Makefile b/regression_test/compileonly/Makefile index 598f9621567e88fc1fca955c9466cd63f435818b..9e8efa50b6278a70cd0e16c625e01a8095c13d00 100644 --- a/regression_test/compileonly/Makefile +++ b/regression_test/compileonly/Makefile @@ -28,7 +28,8 @@ CODIRS := dynamicTemplate styleGuide topLevelPdu \ isbound namedActualParameters assignmentNotation \ attribQualif HT48786 selectCase openTypeNames \ defaultParamUsageBeforeDecl deterministic readFromFile \ - asn1_hyphen nameClash portTranslation UntaggedOnTopLevelUnionSwitch + asn1_hyphen nameClash portTranslation UntaggedOnTopLevelUnionSwitch \ + typeDescrGenWIthNoXER ifdef DYN CODIRS += mfgen-xsd diff --git a/regression_test/compileonly/typeDescrGenWIthNoXER/Makefile b/regression_test/compileonly/typeDescrGenWIthNoXER/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..96691a31e777a556cf015bec63853e86a720c4a6 --- /dev/null +++ b/regression_test/compileonly/typeDescrGenWIthNoXER/Makefile @@ -0,0 +1,52 @@ +############################################################################## +# Copyright (c) 2000-2017 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: +# Botond, Baranyi +# +############################################################################## +TOPDIR := ../.. +include $(TOPDIR)/Makefile.regression + +.PHONY: all clean dep + +TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) + +COMPILER_FLAGS += -X + +TTCN3_MODULES = typeDescrGenWIthNoXER.ttcn + +GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) +GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh) +ifdef CODE_SPLIT +GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc _seqof.cc _setof.cc _union.cc)) +else ifdef SPLIT_TO_SLICES +POSTFIXES := $(foreach file, $(SPLIT_TO_SLICES), $(addsuffix $(file), _part_)) +POSTFIXES := $(foreach file, $(POSTFIXES), $(addprefix $(file), .cc)) +GENERATED_SOURCES2 := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), $(POSTFIXES))) +GENERATED_SOURCES += $(GENERATED_SOURCES2) +endif + +OBJECTS = $(GENERATED_SOURCES:.cc=.o) + +TARGET = typeDescrGenWIthNoXER$(EXESUFFIX) + +all: $(TARGET) + +$(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \ + -L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS) + +$(GENERATED_SOURCES) $(GENERATED_HEADERS): $(TTCN3_MODULES) + $(TTCN3_COMPILER) $(COMPILER_FLAGS) $^ + +clean distclean: + $(RM) $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ + $(GENERATED_SOURCES) compile *.log + +dep: $(GENERATED_SOURCES) + makedepend $(CPPFLAGS) $(GENERATED_SOURCES) diff --git a/regression_test/compileonly/typeDescrGenWIthNoXER/typeDescrGenWIthNoXER.ttcn b/regression_test/compileonly/typeDescrGenWIthNoXER/typeDescrGenWIthNoXER.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..ced844f2e4067458e8786a8080d7d3803d71c452 --- /dev/null +++ b/regression_test/compileonly/typeDescrGenWIthNoXER/typeDescrGenWIthNoXER.ttcn @@ -0,0 +1,73 @@ +/****************************************************************************** + * Copyright (c) 2000-2017 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: + * Baranyi, Botond + * + ******************************************************************************/ + +// This module contains tests for the semantic analysis and code generation of +// list types (record of, set of) with JSON encoding support. +// Previously, the type descriptors of the lists' element types were not generated +// if the XER codec was disabled (with the compiler option -X). + +module typeDescrGenWIthNoXER { + +// structured types used as element types +type record Rec { + integer num, + charstring str +} + +type record of integer IntList; + +type union Uni { + integer num, + octetstring oct +} + +type bitstring BitArray[4]; + +type enumerated Enum { val1, val2 } + +// 'record of' and 'set of' types with structured element types +type record of Rec RecList; + +type set of IntList IntListList; + +type record of Uni UniList; + +type set of BitArray BitArrayList; + +type record of Enum EnumList; + +type set of anytype AnyList; + +// JSON coder functions for the list types +external function f_enc_rec_list(in RecList x) return octetstring + with { extension "prototype(convert) encode(JSON)" } + +external function f_dec_list_list(in octetstring x) return IntListList + with { extension "prototype(convert) decode(JSON)" } + +external function f_dec_uni_list(in octetstring x, out UniList y) + with { extension "prototype(fast) decode(JSON)" } + +external function f_dec_array_list(in BitArrayList x, out octetstring y) + with { extension "prototype(fast) encode(JSON)" } + +external function f_dec_enum_list(in octetstring x, out EnumList y) return integer + with { extension "prototype(backtrack) decode(JSON)" } + +external function f_dec_any_list(inout octetstring x, out AnyList y) return integer + with { extension "prototype(sliding) decode(JSON)" } + +} +with { + encode "JSON"; + extension "anytype integer, boolean"; +} diff --git a/regression_test/templateConcat/TemplateConcatChar.ttcn b/regression_test/templateConcat/TemplateConcatChar.ttcn index 0fd97d3568caaf7155c3f56126d13dcc13fd2909..f5dcc83ba8684c414a59185be342301a01a723f7 100644 --- a/regression_test/templateConcat/TemplateConcatChar.ttcn +++ b/regression_test/templateConcat/TemplateConcatChar.ttcn @@ -62,7 +62,7 @@ testcase tc_char_vt_values() runs on CT { var template charstring vt_char4 := "xx" & t_char & "xx"; var template charstring vt_char4_exp := "xxdefxx"; - + if (log2str(vt_char1) != log2str(vt_char1_exp)) { setverdict(fail, "Expected: ", vt_char1_exp, ", got: ", vt_char1); }