Commit 588d302a authored by Kristof Szabados's avatar Kristof Szabados
Browse files

this exer thing is confusing.


As it can have only 2 values (0/1) it should be consistently used as an integer.
But later it sohuld be checked if an enum with specific name values would be a better choice.
Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent a1834502
......@@ -706,7 +706,7 @@ void defEnumClass(const enum_def *edef, output_struct *output)
"{\n"
" int rd_ok = 1, type;\n"
" const int e_xer = is_exer(p_flavor);\n"
" const boolean e_xer = is_exer(p_flavor);\n"
" const boolean name_tag = !((!e_xer && is_record_of(p_flavor)) || (e_xer && ((p_td.xer_bits & UNTAGGED) ||(is_record_of(p_flavor) && is_exerlist(p_flavor)))));\n"
" if (e_xer && ((p_td.xer_bits & XER_ATTRIBUTE) || is_exerlist(p_flavor))) {\n"
" if ((p_td.xer_bits & XER_ATTRIBUTE)) verify_name(p_reader, p_td, e_xer);\n"
......
......@@ -1922,7 +1922,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
" TTCN_EncDec_ErrorContext ec_0(\"Component '\");\n"
" TTCN_EncDec_ErrorContext ec_1;\n"
" int encoded_length=(int)p_buf.get_len();\n"
" int e_xer = is_exer(p_flavor);\n"
" boolean e_xer = is_exer(p_flavor);\n"
" const boolean omit_tag = e_xer && p_indent "
"&& ((p_td.xer_bits & (UNTAGGED|XER_ATTRIBUTE)) || (p_flavor & (USE_NIL|USE_TYPE_ATTR)));\n"
" if (e_xer && (p_td.xer_bits & EMBED_VALUES)) p_flavor |= XER_CANONICAL;\n"
......@@ -2417,7 +2417,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
"{\n"
/* Remove XER_LIST, XER_RECOF from p_flavor. This is not required
* for is_exer (which tests another bit), but for subsequent code. */
" int e_xer = is_exer(p_flavor);\n"
" boolean e_xer = is_exer(p_flavor);\n"
" unsigned long xerbits = p_td.xer_bits;\n"
" if (p_flavor & XER_TOPLEVEL) xerbits &= ~UNTAGGED;\n"
" const boolean omit_tag = e_xer && ((xerbits & (UNTAGGED|XER_ATTRIBUTE)) "
......@@ -6029,7 +6029,7 @@ static void defEmptyRecordClass(const struct_def *sdef,
"unsigned int p_flavor, 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"
" int e_xer = is_exer(p_flavor);\n"
" boolean e_xer = is_exer(p_flavor);\n"
" if (is_indented) do_indent(p_buf, p_indent);\n"
" p_buf.put_c('<');\n"
" if (e_xer) write_ns_prefix(p_td, p_buf);\n"
......@@ -6045,7 +6045,7 @@ static void defEmptyRecordClass(const struct_def *sdef,
"int %s::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& p_reader, "
"unsigned int p_flavor, unsigned int /*p_flavor2*/, embed_values_dec_struct_t*)\n"
"{\n"
" int e_xer = is_exer(p_flavor);\n"
" boolean e_xer = is_exer(p_flavor);\n"
" bound_flag = TRUE;\n"
" int rd_ok, depth=-1;\n"
" for (rd_ok=p_reader.Ok(); rd_ok==1; rd_ok=p_reader.Read()) {\n"
......
......@@ -1725,7 +1725,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
"int %s::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& p_reader,"
" unsigned int p_flavor, unsigned int p_flavor2, embed_values_dec_struct_t*)\n"
"{\n"
" int e_xer = is_exer(p_flavor);\n"
" boolean e_xer = is_exer(p_flavor);\n"
" int type = 0;\n" /* None */
" int rd_ok=1, xml_depth=-1;\n"
"%s%s"
......
......@@ -827,7 +827,7 @@ int CHARACTER_STRING_identification::XER_encode(const XERdescriptor_t& p_td,
int CHARACTER_STRING_identification::XER_decode(const XERdescriptor_t& p_td,
XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
// we are supposed to be parked on our element
for (int success = 1; success == 1; success = reader.Read()) {
int type = reader.NodeType();
......@@ -2535,7 +2535,7 @@ int CHARACTER_STRING_identification_context__negotiation::XER_encode(const XERde
int CHARACTER_STRING_identification_context__negotiation::XER_decode(
const XERdescriptor_t& p_td, XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int type = reader.NodeType(), depth = -1;
const char* name = (const char*)reader.Name();
int success = reader.Ok();
......@@ -3389,7 +3389,7 @@ int CHARACTER_STRING::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf
int CHARACTER_STRING::XER_decode(const XERdescriptor_t& p_td,
XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success = reader.Ok(), depth = -1, type;
for (; success == 1; success = reader.Read()) {
type = reader.NodeType();
......
......@@ -778,7 +778,7 @@ int EMBEDDED_PDV_identification::XER_encode(const XERdescriptor_t& p_td,
TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const
{
int indenting = !is_canonical(flavor);
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int encoded_length=(int)p_buf.get_len();
if (indenting) do_indent(p_buf, indent);
p_buf.put_c('<');
......@@ -821,7 +821,7 @@ int EMBEDDED_PDV_identification::XER_encode(const XERdescriptor_t& p_td,
int EMBEDDED_PDV_identification::XER_decode(const XERdescriptor_t& p_td,
XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
// we are supposed to be parked on our element
for (int success = 1; success == 1; success = reader.Read()) {
int type = reader.NodeType();
......@@ -1784,7 +1784,7 @@ int EMBEDDED_PDV_identification_syntaxes::XER_encode(const XERdescriptor_t& p_td
TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const
{
int indenting = !is_canonical(flavor);
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int encoded_length=(int)p_buf.get_len();
if (indenting) do_indent(p_buf, indent);
p_buf.put_c('<');
......@@ -2525,7 +2525,7 @@ int EMBEDDED_PDV_identification_context__negotiation::XER_encode(const XERdescri
TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const
{
int indenting = !is_canonical(flavor);
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int encoded_length=(int)p_buf.get_len();
if (indenting) do_indent(p_buf, indent);
p_buf.put_c('<');
......@@ -2547,7 +2547,7 @@ int EMBEDDED_PDV_identification_context__negotiation::XER_encode(const XERdescri
int EMBEDDED_PDV_identification_context__negotiation::XER_decode(
const XERdescriptor_t& p_td, XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int type = reader.NodeType(), depth = -1;
const char* name = (const char*)reader.Name();
int success = reader.Ok();
......@@ -3382,7 +3382,7 @@ int EMBEDDED_PDV::XER_encode(const XERdescriptor_t& p_td,
(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
}
int indenting = !is_canonical(flavor);
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int encoded_length=(int)p_buf.get_len();
if (indenting) do_indent(p_buf, indent);
p_buf.put_c('<');
......@@ -3408,7 +3408,7 @@ int EMBEDDED_PDV::XER_encode(const XERdescriptor_t& p_td,
int EMBEDDED_PDV::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int depth = 1, type, success;
for (success = reader.Ok(); success == 1; success = reader.Read()) {
type = reader.NodeType();
......
......@@ -417,7 +417,7 @@ namespace { /* anonymous namespace */
TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const
{
int indenting = !is_canonical(flavor);
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int encoded_length=(int)p_buf.get_len();
if (indenting) do_indent(p_buf, indent);
p_buf.put_c('<');
......@@ -456,7 +456,7 @@ namespace { /* anonymous namespace */
int EXTERNALtransfer_encoding::XER_decode(const XERdescriptor_t& p_td,
XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success = reader.Ok(), type, depth = -1;
for (; success==1; success = reader.Read()) {
type = reader.NodeType();
......@@ -574,7 +574,7 @@ namespace { /* anonymous namespace */
TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const
{
int indenting = !is_canonical(flavor);
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int encoded_length=(int)p_buf.get_len();
if (indenting) do_indent(p_buf, indent);
p_buf.put_c('<');
......@@ -598,7 +598,7 @@ namespace { /* anonymous namespace */
int EXTERNALtransfer::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success = reader.Ok(), depth = -1;
for (; success == 1; success = reader.Read()) {
int type = reader.NodeType();
......
......@@ -236,7 +236,7 @@ boolean ASN_NULL::BER_decode_TLV(const TTCN_Typedescriptor_t& p_td,
int ASN_NULL::XER_encode(const XERdescriptor_t& p_td,
TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
TTCN_EncDec_ErrorContext ec("While XER encoding NULL type: ");
if(!is_bound()) {
TTCN_EncDec_ErrorContext::error
......@@ -260,7 +260,7 @@ int ASN_NULL::XER_encode(const XERdescriptor_t& p_td,
int ASN_NULL::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
TTCN_EncDec_ErrorContext ec("While XER decoding NULL type: ");
int success = reader.Ok(), depth = -1;
for (; success == 1; success = reader.Read()) {
......
......@@ -1092,7 +1092,7 @@ int BITSTRING::XER_encode(const XERdescriptor_t& p_td,
int BITSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success = reader.Ok(), depth = -1, type;
boolean own_tag = !is_exerlist(flavor) && !(exer && (p_td.xer_bits & UNTAGGED));
......
......@@ -620,7 +620,7 @@ int BOOLEAN::XER_encode(const XERdescriptor_t& p_td,
}
int encoded_length=(int)p_buf.get_len();
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
flavor |= (SIMPLE_TYPE | BXER_EMPTY_ELEM);
if (begin_xml(p_td, p_buf, flavor, indent, FALSE) == -1) --encoded_length;
......
......@@ -962,7 +962,7 @@ int FLOAT::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
{
bound_flag = FALSE;
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success = reader.Ok(), depth = -1;
if (success <= 0) return 0;
boolean own_tag = !(exer && (p_td.xer_bits & UNTAGGED)) && !is_exerlist(flavor);
......
......@@ -924,7 +924,7 @@ Because of this, the bit shifting is different. The first three bytes
int HEXSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success = reader.Ok(), depth = -1, type;
boolean own_tag = !is_exerlist(flavor) && !(exer && (p_td.xer_bits & UNTAGGED));
......
......@@ -561,7 +561,7 @@ void OBJID::from_string(char* p_str)
int OBJID::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success = reader.Ok(), depth = -1;
for (; success == 1; success = reader.Read()) {
int type = reader.NodeType();
......
......@@ -962,7 +962,7 @@ int OCTETSTRING::XER_encode(const XERdescriptor_t& p_td,
int OCTETSTRING::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success = reader.Ok(), depth = -1, type;
boolean own_tag = !is_exerlist(flavor) && !(exer && (p_td.xer_bits & UNTAGGED));
......
......@@ -1056,7 +1056,7 @@ int
OPTIONAL<T_type>::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t* emb_val)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
for (int success = reader.Ok(); success==1; success=reader.Read()) {
int type = reader.NodeType();
const char * name; // name of the optional field
......
......@@ -2115,7 +2115,7 @@ universal_char const uspace = {0,0,0,32};
int UNIVERSAL_CHARSTRING::XER_decode(const XERdescriptor_t& p_td,
XmlReaderWrap& reader, unsigned int flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success = reader.Ok(), depth = -1;
boolean omit_tag = exer
&& ((p_td.xer_bits & UNTAGGED)
......
......@@ -319,7 +319,7 @@ int VERDICTTYPE::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& p_reader
unsigned int p_flavor, unsigned int /*flavor2*/, embed_values_dec_struct_t*)
{
int rd_ok = 1, type;
const int e_xer = is_exer(p_flavor);
const boolean e_xer = is_exer(p_flavor);
const boolean name_tag = !((!e_xer && is_record_of(p_flavor)) || (e_xer && ((p_td.xer_bits & UNTAGGED) ||(is_record_of(p_flavor) && is_exerlist(p_flavor)))));
if (e_xer && ((p_td.xer_bits & XER_ATTRIBUTE) || is_exerlist(p_flavor))) {
if ((p_td.xer_bits & XER_ATTRIBUTE)) verify_name(p_reader, p_td, e_xer);
......
......@@ -49,7 +49,7 @@ int do_indent(TTCN_Buffer& buf, int level)
return level;
}
const char* verify_name(XmlReaderWrap& reader, const XERdescriptor_t& p_td, int exer)
const char* verify_name(XmlReaderWrap& reader, const XERdescriptor_t& p_td, boolean exer)
{
const char *name = (const char*)reader.LocalName();
const char *nsuri= (const char*)reader.NamespaceUri(); // NULL if no ns
......@@ -103,7 +103,7 @@ const char* verify_name(XmlReaderWrap& reader, const XERdescriptor_t& p_td, int
return name;
}
void verify_end(XmlReaderWrap& reader, const XERdescriptor_t& p_td, const int depth, int exer)
void verify_end(XmlReaderWrap& reader, const XERdescriptor_t& p_td, const int depth, boolean exer)
{
TTCN_EncDec_ErrorContext endcontext("While checking end tag: ");
verify_name(reader, p_td, exer);
......
......@@ -15,7 +15,7 @@
#ifndef XER_HH_
#define XER_HH_
//#include "Types.h"
#include "Types.h"
#include "Encdec.hh"
#include <stddef.h> // for size_t
#include <string.h> // strncmp for the inline function
......@@ -178,6 +178,8 @@ inline boolean is_canonical(unsigned int f)
return (f & XER_CANONICAL) != 0;
}
// exer 0 for Basic/Canonical XER, 1 for EXER
// TODO: It would be better to have an enum for the exers
inline boolean is_exer(unsigned int f)
{
return (f & XER_EXTENDED) != 0;
......@@ -396,7 +398,7 @@ struct embed_values_dec_struct_t
* @param exer \c true if Extended XER decoding, \c false for Basic and Canonical XER
* @return \c true if \p name corresponds to the type descriptor, \c false otherwise.
*/
inline boolean check_name(const char *name, const XERdescriptor_t& p_td, int exer)
inline boolean check_name(const char *name, const XERdescriptor_t& p_td, boolean exer)
{
return strncmp(name, p_td.names[exer], p_td.namelens[exer]-2) == 0
&& name[p_td.namelens[exer]-2] == '\0';
......@@ -425,7 +427,7 @@ boolean check_namespace(const char *ns_uri, const XERdescriptor_t& p_td);
* @param exer 0 for Basic/Canonical XER, 1 for EXER
* @return the name of the current element
*/
const char* verify_name(XmlReaderWrap& reader, const XERdescriptor_t& p_td, int exer);
const char* verify_name(XmlReaderWrap& reader, const XERdescriptor_t& p_td, boolean exer);
/** Check the end tag
*
......@@ -437,7 +439,7 @@ const char* verify_name(XmlReaderWrap& reader, const XERdescriptor_t& p_td, int
* @param depth XML tag depth (0 for top-level element)
* @param exer 0 for Basic/Canonical XER, 1 for EXER
*/
void verify_end(XmlReaderWrap& reader, const XERdescriptor_t& p_td, const int depth, int exer);
void verify_end(XmlReaderWrap& reader, const XERdescriptor_t& p_td, const int depth, boolean exer);
class TTCN_Buffer;
......
......@@ -2255,7 +2255,7 @@ int Record_Of_Type::XER_encode_negtest(const Erroneous_descriptor_t* p_err_descr
int Record_Of_Type::XER_decode(const XERdescriptor_t& p_td,
XmlReaderWrap& reader, unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t* emb_val)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
unsigned long xerbits = p_td.xer_bits;
if (flavor & XER_TOPLEVEL) xerbits &= ~UNTAGGED;
boolean own_tag =
......@@ -5139,7 +5139,7 @@ int Record_Type::XER_encode_negtest(const Erroneous_descriptor_t* p_err_descr,
int Record_Type::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t* emb_val_parent)
{
int exer = is_exer(flavor);
boolean exer = is_exer(flavor);
int success, type;
int depth=-1; // depth of the start tag
unsigned long xerbits = p_td.xer_bits;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment