Commit 91177082 authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

XER: encoding union with useType error fixed (Bug 507270)



Change-Id: I401c983ba0d500840eb43484de57b019f9ff26fd
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent 58f54f73
......@@ -280,7 +280,7 @@ JNIEXPORT void JNICALL Java_org_eclipse_titan_executor_jni_JNIMiddleWare_execute
*
* NOTE: Function comment is here, because function declaration is in org_eclipse_titan_executor_jni_JNIMiddleWare.h, which is generated.
*/
JNIEXPORT jint JNICALL Java_org_eclipse_titan_executor_jni_JNIMiddleWare_get_1execute_1cfg_1len(JNIEnv *env, jobject)
JNIEXPORT jint JNICALL Java_org_eclipse_titan_executor_jni_JNIMiddleWare_get_1execute_1cfg_1len(JNIEnv *, jobject)
{
return (jint)Jnimw::mycfg.execute_list_len;
}
......@@ -295,7 +295,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_titan_executor_jni_JNIMiddleWare_get_1ex
*
* NOTE: Function comment is here, because function declaration is in org_eclipse_titan_executor_jni_JNIMiddleWare.h, which is generated.
*/
JNIEXPORT void JNICALL Java_org_eclipse_titan_executor_jni_JNIMiddleWare_execute_1cfg(JNIEnv *env, jobject, jint index)
JNIEXPORT void JNICALL Java_org_eclipse_titan_executor_jni_JNIMiddleWare_execute_1cfg(JNIEnv *, jobject, jint index)
{
if (!Jnimw::userInterface)
return;
......
......@@ -488,7 +488,7 @@ void CodeGenHelper::write_output() {
// If we need to split
if (num_of_chars >= chunk_size) {
size_t base_pos = 0;
for (unsigned int i = 0; i < slice_num; i++) {
for (i = 0; i < slice_num; i++) {
if (i == 0) { // The first slice has the module's name
fname = output->module_dispname;
} else {
......
......@@ -971,7 +971,7 @@ static void fill_continuing_octets(int n_continuing, unsigned char *continuing_p
}
}
ustring decode_utf8(const string & ostr, CharCoding::CharCodingType expected_coding)
ustring decode_utf8(const string & ostr, CharCoding::CharCodingType /*expected_coding*/)
{
size_t length = ostr.size();
if (0 == length) return ustring();
......
......@@ -244,14 +244,14 @@ std::string ProjectDescriptor::setRelativePathTo(const std::string& absPathTo)
}
size_t slashCount = 0;
for (size_t i = lastSlash; i < projectAbsWorkingDir.size(); ++i) {
for (i = lastSlash; i < projectAbsWorkingDir.size(); ++i) {
if (projectAbsWorkingDir.at(i) == SEPARATOR)
++slashCount;
}
std::string relPath;
const std::string upDir("../");
for (size_t i = 0; i < slashCount; ++i)
for (i = 0; i < slashCount; ++i)
relPath.append(upDir);
std::string pathTo = absPathTo.substr(lastSlash+1); // we left the heading slash
......
......@@ -1204,6 +1204,7 @@ void Type::generate_code_Choice(output_struct *target)
if (cftype->xerattrib != NULL) {
sdef.elements[i].xsd_type = cftype->xerattrib->xsd_type;
sdef.elements[i].xerUseUnion = cftype->xerattrib->useUnion_;
}
}
if (sdef.jsonAsValue) {
......
......@@ -8959,6 +8959,7 @@ error:
default:
FATAL_ERROR("Value::is_unfoldable()");
} // switch
FATAL_ERROR("Value::is_unfoldable()");
break; // should never get here
case V_MACRO:
switch (u.macro) {
......@@ -11892,7 +11893,7 @@ error:
Ttcn::ActualParList *parlist = u.expr.r1->get_parlist();
Common::Assignment *ass = u.expr.r1->get_refd_assignment();
if (parlist) str = parlist->rearrange_init_code(str, usage_mod);
(void)ass; // eliminate assigned but not used warning
parlist = u.expr.r2->get_parlist();
ass = u.expr.r2->get_refd_assignment();
if (parlist) str = parlist->rearrange_init_code(str, usage_mod);
......
......@@ -557,7 +557,7 @@ namespace Asn {
json.put_next_token(JSON_TOKEN_OBJECT_END);
}
void Module::generate_debugger_init(output_struct *output)
void Module::generate_debugger_init(output_struct */*output*/)
{
// no debugging in ASN.1 modules
}
......
......@@ -90,6 +90,7 @@ typedef struct {
/** true if the field is a record-of or set-of with optimized memory allocation */
boolean optimizedMemAlloc;
XSD_types xsd_type;
boolean xerUseUnion;
} struct_field;
/** Structure (record, set, union, anytype) descriptor for code generation */
......
......@@ -64,19 +64,19 @@ void def_encdec(const char *p_classname,
#ifndef NDEBUG
"// written by %s in " __FILE__ " at %d\n"
#endif
"int XER_encode(const XERdescriptor_t&, TTCN_Buffer&, unsigned int, int, "
"embed_values_enc_struct_t*) const;\n"
"int XER_encode(const XERdescriptor_t&, TTCN_Buffer&, unsigned int,"
"unsigned int, int, embed_values_enc_struct_t*) const;\n"
"int XER_decode(const XERdescriptor_t&, XmlReaderWrap&, unsigned int, "
"unsigned int, embed_values_dec_struct_t*);\n"
"static boolean can_start(const char *name, const char *uri, "
"XERdescriptor_t const& xd, unsigned int);\n"
"XERdescriptor_t const& xd, unsigned int, unsigned int);\n"
"%s"
#ifndef NDEBUG
, __FUNCTION__, __LINE__
#endif
, use_runtime_2 ?
"boolean can_start_v(const char *name, const char *uri, "
"XERdescriptor_t const& xd, unsigned int);\n" : ""
"XERdescriptor_t const& xd, unsigned int, unsigned int);\n" : ""
);
if(json) {
def = mputprintf(def,
......@@ -130,7 +130,7 @@ void def_encdec(const char *p_classname,
/* Do not use %s_xer_ here. It supplies the XER descriptor of oldtype
* even if encoding newtype for:
* <ttcn>type newtype oldtype;</ttcn> */
" XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0);\n"
" XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);\n"
" p_buf.put_c('\\n');\n" /* make sure it has a newline */
" break;}\n"
" case TTCN_EncDec::CT_JSON: {\n"
......
......@@ -655,7 +655,7 @@ void defEnumClass(const enum_def *edef, output_struct *output)
*/
src = mputprintf(src,
"boolean %s::can_start(const char *name, const char *uri, "
"const XERdescriptor_t& xd, unsigned int flavor) {\n"
"const XERdescriptor_t& xd, unsigned int flavor, unsigned int) {\n"
" boolean exer = is_exer(flavor);\n"
" return check_name(name, xd, exer) && (!exer || check_namespace(uri, xd));\n"
"}\n\n"
......@@ -664,7 +664,7 @@ void defEnumClass(const enum_def *edef, output_struct *output)
src = mputprintf(src,
"int %s::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,"
" unsigned int p_flavor, int p_indent, embed_values_enc_struct_t*) const\n"
" unsigned int p_flavor, unsigned int, int p_indent, embed_values_enc_struct_t*) const\n"
"{\n"
" int encoded_length=(int)p_buf.get_len();\n"
" const boolean e_xer = is_exer(p_flavor);\n"
......@@ -814,7 +814,7 @@ void defEnumClass(const enum_def *edef, output_struct *output)
" boolean use_default = p_td.json->default_value && 0 == p_tok.get_buffer_length();\n"
" if (use_default) {\n"
// No JSON data in the buffer -> use default value
" value = (char*)p_td.json->default_value;\n"
" value = const_cast<char*>(p_td.json->default_value);\n"
" value_len = strlen(value);\n"
" } else {\n"
" dec_len = p_tok.get_next_token(&token, &value, &value_len);\n"
......
......@@ -2932,9 +2932,9 @@ static void print_makefile(struct makefile_struct *makefile)
print_generated_file_name(fp, module, FALSE, "_setof.so");
print_generated_file_name(fp, module, FALSE, "_union.so");
} else if((n_slices = atoi(makefile->code_splitting_mode + 2))) {
for (int i = 1; i < n_slices; i++) {
for (int slice = 1; slice < n_slices; slice++) {
char buffer[16]; // 6 digits + 4 chars + _part
sprintf(buffer, "_part_%i.so", i);
sprintf(buffer, "_part_%i.so", slice);
print_generated_file_name(fp, module, FALSE, buffer);
}
}
......@@ -2955,9 +2955,9 @@ static void print_makefile(struct makefile_struct *makefile)
print_generated_file_name(fp, module, FALSE, "_setof.so");
print_generated_file_name(fp, module, FALSE, "_union.so");
} else if((n_slices = atoi(makefile->code_splitting_mode + 2))) {
for (int i = 1; i < n_slices; i++) {
for (int slice = 1; slice < n_slices; slice++) {
char buffer[16]; // 6 digits + 4 chars + _part
sprintf(buffer, "_part_%i.so", i);
sprintf(buffer, "_part_%i.so", slice);
print_generated_file_name(fp, module, FALSE, buffer);
}
}
......@@ -2978,9 +2978,9 @@ static void print_makefile(struct makefile_struct *makefile)
print_generated_file_name(fp, module, FALSE, "_setof.so");
print_generated_file_name(fp, module, FALSE, "_union.so");
} else if((n_slices = atoi(makefile->code_splitting_mode + 2))) {
for (int i = 1; i < n_slices; i++) {
for (int slice = 1; slice < n_slices; slice++) {
char buffer[16]; // 6 digits + 4 chars + _part
sprintf(buffer, "_part_%i.so", i);
sprintf(buffer, "_part_%i.so", slice);
print_generated_file_name(fp, module, FALSE, buffer);
}
}
......@@ -3000,9 +3000,9 @@ static void print_makefile(struct makefile_struct *makefile)
print_generated_file_name(fp, module, FALSE, "_setof.so");
print_generated_file_name(fp, module, FALSE, "_union.so");
} else if((n_slices = atoi(makefile->code_splitting_mode + 2))) {
for (int i = 1; i < n_slices; i++) {
for (int slice = 1; slice < n_slices; slice++) {
char buffer[16]; // 6 digits + 4 chars + _part
sprintf(buffer, "_part_%i.so", i);
sprintf(buffer, "_part_%i.so", slice);
print_generated_file_name(fp, module, FALSE, buffer);
}
}
......@@ -3042,9 +3042,9 @@ static void print_makefile(struct makefile_struct *makefile)
print_generated_file_name(fp, module, FALSE, "_setof.o");
print_generated_file_name(fp, module, FALSE, "_union.o");
} else if((n_slices = atoi(makefile->code_splitting_mode + 2))) {
for (int i = 1; i < n_slices; i++) {
for (int slice = 1; slice < n_slices; slice++) {
char buffer[16]; // 6 digits + 4 chars + _part
sprintf(buffer, "_part_%i.o", i);
sprintf(buffer, "_part_%i.o", slice);
print_generated_file_name(fp, module, FALSE, buffer);
}
}
......@@ -3065,9 +3065,9 @@ static void print_makefile(struct makefile_struct *makefile)
print_generated_file_name(fp, module, FALSE, "_setof.o");
print_generated_file_name(fp, module, FALSE, "_union.o");
} else if((n_slices = atoi(makefile->code_splitting_mode + 2))) {
for (int i = 1; i < n_slices; i++) {
for (int slice = 1; slice < n_slices; slice++) {
char buffer[16]; // 6 digits + 4 chars + _part
sprintf(buffer, "_part_%i.o", i);
sprintf(buffer, "_part_%i.o", slice);
print_generated_file_name(fp, module, FALSE, buffer);
}
}
......@@ -3088,9 +3088,9 @@ static void print_makefile(struct makefile_struct *makefile)
print_generated_file_name(fp, module, FALSE, "_setof.o");
print_generated_file_name(fp, module, FALSE, "_union.o");
} else if((n_slices = atoi(makefile->code_splitting_mode + 2))) {
for (int i = 1; i < n_slices; i++) {
for (int slice = 1; slice < n_slices; slice++) {
char buffer[16]; // 6 digits + 4 chars + _part
sprintf(buffer, "_part_%i.o", i);
sprintf(buffer, "_part_%i.o", slice);
print_generated_file_name(fp, module, FALSE, buffer);
}
}
......@@ -3111,9 +3111,9 @@ static void print_makefile(struct makefile_struct *makefile)
print_generated_file_name(fp, module, FALSE, "_setof.o");
print_generated_file_name(fp, module, FALSE, "_union.o");
} else if((n_slices = atoi(makefile->code_splitting_mode + 2))) {
for (int i = 1; i < n_slices; i++) {
for (int slice = 1; slice < n_slices; slice++) {
char buffer[16]; // 6 digits + 4 chars + _part
sprintf(buffer, "_part_%i.o", i);
sprintf(buffer, "_part_%i.o", slice);
print_generated_file_name(fp, module, FALSE, buffer);
}
}
......
......@@ -1843,10 +1843,10 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
/* Write some helper functions */
def = mputstr(def,
"char **collect_ns(const XERdescriptor_t& p_td, size_t& num_ns, bool& def_ns) const;\n");
"char **collect_ns(const XERdescriptor_t& p_td, size_t& num_ns, bool& def_ns, unsigned int flavor = 0) const;\n");
src = mputprintf(src,
"char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num_ns, bool& def_ns) const {\n"
"char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num_ns, bool& def_ns, unsigned int) const {\n"
" size_t num_collected;\n"
" char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns);\n"
/* The above might throw but then nothing was allocated. */
......@@ -1894,14 +1894,14 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
);
src = mputprintf(src,
"boolean %s::can_start(const char *name, const char *uri, const XERdescriptor_t& xd, unsigned int flavor) {\n"
"boolean %s::can_start(const char *name, const char *uri, const XERdescriptor_t& xd, unsigned int flavor, unsigned int flavor2) {\n"
" boolean e_xer = is_exer(flavor &= ~XER_RECOF);\n"
" if (!e_xer || !((xd.xer_bits & UNTAGGED) || (flavor & (USE_NIL|XER_RECOF)))) return check_name(name, xd, e_xer) && (!e_xer || check_namespace(uri, xd));\n"
, name
);
for (i = start_at; i < sdef->nElements; ++i) {
src = mputprintf(src,
" else if (%s::can_start(name, uri, %s_xer_, flavor)) return TRUE;\n"
" else if (%s::can_start(name, uri, %s_xer_, flavor, flavor2)) return TRUE;\n"
/* Here we know for sure it's exer */
, sdef->elements[i].type
, sdef->elements[i].typegen
......@@ -1915,7 +1915,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
/* * * * * * * * * * XER_encode * * * * * * * * * * * * * * */
src = mputprintf(src,
"int %s::XER_encode(const XERdescriptor_t& p_td, "
"TTCN_Buffer& p_buf, unsigned int p_flavor, int p_indent, embed_values_enc_struct_t* emb_val_parent) const\n"
"TTCN_Buffer& p_buf, unsigned int p_flavor, unsigned int p_flavor2, int p_indent, embed_values_enc_struct_t* emb_val_parent) const\n"
"{\n"
" if (!is_bound()) TTCN_EncDec_ErrorContext::error"
"(TTCN_EncDec::ET_UNBOUND, \"Encoding an unbound value.\");\n"
......@@ -2007,7 +2007,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
" if (e_xer && (p_td.xer_bits & USE_QNAME)) {\n"
" if (field_%s.is_value()) {\n"
" p_buf.put_s(11, (cbyte*)\" xmlns:b0='\");\n"
" field_%s.XER_encode(%s_xer_, p_buf, p_flavor | XER_LIST, p_indent+1, 0);\n"
" field_%s.XER_encode(%s_xer_, p_buf, p_flavor | XER_LIST, p_flavor2, p_indent+1, 0);\n"
" p_buf.put_c('\\'');\n"
" }\n"
" if (p_td.xer_bits & XER_ATTRIBUTE) begin_attribute(p_td, p_buf);\n"
......@@ -2016,7 +2016,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
" p_buf.put_s(3, (cbyte*)\"b0:\");\n"
" sub_len += 3;\n"
" }\n"
" sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor | XER_LIST, p_indent+1, 0);\n"
" sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor | XER_LIST, p_flavor2, p_indent+1, 0);\n"
" if (p_td.xer_bits & XER_ATTRIBUTE) p_buf.put_c('\\'');\n"
" } else" /* no newline */
, sdef->elements[0].name
......@@ -2032,7 +2032,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
src = mputprintf(src,
" if (!e_xer && (p_td.xer_bits & EMBED_VALUES)) {\n"
" ec_1.set_msg(\"%s': \");\n"
" sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_indent+1, 0);\n"
" sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_flavor2, p_indent+1, 0);\n"
" }\n"
, sdef->elements[0].dispname
, sdef->elements[0].name, sdef->elements[0].typegen
......@@ -2042,7 +2042,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
if (sdef->xerUseOrderPossible) {
src = mputprintf(src,
" if (!e_xer && (p_td.xer_bits & USE_ORDER)) {\n"
" sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_indent+1, 0);\n"
" sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_flavor2, p_indent+1, 0);\n"
" }\n"
, sdef->elements[uo].name, sdef->elements[uo].typegen
);
......@@ -2078,7 +2078,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
if (i==0 && sdef->xerEmbedValuesPossible && (sdef->elements[i].xerAnyKind & ANY_ATTRIB_BIT)) continue ;
src = mputprintf(src,
" ec_1.set_msg(\"%s': \");\n"
" tmp_len = field_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_indent+1, 0);\n"
" tmp_len = field_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_flavor2, p_indent+1, 0);\n"
" %ssub_len += tmp_len;\n" /* do not add if attribute and EXER */
, sdef->elements[i].dispname
, sdef->elements[i].name, sdef->elements[i].typegen
......@@ -2114,7 +2114,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
" if (e_xer && (p_td.xer_bits & EMBED_VALUES)) {\n"
/* write the first string (must come AFTER the attributes) */
" if (%s%s%s field_%s%s.size_of() > 0) {\n"
" sub_len += field_%s%s[0].XER_encode(UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
" sub_len += field_%s%s[0].XER_encode(UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_flavor2, p_indent+1, 0);\n"
" }\n"
" }\n"
, sdef->elements[0].dispname
......@@ -2127,7 +2127,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
if (want_namespaces) { /* here's another chance */
src = mputprintf(src,
" else if ( !(p_td.xer_bits & EMBED_VALUES)) {\n"
" %sfield_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_indent+1, 0);\n"
" %sfield_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_flavor2, p_indent+1, 0);\n"
" }\n"
, ((sdef->elements[0].xerAnyKind & ANY_ATTRIB_BIT) ? "" : "sub_len += " )
, sdef->elements[0].name, sdef->elements[0].typegen
......@@ -2183,7 +2183,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
src = mputprintf(src,
" if (!nil_attribute) {\n"
"%s"
" if (!e_xer) sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_indent+!omit_tag, 0);\n"
" if (!e_xer) sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor, p_flavor2, p_indent+!omit_tag, 0);\n"
" else" /* no newline */
, (sdef->xerUseNilPossible ? " if (!(p_td.xer_bits & USE_ORDER)) p_flavor |= (p_td.xer_bits & USE_NIL);\n" : "")
/* If USE-ORDER is on, the tag-removing effect of USE-NIL has been
......@@ -2238,7 +2238,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
src = mputprintf(src,
" case %lu:\n"
" ec_1.set_msg(\"%s': \");\n"
" sub_len += field_%s%s%s%s.XER_encode(%s_xer_, p_buf, p_flavor, p_indent+!omit_tag, %s);\n"
" sub_len += field_%s%s%s%s.XER_encode(%s_xer_, p_buf, p_flavor, p_flavor2, p_indent+!omit_tag, %s);\n"
, (unsigned long)offset++
, sdef->elements[i].dispname
......@@ -2263,7 +2263,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
" if (e_xer && (p_td.xer_bits & EMBED_VALUES) && 0 != emb_val &&\n"
" %s%s%s emb_val->embval_index < field_%s%s.size_of()) { // embed-val\n"
" field_%s%s[emb_val->embval_index].XER_encode(\n"
" UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
" UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_flavor2, p_indent+1, 0);\n"
" ++emb_val->embval_index;\n"
" }\n"
, sdef->elements[0].isOptional ? "field_" : ""
......@@ -2295,13 +2295,13 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
" if (0 != emb_val_parent->embval_array_reg) {\n"
" if (emb_val_parent->embval_index < emb_val_parent->embval_array_reg->size_of()) {\n"
" (*emb_val_parent->embval_array_reg)[emb_val_parent->embval_index].XER_encode(UNIVERSAL_CHARSTRING_xer_"
" , p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
" , p_buf, p_flavor | EMBED_VALUES, p_flavor2, p_indent+1, 0);\n"
" ++emb_val_parent->embval_index;\n"
" }\n"
" } else {\n"
" if (emb_val_parent->embval_index < emb_val_parent->embval_array_opt->size_of()) {\n"
" (*emb_val_parent->embval_array_opt)[emb_val_parent->embval_index].XER_encode(UNIVERSAL_CHARSTRING_xer_"
" , p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
" , p_buf, p_flavor | EMBED_VALUES, p_flavor2, p_indent+1, 0);\n"
" ++emb_val_parent->embval_index;\n"
" }\n"
" }\n"
......@@ -2312,7 +2312,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
);
}
src = mputprintf(src,
" sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor%s, p_indent+!omit_tag, %s);\n"
" sub_len += field_%s.XER_encode(%s_xer_, p_buf, p_flavor%s, p_flavor2, p_indent+!omit_tag, %s);\n"
, sdef->elements[i].name, sdef->elements[i].typegen
, sdef->xerUseNilPossible ? "| (p_td.xer_bits & USE_NIL)" : ""
, sdef->xerEmbedValuesPossible ? "emb_val" : "0"
......@@ -2323,7 +2323,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
" if (e_xer && (p_td.xer_bits & EMBED_VALUES) && 0 != emb_val &&\n"
" %s%s%s %s%s%s emb_val->embval_index < field_%s%s.size_of()) {\n"
" field_%s%s[emb_val->embval_index].XER_encode(\n"
" UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
" UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_flavor2, p_indent+1, 0);\n"
" ++emb_val->embval_index;\n"
" }\n"
, sdef->elements[0].isOptional ? "field_" : ""
......@@ -2602,7 +2602,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
if (sdef->control_ns_prefix && !(num_attributes==1 && aa_index!=-1)) {
src = mputprintf(src,
" if (parent_tag && !strcmp(attr_name, \"type\") "
" if (/*parent_tag &&*/ !strcmp(attr_name, \"type\") "
"&& !strcmp((const char*)p_reader.Prefix(), \"%s\")) {} else\n"
, sdef->control_ns_prefix);
/* xsi:type; already processed by parent with USE-UNION or USE-TYPE */
......@@ -6016,7 +6016,7 @@ static void defEmptyRecordClass(const struct_def *sdef,
if (xer_needed) { /* XERSTUFF codegen for empty record/SEQUENCE */
src=mputprintf(src,
"boolean %s::can_start(const char *p_name, const char *p_uri, "
"const XERdescriptor_t& p_td, unsigned int p_flavor) {\n"
"const XERdescriptor_t& p_td, unsigned int p_flavor, unsigned int /*p_flavor2*/) {\n"
" boolean e_xer = is_exer(p_flavor);\n"
" if (e_xer && (p_td.xer_bits & UNTAGGED)) return FALSE;\n"
" else return check_name(p_name, p_td, e_xer) && (!e_xer || check_namespace(p_uri, p_td));\n"
......@@ -6026,7 +6026,7 @@ static void defEmptyRecordClass(const struct_def *sdef,
);
src = mputprintf(src,
"int %s::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf, "
"unsigned int p_flavor, int p_indent, embed_values_enc_struct_t*) const{\n"
"unsigned int p_flavor, unsigned int, int p_indent, embed_values_enc_struct_t*) const{\n"
" int encoded_length=(int)p_buf.get_len();\n"
" int is_indented = !is_canonical(p_flavor);\n"
" boolean e_xer = is_exer(p_flavor);\n"
......@@ -6952,9 +6952,9 @@ check_generate_end:
"static const XERdescriptor_t* xer_descriptors[];\n"
"const XERdescriptor_t* xer_descr(int p_index) const;\n"
"virtual boolean can_start_v(const char *name, const char *prefix, "
"XERdescriptor_t const& xd, unsigned int flavor);\n"
"XERdescriptor_t const& xd, unsigned int flavor, unsigned int flavor2);\n"
"static boolean can_start (const char *name, const char *prefix, "
"XERdescriptor_t const& xd, unsigned int flavor);\n");
"XERdescriptor_t const& xd, unsigned int flavor, unsigned int flavor2);\n");
src = mputprintf(src, "const XERdescriptor_t* %s::xer_descriptors[] = ", name);
for (i = 0; i < sdef->nElements; i++) {
src = mputprintf(src, "%c &%s_xer_",
......@@ -6968,16 +6968,16 @@ check_generate_end:
* We must make a virtual call in Record_Type::XER_decode because
* we don't know the actual type (derived from Record_Type) */
"boolean %s::can_start_v(const char *p_name, const char *p_uri, "
"XERdescriptor_t const& p_td, unsigned int p_flavor)\n"
"{ return can_start(p_name, p_uri, p_td, p_flavor); }\n"
"XERdescriptor_t const& p_td, unsigned int p_flavor, unsigned int p_flavor2)\n"
"{ return can_start(p_name, p_uri, p_td, p_flavor, p_flavor2); }\n"
"boolean %s::can_start(const char *p_name, const char *p_uri, "
"XERdescriptor_t const& p_td, unsigned int p_flavor) {\n"
"XERdescriptor_t const& p_td, unsigned int p_flavor, unsigned int p_flavor2) {\n"
" boolean e_xer = is_exer(p_flavor);\n"
" if (!e_xer || (!(p_td.xer_bits & UNTAGGED) && !(p_flavor & USE_NIL))) return check_name(p_name, p_td, e_xer) && (!e_xer || check_namespace(p_uri, p_td));\n"
, name , name, name);
for (i = 0; i < sdef->nElements; i++) {
src = mputprintf(src,
" else if (%s::can_start(p_name, p_uri, %s_xer_, p_flavor)) return TRUE;\n"
" else if (%s::can_start(p_name, p_uri, %s_xer_, p_flavor, p_flavor2)) return TRUE;\n"
, sdef->elements[i].type, sdef->elements[i].typegen);
}
src = mputstr(src,
......@@ -7001,7 +7001,7 @@ check_generate_end:
}
else { /* XER not needed */
def = mputstr(def,
"boolean can_start_v(const char *, const char *, XERdescriptor_t const&, unsigned int)\n"
"boolean can_start_v(const char *, const char *, XERdescriptor_t const&, unsigned int, unsigned int)\n"
"{ return FALSE; }\n"
);
} /* if (xer_needed) */
......
......@@ -1046,13 +1046,13 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
if (xer_needed) { /* XERSTUFF encoder codegen for record-of, RT1 */
def = mputstr(def,
"char **collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns) const;\n");
"char **collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int flavor = 0) const;\n");
/* Write the body of the XER encoder/decoder functions. The declaration
* is written by def_encdec() in encdec.c */
src = mputprintf(src,
"boolean %s::can_start(const char *name, const char *uri, "
"XERdescriptor_t const& xd, unsigned int flavor) {\n"
"XERdescriptor_t const& xd, unsigned int flavor, unsigned int flavor2) {\n"
" boolean e_xer = is_exer(flavor);\n"
" if ((!e_xer || !(xd.xer_bits & UNTAGGED)) && !(flavor & XER_RECOF)) return "
"check_name(name, xd, e_xer) && (!e_xer || check_namespace(uri, xd));\n"
......@@ -1067,7 +1067,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
src = mputstr(src, "{\n");
for (f = 0; f < sdef->nFollowers; ++f) {
src = mputprintf(src,
" if (%s::can_start(name, uri, %s_xer_, flavor)) return FALSE;\n"
" if (%s::can_start(name, uri, %s_xer_, flavor, flavor2)) return FALSE;\n"
, sdef->followers[f].type
, sdef->followers[f].typegen
);
......@@ -1079,13 +1079,13 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
else src = mputstr(src, "return TRUE;\n");
src = mputprintf(src,
" return %s::can_start(name, uri, *xd.oftype_descr, flavor | XER_RECOF);\n"
" return %s::can_start(name, uri, *xd.oftype_descr, flavor | XER_RECOF, flavor2);\n"
"}\n\n"
, sdef->type
);
src = mputprintf(src,
"char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns) const {\n"
"char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int) const {\n"
" size_t num_collected;\n"
" char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns);\n"
/* The above may throw but then nothing was allocated. */
......@@ -1113,7 +1113,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
src=mputprintf(src,
"int %s::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf, "
"unsigned int p_flavor, int p_indent, embed_values_enc_struct_t* emb_val) const\n{\n"
"unsigned int p_flavor, unsigned int p_flavor2, int p_indent, embed_values_enc_struct_t* emb_val) const\n{\n"
" if (val_ptr == 0) TTCN_error(\"Attempt to XER-encode an unbound record of\");\n" /* TODO type name */
" int encoded_length=(int)p_buf.get_len();\n"
" boolean e_xer = is_exer(p_flavor);\n"
......@@ -1209,7 +1209,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" p_buf.put_s(ns_len, (const unsigned char*)ns);\n"
" UNIVERSAL_CHARSTRING before(sp_at, (const universal_char*)(*val_ptr->value_elements[i]));\n"
" before.XER_encode(UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | ANY_ATTRIBUTES, p_indent, 0);\n"
" before.XER_encode(UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | ANY_ATTRIBUTES, p_flavor2, p_indent, 0);\n"
// Ensure the namespace abides to its restrictions
" if (p_td.xer_bits & (ANY_FROM | ANY_EXCEPT)) {\n"
" TTCN_Buffer ns_buf;\n"
......@@ -1237,7 +1237,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" }\n"
" UNIVERSAL_CHARSTRING after(len - j, (const universal_char*)(*val_ptr->value_elements[i]) + j);\n"
" after.XER_encode(UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | ANY_ATTRIBUTES, p_indent, 0);\n"
" after.XER_encode(UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | ANY_ATTRIBUTES, p_flavor2, p_indent, 0);\n"
// Put this attribute in a dummy element and walk through it to check its validity
" TTCN_Buffer check_buf;\n"
" check_buf.put_s(2, (const unsigned char*)\"<a\");\n"
......@@ -1300,17 +1300,17 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" emb_val->embval_array_reg->size_of() : emb_val->embval_array_opt->size_of())) {\n"
" if (0 != emb_val->embval_array_reg) {\n"
" (*emb_val->embval_array_reg)[emb_val->embval_index].XER_encode(\n"
" UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
" UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_flavor2, p_indent+1, 0);\n"
" }\n"
" else {\n"
" (*emb_val->embval_array_opt)[emb_val->embval_index].XER_encode(\n"
" UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_indent+1, 0);\n"
" UNIVERSAL_CHARSTRING_xer_, p_buf, p_flavor | EMBED_VALUES, p_flavor2, p_indent+1, 0);\n"
" }\n"
" ++emb_val->embval_index;\n"
" }\n"
" ec_1.set_msg(\"%d: \", i);\n"
" if (e_xer && (p_td.xer_bits & XER_LIST) && i>0) p_buf.put_c(' ');\n"
" (*this)[i].XER_encode(*p_td.oftype_descr, p_buf, p_flavor, p_indent+own_tag, emb_val);\n"
" (*this)[i].XER_encode(*p_td.oftype_descr, p_buf, p_flavor, p_flavor2, p_indent+own_tag, emb_val);\n"
" }\n"
" if (indenting && !is_exerlist(p_flavor)) {\n"
);
......@@ -1486,7 +1486,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
/* An untagged record-of ends if it encounters an element with a name
* that doesn't match its component */
" if (!own_tag && !can_start((const char*)p_reader.LocalName(), "
"(const char*)p_reader.NamespaceUri(), p_td, p_flavor)) {\n"
"(const char*)p_reader.NamespaceUri(), p_td, p_flavor, p_flavor2)) {\n"
" for (; rd_ok == 1 && p_reader.Depth() > xml_depth; rd_ok = p_reader.Read()) ;\n"
" break;\n"
" }\n"
......@@ -2514,13 +2514,13 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
if (xer_needed) { /* XERSTUFF encoder codegen for record-of, RT1 */
def = mputstr(def,
"char **collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns) const;\n");
"char **collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int flavor = 0) const;\n");
/* Write the body of the XER encoder/decoder functions. The declaration
* is written by def_encdec() in encdec.c */
src = mputprintf(src,
"boolean %s::can_start(const char *name, const char *uri, "
"XERdescriptor_t const& xd, unsigned int flavor) {\n"
"XERdescriptor_t const& xd, unsigned int flavor, unsigned int flavor2) {\n"
" boolean e_xer = is_exer(flavor);\n"
" if ((!e_xer || !(xd.xer_bits & UNTAGGED)) && !(flavor & XER_RECOF)) return "
"check_name(name, xd, e_xer) && (!e_xer || check_namespace(uri, xd));\n"
......@@ -2535,7 +2535,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
src = mputstr(src, "{\n");
for (f = 0; f < sdef->nFollowers; ++f) {
src = mputprintf(src,
" if (%s::can_start(name, uri, %s_xer_, flavor)) return FALSE;\n"
" if (%s::can_start(name, uri, %s_xer_, flavor, flavor2)) return FALSE;\n"
, sdef->followers[f].type
, sdef->followers[f].typegen
);
......@@ -2547,13 +2547,13 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
else src = mputstr(src, "return TRUE;\n");
src = mputprintf(src,
" return %s::can_start(name, uri, *xd.oftype_descr, flavor | XER_RECOF);\n"
" return %s::can_start(name, uri, *xd.oftype_descr, flavor | XER_RECOF, flavor2);\n"
"}\n\n"
, sdef->type
);
src = mputprintf(src,
"char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns) const {\n"
"char ** %s::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& def_ns, unsigned int) const {\n"
" size_t num_collected;\n"
" char **collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns);\n"