Commit a908f98f authored by Botond Baranyi's avatar Botond Baranyi Committed by Gerrit Code Review
Browse files

Merge "changed PER encoding to work the same way as custom encoding, and...

Merge "changed PER encoding to work the same way as custom encoding, and enabled bitstring as stream type for all codecs (bug 508200)"
parents 35e9099e c27f89d0
...@@ -176,6 +176,9 @@ namespace Common { ...@@ -176,6 +176,9 @@ namespace Common {
Type *Type::get_stream_type(MessageEncodingType_t encoding_type, int stream_variant) Type *Type::get_stream_type(MessageEncodingType_t encoding_type, int stream_variant)
{ {
if (stream_variant == 0) {
return get_pooltype(T_BSTR);
}
switch (encoding_type) { switch (encoding_type) {
case CT_BER: case CT_BER:
case CT_PER: case CT_PER:
...@@ -184,13 +187,11 @@ namespace Common { ...@@ -184,13 +187,11 @@ namespace Common {
case CT_JSON: case CT_JSON:
return get_pooltype(T_OSTR); return get_pooltype(T_OSTR);
case CT_TEXT: case CT_TEXT:
if(stream_variant==0){ if(stream_variant==1){
return get_pooltype(T_CSTR); return get_pooltype(T_CSTR);
} else { } else {
return get_pooltype(T_OSTR); return get_pooltype(T_OSTR);
} }
case CT_CUSTOM:
return get_pooltype(T_BSTR);
default: default:
FATAL_ERROR("Type::get_stream_type()"); FATAL_ERROR("Type::get_stream_type()");
return 0; return 0;
...@@ -606,6 +607,8 @@ namespace Common { ...@@ -606,6 +607,8 @@ namespace Common {
chk_finished = false; chk_finished = false;
pard_type_instance = false; pard_type_instance = false;
needs_any_from_done = false; needs_any_from_done = false;
encoding_by_function = false;
decoding_by_function = false;
asn_encoding = CT_UNDEF; asn_encoding = CT_UNDEF;
asn_decoding = CT_UNDEF; asn_decoding = CT_UNDEF;
} }
...@@ -4395,27 +4398,45 @@ namespace Common { ...@@ -4395,27 +4398,45 @@ namespace Common {
void Type::set_coding_function(bool encode, const string& function_name) void Type::set_coding_function(bool encode, const string& function_name)
{ {
string& coding_str = encode ? encoding_str : decoding_str; string& coding_function = encode ? encoding_function : decoding_function;
if (!coding_str.empty()) { MessageEncodingType_t& asn_coding = encode ? asn_encoding : asn_decoding;
error("Multiple custom %s functions declared for type '%s' (function `%s' " bool& coding_by_function = encode ?
"is already set)", encode ? "encoding" : "decoding", encoding_by_function : decoding_by_function;
get_typename().c_str(), coding_str.c_str()); if (!coding_function.empty()) {
// leave coding_by_function as true, this will indicate that there are
// multiple coding functions set
coding_function.clear();
}
else if (asn_coding != CT_UNDEF) {
// a different encoding type is already set for the ASN.1 type
asn_coding = CT_MULTIPLE;
coding_function.clear();
return; return;
} }
coding_str = function_name; else {
coding_by_function = true; if (is_asn1()) {
asn_coding = CT_PER;
}
coding_function = function_name;
coding_by_function = true;
}
} }
void Type::set_asn_coding(bool encode, Type::MessageEncodingType_t new_coding) void Type::set_asn_coding(bool encode, Type::MessageEncodingType_t new_coding)
{ {
MessageEncodingType_t& coding = encode ? asn_encoding : asn_decoding; MessageEncodingType_t& coding = encode ? asn_encoding : asn_decoding;
if (coding == CT_UNDEF) { bool& coding_by_function = encode ?
encoding_by_function : decoding_by_function; // true = PER coder is set
string& coding_function = encode ? encoding_function : decoding_function; // PER coder
if (coding == CT_UNDEF && !coding_by_function) {
// this is the first encoding/decoding function for this type, store it // this is the first encoding/decoding function for this type, store it
// (also, no PER coders have been set for the type yet)
coding = new_coding; coding = new_coding;
} }
else if (coding != new_coding) { else if (coding != new_coding || coding_by_function) {
// there are several encoding/decoding functions declared for this type // there are several encoding/decoding functions declared for this type
// with different codings (encvalue/decvalue cannot be used in this case) // with different codings (encvalue/decvalue cannot be used in this case)
coding_function.clear();
coding = CT_MULTIPLE; coding = CT_MULTIPLE;
} }
} }
...@@ -4424,7 +4445,8 @@ namespace Common { ...@@ -4424,7 +4445,8 @@ namespace Common {
string& coding_str = encode ? encoding_str : decoding_str; string& coding_str = encode ? encoding_str : decoding_str;
if (!coding_str.empty()) if (!coding_str.empty())
return; return;
coding_by_function = false; bool& coding_by_function = encode ?
encoding_by_function : decoding_by_function;
Type::MessageEncodingType_t coding = CT_UNDEF; Type::MessageEncodingType_t coding = CT_UNDEF;
if (!is_asn1()) { if (!is_asn1()) {
...@@ -4517,18 +4539,18 @@ namespace Common { ...@@ -4517,18 +4539,18 @@ namespace Common {
else { // ASN.1 type else { // ASN.1 type
coding = encode ? asn_encoding : asn_decoding; coding = encode ? asn_encoding : asn_decoding;
if ((coding == CT_UNDEF && delayed) || coding == CT_MULTIPLE) { if ((coding == CT_UNDEF && delayed) || coding == CT_MULTIPLE) {
// either this is the delayed call and no external function has been // either this is the delayed call and no external functions have been
// found, or there was already more than one function // found, or there was already more than one function
error("Cannot determine the %s rules for ASN.1 type `%s'. " error("Cannot determine the %s rules for ASN.1 type `%s'. "
"%s %s external function%s found%s", encode ? "encoding" : "decoding", "%s %s external functions found%s", encode ? "encoding" : "decoding",
get_typename().c_str(), coding == CT_UNDEF ? "No" : "Multiple", get_typename().c_str(), coding == CT_UNDEF ? "No" : "Multiple",
encode ? "encoding" : "decoding", coding == CT_UNDEF ? "" : "s", encode ? "encoding" : "decoding",
coding == CT_UNDEF ? "" : " with different rules"); coding == CT_UNDEF ? "" : " with different rules");
return; return;
} }
if (coding == CT_UNDEF && !delayed) { if (!delayed) {
// the coding type is set by the external function's checker in this case; // there have been no errors so far in determining the coding type,
// it's possible, that the function exists, but has not been reached yet; // but there might still be unchecked external functions out there;
// delay this function until everything else has been checked // delay this function until everything else has been checked
Modules::delay_type_encode_check(this, encode); Modules::delay_type_encode_check(this, encode);
return; return;
...@@ -4547,9 +4569,6 @@ namespace Common { ...@@ -4547,9 +4569,6 @@ namespace Common {
case CT_TEXT: case CT_TEXT:
coding_str = "TEXT"; coding_str = "TEXT";
break; break;
case CT_PER:
coding_str = "PER";
break;
case CT_XER: case CT_XER:
coding_str = "XER, XER_EXTENDED"; // TODO: fine tuning this parameter coding_str = "XER, XER_EXTENDED"; // TODO: fine tuning this parameter
break; break;
...@@ -4568,20 +4587,31 @@ namespace Common { ...@@ -4568,20 +4587,31 @@ namespace Common {
if (!berattrib) if (!berattrib)
delete ber; delete ber;
break; } break; }
case CT_CUSTOM: case CT_PER:
if (!delayed) { case CT_CUSTOM: {
// coding_str is set by the coding function's checker in this case; // the coding function is set by its semantic checker in this case
// it's possible, that the function exists, but has not been reached yet; string& coding_function = encode ? encoding_function : decoding_function;
if (coding_function.empty() && coding_by_function) {
error("Multiple %s %s functions set for type `%s'",
get_encoding_name(coding), encode ? "encoding" : "decoding",
get_typename().c_str());
}
else if (!delayed) {
// there have been no errors so far in determining the coding function,
// but there might still be unchecked external functions out there;
// delay this function until everything else has been checked // delay this function until everything else has been checked
Modules::delay_type_encode_check(this, encode); Modules::delay_type_encode_check(this, encode);
} }
else if (coding_str.empty()) { else if (coding_function.empty()) {
// this is the delayed call, and the custom coding function has still // this is the delayed call, and the coding function has still not been set
// not been found error("No %s %s function found for type `%s'", get_encoding_name(coding),
error("No custom %s function found for type `%s'",
encode ? "encoding" : "decoding", get_typename().c_str()); encode ? "encoding" : "decoding", get_typename().c_str());
} }
return; else {
// this is the delayed call, and exactly one coding function has been set
coding_str = coding_function;
}
return; }
default: default:
error("Unknown coding selected for type '%s'", get_typename().c_str()); error("Unknown coding selected for type '%s'", get_typename().c_str());
break; break;
...@@ -4589,8 +4619,8 @@ namespace Common { ...@@ -4589,8 +4619,8 @@ namespace Common {
coding_by_function = false; coding_by_function = false;
} }
bool Type::is_coding_by_function() const { bool Type::is_coding_by_function(bool encode) const {
return coding_by_function; return encode ? encoding_by_function : decoding_by_function;
} }
const string& Type::get_coding(bool encode) const { const string& Type::get_coding(bool encode) const {
......
...@@ -307,7 +307,10 @@ namespace Common { ...@@ -307,7 +307,10 @@ namespace Common {
string encoding_str; // needed by codegen for encvalue() and decvalue() string encoding_str; // needed by codegen for encvalue() and decvalue()
string decoding_str; string decoding_str;
bool coding_by_function; // false - coding attribute is set, true - coding via coding function bool encoding_by_function; // false - coding attribute is set, true - coding via coding function
bool decoding_by_function; // same for decoding
string encoding_function; // name of custom or PER encoder
string decoding_function; // name of custom or PER decoder
MessageEncodingType_t asn_encoding; // set by the semantic analysis of encoding MessageEncodingType_t asn_encoding; // set by the semantic analysis of encoding
MessageEncodingType_t asn_decoding; // and decoding external functions for ASN.1 types MessageEncodingType_t asn_decoding; // and decoding external functions for ASN.1 types
/** What kind of AST element owns the type. /** What kind of AST element owns the type.
...@@ -659,7 +662,7 @@ namespace Common { ...@@ -659,7 +662,7 @@ namespace Common {
void set_coding_function(bool encode, const string& function_name); void set_coding_function(bool encode, const string& function_name);
void set_asn_coding(bool encode, MessageEncodingType_t new_coding); void set_asn_coding(bool encode, MessageEncodingType_t new_coding);
void chk_coding(bool encode, bool delayed = false); void chk_coding(bool encode, bool delayed = false);
bool is_coding_by_function() const; bool is_coding_by_function(bool encode) const;
const string& get_coding(bool encode) const; const string& get_coding(bool encode) const;
private: private:
static MessageEncodingType_t get_enc_type(const Ttcn::SingleWithAttrib& enc); static MessageEncodingType_t get_enc_type(const Ttcn::SingleWithAttrib& enc);
......
...@@ -12970,7 +12970,7 @@ error: ...@@ -12970,7 +12970,7 @@ error:
break; break;
} }
if (!gov_last->is_coding_by_function()) { if (!gov_last->is_coding_by_function(true)) {
const string& tmp_id = get_temporary_id(); const string& tmp_id = get_temporary_id();
const string& tmp_buf_id = get_temporary_id(); const string& tmp_buf_id = get_temporary_id();
const string& tmp_ref_id = get_temporary_id(); const string& tmp_ref_id = get_temporary_id();
...@@ -13031,7 +13031,7 @@ error: ...@@ -13031,7 +13031,7 @@ error:
if (expr2.preamble) if (expr2.preamble)
expr->preamble = mputprintf(expr->preamble, "%s", expr2.preamble); expr->preamble = mputprintf(expr->preamble, "%s", expr2.preamble);
if (!_type->is_coding_by_function()) { if (!_type->is_coding_by_function(false)) {
const string& tmp_id = get_temporary_id(); const string& tmp_id = get_temporary_id();
const string& buffer_id = get_temporary_id(); const string& buffer_id = get_temporary_id();
const string& retval_id = get_temporary_id(); const string& retval_id = get_temporary_id();
...@@ -13127,7 +13127,7 @@ void Value::generate_code_expr_encvalue_unichar(expression_struct *expr) ...@@ -13127,7 +13127,7 @@ void Value::generate_code_expr_encvalue_unichar(expression_struct *expr)
v2_code = generate_code_char_coding_check(expr, u.expr.v2, "encvalue_unichar"); v2_code = generate_code_char_coding_check(expr, u.expr.v2, "encvalue_unichar");
} }
if (!gov_last->is_coding_by_function()) { if (!gov_last->is_coding_by_function(true)) {
const string& tmp_id = get_temporary_id(); const string& tmp_id = get_temporary_id();
const string& tmp_buf_id = get_temporary_id(); const string& tmp_buf_id = get_temporary_id();
const string& tmp_ref_id = get_temporary_id(); const string& tmp_ref_id = get_temporary_id();
...@@ -13205,7 +13205,7 @@ void Value::generate_code_expr_encvalue_unichar(expression_struct *expr) ...@@ -13205,7 +13205,7 @@ void Value::generate_code_expr_encvalue_unichar(expression_struct *expr)
v3_code = generate_code_char_coding_check(expr, u.expr.v3, "decvalue_unichar"); v3_code = generate_code_char_coding_check(expr, u.expr.v3, "decvalue_unichar");
} }
if (!_type->is_coding_by_function()) { if (!_type->is_coding_by_function(false)) {
const string& tmp_id = get_temporary_id(); const string& tmp_id = get_temporary_id();
const string& buffer_id = get_temporary_id(); const string& buffer_id = get_temporary_id();
const string& retval_id = get_temporary_id(); const string& retval_id = get_temporary_id();
......
...@@ -6561,9 +6561,11 @@ namespace Ttcn { ...@@ -6561,9 +6561,11 @@ namespace Ttcn {
// "untagged" on the (toplevel) input type will have no effect. // "untagged" on the (toplevel) input type will have no effect.
warning("UNTAGGED encoding attribute is ignored on top-level type"); warning("UNTAGGED encoding attribute is ignored on top-level type");
} }
if (Common::Type::CT_CUSTOM == encoding_type) { if (Common::Type::CT_CUSTOM == encoding_type ||
Common::Type::CT_PER == encoding_type) {
if (PROTOTYPE_CONVERT != prototype) { if (PROTOTYPE_CONVERT != prototype) {
error("Only `prototype(convert)' is allowed for custom encoding functions"); error("Only `prototype(convert)' is allowed for %s encoding functions",
Type::get_encoding_name(encoding_type));
} }
else { else {
// let the input type know that this is its encoding function // let the input type know that this is its encoding function
...@@ -6580,17 +6582,25 @@ namespace Ttcn { ...@@ -6580,17 +6582,25 @@ namespace Ttcn {
} }
} }
if (output_type) { if (output_type) {
if(encoding_type == Common::Type::CT_TEXT) { // TEXT encoding supports both octetstring and charstring stream types if(encoding_type == Common::Type::CT_TEXT) {
// TEXT encoding supports bitstring, octetstring and charstring stream types
Type *stream_type = Type::get_stream_type(encoding_type,0); Type *stream_type = Type::get_stream_type(encoding_type,0);
Type *stream_type2 = Type::get_stream_type(encoding_type,1); Type *stream_type2 = Type::get_stream_type(encoding_type,1);
if ( (!stream_type->is_identical(output_type)) && (!stream_type2->is_identical(output_type)) ) { Type *stream_type3 = Type::get_stream_type(encoding_type,2);
output_type->error("The output type of %s encoding should be `%s' or `%s' " if ( (!stream_type->is_identical(output_type)) &&
"instead of `%s'", Type::get_encoding_name(encoding_type), (!stream_type2->is_identical(output_type)) &&
(!stream_type3->is_identical(output_type))) {
output_type->error("The output type of %s encoding should be `%s', "
"`%s' or `%s' instead of `%s'", Type::get_encoding_name(encoding_type),
stream_type->get_typename().c_str(), stream_type->get_typename().c_str(),
stream_type2->get_typename().c_str(), stream_type2->get_typename().c_str(),
stream_type3->get_typename().c_str(),
output_type->get_typename().c_str()); output_type->get_typename().c_str());
} }
} else { }
else if (encoding_type == Common::Type::CT_CUSTOM ||
encoding_type == Common::Type::CT_PER) {
// custom and PER encodings only support the bitstring stream type
Type *stream_type = Type::get_stream_type(encoding_type); Type *stream_type = Type::get_stream_type(encoding_type);
if (!stream_type->is_identical(output_type)) { if (!stream_type->is_identical(output_type)) {
output_type->error("The output type of %s encoding should be `%s' " output_type->error("The output type of %s encoding should be `%s' "
...@@ -6599,6 +6609,19 @@ namespace Ttcn { ...@@ -6599,6 +6609,19 @@ namespace Ttcn {
output_type->get_typename().c_str()); output_type->get_typename().c_str());
} }
} }
else {
// all other encodings support bitstring and octetstring stream types
Type *stream_type = Type::get_stream_type(encoding_type, 0);
Type *stream_type2 = Type::get_stream_type(encoding_type, 1);
if (!stream_type->is_identical(output_type) &&
!stream_type2->is_identical(output_type)) {
output_type->error("The output type of %s encoding should be `%s' "
"or '%s' instead of `%s'", Type::get_encoding_name(encoding_type),
stream_type->get_typename().c_str(),
stream_type2->get_typename().c_str(),
output_type->get_typename().c_str());
}
}
} }
if (eb_list) eb_list->chk(); if (eb_list) eb_list->chk();
chk_allowed_encode(); chk_allowed_encode();
...@@ -6608,17 +6631,25 @@ namespace Ttcn { ...@@ -6608,17 +6631,25 @@ namespace Ttcn {
error("Attribute `decode' cannot be used without `prototype'"); error("Attribute `decode' cannot be used without `prototype'");
} }
if (input_type) { if (input_type) {
if(encoding_type == Common::Type::CT_TEXT) { // TEXT encoding supports both octetstring and charstring stream types if(encoding_type == Common::Type::CT_TEXT) {
// TEXT encoding supports bitstring, octetstring and charstring stream types
Type *stream_type = Type::get_stream_type(encoding_type,0); Type *stream_type = Type::get_stream_type(encoding_type,0);
Type *stream_type2 = Type::get_stream_type(encoding_type,1); Type *stream_type2 = Type::get_stream_type(encoding_type,1);
if ( (!stream_type->is_identical(input_type)) && (!stream_type2->is_identical(input_type)) ) { Type *stream_type3 = Type::get_stream_type(encoding_type,2);
input_type->error("The input type of %s decoding should be `%s' or `%s' " if ( (!stream_type->is_identical(input_type)) &&
"instead of `%s'", Type::get_encoding_name(encoding_type), (!stream_type2->is_identical(input_type)) &&
(!stream_type3->is_identical(input_type))) {
input_type->error("The input type of %s decoding should be `%s', "
"`%s' or `%s' instead of `%s'", Type::get_encoding_name(encoding_type),
stream_type->get_typename().c_str(), stream_type->get_typename().c_str(),
stream_type2->get_typename().c_str(), stream_type2->get_typename().c_str(),
stream_type3->get_typename().c_str(),
input_type->get_typename().c_str()); input_type->get_typename().c_str());
} }
} else { }
else if (encoding_type == Common::Type::CT_CUSTOM ||
encoding_type == Common::Type::CT_PER) {
// custom and PER encodings only support the bitstring stream type
Type *stream_type = Type::get_stream_type(encoding_type); Type *stream_type = Type::get_stream_type(encoding_type);
if (!stream_type->is_identical(input_type)) { if (!stream_type->is_identical(input_type)) {
input_type->error("The input type of %s decoding should be `%s' " input_type->error("The input type of %s decoding should be `%s' "
...@@ -6627,7 +6658,19 @@ namespace Ttcn { ...@@ -6627,7 +6658,19 @@ namespace Ttcn {
input_type->get_typename().c_str()); input_type->get_typename().c_str());
} }
} }
else {
// all other encodings support bitstring and octetstring stream types
Type *stream_type = Type::get_stream_type(encoding_type, 0);
Type *stream_type2 = Type::get_stream_type(encoding_type, 1);
if (!stream_type->is_identical(input_type) &&
!stream_type2->is_identical(input_type)) {
input_type->error("The input type of %s decoding should be `%s' "
"or `%s' instead of `%s'", Type::get_encoding_name(encoding_type),
stream_type->get_typename().c_str(),
stream_type2->get_typename().c_str(),
input_type->get_typename().c_str());
}
}
} }
if (output_type && !output_type->has_encoding(encoding_type, encoding_options)) { if (output_type && !output_type->has_encoding(encoding_type, encoding_options)) {
if (Common::Type::CT_CUSTOM == encoding_type) { if (Common::Type::CT_CUSTOM == encoding_type) {
...@@ -6641,9 +6684,11 @@ namespace Ttcn { ...@@ -6641,9 +6684,11 @@ namespace Ttcn {
} }
} }
else { else {
if (Common::Type::CT_CUSTOM == encoding_type) { if (Common::Type::CT_CUSTOM == encoding_type ||
Common::Type::CT_PER == encoding_type) {
if (PROTOTYPE_SLIDING != prototype) { if (PROTOTYPE_SLIDING != prototype) {
error("Only `prototype(sliding)' is allowed for custom decoding functions"); error("Only `prototype(sliding)' is allowed for %s decoding functions",
Type::get_encoding_name(encoding_type));
} }
else if (output_type) { else if (output_type) {
// let the output type know that this is its decoding function // let the output type know that this is its decoding function
...@@ -6863,13 +6908,25 @@ namespace Ttcn { ...@@ -6863,13 +6908,25 @@ namespace Ttcn {
result_name = 0; result_name = 0;
} }
// taking the result from the buffer and producing debug printout // taking the result from the buffer and producing debug printout
str = mputprintf(str, "ttcn_buffer.get_string(%s);\n" if (output_type->get_type_refd_last()->get_typetype_ttcn3() ==
Common::Type::T_BSTR) {
// cannot extract a bitstring from the buffer, use temporary octetstring
// and convert it to bitstring
str = mputprintf(str,
"OCTETSTRING tmp_os;\n"
"ttcn_buffer.get_string(tmp_os);\n"
"%s = oct2bit(tmp_os);\n", result_name);
}
else {
str = mputprintf(str, "ttcn_buffer.get_string(%s);\n", result_name);
}
str = mputprintf(str,
"if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {\n" "if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC)) {\n"
"TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);\n" "TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);\n"
"TTCN_Logger::log_event_str(\"%s(): Stream after encoding: \");\n" "TTCN_Logger::log_event_str(\"%s(): Stream after encoding: \");\n"
"%s.log();\n" "%s.log();\n"
"TTCN_Logger::end_event();\n" "TTCN_Logger::end_event();\n"
"}\n", result_name, function_name, result_name); "}\n", function_name, result_name);
// returning the result stream if necessary // returning the result stream if necessary
if (prototype == PROTOTYPE_CONVERT) { if (prototype == PROTOTYPE_CONVERT) {
if (debugger_active) { if (debugger_active) {
...@@ -6909,9 +6966,17 @@ namespace Ttcn { ...@@ -6909,9 +6966,17 @@ namespace Ttcn {
"TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);\n"); "TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);\n");
} else str = mputstr(str, "TTCN_EncDec::set_error_behavior(" } else str = mputstr(str, "TTCN_EncDec::set_error_behavior("
"TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);\n"); "TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);\n");
str = mputstr(str, "TTCN_EncDec::clear_error();\n");
// creating a buffer from the input stream // creating a buffer from the input stream
str = mputprintf(str, "TTCN_EncDec::clear_error();\n" if (input_type->get_type_refd_last()->get_typetype_ttcn3() ==
"TTCN_Buffer ttcn_buffer(%s);\n", first_par_name); Common::Type::T_BSTR) {
// cannot create a buffer from a bitstring, convert it to octetstring
str = mputprintf(str, "TTCN_Buffer ttcn_buffer(bit2oct(%s));\n",
first_par_name);
}
else {
str = mputprintf(str, "TTCN_Buffer ttcn_buffer(%s);\n", first_par_name);
}
const char *result_name; const char *result_name;
if (prototype == PROTOTYPE_CONVERT) { if (prototype == PROTOTYPE_CONVERT) {
// creating a local variable for the result // creating a local variable for the result
...@@ -6949,14 +7014,25 @@ namespace Ttcn { ...@@ -6949,14 +7014,25 @@ namespace Ttcn {
"if (ttcn_buffer.get_pos() < ttcn_buffer.get_len()-1 && " "if (ttcn_buffer.get_pos() < ttcn_buffer.get_len()-1 && "
"TTCN_Logger::log_this_event(TTCN_WARNING)) {\n" "TTCN_Logger::log_this_event(TTCN_WARNING)) {\n"
"ttcn_buffer.cut();\n" "ttcn_buffer.cut();\n"
"%s remaining_stream;\n" "%s remaining_stream;\n",
"ttcn_buffer.get_string(remaining_stream);\n" input_type->get_genname_value(my_scope).c_str());
if (input_type->get_type_refd_last()->get_typetype_ttcn3() ==
Common::Type::T_BSTR) {
str = mputstr(str,
"OCTETSTRING tmp_os;\n"
"ttcn_buffer.get_string(tmp_os);\n"
"remaining_stream = oct2bit(tmp_os);\n");
}
else {
str = mputstr(str, "ttcn_buffer.get_string(remaining_stream);\n");
}
str = mputprintf(str,
"TTCN_Logger::begin_event(TTCN_WARNING);\n" "TTCN_Logger::begin_event(TTCN_WARNING);\n"
"TTCN_Logger::log_event_str(\"%s(): Warning: Data remained at the end " "TTCN_Logger::log_event_str(\"%s(): Warning: Data remained at the end "
"of the stream after successful decoding: \");\n" "of the stream after successful decoding: \");\n"
"remaining_stream.log();\n" "remaining_stream.log();\n"
"TTCN_Logger::end_event();\n" "TTCN_Logger::end_event();\n"
"}\n", input_type->get_genname_value(my_scope).c_str(), function_name); "}\n", function_name);
// closing the block and returning the appropriate result or status code // closing the block and returning the appropriate result or status code
if (prototype == PROTOTYPE_BACKTRACK) { if (prototype == PROTOTYPE_BACKTRACK) {
if (debugger_active) { if (debugger_active) {
...@@ -6984,11 +7060,21 @@ namespace Ttcn { ...@@ -6984,11 +7060,21 @@ namespace Ttcn {
} }
} else { } else {
// result handling and debug printout for sliding decoders // result handling and debug printout for sliding decoders
str = mputprintf(str, "switch (TTCN_EncDec::get_last_error_type()) {\n" str = mputstr(str, "switch (TTCN_EncDec::get_last_error_type()) {\n"
"case TTCN_EncDec::ET_NONE:\n" "case TTCN_EncDec::ET_NONE:\n"
// TTCN_Buffer::get_string will call OCTETSTRING::clean_up()