Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
0f5d74c6
Commit
0f5d74c6
authored
Aug 14, 2005
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unions are not anonymous
parent
a02fb390
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
64 additions
and
52 deletions
+64
-52
ChangeLog
ChangeLog
+1
-0
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+47
-36
tests/31-set-of-OK.asn1.-P
tests/31-set-of-OK.asn1.-P
+1
-1
tests/42-real-life-OK.asn1.-PR
tests/42-real-life-OK.asn1.-PR
+1
-1
tests/43-recursion-OK.asn1.-P
tests/43-recursion-OK.asn1.-P
+1
-1
tests/44-choice-in-sequence-OK.asn1.-P
tests/44-choice-in-sequence-OK.asn1.-P
+3
-3
tests/47-set-ext-OK.asn1.-P
tests/47-set-ext-OK.asn1.-P
+2
-2
tests/59-choice-extended-OK.asn1.-P
tests/59-choice-extended-OK.asn1.-P
+1
-1
tests/70-xer-test-OK.asn1.-P
tests/70-xer-test-OK.asn1.-P
+1
-1
tests/72-same-names-OK.asn1.-P
tests/72-same-names-OK.asn1.-P
+2
-2
tests/84-param-tags-OK.asn1.-P
tests/84-param-tags-OK.asn1.-P
+2
-2
tests/89-bit-string-enum-OK.asn1.-P
tests/89-bit-string-enum-OK.asn1.-P
+1
-1
tests/89-bit-string-enum-OK.asn1.-Pfcompound-names
tests/89-bit-string-enum-OK.asn1.-Pfcompound-names
+1
-1
No files found.
ChangeLog
View file @
0f5d74c6
...
...
@@ -7,6 +7,7 @@
* Generating enumeration tables for BIT STRING types (Test case 89).
* Conditional INTEGER/ENUMERATED representation: long vs. INTEGER_t
type is chosen based on PER visible constraints (Test cases 90, 91).
* Union structures for CHOICE type are not anonymous anymore.
0.9.17: 2005-Aug-07
...
...
libasn1compiler/asn1c_C.c
View file @
0f5d74c6
...
...
@@ -24,6 +24,12 @@ typedef enum fte {
static
int
_fill_tag2el_map
(
arg_t
*
arg
,
tag2el_t
**
tag2el
,
int
*
count
,
int
el_no
,
fte_e
flags
);
static
int
_add_tag2el_member
(
arg_t
*
arg
,
tag2el_t
**
tag2el
,
int
*
count
,
int
el_no
,
fte_e
flags
);
enum
onc_flags
{
ONC_noflags
=
0x00
,
ONC_avoid_keywords
=
0x01
,
ONC_force_compound_name
=
0x02
,
};
static
int
out_name_chain
(
arg_t
*
arg
,
enum
onc_flags
);
static
int
asn1c_lang_C_type_SEQUENCE_def
(
arg_t
*
arg
);
static
int
asn1c_lang_C_type_SET_def
(
arg_t
*
arg
);
static
int
asn1c_lang_C_type_CHOICE_def
(
arg_t
*
arg
);
...
...
@@ -36,7 +42,6 @@ static int expr_elements_count(arg_t *arg, asn1p_expr_t *expr);
static
int
emit_member_table
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
);
static
int
emit_tag2member_map
(
arg_t
*
arg
,
tag2el_t
*
tag2el
,
int
tag2el_count
,
const
char
*
opt_modifier
);
static
int
emit_include_dependencies
(
arg_t
*
arg
);
static
int
out_name_chain
(
arg_t
*
arg
,
int
check_reserved_keywords
);
enum
tvm_compat
{
_TVM_SAME
=
0
,
/* tags and all_tags are same */
...
...
@@ -117,13 +122,13 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
eidx
=
0
;
REDIR
(
OT_DEPS
);
OUT
(
"typedef enum "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
switch
(
v
->
expr_type
)
{
case
A1TC_UNIVERVAL
:
OUT
(
"
\t
"
);
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_%s"
,
MKID
(
v
->
Identifier
));
OUT
(
"
\t
= %"
PRIdASN
"%s
\n
"
,
v
->
value
->
value
.
v_integer
,
...
...
@@ -143,7 +148,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
}
}
OUT
(
"} "
);
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_e;
\n
"
);
assert
(
eidx
==
el_count
);
}
...
...
@@ -223,7 +228,7 @@ asn1c_lang_C_type_BIT_STRING(arg_t *arg) {
int
eidx
=
0
;
REDIR
(
OT_DEPS
);
OUT
(
"typedef enum "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
eidx
++
;
...
...
@@ -233,14 +238,14 @@ asn1c_lang_C_type_BIT_STRING(arg_t *arg) {
continue
;
}
OUT
(
"
\t
"
);
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_%s"
,
MKID
(
v
->
Identifier
));
OUT
(
"
\t
= %"
PRIdASN
"%s
\n
"
,
v
->
value
->
value
.
v_integer
,
(
eidx
<
el_count
)
?
","
:
""
);
}
OUT
(
"} "
);
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_e;
\n
"
);
assert
(
eidx
==
el_count
);
}
...
...
@@ -258,7 +263,7 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
if
(
arg
->
embed
)
{
OUT
(
"struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
}
else
{
OUT
(
"typedef struct %s {
\n
"
,
...
...
@@ -352,8 +357,8 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
OUT
(
"static asn_SEQUENCE_specifics_t asn_SPC_%s_%d_specs = {
\n
"
,
MKID
(
expr
->
Identifier
),
expr
->
_type_unique_index
);
INDENTED
(
OUT
(
"sizeof(struct "
);
out_name_chain
(
arg
,
1
);
OUT
(
"),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
1
);
OUT
(
", _asn_ctx),
\n
"
);
OUT
(
"sizeof(struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
"),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _asn_ctx),
\n
"
);
if
(
tag2el_count
)
{
OUT
(
"asn_MAP_%s_%d_tag2el,
\n
"
,
...
...
@@ -400,12 +405,12 @@ asn1c_lang_C_type_SET(arg_t *arg) {
OUT
(
" */
\n
"
);
mcount
=
0
;
OUT
(
"typedef enum "
);
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR {
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
continue
;
INDENTED
(
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR_"
);
id
=
MKID
(
v
->
Identifier
);
OUT
(
"%s,
\t
/* Member %s is present */
\n
"
,
...
...
@@ -413,13 +418,13 @@ asn1c_lang_C_type_SET(arg_t *arg) {
);
mcount
++
;
}
OUT
(
"} "
);
out_name_chain
(
arg
,
0
);
OUT
(
"_PR;
\n
"
);
OUT
(
"} "
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR;
\n
"
);
REDIR
(
OT_TYPE_DECLS
);
if
(
arg
->
embed
)
{
OUT
(
"struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
}
else
{
OUT
(
"typedef struct %s {
\n
"
,
MKID_safe
(
expr
->
Identifier
));
...
...
@@ -566,13 +571,13 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
MKID
(
expr
->
Identifier
),
expr
->
_type_unique_index
);
INDENTED
(
OUT
(
"sizeof(struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
"),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _asn_ctx),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _presence_map),
\n
"
);
p
=
MKID
(
expr
->
Identifier
);
OUT
(
"asn_MAP_%s_%d_tag2el,
\n
"
,
p
,
expr
->
_type_unique_index
);
...
...
@@ -612,7 +617,7 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
if
(
arg
->
embed
)
{
OUT
(
"struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
}
else
{
OUT
(
"typedef struct %s {
\n
"
,
MKID_safe
(
expr
->
Identifier
));
...
...
@@ -715,10 +720,10 @@ asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) {
MKID
(
expr
->
Identifier
),
expr
->
_type_unique_index
);
INDENTED
(
OUT
(
"sizeof(struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
"),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _asn_ctx),
\n
"
);
if
(
expr_as_xmlvaluelist
(
arg
,
v
))
...
...
@@ -750,36 +755,41 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
REDIR
(
OT_DEPS
);
OUT
(
"typedef enum "
);
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR {
\n
"
);
INDENTED
(
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR_NOTHING,
\t
/* No components present */
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
{
OUT
(
"/* Extensions may appear below */
\n
"
);
continue
;
}
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR_"
);
id
=
MKID
(
v
->
Identifier
);
OUT
(
"%s,
\n
"
,
id
,
id
);
}
);
OUT
(
"} "
);
out_name_chain
(
arg
,
0
);
OUT
(
"_PR;
\n
"
);
OUT
(
"} "
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR;
\n
"
);
REDIR
(
OT_TYPE_DECLS
);
if
(
arg
->
embed
)
{
OUT
(
"struct "
);
out_name_chain
(
arg
,
1
);
OUT
(
" {
\n
"
);
OUT
(
"struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
}
else
{
OUT
(
"typedef struct %s {
\n
"
,
MKID_safe
(
expr
->
Identifier
));
}
INDENTED
(
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR present;
\n
"
);
OUT
(
"union {
\n
"
);
OUT
(
"union "
);
if
(
UNNAMED_UNIONS
==
0
)
{
out_name_chain
(
arg
,
ONC_force_compound_name
);
OUT
(
"_u "
);
}
OUT
(
"{
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
if
(
expr_better_indirect
(
arg
,
v
))
v
->
marker
.
flags
|=
EM_INDIRECT
;
...
...
@@ -868,16 +878,16 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
MKID
(
expr
->
Identifier
),
expr
->
_type_unique_index
);
INDENTED
(
OUT
(
"sizeof(struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
"),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _asn_ctx),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", present),
\n
"
);
OUT
(
"sizeof(((struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" *)0)->present),
\n
"
);
OUT
(
"asn_MAP_%s_%d_tag2el,
\n
"
,
MKID
(
expr
->
Identifier
),
expr
->
_type_unique_index
);
...
...
@@ -1678,7 +1688,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr) {
OUT
(
"0,
\n
"
);
}
else
{
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", "
);
if
(
arg
->
expr
->
expr_type
==
ASN_CONSTR_CHOICE
&&
(
!
UNNAMED_UNIONS
))
OUT
(
"choice."
);
...
...
@@ -1940,13 +1950,14 @@ expr_as_xmlvaluelist(arg_t *arg, asn1p_expr_t *expr) {
}
static
int
out_name_chain
(
arg_t
*
arg
,
int
check_reserved_keyword
s
)
{
out_name_chain
(
arg_t
*
arg
,
enum
onc_flags
onc_flag
s
)
{
asn1p_expr_t
*
expr
=
arg
->
expr
;
char
*
id
;
assert
(
expr
->
Identifier
);
if
(
arg
->
flags
&
A1C_COMPOUND_NAMES
if
((
arg
->
flags
&
A1C_COMPOUND_NAMES
||
onc_flags
&
ONC_force_compound_name
)
&&
((
expr
->
expr_type
&
ASN_CONSTR_MASK
)
||
expr
->
expr_type
==
ASN_BASIC_ENUMERATED
||
((
expr
->
expr_type
==
ASN_BASIC_INTEGER
...
...
@@ -1960,14 +1971,14 @@ out_name_chain(arg_t *arg, int check_reserved_keywords) {
tmparg
.
expr
=
expr
->
parent_expr
;
if
(
0
)
tmparg
.
flags
&=
~
A1C_COMPOUND_NAMES
;
out_name_chain
(
&
tmparg
,
0
);
out_name_chain
(
&
tmparg
,
onc_flags
);
OUT
(
"__"
);
/* a separator between id components */
/* Fall through */
}
if
(
check_reserve
d_keywords
)
if
(
onc_flags
&
ONC_avoi
d_keywords
)
id
=
MKID_safe
(
expr
->
Identifier
);
else
id
=
MKID
(
expr
->
Identifier
);
...
...
tests/31-set-of-OK.asn1.-P
View file @
0f5d74c6
...
...
@@ -203,7 +203,7 @@ typedef struct Stuff {
*/
struct other {
other_PR present;
union {
union
Stuff__other_u
{
INTEGER_t a;
INTEGER_t b;
} choice;
...
...
tests/42-real-life-OK.asn1.-PR
View file @
0f5d74c6
...
...
@@ -339,7 +339,7 @@ typedef enum VariablePart_PR {
typedef struct VariablePart {
VariablePart_PR present;
union {
union
VariablePart_u
{
struct vset {
A_SET_OF(VisibleString_t) list;
...
...
tests/43-recursion-OK.asn1.-P
View file @
0f5d74c6
...
...
@@ -220,7 +220,7 @@ struct Choice_1;
typedef struct Choice_1 {
Choice_1_PR present;
union {
union
Choice_1_u
{
struct Choice_1 *and;
struct or {
A_SET_OF(struct Choice_1) list;
...
...
tests/44-choice-in-sequence-OK.asn1.-P
View file @
0f5d74c6
...
...
@@ -31,12 +31,12 @@ typedef struct T {
NULL_t a;
struct b {
b_PR present;
union {
union
T__b_u
{
NULL_t c;
NULL_t d;
struct e {
e_PR present;
union {
union
T__b__e_u
{
NULL_t f;
NULL_t g;
} choice;
...
...
@@ -46,7 +46,7 @@ typedef struct T {
} e;
struct h {
h_PR present;
union {
union
T__b__h_u
{
NULL_t i;
NULL_t j;
} choice;
...
...
tests/47-set-ext-OK.asn1.-P
View file @
0f5d74c6
...
...
@@ -196,7 +196,7 @@ typedef enum T3_PR {
typedef struct T3 {
T3_PR present;
union {
union
T3_u
{
INTEGER_t i;
/*
* This type is extensible,
...
...
@@ -273,7 +273,7 @@ typedef enum T4_PR {
typedef struct T4 {
T4_PR present;
union {
union
T4_u
{
INTEGER_t i;
/*
* This type is extensible,
...
...
tests/59-choice-extended-OK.asn1.-P
View file @
0f5d74c6
...
...
@@ -23,7 +23,7 @@ struct Choice;
typedef struct Choice {
Choice_PR present;
union {
union
Choice_u
{
INTEGER_t a;
/*
* This type is extensible,
...
...
tests/70-xer-test-OK.asn1.-P
View file @
0f5d74c6
...
...
@@ -34,7 +34,7 @@ typedef enum PDU_PR {
typedef struct PDU {
PDU_PR present;
union {
union
PDU_u
{
Sequence_t sequence;
Set_t set;
SetOf_t setOf;
...
...
tests/72-same-names-OK.asn1.-P
View file @
0f5d74c6
...
...
@@ -141,7 +141,7 @@ typedef enum one_name_PR {
typedef struct Type1 {
struct one_name {
one_name_PR present;
union {
union
Type1__one_name_u
{
struct another_name {
INTEGER_t a;
INTEGER_t b;
...
...
@@ -340,7 +340,7 @@ typedef enum a {
typedef struct Type2 {
Type2_PR present;
union {
union
Type2_u
{
struct one_name {
struct another_name {
BIT_STRING_t a;
...
...
tests/84-param-tags-OK.asn1.-P
View file @
0f5d74c6
...
...
@@ -18,7 +18,7 @@ typedef enum TestChoice_PR {
typedef struct TestChoice {
TestChoice_PR present;
union {
union
TestChoice_u
{
struct type1 {
long *common /* DEFAULT 0 */;
...
...
@@ -233,7 +233,7 @@ typedef enum AutoChoice_PR {
typedef struct AutoChoice {
AutoChoice_PR present;
union {
union
AutoChoice_u
{
struct type1 {
long common;
...
...
tests/89-bit-string-enum-OK.asn1.-P
View file @
0f5d74c6
...
...
@@ -19,7 +19,7 @@ typedef enum bs {
typedef struct T {
T_PR present;
union {
union
T_u
{
BIT_STRING_t bs;
} choice;
...
...
tests/89-bit-string-enum-OK.asn1.-Pfcompound-names
View file @
0f5d74c6
...
...
@@ -19,7 +19,7 @@ typedef enum T__bs {
typedef struct T {
T_PR present;
union {
union
T_u
{
BIT_STRING_t bs;
} choice;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment