Commit da78f97b authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu

Rewrite the solution in PR 227

Set the key.sequence to eclass's _type_unique_index and increment
it in each object parsing call, then set the result back to
_type_unique_index field. It can keep a class-wise counter for
eash object instantiated.

This new method not only solve name duplication when union two
information object sets, but also avoid name duplication within
multiple instances of this class.
parent 939573d7
...@@ -268,7 +268,7 @@ asn1f_parse_class_object(arg_t *arg) { ...@@ -268,7 +268,7 @@ asn1f_parse_class_object(arg_t *arg) {
.arg = arg, .arg = arg,
.expr = expr, .expr = expr,
.eclass = eclass, .eclass = eclass,
.sequence = 0 .sequence = eclass->_type_unique_index
}; };
if(!expr->ioc_table) { if(!expr->ioc_table) {
...@@ -295,6 +295,8 @@ asn1f_parse_class_object(arg_t *arg) { ...@@ -295,6 +295,8 @@ asn1f_parse_class_object(arg_t *arg) {
} }
} }
eclass->_type_unique_index = key.sequence;
return 0; return 0;
} }
......
...@@ -27,13 +27,11 @@ asn1p_ioc_table_add(asn1p_ioc_table_t *it, asn1p_ioc_row_t *row) { ...@@ -27,13 +27,11 @@ asn1p_ioc_table_add(asn1p_ioc_table_t *it, asn1p_ioc_row_t *row) {
void void
asn1p_ioc_table_append(asn1p_ioc_table_t *it, asn1p_ioc_table_t *src) { asn1p_ioc_table_append(asn1p_ioc_table_t *it, asn1p_ioc_table_t *src) {
int base_idx;
if(!src || !it) return; if(!src || !it) return;
base_idx = it->rows;
for(size_t i = 0; i < src->rows; i++) { for(size_t i = 0; i < src->rows; i++) {
asn1p_ioc_table_add(it, asn1p_ioc_row_clone(src->row[i], base_idx)); asn1p_ioc_table_add(it, asn1p_ioc_row_clone(src->row[i]));
} }
} }
...@@ -106,7 +104,7 @@ asn1p_ioc_row_new(asn1p_expr_t *oclass) { ...@@ -106,7 +104,7 @@ asn1p_ioc_row_new(asn1p_expr_t *oclass) {
} }
asn1p_ioc_row_t * asn1p_ioc_row_t *
asn1p_ioc_row_clone(asn1p_ioc_row_t *src, int base_idx) { asn1p_ioc_row_clone(asn1p_ioc_row_t *src) {
asn1p_ioc_row_t *row; asn1p_ioc_row_t *row;
row = calloc(1, sizeof *row); row = calloc(1, sizeof *row);
...@@ -124,7 +122,6 @@ asn1p_ioc_row_clone(asn1p_ioc_row_t *src, int base_idx) { ...@@ -124,7 +122,6 @@ asn1p_ioc_row_clone(asn1p_ioc_row_t *src, int base_idx) {
row->column[i].value = 0; row->column[i].value = 0;
if(src->column[i].value) { if(src->column[i].value) {
row->column[i].value = asn1p_expr_clone(src->column[i].value, 0); row->column[i].value = asn1p_expr_clone(src->column[i].value, 0);
row->column[i].value->_type_unique_index += base_idx;
} }
row->column[i].new_ref = 1; row->column[i].new_ref = 1;
} }
......
...@@ -16,7 +16,7 @@ typedef struct asn1p_ioc_row_s { ...@@ -16,7 +16,7 @@ typedef struct asn1p_ioc_row_s {
} asn1p_ioc_row_t; } asn1p_ioc_row_t;
asn1p_ioc_row_t *asn1p_ioc_row_new(struct asn1p_expr_s *oclass); asn1p_ioc_row_t *asn1p_ioc_row_new(struct asn1p_expr_s *oclass);
asn1p_ioc_row_t *asn1p_ioc_row_clone(asn1p_ioc_row_t *src, int base_idx); asn1p_ioc_row_t *asn1p_ioc_row_clone(asn1p_ioc_row_t *src);
size_t asn1p_ioc_row_max_identifier_length(asn1p_ioc_row_t *); size_t asn1p_ioc_row_max_identifier_length(asn1p_ioc_row_t *);
void asn1p_ioc_row_delete(asn1p_ioc_row_t *); void asn1p_ioc_row_delete(asn1p_ioc_row_t *);
......
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .158
ModuleMultipleParameterizedInstance
{ iso org(3) dod(6) internet(1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 158 }
DEFINITIONS ::= BEGIN
MYID ::= CLASS {
&id INTEGER UNIQUE,
&Type
} WITH SYNTAX {&Type IDENTIFIED BY &id}
TotalRegionExtension MYID ::= {
RegionalExtension1 |
RegionalExtension2
}
RegionalExtension1 MYID ::= {
{INTEGER IDENTIFIED BY 1} |
{BOOLEAN IDENTIFIED BY 2},
...,
{OCTET STRING IDENTIFIED BY 3}
}
RegionalExtension2 MYID ::= {
{INTEGER IDENTIFIED BY 1},
...,
{BOOLEAN IDENTIFIED BY 2} |
{OCTET STRING IDENTIFIED BY 3}
}
RegionalExtension3 MYID ::= {
{OCTET STRING IDENTIFIED BY 1} |
{OCTET STRING IDENTIFIED BY 4},
...
}
RegionalExtension4 MYID ::= {
{INTEGER IDENTIFIED BY 5},
...,
{OCTET STRING (5) IDENTIFIED BY 6}
}
Message1 ::= SEQUENCE {
content SpecializedContent {{TotalRegionExtension}}
}
Message2 ::= SEQUENCE {
content SpecializedContent {{RegionalExtension3}}
}
Message3 ::= SEQUENCE {
content SpecializedContent {{RegionalExtension4}}
}
SpecializedContent {MYID : Set} ::= SEQUENCE {
id MYID.&id({Set}),
value MYID.&Type({Set}{@id})
}
END
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