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
b46156d9
Commit
b46156d9
authored
7 years ago
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
naming abstraction
parent
e4ea1750
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
749 additions
and
148 deletions
+749
-148
libasn1compiler/Makefile.am
libasn1compiler/Makefile.am
+13
-12
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+66
-133
libasn1compiler/asn1c_misc.c
libasn1compiler/asn1c_misc.c
+1
-1
libasn1compiler/asn1c_misc.h
libasn1compiler/asn1c_misc.h
+1
-1
libasn1compiler/asn1c_naming.c
libasn1compiler/asn1c_naming.c
+137
-0
libasn1compiler/asn1c_naming.h
libasn1compiler/asn1c_naming.h
+19
-0
libasn1compiler/asn1c_save.c
libasn1compiler/asn1c_save.c
+1
-1
tests/tests-asn1c-compiler/31-set-of-OK.asn1.-Pfcompound-names
.../tests-asn1c-compiler/31-set-of-OK.asn1.-Pfcompound-names
+511
-0
No files found.
libasn1compiler/Makefile.am
View file @
b46156d9
...
@@ -9,15 +9,16 @@ AM_CPPFLAGS = \
...
@@ -9,15 +9,16 @@ AM_CPPFLAGS = \
noinst_LTLIBRARIES
=
libasn1compiler.la
noinst_LTLIBRARIES
=
libasn1compiler.la
libasn1compiler_la_SOURCES
=
\
libasn1compiler_la_SOURCES
=
\
asn1compiler.c asn1compiler.h
\
asn1compiler.c asn1compiler.h
\
asn1c_misc.c asn1c_misc.h
\
asn1c_misc.c asn1c_misc.h
\
asn1c_out.c asn1c_out.h
\
asn1c_out.c asn1c_out.h
\
asn1c_lang.c asn1c_lang.h
\
asn1c_lang.c asn1c_lang.h
\
asn1c_save.c asn1c_save.h
\
asn1c_naming.c asn1c_naming.h
\
asn1c_C.c asn1c_C.h
\
asn1c_save.c asn1c_save.h
\
asn1c_constraint.c asn1c_constraint.h
\
asn1c_C.c asn1c_C.h
\
asn1c_compat.c asn1c_compat.h
\
asn1c_constraint.c asn1c_constraint.h
\
asn1c_ioc.c asn1c_ioc.h
\
asn1c_compat.c asn1c_compat.h
\
asn1c_fdeps.c asn1c_fdeps.h
\
asn1c_ioc.c asn1c_ioc.h
\
asn1c_internal.h
asn1c_fdeps.c asn1c_fdeps.h
\
asn1c_internal.h
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_C.c
View file @
b46156d9
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include "asn1c_out.h"
#include "asn1c_out.h"
#include "asn1c_misc.h"
#include "asn1c_misc.h"
#include "asn1c_ioc.h"
#include "asn1c_ioc.h"
#include "asn1c_naming.h"
#include <asn1print.h>
#include <asn1print.h>
#include <asn1fix_crange.h>
/* constraint groker from libasn1fix */
#include <asn1fix_crange.h>
/* constraint groker from libasn1fix */
#include <asn1fix_export.h>
/* other exportables from libasn1fix */
#include <asn1fix_export.h>
/* other exportables from libasn1fix */
...
@@ -140,15 +141,12 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
...
@@ -140,15 +141,12 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
if
(
expr
->
expr_type
==
ASN_BASIC_ENUMERATED
||
el_count
)
{
if
(
expr
->
expr_type
==
ASN_BASIC_ENUMERATED
||
el_count
)
{
eidx
=
0
;
eidx
=
0
;
REDIR
(
OT_DEPS
);
REDIR
(
OT_DEPS
);
OUT
(
"typedef enum "
);
OUT
(
"typedef %s {
\n
"
,
c_name
(
arg
).
members_enum
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
switch
(
v
->
expr_type
)
{
switch
(
v
->
expr_type
)
{
case
A1TC_UNIVERVAL
:
case
A1TC_UNIVERVAL
:
OUT
(
"
\t
"
);
OUT
(
"
\t
"
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"%s"
,
c_member_name
(
arg
,
v
));
OUT
(
"_%s"
,
MKID
(
v
));
OUT
(
"
\t
= %s%s
\n
"
,
OUT
(
"
\t
= %s%s
\n
"
,
asn1p_itoa
(
v
->
value
->
value
.
v_integer
),
asn1p_itoa
(
v
->
value
->
value
.
v_integer
),
(
eidx
+
1
<
el_count
)
?
","
:
""
);
(
eidx
+
1
<
el_count
)
?
","
:
""
);
...
@@ -167,9 +165,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
...
@@ -167,9 +165,7 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
return
-
1
;
return
-
1
;
}
}
}
}
OUT
(
"} e_"
);
OUT
(
"} %s;
\n
"
,
c_name
(
arg
).
members_name
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
";
\n
"
);
assert
(
eidx
==
el_count
);
assert
(
eidx
==
el_count
);
}
}
...
@@ -275,9 +271,7 @@ asn1c_lang_C_type_BIT_STRING(arg_t *arg) {
...
@@ -275,9 +271,7 @@ asn1c_lang_C_type_BIT_STRING(arg_t *arg) {
if
(
el_count
)
{
if
(
el_count
)
{
int
eidx
=
0
;
int
eidx
=
0
;
REDIR
(
OT_DEPS
);
REDIR
(
OT_DEPS
);
OUT
(
"typedef enum "
);
OUT
(
"typedef %s {
\n
"
,
c_name
(
arg
).
members_enum
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
if
(
v
->
expr_type
!=
A1TC_UNIVERVAL
)
{
if
(
v
->
expr_type
!=
A1TC_UNIVERVAL
)
{
OUT
(
"/* Unexpected BIT STRING element: %s */
\n
"
,
OUT
(
"/* Unexpected BIT STRING element: %s */
\n
"
,
...
@@ -286,15 +280,12 @@ asn1c_lang_C_type_BIT_STRING(arg_t *arg) {
...
@@ -286,15 +280,12 @@ asn1c_lang_C_type_BIT_STRING(arg_t *arg) {
}
}
eidx
++
;
eidx
++
;
OUT
(
"
\t
"
);
OUT
(
"
\t
"
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"%s"
,
c_member_name
(
arg
,
v
));
OUT
(
"_%s"
,
MKID
(
v
));
OUT
(
"
\t
= %s%s
\n
"
,
OUT
(
"
\t
= %s%s
\n
"
,
asn1p_itoa
(
v
->
value
->
value
.
v_integer
),
asn1p_itoa
(
v
->
value
->
value
.
v_integer
),
(
eidx
<
el_count
)
?
","
:
""
);
(
eidx
<
el_count
)
?
","
:
""
);
}
}
OUT
(
"} e_"
);
OUT
(
"} %s;
\n
"
,
c_name
(
arg
).
members_name
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
";
\n
"
);
assert
(
eidx
==
el_count
);
assert
(
eidx
==
el_count
);
}
}
...
@@ -355,13 +346,10 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
...
@@ -355,13 +346,10 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
REDIR
(
OT_FWD_DEFS
);
REDIR
(
OT_FWD_DEFS
);
OUT
(
"typedef "
);
OUT
(
"typedef "
);
}
}
OUT
(
"struct "
);
OUT
(
"%s {
\n
"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
}
else
{
}
else
{
REDIR
(
OT_TYPE_DECLS
);
REDIR
(
OT_TYPE_DECLS
);
OUT
(
"typedef struct %s {
\n
"
,
OUT
(
"typedef %s {
\n
"
,
c_name
(
arg
).
full_name
);
MKID_safe
(
expr
));
}
}
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
...
@@ -390,21 +378,16 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
...
@@ -390,21 +378,16 @@ asn1c_lang_C_type_SEQUENCE(arg_t *arg) {
PCTX_DEF
;
PCTX_DEF
;
if
(
arg
->
embed
&&
expr
->
_anonymous_type
)
{
if
(
arg
->
embed
&&
expr
->
_anonymous_type
)
{
OUT
(
"} %s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
);
OUT
(
"} %s%s;
\n
"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
out_name_chain
(
arg
,
ONC_avoid_keywords
);
c_name
(
arg
).
base_name
);
OUT
(
"%s;
\n
"
,
arg
->
embed
?
""
:
"_t"
);
REDIR
(
saved_target
);
REDIR
(
saved_target
);
OUT
(
"%s
"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
);
OUT
(
"%s
%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
out_name_chain
(
arg
,
ONC_avoid_keywords
);
c_name
(
arg
).
base_name
);
}
else
{
}
else
{
OUT
(
"} %s%s%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
OUT
(
"} %s%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
expr
->
_anonymous_type
?
""
:
c_name
(
arg
).
short_name
);
arg
->
embed
?
MKID_safe
(
expr
)
:
MKID
(
expr
),
arg
->
embed
?
""
:
"_t"
);
}
}
return
asn1c_lang_C_type_SEQUENCE_def
(
arg
,
ioc_tao
.
ioct
?
&
ioc_tao
:
0
);
return
asn1c_lang_C_type_SEQUENCE_def
(
arg
,
ioc_tao
.
ioct
?
&
ioc_tao
:
0
);
...
@@ -550,10 +533,8 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg, asn1c_ioc_table_and_objset_t *opt_ioc
...
@@ -550,10 +533,8 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg, asn1c_ioc_table_and_objset_t *opt_ioc
OUT
(
"asn_SEQUENCE_specifics_t asn_SPC_%s_specs_%d = {
\n
"
,
OUT
(
"asn_SEQUENCE_specifics_t asn_SPC_%s_specs_%d = {
\n
"
,
MKID
(
expr
),
expr
->
_type_unique_index
);
MKID
(
expr
),
expr
->
_type_unique_index
);
INDENT
(
+
1
);
INDENT
(
+
1
);
OUT
(
"sizeof(struct "
);
OUT
(
"sizeof(%s),
\n
"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
"),
\n
"
);
OUT
(
"offsetof(%s, _asn_ctx),
\n
"
,
c_name
(
arg
).
full_name
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _asn_ctx),
\n
"
);
emit_tag2member_reference
(
arg
,
expr
,
tag2el_count
);
emit_tag2member_reference
(
arg
,
expr
,
tag2el_count
);
if
(
roms_count
+
aoms_count
)
{
if
(
roms_count
+
aoms_count
)
{
OUT
(
"asn_MAP_%s_oms_%d,
\t
/* Optional members */
\n
"
,
OUT
(
"asn_MAP_%s_oms_%d,
\t
/* Optional members */
\n
"
,
...
@@ -587,7 +568,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
...
@@ -587,7 +568,7 @@ asn1c_lang_C_type_SET(arg_t *arg) {
asn1p_expr_t
*
expr
=
arg
->
expr
;
asn1p_expr_t
*
expr
=
arg
->
expr
;
asn1p_expr_t
*
v
;
asn1p_expr_t
*
v
;
long
mcount
;
long
mcount
;
char
*
id
;
c
onst
c
har
*
id
;
int
comp_mode
=
0
;
/* {root,ext=1,root,root,...} */
int
comp_mode
=
0
;
/* {root,ext=1,root,root,...} */
int
saved_target
=
arg
->
target
->
target
;
int
saved_target
=
arg
->
target
->
target
;
...
@@ -600,21 +581,16 @@ asn1c_lang_C_type_SET(arg_t *arg) {
...
@@ -600,21 +581,16 @@ asn1c_lang_C_type_SET(arg_t *arg) {
OUT
(
" * Method of determining the components presence
\n
"
);
OUT
(
" * Method of determining the components presence
\n
"
);
OUT
(
" */
\n
"
);
OUT
(
" */
\n
"
);
mcount
=
0
;
mcount
=
0
;
OUT
(
"typedef enum "
);
OUT
(
"typedef %s {
\n
"
,
c_name
(
arg
).
presence_enum
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR {
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
continue
;
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
)
continue
;
INDENTED
(
INDENTED
(
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"%s,"
,
c_presence_name
(
arg
,
v
));
OUT
(
"_PR_"
);
OUT
(
"
\t
/* Member %s is present */
\n
"
,
MKID
(
v
));
id
=
MKID
(
v
);
OUT
(
"%s,
\t
/* Member %s is present */
\n
"
,
id
,
id
)
);
);
mcount
++
;
mcount
++
;
}
}
OUT
(
"}
"
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR;
\n
"
);
OUT
(
"}
%s;
\n
"
,
c_name
(
arg
).
presence_name
);
REDIR
(
saved_target
);
REDIR
(
saved_target
);
...
@@ -623,13 +599,10 @@ asn1c_lang_C_type_SET(arg_t *arg) {
...
@@ -623,13 +599,10 @@ asn1c_lang_C_type_SET(arg_t *arg) {
REDIR
(
OT_FWD_DEFS
);
REDIR
(
OT_FWD_DEFS
);
OUT
(
"typedef "
);
OUT
(
"typedef "
);
}
}
OUT
(
"struct "
);
OUT
(
"%s {
\n
"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
}
else
{
}
else
{
REDIR
(
OT_TYPE_DECLS
);
REDIR
(
OT_TYPE_DECLS
);
OUT
(
"typedef struct %s {
\n
"
,
OUT
(
"typedef %s {
\n
"
,
c_name
(
arg
).
full_name
);
MKID_safe
(
expr
));
}
}
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
...
@@ -653,18 +626,16 @@ asn1c_lang_C_type_SET(arg_t *arg) {
...
@@ -653,18 +626,16 @@ asn1c_lang_C_type_SET(arg_t *arg) {
PCTX_DEF
;
PCTX_DEF
;
if
(
arg
->
embed
&&
expr
->
_anonymous_type
)
{
if
(
arg
->
embed
&&
expr
->
_anonymous_type
)
{
OUT
(
"} %s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
);
OUT
(
"} %s%s;
\n
"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
out_name_chain
(
arg
,
ONC_avoid_keywords
);
c_name
(
arg
).
base_name
);
OUT
(
"%s;
\n
"
,
arg
->
embed
?
""
:
"_t"
);
REDIR
(
saved_target
);
REDIR
(
saved_target
);
OUT
(
"%s
"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
);
OUT
(
"%s
%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
out_name_chain
(
arg
,
ONC_avoid_keywords
);
c_name
(
arg
).
base_name
);
}
else
{
}
else
{
OUT
(
"} %s%s%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
OUT
(
"} %s%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
expr
->
_anonymous_type
?
""
:
MKID_safe
(
expr
),
c_name
(
arg
).
short_name
);
arg
->
embed
?
""
:
"_t"
);
}
}
return
asn1c_lang_C_type_SET_def
(
arg
);
return
asn1c_lang_C_type_SET_def
(
arg
);
...
@@ -682,7 +653,7 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
...
@@ -682,7 +653,7 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
int
tags_count
;
int
tags_count
;
int
all_tags_count
;
int
all_tags_count
;
enum
tvm_compat
tv_mode
;
enum
tvm_compat
tv_mode
;
char
*
p
;
c
onst
c
har
*
p
;
int
saved_target
=
arg
->
target
->
target
;
int
saved_target
=
arg
->
target
->
target
;
/*
/*
...
@@ -780,15 +751,9 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
...
@@ -780,15 +751,9 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
OUT
(
"asn_SET_specifics_t asn_SPC_%s_specs_%d = {
\n
"
,
OUT
(
"asn_SET_specifics_t asn_SPC_%s_specs_%d = {
\n
"
,
MKID
(
expr
),
expr
->
_type_unique_index
);
MKID
(
expr
),
expr
->
_type_unique_index
);
INDENTED
(
INDENTED
(
OUT
(
"sizeof(struct "
);
OUT
(
"sizeof(%s),
\n
"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
"offsetof(%s, _asn_ctx),
\n
"
,
c_name
(
arg
).
full_name
);
OUT
(
"),
\n
"
);
OUT
(
"offsetof(%s, _presence_map),
\n
"
,
c_name
(
arg
).
full_name
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _asn_ctx),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _presence_map),
\n
"
);
emit_tag2member_reference
(
arg
,
expr
,
tag2el_count
);
emit_tag2member_reference
(
arg
,
expr
,
tag2el_count
);
p
=
MKID
(
expr
);
p
=
MKID
(
expr
);
if
(
tag2el_cxer
)
if
(
tag2el_cxer
)
...
@@ -833,11 +798,9 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
...
@@ -833,11 +798,9 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
REDIR
(
OT_FWD_DEFS
);
REDIR
(
OT_FWD_DEFS
);
OUT
(
"typedef "
);
OUT
(
"typedef "
);
}
}
OUT
(
"struct "
);
OUT
(
"%s {
\n
"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
}
else
{
}
else
{
OUT
(
"typedef
struct %s {
\n
"
,
MKID_safe
(
expr
)
);
OUT
(
"typedef
%s {
\n
"
,
c_name
(
arg
).
full_name
);
}
}
INDENT
(
+
1
);
INDENT
(
+
1
);
...
@@ -892,18 +855,16 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
...
@@ -892,18 +855,16 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
PCTX_DEF
;
PCTX_DEF
;
if
(
arg
->
embed
&&
expr
->
_anonymous_type
)
{
if
(
arg
->
embed
&&
expr
->
_anonymous_type
)
{
OUT
(
"} %s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
);
OUT
(
"} %s%s;
\n
"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
out_name_chain
(
arg
,
ONC_avoid_keywords
);
c_name
(
arg
).
base_name
);
OUT
(
"%s;
\n
"
,
arg
->
embed
?
""
:
"_t"
);
REDIR
(
saved_target
);
REDIR
(
saved_target
);
OUT
(
"%s
"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
);
OUT
(
"%s
%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
out_name_chain
(
arg
,
ONC_avoid_keywords
);
c_name
(
arg
).
base_name
);
}
else
{
}
else
{
OUT
(
"} %s%s%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
OUT
(
"} %s%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
expr
->
_anonymous_type
?
""
:
MKID_safe
(
expr
),
c_name
(
arg
).
short_name
);
arg
->
embed
?
""
:
"_t"
);
}
}
/*
/*
...
@@ -965,12 +926,8 @@ asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) {
...
@@ -965,12 +926,8 @@ asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) {
OUT
(
"asn_SET_OF_specifics_t asn_SPC_%s_specs_%d = {
\n
"
,
OUT
(
"asn_SET_OF_specifics_t asn_SPC_%s_specs_%d = {
\n
"
,
MKID
(
expr
),
expr
->
_type_unique_index
);
MKID
(
expr
),
expr
->
_type_unique_index
);
INDENTED
(
INDENTED
(
OUT
(
"sizeof(struct "
);
OUT
(
"sizeof(%s),
\n
"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
"offsetof(%s, _asn_ctx),
\n
"
,
c_name
(
arg
).
full_name
);
OUT
(
"),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _asn_ctx),
\n
"
);
{
{
int
as_xvl
=
expr_as_xmlvaluelist
(
arg
,
v
);
int
as_xvl
=
expr_as_xmlvaluelist
(
arg
,
v
);
OUT
(
"%d,
\t
/* XER encoding is %s */
\n
"
,
OUT
(
"%d,
\t
/* XER encoding is %s */
\n
"
,
...
@@ -995,20 +952,16 @@ int
...
@@ -995,20 +952,16 @@ int
asn1c_lang_C_type_CHOICE
(
arg_t
*
arg
)
{
asn1c_lang_C_type_CHOICE
(
arg_t
*
arg
)
{
asn1p_expr_t
*
expr
=
arg
->
expr
;
asn1p_expr_t
*
expr
=
arg
->
expr
;
asn1p_expr_t
*
v
;
asn1p_expr_t
*
v
;
char
*
id
;
int
saved_target
=
arg
->
target
->
target
;
int
saved_target
=
arg
->
target
->
target
;
DEPENDENCIES
;
DEPENDENCIES
;
REDIR
(
OT_DEPS
);
REDIR
(
OT_DEPS
);
OUT
(
"typedef enum "
);
OUT
(
"typedef %s {
\n
"
,
c_name
(
arg
).
presence_enum
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR {
\n
"
);
INDENTED
(
INDENTED
(
int
skipComma
=
1
;
int
skipComma
=
1
;
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"%s,
\t
/* No components present */
\n
"
,
c_presence_name
(
arg
,
0
));
OUT
(
"_PR_NOTHING,
\t
/* No components present */
\n
"
);
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
TQ_FOR
(
v
,
&
(
expr
->
members
),
next
)
{
if
(
skipComma
)
skipComma
=
0
;
if
(
skipComma
)
skipComma
=
0
;
else
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
&&
!
TQ_NEXT
(
v
,
next
))
OUT
(
"
\n
"
);
else
if
(
v
->
expr_type
==
A1TC_EXTENSIBLE
&&
!
TQ_NEXT
(
v
,
next
))
OUT
(
"
\n
"
);
...
@@ -1018,13 +971,11 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
...
@@ -1018,13 +971,11 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
skipComma
=
1
;
skipComma
=
1
;
continue
;
continue
;
}
}
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"%s"
,
c_presence_name
(
arg
,
v
));
id
=
MKID
(
v
);
OUT
(
"_PR_%s"
,
id
);
}
}
OUT
(
"
\n
"
);
OUT
(
"
\n
"
);
);
);
OUT
(
"}
"
);
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"_PR;
\n
"
);
OUT
(
"}
%s;
\n
"
,
c_name
(
arg
).
presence_name
);
REDIR
(
saved_target
);
REDIR
(
saved_target
);
...
@@ -1033,15 +984,14 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
...
@@ -1033,15 +984,14 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
REDIR
(
OT_FWD_DEFS
);
REDIR
(
OT_FWD_DEFS
);
OUT
(
"typedef "
);
OUT
(
"typedef "
);
}
}
OUT
(
"
struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" {
\n
"
);
OUT
(
"
%s {
\n
"
,
c_name
(
arg
).
full_name
);
}
else
{
}
else
{
REDIR
(
OT_TYPE_DECLS
);
REDIR
(
OT_TYPE_DECLS
);
OUT
(
"typedef
struct %s {
\n
"
,
MKID_safe
(
expr
)
);
OUT
(
"typedef
%s {
\n
"
,
c_name
(
arg
).
full_name
);
}
}
INDENTED
(
INDENTED
(
out_name_chain
(
arg
,
ONC_noflags
);
OUT
(
"%s present;
\n
"
,
c_name
(
arg
).
presence_name
);
OUT
(
"_PR present;
\n
"
);
OUT
(
"union "
);
OUT
(
"union "
);
if
(
UNNAMED_UNIONS
==
0
)
{
if
(
UNNAMED_UNIONS
==
0
)
{
out_name_chain
(
arg
,
ONC_force_compound_name
);
out_name_chain
(
arg
,
ONC_force_compound_name
);
...
@@ -1058,21 +1008,16 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
...
@@ -1058,21 +1008,16 @@ asn1c_lang_C_type_CHOICE(arg_t *arg) {
PCTX_DEF
;
PCTX_DEF
;
if
(
arg
->
embed
&&
expr
->
_anonymous_type
)
{
if
(
arg
->
embed
&&
expr
->
_anonymous_type
)
{
OUT
(
"} %s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
);
OUT
(
"} %s%s;
\n
"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
out_name_chain
(
arg
,
ONC_avoid_keywords
);
c_name
(
arg
).
base_name
);
OUT
(
"%s;
\n
"
,
arg
->
embed
?
""
:
"_t"
);
REDIR
(
saved_target
);
REDIR
(
saved_target
);
OUT
(
"%s
"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
);
OUT
(
"%s
%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
out_name_chain
(
arg
,
ONC_avoid_keywords
);
c_name
(
arg
).
base_name
);
}
else
{
}
else
{
OUT
(
"} %s%s%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
OUT
(
"} %s%s"
,
(
expr
->
marker
.
flags
&
EM_INDIRECT
)
?
"*"
:
""
,
expr
->
_anonymous_type
?
""
:
c_name
(
arg
).
short_name
);
arg
->
embed
?
MKID_safe
(
expr
)
:
MKID
(
expr
),
arg
->
embed
?
""
:
"_t"
);
}
}
return
asn1c_lang_C_type_CHOICE_def
(
arg
);
return
asn1c_lang_C_type_CHOICE_def
(
arg
);
...
@@ -1219,18 +1164,10 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
...
@@ -1219,18 +1164,10 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
OUT
(
"asn_CHOICE_specifics_t asn_SPC_%s_specs_%d = {
\n
"
,
OUT
(
"asn_CHOICE_specifics_t asn_SPC_%s_specs_%d = {
\n
"
,
MKID
(
expr
),
expr
->
_type_unique_index
);
MKID
(
expr
),
expr
->
_type_unique_index
);
INDENTED
(
INDENTED
(
OUT
(
"sizeof(struct "
);
OUT
(
"sizeof(%s),
\n
"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
"offsetof(%s, _asn_ctx),
\n
"
,
c_name
(
arg
).
full_name
);
OUT
(
"),
\n
"
);
OUT
(
"offsetof(%s, present),
\n
"
,
c_name
(
arg
).
full_name
);
OUT
(
"offsetof(struct "
);
OUT
(
"sizeof(((%s *)0)->present),
\n
"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", _asn_ctx),
\n
"
);
OUT
(
"offsetof(struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", present),
\n
"
);
OUT
(
"sizeof(((struct "
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
" *)0)->present),
\n
"
);
emit_tag2member_reference
(
arg
,
expr
,
tag2el_count
);
emit_tag2member_reference
(
arg
,
expr
,
tag2el_count
);
if
(
C99_MODE
)
OUT
(
".canonical_order = "
);
if
(
C99_MODE
)
OUT
(
".canonical_order = "
);
if
(
cmap
)
OUT
(
"asn_MAP_%s_cmap_%d,
\t
/* Canonically sorted */
\n
"
,
if
(
cmap
)
OUT
(
"asn_MAP_%s_cmap_%d,
\t
/* Canonically sorted */
\n
"
,
...
@@ -1306,7 +1243,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
...
@@ -1306,7 +1243,7 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
int
all_tags_count
;
int
all_tags_count
;
enum
tvm_compat
tv_mode
;
enum
tvm_compat
tv_mode
;
enum
etd_spec
etd_spec
;
enum
etd_spec
etd_spec
;
char
*
p
;
c
onst
c
har
*
p
;
int
saved_target
=
arg
->
target
->
target
;
int
saved_target
=
arg
->
target
->
target
;
if
(
arg
->
embed
)
{
if
(
arg
->
embed
)
{
...
@@ -2890,8 +2827,7 @@ emit_member_type_selector(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_ob
...
@@ -2890,8 +2827,7 @@ emit_member_type_selector(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_ob
const
char
*
tname
=
asn1c_type_name
(
arg
,
constraining_memb
,
TNF_SAFE
);
const
char
*
tname
=
asn1c_type_name
(
arg
,
constraining_memb
,
TNF_SAFE
);
if
(
constraining_memb
->
marker
.
flags
&
EM_INDIRECT
)
{
if
(
constraining_memb
->
marker
.
flags
&
EM_INDIRECT
)
{
OUT
(
"const void *memb_ptr = *(const void **)"
);
OUT
(
"const void *memb_ptr = *(const void **)"
);
OUT
(
"((const char *)parent_sptr + offsetof(struct "
);
OUT
(
"((const char *)parent_sptr + offsetof(%s"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", %s));"
,
MKID_safe
(
constraining_memb
));
OUT
(
", %s));"
,
MKID_safe
(
constraining_memb
));
OUT
(
"if(!memb_ptr) return result;
\n
"
);
OUT
(
"if(!memb_ptr) return result;
\n
"
);
OUT
(
"
\n
"
);
OUT
(
"
\n
"
);
...
@@ -2912,8 +2848,7 @@ emit_member_type_selector(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_ob
...
@@ -2912,8 +2848,7 @@ emit_member_type_selector(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_ob
if
(
constraining_memb
->
marker
.
flags
&
EM_INDIRECT
)
{
if
(
constraining_memb
->
marker
.
flags
&
EM_INDIRECT
)
{
OUT
(
"memb_ptr;
\n
"
);
OUT
(
"memb_ptr;
\n
"
);
}
else
{
}
else
{
OUT
(
"((const char *)parent_sptr + offsetof(struct "
);
OUT
(
"((const char *)parent_sptr + offsetof(%s"
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", %s));
\n
"
,
MKID_safe
(
constraining_memb
));
OUT
(
", %s));
\n
"
,
MKID_safe
(
constraining_memb
));
}
}
OUT
(
"
\n
"
);
OUT
(
"
\n
"
);
...
@@ -2987,9 +2922,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_objset_t *
...
@@ -2987,9 +2922,7 @@ emit_member_table(arg_t *arg, asn1p_expr_t *expr, asn1c_ioc_table_and_objset_t *
||
arg
->
expr
->
expr_type
==
ASN_CONSTR_SEQUENCE_OF
);
||
arg
->
expr
->
expr_type
==
ASN_CONSTR_SEQUENCE_OF
);
OUT
(
"0,
\n
"
);
OUT
(
"0,
\n
"
);
}
else
{
}
else
{
OUT
(
"offsetof(struct "
);
OUT
(
"offsetof(%s, "
,
c_name
(
arg
).
full_name
);
out_name_chain
(
arg
,
ONC_avoid_keywords
);
OUT
(
", "
);
if
((
arg
->
expr
->
expr_type
==
ASN_CONSTR_CHOICE
if
((
arg
->
expr
->
expr_type
==
ASN_CONSTR_CHOICE
||
arg
->
expr
->
expr_type
==
ASN_CONSTR_OPEN_TYPE
)
||
arg
->
expr
->
expr_type
==
ASN_CONSTR_OPEN_TYPE
)
&&
(
!
UNNAMED_UNIONS
))
&&
(
!
UNNAMED_UNIONS
))
...
@@ -3372,7 +3305,7 @@ expr_as_xmlvaluelist(arg_t *arg, asn1p_expr_t *expr) {
...
@@ -3372,7 +3305,7 @@ expr_as_xmlvaluelist(arg_t *arg, asn1p_expr_t *expr) {
static
int
static
int
out_name_chain
(
arg_t
*
arg
,
enum
onc_flags
onc_flags
)
{
out_name_chain
(
arg_t
*
arg
,
enum
onc_flags
onc_flags
)
{
asn1p_expr_t
*
expr
=
arg
->
expr
;
asn1p_expr_t
*
expr
=
arg
->
expr
;
char
*
id
;
c
onst
c
har
*
id
;
if
((
arg
->
flags
&
A1C_COMPOUND_NAMES
if
((
arg
->
flags
&
A1C_COMPOUND_NAMES
||
onc_flags
&
ONC_force_compound_name
||
onc_flags
&
ONC_force_compound_name
...
...
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_misc.c
View file @
b46156d9
...
@@ -42,7 +42,7 @@ reserved_keyword(const char *str) {
...
@@ -42,7 +42,7 @@ reserved_keyword(const char *str) {
* Construct identifier from multiple parts.
* Construct identifier from multiple parts.
* Convert unsafe characters to underscores.
* Convert unsafe characters to underscores.
*/
*/
char
*
c
onst
c
har
*
asn1c_make_identifier
(
enum
ami_flags_e
flags
,
asn1p_expr_t
*
expr
,
...)
{
asn1c_make_identifier
(
enum
ami_flags_e
flags
,
asn1p_expr_t
*
expr
,
...)
{
static
char
*
storage
;
static
char
*
storage
;
static
int
storage_size
;
static
int
storage_size
;
...
...
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_misc.h
View file @
b46156d9
...
@@ -12,7 +12,7 @@ enum ami_flags_e {
...
@@ -12,7 +12,7 @@ enum ami_flags_e {
AMI_NODELIMITER
=
4
,
/* Do not put delimiter, just concatenate */
AMI_NODELIMITER
=
4
,
/* Do not put delimiter, just concatenate */
AMI_USE_PREFIX
=
8
,
/* Use Prefix when generating identifier */
AMI_USE_PREFIX
=
8
,
/* Use Prefix when generating identifier */
};
};
char
*
asn1c_make_identifier
(
enum
ami_flags_e
,
asn1p_expr_t
*
expr
,
...);
c
onst
c
har
*
asn1c_make_identifier
(
enum
ami_flags_e
,
asn1p_expr_t
*
expr
,
...);
/*
/*
* Return the type name of the specified expression.
* Return the type name of the specified expression.
...
...
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_naming.c
0 → 100644
View file @
b46156d9
#include "asn1c_internal.h"
#include "asn1c_naming.h"
#include "asn1c_misc.h"
#include "asn1c_misc.h"
#include <asn1_buffer.h>
static
abuf
*
construct_base_name
(
abuf
*
buf
,
arg_t
*
arg
,
int
compound_names
,
int
avoid_keywords
)
{
const
char
*
id
;
if
(
!
buf
)
buf
=
abuf_new
();
if
(
compound_names
&&
arg
->
expr
->
parent_expr
)
{
arg_t
tmparg
=
*
arg
;
tmparg
.
expr
=
arg
->
expr
->
parent_expr
;
construct_base_name
(
buf
,
&
tmparg
,
compound_names
,
0
);
if
(
buf
->
length
)
{
abuf_str
(
buf
,
"__"
);
/* component separator */
}
}
id
=
asn1c_make_identifier
(
((
avoid_keywords
&&
!
buf
->
length
)
?
AMI_CHECK_RESERVED
:
0
),
arg
->
expr
,
0
);
abuf_str
(
buf
,
id
);
return
buf
;
}
static
struct
c_names
c_name_impl
(
arg_t
*
arg
,
int
avoid_keywords
)
{
asn1p_expr_type_e
expr_type
=
arg
->
expr
->
expr_type
;
struct
c_names
names
;
int
compound_names
=
0
;
static
abuf
b_base_name
;
static
abuf
b_short_name
;
static
abuf
b_full_name
;
static
abuf
b_as_member
;
static
abuf
b_presence_enum
;
static
abuf
b_presence_name
;
static
abuf
b_members_enum
;
static
abuf
b_members_name
;
abuf_clear
(
&
b_base_name
);
abuf_clear
(
&
b_short_name
);
abuf_clear
(
&
b_full_name
);
abuf_clear
(
&
b_as_member
);
abuf_clear
(
&
b_presence_enum
);
abuf_clear
(
&
b_presence_name
);
abuf_clear
(
&
b_members_enum
);
abuf_clear
(
&
b_members_name
);
if
((
arg
->
flags
&
A1C_COMPOUND_NAMES
))
{
if
((
expr_type
&
ASN_CONSTR_MASK
)
||
expr_type
==
ASN_BASIC_ENUMERATED
||
((
expr_type
==
ASN_BASIC_INTEGER
||
expr_type
==
ASN_BASIC_BIT_STRING
)))
{
compound_names
=
1
;
}
}
abuf
*
base_name
=
construct_base_name
(
NULL
,
arg
,
compound_names
,
avoid_keywords
);
abuf
*
part_name
=
construct_base_name
(
NULL
,
arg
,
compound_names
,
0
);
abuf
*
member_name
=
construct_base_name
(
NULL
,
arg
,
0
,
1
);
abuf_printf
(
&
b_base_name
,
"%s"
,
base_name
->
buffer
);
if
(
!
arg
->
expr
->
_anonymous_type
)
{
if
(
arg
->
embed
)
{
abuf_printf
(
&
b_short_name
,
"%s"
,
member_name
->
buffer
);
}
else
{
abuf_printf
(
&
b_short_name
,
"%s_t"
,
member_name
->
buffer
);
}
}
abuf_printf
(
&
b_full_name
,
"struct %s"
,
base_name
->
buffer
);
abuf_printf
(
&
b_as_member
,
"%s"
,
member_name
->
buffer
);
abuf_printf
(
&
b_presence_enum
,
"enum %s_PR"
,
part_name
->
buffer
);
abuf_printf
(
&
b_presence_name
,
"%s_PR"
,
part_name
->
buffer
);
abuf_printf
(
&
b_members_enum
,
"enum %s"
,
base_name
->
buffer
);
abuf_printf
(
&
b_members_name
,
"e_%s"
,
part_name
->
buffer
);
names
.
base_name
=
b_base_name
.
buffer
;
names
.
short_name
=
b_short_name
.
buffer
;
names
.
full_name
=
b_full_name
.
buffer
;
names
.
as_member
=
b_as_member
.
buffer
;
names
.
presence_enum
=
b_presence_enum
.
buffer
;
names
.
presence_name
=
b_presence_name
.
buffer
;
names
.
members_enum
=
b_members_enum
.
buffer
;
names
.
members_name
=
b_members_name
.
buffer
;
abuf_free
(
base_name
);
abuf_free
(
part_name
);
abuf_free
(
member_name
);
return
names
;
}
struct
c_names
c_name
(
arg_t
*
arg
)
{
return
c_name_impl
(
arg
,
1
);
}
const
char
*
c_member_name
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
static
abuf
ab
;
abuf_clear
(
&
ab
);
abuf_printf
(
&
ab
,
"%s_%s"
,
c_name_impl
(
arg
,
0
).
base_name
,
asn1c_make_identifier
(
0
,
expr
,
0
));
return
ab
.
buffer
;
}
const
char
*
c_presence_name
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
)
{
static
abuf
ab
;
abuf_clear
(
&
ab
);
if
(
expr
)
{
abuf_printf
(
&
ab
,
"%s_PR_%s"
,
c_name_impl
(
arg
,
0
).
base_name
,
asn1c_make_identifier
(
0
,
expr
,
0
));
}
else
{
abuf_printf
(
&
ab
,
"%s_PR_NOTHING"
,
c_name_impl
(
arg
,
0
).
base_name
);
}
return
ab
.
buffer
;
}
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_naming.h
0 → 100644
View file @
b46156d9
#ifndef ASN1_COMPILER_NAMING_H
#define ASN1_COMPILER_NAMING_H
struct
c_names
{
const
char
*
base_name
;
/* "foo" */
const
char
*
short_name
;
/* "foo_t", "e_foo" */
const
char
*
full_name
;
/* "struct foo", "enum foo" */
const
char
*
as_member
;
/* "foo" (not compounded) */
const
char
*
presence_enum
;
/* "enum foo_PR" */
const
char
*
presence_name
;
/* "foo_PR" */
const
char
*
members_enum
;
/* "enum foo" */
const
char
*
members_name
;
/* "e_foo" */
};
struct
c_names
c_name
(
arg_t
*
);
const
char
*
c_member_name
(
arg_t
*
,
asn1p_expr_t
*
);
/* %s_%s */
const
char
*
c_presence_name
(
arg_t
*
,
asn1p_expr_t
*
);
/* %s_PR_%s */
#endif
/* ASN1_COMPILER_NAMING_H */
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_save.c
View file @
b46156d9
...
@@ -243,7 +243,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
...
@@ -243,7 +243,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps, int optc, char **argv) {
FILE
*
fp_c
,
*
fp_h
;
FILE
*
fp_c
,
*
fp_h
;
char
*
tmpname_c
,
*
tmpname_h
;
char
*
tmpname_c
,
*
tmpname_h
;
char
*
name_buf
;
char
*
name_buf
;
char
*
header_id
;
c
onst
c
har
*
header_id
;
const
char
*
c_retained
=
""
;
const
char
*
c_retained
=
""
;
const
char
*
h_retained
=
""
;
const
char
*
h_retained
=
""
;
char
*
filename
;
char
*
filename
;
...
...
This diff is collapsed.
Click to expand it.
tests/tests-asn1c-compiler/31-set-of-OK.asn1.-Pfcompound-names
0 → 100644
View file @
b46156d9
/*** <<< INCLUDES [Forest] >>> ***/
#include <asn_SET_OF.h>
#include <constr_SET_OF.h>
/*** <<< FWD-DECLS [Forest] >>> ***/
struct Tree;
/*** <<< TYPE-DECLS [Forest] >>> ***/
typedef struct Forest {
A_SET_OF(struct Tree) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Forest_t;
/*** <<< FUNC-DECLS [Forest] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Forest;
extern asn_SET_OF_specifics_t asn_SPC_Forest_specs_1;
extern asn_TYPE_member_t asn_MBR_Forest_1[1];
/*** <<< POST-INCLUDE [Forest] >>> ***/
#include "Tree.h"
/*** <<< STAT-DEFS [Forest] >>> ***/
asn_TYPE_member_t asn_MBR_Forest_1[] = {
{ ATF_POINTER, 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = &asn_DEF_Tree,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = ""
},
};
static const ber_tlv_tag_t asn_DEF_Forest_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
asn_SET_OF_specifics_t asn_SPC_Forest_specs_1 = {
sizeof(struct Forest),
offsetof(struct Forest, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
};
asn_TYPE_descriptor_t asn_DEF_Forest = {
"Forest",
"Forest",
&asn_OP_SET_OF,
SET_OF_constraint,
asn_DEF_Forest_tags_1,
sizeof(asn_DEF_Forest_tags_1)
/sizeof(asn_DEF_Forest_tags_1[0]), /* 1 */
asn_DEF_Forest_tags_1, /* Same as above */
sizeof(asn_DEF_Forest_tags_1)
/sizeof(asn_DEF_Forest_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_Forest_1,
1, /* Single element */
&asn_SPC_Forest_specs_1 /* Additional specs */
};
/*** <<< INCLUDES [Tree] >>> ***/
#include <NativeInteger.h>
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [Tree] >>> ***/
typedef struct Tree {
long height;
long width;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Tree_t;
/*** <<< FUNC-DECLS [Tree] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Tree;
extern asn_SEQUENCE_specifics_t asn_SPC_Tree_specs_1;
extern asn_TYPE_member_t asn_MBR_Tree_1[2];
/*** <<< STAT-DEFS [Tree] >>> ***/
asn_TYPE_member_t asn_MBR_Tree_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Tree, height),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_NativeInteger,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "height"
},
{ ATF_NOFLAGS, 0, offsetof(struct Tree, width),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_NativeInteger,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "width"
},
};
static const ber_tlv_tag_t asn_DEF_Tree_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_Tree_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 1 }, /* height */
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, -1, 0 } /* width */
};
asn_SEQUENCE_specifics_t asn_SPC_Tree_specs_1 = {
sizeof(struct Tree),
offsetof(struct Tree, _asn_ctx),
.tag2el = asn_MAP_Tree_tag2el_1,
.tag2el_count = 2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_Tree = {
"Tree",
"Tree",
&asn_OP_SEQUENCE,
SEQUENCE_constraint,
asn_DEF_Tree_tags_1,
sizeof(asn_DEF_Tree_tags_1)
/sizeof(asn_DEF_Tree_tags_1[0]), /* 1 */
asn_DEF_Tree_tags_1, /* Same as above */
sizeof(asn_DEF_Tree_tags_1)
/sizeof(asn_DEF_Tree_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_Tree_1,
2, /* Elements count */
&asn_SPC_Tree_specs_1 /* Additional specs */
};
/*** <<< INCLUDES [Stuff] >>> ***/
#include <asn_SET_OF.h>
#include <constr_SET_OF.h>
#include <BIT_STRING.h>
#include <constr_SEQUENCE.h>
#include <NativeInteger.h>
#include <constr_CHOICE.h>
#include <constr_SET.h>
/*** <<< DEPS [Stuff] >>> ***/
/*
* Method of determining the components presence
*/
typedef enum Stuff_PR {
Stuff_PR_trees, /* Member trees is present */
Stuff_PR_anything, /* Member anything is present */
Stuff_PR_other, /* Member other is present */
} Stuff_PR;
typedef enum Stuff__other_PR {
Stuff__other_PR_NOTHING, /* No components present */
Stuff__other_PR_a,
Stuff__other_PR_b
} Stuff__other_PR;
/*** <<< FWD-DECLS [Stuff] >>> ***/
struct Forest;
/*** <<< FWD-DEFS [Stuff] >>> ***/
typedef struct Stuff__anything__Member {
BIT_STRING_t cup_of_coffee;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Stuff__anything__Member;
/*** <<< TYPE-DECLS [Stuff] >>> ***/
typedef struct Stuff {
struct Stuff__trees {
A_SET_OF(struct Forest) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} *trees;
struct Stuff__anything {
A_SET_OF(Stuff__anything__Member) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} *anything;
/*
* This type is extensible,
* possible extensions are below.
*/
struct Stuff__other {
Stuff__other_PR present;
union Stuff__other_u {
long a;
long b;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} *other;
/* Presence bitmask: ASN_SET_ISPRESENT(pStuff, Stuff_PR_x) */
unsigned int _presence_map
[((3+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))];
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Stuff_t;
/*** <<< FUNC-DECLS [Stuff] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Stuff;
/*** <<< POST-INCLUDE [Stuff] >>> ***/
#include "Forest.h"
/*** <<< STAT-DEFS [Stuff] >>> ***/
static asn_TYPE_member_t asn_MBR_trees_2[] = {
{ ATF_POINTER, 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
.tag_mode = 0,
.type = &asn_DEF_Forest,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = ""
},
};
static const ber_tlv_tag_t asn_DEF_trees_tags_2[] = {
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn_SET_OF_specifics_t asn_SPC_trees_specs_2 = {
sizeof(struct Stuff__trees),
offsetof(struct Stuff__trees, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_trees_2 = {
"trees",
"trees",
&asn_OP_SET_OF,
SET_OF_constraint,
asn_DEF_trees_tags_2,
sizeof(asn_DEF_trees_tags_2)
/sizeof(asn_DEF_trees_tags_2[0]) - 1, /* 1 */
asn_DEF_trees_tags_2, /* Same as above */
sizeof(asn_DEF_trees_tags_2)
/sizeof(asn_DEF_trees_tags_2[0]), /* 2 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_trees_2,
1, /* Single element */
&asn_SPC_trees_specs_2 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_Member_5[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Stuff__anything__Member, cup_of_coffee),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)),
.tag_mode = 0,
.type = &asn_DEF_BIT_STRING,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "cup-of-coffee"
},
};
static const ber_tlv_tag_t asn_DEF_Member_tags_5[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_Member_tag2el_5[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), 0, 0, 0 } /* cup-of-coffee */
};
static asn_SEQUENCE_specifics_t asn_SPC_Member_specs_5 = {
sizeof(struct Stuff__anything__Member),
offsetof(struct Stuff__anything__Member, _asn_ctx),
.tag2el = asn_MAP_Member_tag2el_5,
.tag2el_count = 1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
0, /* Start extensions */
2 /* Stop extensions */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_Member_5 = {
"SEQUENCE",
"SEQUENCE",
&asn_OP_SEQUENCE,
SEQUENCE_constraint,
asn_DEF_Member_tags_5,
sizeof(asn_DEF_Member_tags_5)
/sizeof(asn_DEF_Member_tags_5[0]), /* 1 */
asn_DEF_Member_tags_5, /* Same as above */
sizeof(asn_DEF_Member_tags_5)
/sizeof(asn_DEF_Member_tags_5[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_Member_5,
1, /* Elements count */
&asn_SPC_Member_specs_5 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_anything_4[] = {
{ ATF_POINTER, 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = &asn_DEF_Member_5,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = ""
},
};
static const ber_tlv_tag_t asn_DEF_anything_tags_4[] = {
(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn_SET_OF_specifics_t asn_SPC_anything_specs_4 = {
sizeof(struct Stuff__anything),
offsetof(struct Stuff__anything, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_anything_4 = {
"anything",
"anything",
&asn_OP_SET_OF,
SET_OF_constraint,
asn_DEF_anything_tags_4,
sizeof(asn_DEF_anything_tags_4)
/sizeof(asn_DEF_anything_tags_4[0]) - 1, /* 1 */
asn_DEF_anything_tags_4, /* Same as above */
sizeof(asn_DEF_anything_tags_4)
/sizeof(asn_DEF_anything_tags_4[0]), /* 2 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_anything_4,
1, /* Single element */
&asn_SPC_anything_specs_4 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_other_9[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Stuff__other, choice.a),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "a"
},
{ ATF_NOFLAGS, 0, offsetof(struct Stuff__other, choice.b),
.tag = (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "b"
},
};
static const asn_TYPE_tag2member_t asn_MAP_other_tag2el_9[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* a */
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 1, 0, 0 } /* b */
};
static asn_CHOICE_specifics_t asn_SPC_other_specs_9 = {
sizeof(struct Stuff__other),
offsetof(struct Stuff__other, _asn_ctx),
offsetof(struct Stuff__other, present),
sizeof(((struct Stuff__other *)0)->present),
.tag2el = asn_MAP_other_tag2el_9,
.tag2el_count = 2, /* Count of tags in the map */
.canonical_order = 0,
.ext_start = -1 /* Extensions start */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_other_9 = {
"other",
"other",
&asn_OP_CHOICE,
CHOICE_constraint,
0, /* No effective tags (pointer) */
0, /* No effective tags (count) */
0, /* No tags (pointer) */
0, /* No tags (count) */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_other_9,
2, /* Elements count */
&asn_SPC_other_specs_9 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_Stuff_1[] = {
{ ATF_POINTER, 3, offsetof(struct Stuff, trees),
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
.tag_mode = 0,
.type = &asn_DEF_trees_2,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "trees"
},
{ ATF_POINTER, 2, offsetof(struct Stuff, anything),
.tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_anything_4,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "anything"
},
{ ATF_POINTER, 1, offsetof(struct Stuff, other),
.tag = -1 /* Ambiguous tag (CHOICE?) */,
.tag_mode = 0,
.type = &asn_DEF_other_9,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "other"
},
};
static const ber_tlv_tag_t asn_DEF_Stuff_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_Stuff_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 2, 0, 0 }, /* a */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* trees */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* anything */
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 2, 0, 0 } /* b */
};
static const asn_TYPE_tag2member_t asn_MAP_Stuff_tag2el_cxer_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 }, /* trees */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 1, 0, 0 }, /* anything */
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 2, 0, 0 } /* a */
};
static const uint8_t asn_MAP_Stuff_mmap_1[(3 + (8 * sizeof(unsigned int)) - 1) / 8] = {
(0 << 7) | (0 << 6) | (0 << 5)
};
static
asn_SET_specifics_t asn_SPC_Stuff_specs_1 = {
sizeof(struct Stuff),
offsetof(struct Stuff, _asn_ctx),
offsetof(struct Stuff, _presence_map),
.tag2el = asn_MAP_Stuff_tag2el_1,
.tag2el_count = 4, /* Count of tags in the map */
asn_MAP_Stuff_tag2el_cxer_1,
3, /* Count of tags in the CXER map */
1, /* Whether extensible */
(const unsigned int *)asn_MAP_Stuff_mmap_1 /* Mandatory elements map */
};
asn_TYPE_descriptor_t asn_DEF_Stuff = {
"Stuff",
"Stuff",
&asn_OP_SET,
SET_constraint,
asn_DEF_Stuff_tags_1,
sizeof(asn_DEF_Stuff_tags_1)
/sizeof(asn_DEF_Stuff_tags_1[0]), /* 1 */
asn_DEF_Stuff_tags_1, /* Same as above */
sizeof(asn_DEF_Stuff_tags_1)
/sizeof(asn_DEF_Stuff_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_Stuff_1,
3, /* Elements count */
&asn_SPC_Stuff_specs_1 /* Additional specs */
};
This diff is collapsed.
Click to expand it.
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