Commit 939573d7 authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu

Use a simplier method to solve duplicate type names generated

If one item's name already exists in this OPEN TYPE, simply do not
add it to expression open_type_choice.

It slightly modifies previous commit :
dcc822a0.
parent aa8c06f9
......@@ -1067,9 +1067,10 @@ asn1c_lang_C_OpenType(arg_t *arg, asn1c_ioc_table_and_objset_t *opt_ioc,
if(!cell->value) continue;
if(asn1p_lookup_child(open_type_choice, cell->value->Identifier))
continue;
asn1p_expr_t *m = asn1p_expr_clone(cell->value, 0);
if (asn1p_lookup_child(open_type_choice, m->Identifier))
m->_mark |= TM_SKIPinUNION;
asn1p_expr_add(open_type_choice, m);
}
......@@ -1282,14 +1283,11 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
}
}
if(!(expr->_mark & TM_SKIPinUNION))
OUT("%s", asn1c_type_name(arg, arg->expr, tnfmt));
OUT("%s", asn1c_type_name(arg, arg->expr, tnfmt));
if(!expr->_anonymous_type) {
if(!(expr->_mark & TM_SKIPinUNION)) {
OUT("%s", (expr->marker.flags&EM_INDIRECT)?"\t*":"\t ");
OUT("%s", MKID_safe(expr));
}
OUT("%s", (expr->marker.flags&EM_INDIRECT)?"\t*":"\t ");
OUT("%s", MKID_safe(expr));
if((expr->marker.flags & (EM_DEFAULT & ~EM_INDIRECT))
== (EM_DEFAULT & ~EM_INDIRECT))
OUT("\t/* DEFAULT %s */",
......
......@@ -250,10 +250,8 @@ typedef struct asn1p_expr_s {
TM_RECURSION = (1<<0), /* Used to break recursion */
TM_BROKEN = (1<<1), /* A warning was already issued */
TM_PERFROMCT = (1<<2), /* PER FROM() constraint tables emitted */
TM_NAMECLASH = (1<<3), /* Name clash found, need to add module name to resolve */
TM_NAMEGIVEN = (1<<4), /* The expression has already yielded a name */
TM_SKIPinUNION = (1<<5) /* Do not include this identifier in union again due to name duplication,
especially for OPENTYPE. */
TM_NAMECLASH = (1<<3), /* Name clash found, need to add module name to resolve */
TM_NAMEGIVEN = (1<<4) /* The expression has already yielded a name */
} _mark;
/*
......
......@@ -78,7 +78,6 @@ typedef enum value_PR {
value_PR_NOTHING, /* No components present */
value_PR_INTEGER,
value_PR_BOOLEAN,
value_PR_BOOLEAN,
value_PR_OCTET_STRING
} value_PR;
......@@ -91,7 +90,6 @@ typedef struct SpecializedContent_42P0 {
union SpecializedContent_42P0__value_u {
long INTEGER;
BOOLEAN_t BOOLEAN;
;
OCTET_STRING_t OCTET_STRING;
} choice;
......@@ -227,15 +225,6 @@ static asn_TYPE_member_t asn_MBR_value_3[] = {
0, 0, /* No default value */
.name = "BOOLEAN"
},
{ ATF_NOFLAGS, 0, offsetof(struct value, choice.BOOLEAN),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
.tag_mode = 0,
.type = &asn_DEF_BOOLEAN,
.type_selector = 0,
{ .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 },
0, 0, /* No default value */
.name = "BOOLEAN"
},
{ ATF_NOFLAGS, 0, offsetof(struct value, choice.OCTET_STRING),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)),
.tag_mode = 0,
......@@ -246,13 +235,12 @@ static asn_TYPE_member_t asn_MBR_value_3[] = {
.name = "OCTET STRING"
},
};
static const unsigned asn_MAP_value_to_canonical_3[] = { 1, 2, 0, 3 };
static const unsigned asn_MAP_value_from_canonical_3[] = { 2, 0, 1, 3 };
static const unsigned asn_MAP_value_to_canonical_3[] = { 1, 0, 2 };
static const unsigned asn_MAP_value_from_canonical_3[] = { 1, 0, 2 };
static const asn_TYPE_tag2member_t asn_MAP_value_tag2el_3[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 1, 0, 1 }, /* BOOLEAN */
{ (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 2, -1, 0 }, /* BOOLEAN */
{ (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 1, 0, 0 }, /* BOOLEAN */
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* INTEGER */
{ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), 3, 0, 0 } /* OCTET STRING */
{ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), 2, 0, 0 } /* OCTET STRING */
};
static asn_CHOICE_specifics_t asn_SPC_value_specs_3 = {
sizeof(struct value),
......@@ -260,7 +248,7 @@ static asn_CHOICE_specifics_t asn_SPC_value_specs_3 = {
offsetof(struct value, present),
sizeof(((struct value *)0)->present),
.tag2el = asn_MAP_value_tag2el_3,
.tag2el_count = 4, /* Count of tags in the map */
.tag2el_count = 3, /* Count of tags in the map */
.to_canonical_order = asn_MAP_value_to_canonical_3,
.from_canonical_order = asn_MAP_value_from_canonical_3,
.first_extension = -1 /* Extensions start */
......@@ -276,7 +264,7 @@ asn_TYPE_descriptor_t asn_DEF_value_3 = {
0, /* No tags (count) */
{ 0, 0, OPEN_TYPE_constraint },
asn_MBR_value_3,
4, /* Elements count */
3, /* Elements count */
&asn_SPC_value_specs_3 /* Additional specs */
};
......
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