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
5efafc56
Commit
5efafc56
authored
Sep 05, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
early suggestion of -fcompound-names
parent
c17e14e6
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
181 additions
and
70 deletions
+181
-70
examples/sample.source.LDAP3/Makefile
examples/sample.source.LDAP3/Makefile
+45
-27
libasn1compiler/asn1c_naming.c
libasn1compiler/asn1c_naming.c
+72
-2
libasn1compiler/asn1c_naming.h
libasn1compiler/asn1c_naming.h
+9
-0
libasn1compiler/asn1compiler.c
libasn1compiler/asn1compiler.c
+17
-0
libasn1parser/asn1p_expr.h
libasn1parser/asn1p_expr.h
+2
-1
tests/tests-asn1c-compiler/110-param-3-OK.asn1.-Pfcompound-names
...ests-asn1c-compiler/110-param-3-OK.asn1.-Pfcompound-names
+26
-30
tests/tests-asn1c-compiler/142-anonymous-types-deco-OK.asn1.-Pfcompound-names
...mpiler/142-anonymous-types-deco-OK.asn1.-Pfcompound-names
+10
-10
No files found.
examples/sample.source.LDAP3/Makefile
View file @
5efafc56
...
@@ -206,66 +206,84 @@ regen-makefile:
...
@@ -206,66 +206,84 @@ regen-makefile:
CPPFLAGS
=
""
\
CPPFLAGS
=
""
\
../sample.makefile.regen
../sample.makefile.regen
check
:
${TARGET} check-ber check-xer check-per
check
:
${TARGET} check-ber check-xer check-
oer check-
per
@
echo
================
@
echo
================
@
echo
All tests passed
@
echo
All tests passed
@
echo
================
@
echo
================
check-ber
:
check-ber
:
@
if
test
-f
sample-LDAPMessage-1.[db]er
;
then
\
@
if
test
-f
sample-LDAPMessage-1.[db]er
;
then
\
for
f
in
sample-LDAPMessage-
*
.[db]er
;
do
\
for
f
in
sample-
*
-
*
.[db]er
;
do
\
pdu
=
`
echo
$$
f |
sed
-E
-e
"s/sample-([A-Za-z0-9-]+)-[0-9].*/
\1
/"
`
;
\
for
b
in
1 17 33 980 8192
;
do
\
for
b
in
1 17 33 980 8192
;
do
\
echo
"Recoding
$$
f into XER and back (
$$
b)..."
;
\
echo
"Recoding
$$
f
(
$$
pdu)
into XER and back (
$$
b)..."
;
\
./
${TARGET}
-b
$$
b
-iber
-oxer
$$
f
>
./.tmp.1.
$$$$
||
exit
2
;
\
./
${TARGET}
-
p
$$
pdu
-
b
$$
b
-iber
-oxer
$$
f
>
./.tmp.1.
$$$$
||
exit
2
;
\
./
${TARGET}
-b
$$
b
-ixer
-oxer
./.tmp.1.
$$$$
>
./.tmp.2.
$$$$
||
exit
3
;
\
./
${TARGET}
-
p
$$
pdu
-
b
$$
b
-ixer
-oxer
./.tmp.1.
$$$$
>
./.tmp.2.
$$$$
||
exit
3
;
\
diff ./.tmp.1.
$$$$
./.tmp.2.
$$$$
||
exit
4
;
\
diff ./.tmp.1.
$$$$
./.tmp.2.
$$$$
||
exit
4
;
\
rm
-f
./.tmp.[12].
$$$$
;
\
rm
-f
./.tmp.[12].
$$$$
;
\
echo
"Test junking
$$
f (please wait)..."
;
\
echo
"Test junking
$$
f (please wait)..."
;
\
./
${TARGET}
-J0
.0001
-n
1000
-b
$$
b
-iber
-onull
$$
f
||
exit
5
;
\
./
${TARGET}
-J0
.0001
-n
1000
-
p
$$
pdu
-
b
$$
b
-iber
-onull
$$
f
||
exit
5
;
\
./
${TARGET}
-J0
.001
-n
1000
-b
$$
b
-iber
-onull
$$
f
||
exit
6
;
\
./
${TARGET}
-J0
.001
-n
1000
-
p
$$
pdu
-
b
$$
b
-iber
-onull
$$
f
||
exit
6
;
\
done
;
done
;
fi
done
;
done
;
fi
check-xer
:
check-xer
:
@
if
test
-f
sample-LDAPMessage-1.xer
;
then
\
@
if
test
-f
sample-LDAPMessage-1.xer
;
then
\
for
f
in
sample-LDAPMessage-
*
.xer
;
do
\
for
f
in
sample-
*
-
*
.xer
;
do
\
pdu
=
`
echo
$$
f |
sed
-E
-e
"s/sample-([A-Za-z0-9-]+)-[0-9].*/
\1
/"
`
;
\
for
b
in
1 17 33 980 8192
;
do
\
for
b
in
1 17 33 980 8192
;
do
\
echo
"Recoding
$$
f into DER and back (
$$
b)..."
;
\
echo
"Recoding
$$
f
(
$$
pdu)
into DER and back (
$$
b)..."
;
\
./
${TARGET}
-b
$$
b
-ixer
-oder
$$
f
>
./.tmp.1.
$$$$
||
exit
2
;
\
./
${TARGET}
-
p
$$
pdu
-
b
$$
b
-ixer
-oder
$$
f
>
./.tmp.1.
$$$$
||
exit
2
;
\
./
${TARGET}
-b
$$
b
-iber
-oxer
./.tmp.1.
$$$$
>
./.tmp.2.
$$$$
||
exit
3
;
\
./
${TARGET}
-
p
$$
pdu
-
b
$$
b
-iber
-oxer
./.tmp.1.
$$$$
>
./.tmp.2.
$$$$
||
exit
3
;
\
diff
$$
f ./.tmp.2.
$$$$
||
exit
4
;
\
diff
$$
f ./.tmp.2.
$$$$
||
exit
4
;
\
rm
-f
./.tmp.[12].
$$$$
;
\
rm
-f
./.tmp.[12].
$$$$
;
\
echo
"Test junking
$$
f (please wait)..."
;
\
echo
"Test junking
$$
f (please wait)..."
;
\
./
${TARGET}
-J0
.0001
-n
1000
-b
$$
b
-ixer
-onull
$$
f
||
exit
5
;
\
./
${TARGET}
-J0
.0001
-n
1000
-p
$$
pdu
-b
$$
b
-ixer
-onull
$$
f
||
exit
5
;
\
./
${TARGET}
-J0
.001
-n
1000
-b
$$
b
-ixer
-onull
$$
f
||
exit
6
;
\
./
${TARGET}
-J0
.001
-n
1000
-p
$$
pdu
-b
$$
b
-ixer
-onull
$$
f
||
exit
6
;
\
done
;
done
;
fi
check-oer
:
@
if
test
-f
sample-LDAPMessage-1.
*
oer
;
then
\
for
f
in
sample-
*
-
*
.
*
oer
;
do
\
pdu
=
`
echo
$$
f |
sed
-E
-e
"s/sample-([A-Za-z0-9-]+)-[0-9].*/
\1
/"
`
;
\
for
b
in
1 17 33 980 8192
;
do
\
echo
"Recoding
$$
f (
$$
pdu) into XER and back (
$$
b)..."
;
\
./
${TARGET}
-p
$$
pdu
-b
$$
b
-ioer
-oxer
$$
f
>
./.tmp.1.
$$$$
||
exit
2
;
\
./
${TARGET}
-p
$$
pdu
-b
$$
b
-ixer
-ooer
./.tmp.1.
$$$$
>
./.tmp.2.
$$$$
||
exit
3
;
\
diff
$$
f ./.tmp.2.
$$$$
||
exit
4
;
\
rm
-f
./.tmp.[12].
$$$$
;
\
echo
"Test junking
$$
f (please wait) (
$$
b) ..."
;
\
./
${TARGET}
-J0
.0001
-n
1000
-p
$$
pdu
-b
$$
b
-ioer
-onull
$$
f
||
exit
5
;
\
./
${TARGET}
-J0
.001
-n
1000
-p
$$
pdu
-b
$$
b
-ioer
-onull
$$
f
||
exit
6
;
\
done
;
done
;
fi
done
;
done
;
fi
check-per
:
check-per
:
@
if
test
-f
sample-LDAPMessage-1-nopad.per
;
then
\
@
if
test
-f
sample-LDAPMessage-1-nopad.per
;
then
\
for
f
in
sample-LDAPMessage-[1-9]-nopad.per
;
do
\
for
f
in
sample-
*
-[1-9]-nopad.per
;
do
\
pdu
=
`
echo
$$
f |
sed
-E
-e
"s/sample-([A-Za-z0-9-]+)-[0-9].*/
\1
/"
`
;
\
for
b
in
1 17 33 980 8192
;
do
\
for
b
in
1 17 33 980 8192
;
do
\
echo
"Recoding non-padded
$$
f into DER into XER and back (
$$
b)..."
;
\
echo
"Recoding non-padded
$$
f
(
$$
pdu)
into DER into XER and back (
$$
b)..."
;
\
./
${TARGET}
-b
$$
b
-per-nopad
-iper
-oder
$$
f
>
./.tmp.1.
$$$$
||
exit
2
;
\
./
${TARGET}
-
p
$$
pdu
-
b
$$
b
-per-nopad
-iper
-oder
$$
f
>
./.tmp.1.
$$$$
||
exit
2
;
\
./
${TARGET}
-b
$$
b
-iber
-oxer
./.tmp.1.
$$$$
>
./.tmp.2.
$$$$
||
exit
3
;
\
./
${TARGET}
-
p
$$
pdu
-
b
$$
b
-iber
-oxer
./.tmp.1.
$$$$
>
./.tmp.2.
$$$$
||
exit
3
;
\
./
${TARGET}
-b
$$
b
-ixer
-oder
./.tmp.2.
$$$$
>
./.tmp.3.
$$$$
||
exit
4
;
\
./
${TARGET}
-
p
$$
pdu
-
b
$$
b
-ixer
-oder
./.tmp.2.
$$$$
>
./.tmp.3.
$$$$
||
exit
4
;
\
diff ./.tmp.1.
$$$$
./.tmp.3.
$$$$
||
exit
5
;
\
diff ./.tmp.1.
$$$$
./.tmp.3.
$$$$
||
exit
5
;
\
rm
-f
./.tmp.[123].
$$$$
;
\
rm
-f
./.tmp.[123].
$$$$
;
\
echo
"Test junking
$$
f (please wait)..."
;
\
echo
"Test junking
$$
f (please wait)..."
;
\
./
${TARGET}
-J0
.0001
-n
1000
-b
$$
b
-per-nopad
-iper
-onull
$$
f
||
exit
6
;
\
./
${TARGET}
-J0
.0001
-n
1000
-
p
$$
pdu
-
b
$$
b
-per-nopad
-iper
-onull
$$
f
||
exit
6
;
\
./
${TARGET}
-J0
.001
-n
1000
-b
$$
b
-per-nopad
-iper
-onull
$$
f
||
exit
7
;
\
./
${TARGET}
-J0
.001
-n
1000
-
p
$$
pdu
-
b
$$
b
-per-nopad
-iper
-onull
$$
f
||
exit
7
;
\
done
;
done
;
fi
done
;
done
;
fi
@
if
test
-f
sample-LDAPMessage-1.per
;
then
\
@
if
test
-f
sample-LDAPMessage-1.per
;
then
\
for
f
in
sample-
*
-[1-9].per
;
do
\
for
f
in
sample-
*
-[1-9].per
;
do
\
pdu
=
`
echo
$$
f |
sed
-E
-e
"s/sample-([A-Za-z-]+)-[0-9].*/
\1
/"
`
;
\
pdu
=
`
echo
$$
f |
sed
-E
-e
"s/sample-([A-Za-z
0-9
-]+)-[0-9].*/
\1
/"
`
;
\
for
b
in
1 17 33 980 8192
;
do
\
for
b
in
1 17 33 980 8192
;
do
\
echo
"Recoding
$$
f into DER into XER and back (
$$
b)..."
;
\
echo
"Recoding
$$
f
(
$$
pdu)
into DER into XER and back (
$$
b)..."
;
\
./
${TARGET}
-
b
$$
b
-p
$$
pdu
-iper
-oder
$$
f
>
./.tmp.1.
$$$$
||
exit
3
;
\
./
${TARGET}
-
p
$$
pdu
-b
$$
b
-iper
-oder
$$
f
>
./.tmp.1.
$$$$
||
exit
3
;
\
./
${TARGET}
-
b
$$
b
-p
$$
pdu
-iber
-oxer
./.tmp.1.
$$$$
>
./.tmp.2.
$$$$
||
exit
4
;
\
./
${TARGET}
-
p
$$
pdu
-b
$$
b
-iber
-oxer
./.tmp.1.
$$$$
>
./.tmp.2.
$$$$
||
exit
4
;
\
./
${TARGET}
-
b
$$
b
-p
$$
pdu
-ixer
-oper
./.tmp.2.
$$$$
>
./.tmp.1.
$$$$
||
exit
5
;
\
./
${TARGET}
-
p
$$
pdu
-b
$$
b
-ixer
-oper
./.tmp.2.
$$$$
>
./.tmp.1.
$$$$
||
exit
5
;
\
diff
$$
f ./.tmp.1.
$$$$
||
exit
6
;
\
diff
$$
f ./.tmp.1.
$$$$
||
exit
6
;
\
rm
-f
./.tmp.[12].
$$$$
;
\
rm
-f
./.tmp.[12].
$$$$
;
\
echo
"Test junking
$$
f (please wait)..."
;
\
echo
"Test junking
$$
f (please wait)..."
;
\
./
${TARGET}
-J0
.0001
-n
1000
-b
$$
b
-iper
-onull
$$
f
||
exit
7
;
\
./
${TARGET}
-J0
.0001
-n
1000
-
p
$$
pdu
-
b
$$
b
-iper
-onull
$$
f
||
exit
7
;
\
./
${TARGET}
-J0
.001
-n
1000
-b
$$
b
-iper
-onull
$$
f
||
exit
8
;
\
./
${TARGET}
-J0
.001
-n
1000
-
p
$$
pdu
-
b
$$
b
-iper
-onull
$$
f
||
exit
8
;
\
done
;
done
;
fi
done
;
done
;
fi
maybe-wip-pause
:
maybe-wip-pause
:
...
...
libasn1compiler/asn1c_naming.c
View file @
5efafc56
...
@@ -4,6 +4,68 @@
...
@@ -4,6 +4,68 @@
#include "asn1c_misc.h"
#include "asn1c_misc.h"
#include <asn1_buffer.h>
#include <asn1_buffer.h>
struct
intl_name
{
asn1p_expr_t
*
expr
;
asn1p_expr_t
*
clashes_with
;
const
char
*
name
;
TQ_ENTRY
(
struct
intl_name
)
next
;
};
static
TQ_HEAD
(
struct
intl_name
)
used_names
;
void
c_name_clash_finder_init
()
{
TQ_INIT
(
&
used_names
);
}
static
void
register_global_name
(
arg_t
*
arg
,
const
char
*
name
)
{
struct
intl_name
*
n
;
TQ_FOR
(
n
,
&
used_names
,
next
)
{
if
(
strcmp
(
n
->
name
,
name
)
==
0
)
{
if
(
!
(
arg
->
expr
->
_mark
&
TM_NAMEGIVEN
)
&&
arg
->
expr
!=
n
->
expr
)
{
n
->
clashes_with
=
arg
->
expr
;
return
;
}
}
}
n
=
calloc
(
1
,
sizeof
(
*
n
));
assert
(
n
);
n
->
expr
=
arg
->
expr
;
n
->
name
=
strdup
(
name
);
TQ_ADD
(
&
used_names
,
n
,
next
);
}
int
c_name_clash
(
arg_t
*
arg
)
{
struct
intl_name
*
n
;
size_t
n_clashes
=
0
;
const
size_t
max_clashes
=
5
;
TQ_FOR
(
n
,
&
used_names
,
next
)
{
if
(
n
->
clashes_with
)
{
if
(
n_clashes
++
>
max_clashes
)
continue
;
FATAL
(
"Name
\"
%s
\"
is generated by %s.%s at line %s:%d and "
"%s.%s at line %s:%d"
,
n
->
name
,
n
->
expr
->
module
->
ModuleName
,
n
->
expr
->
Identifier
,
n
->
expr
->
module
->
source_file_name
,
n
->
expr
->
_lineno
,
n
->
clashes_with
->
module
->
ModuleName
,
n
->
clashes_with
->
Identifier
,
n
->
clashes_with
->
module
->
source_file_name
,
n
->
clashes_with
->
_lineno
);
}
}
if
(
n_clashes
>
max_clashes
)
{
FATAL
(
"... %zu more name clashes not shown"
,
n_clashes
-
max_clashes
);
}
return
n_clashes
>
0
;
}
static
abuf
*
static
abuf
*
construct_base_name
(
abuf
*
buf
,
arg_t
*
arg
,
int
compound_names
,
construct_base_name
(
abuf
*
buf
,
arg_t
*
arg
,
int
compound_names
,
int
avoid_keywords
)
{
int
avoid_keywords
)
{
...
@@ -97,6 +159,16 @@ c_name_impl(arg_t *arg, int avoid_keywords) {
...
@@ -97,6 +159,16 @@ c_name_impl(arg_t *arg, int avoid_keywords) {
abuf_free
(
part_name
);
abuf_free
(
part_name
);
abuf_free
(
member_name
);
abuf_free
(
member_name
);
/* A _subset_ of names is checked against being globally unique */
register_global_name
(
arg
,
names
.
base_name
);
register_global_name
(
arg
,
names
.
full_name
);
register_global_name
(
arg
,
names
.
presence_enum
);
register_global_name
(
arg
,
names
.
presence_name
);
register_global_name
(
arg
,
names
.
members_enum
);
register_global_name
(
arg
,
names
.
members_name
);
arg
->
expr
->
_mark
|=
TM_NAMEGIVEN
;
return
names
;
return
names
;
}
}
...
@@ -133,5 +205,3 @@ c_presence_name(arg_t *arg, asn1p_expr_t *expr) {
...
@@ -133,5 +205,3 @@ c_presence_name(arg_t *arg, asn1p_expr_t *expr) {
return
ab
.
buffer
;
return
ab
.
buffer
;
}
}
libasn1compiler/asn1c_naming.h
View file @
5efafc56
...
@@ -16,4 +16,13 @@ struct c_names c_name(arg_t *);
...
@@ -16,4 +16,13 @@ struct c_names c_name(arg_t *);
const
char
*
c_member_name
(
arg_t
*
,
asn1p_expr_t
*
);
/* %s_%s */
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 */
const
char
*
c_presence_name
(
arg_t
*
,
asn1p_expr_t
*
);
/* %s_PR_%s */
/*
* Returns 0 if no C name clashes have been encountered.
* Returns 1 if C name clashes have been encountered.
* Prints out the clashing items and suggests -fcompound-names.
*/
int
c_name_clash
(
arg_t
*
arg
);
void
c_name_clash_finder_init
(
void
);
#endif
/* ASN1_COMPILER_NAMING_H */
#endif
/* ASN1_COMPILER_NAMING_H */
libasn1compiler/asn1compiler.c
View file @
5efafc56
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "asn1c_out.h"
#include "asn1c_out.h"
#include "asn1c_save.h"
#include "asn1c_save.h"
#include "asn1c_ioc.h"
#include "asn1c_ioc.h"
#include "asn1c_naming.h"
static
void
default_logger_cb
(
int
,
const
char
*
fmt
,
...);
static
void
default_logger_cb
(
int
,
const
char
*
fmt
,
...);
static
int
asn1c_compile_expr
(
arg_t
*
arg
,
const
asn1c_ioc_table_and_objset_t
*
);
static
int
asn1c_compile_expr
(
arg_t
*
arg
,
const
asn1c_ioc_table_and_objset_t
*
);
...
@@ -17,6 +18,8 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
...
@@ -17,6 +18,8 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
asn1p_module_t
*
mod
;
asn1p_module_t
*
mod
;
int
ret
;
int
ret
;
c_name_clash_finder_init
();
/*
/*
* Initialize target language.
* Initialize target language.
*/
*/
...
@@ -60,6 +63,20 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
...
@@ -60,6 +63,20 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
}
}
}
}
if
(
c_name_clash
(
arg
))
{
if
(
arg
->
flags
&
A1C_COMPOUND_NAMES
)
{
FATAL
(
"Name clashes encountered even with -fcompound-names flag"
);
/* Proceed further for better debugging. */
}
else
{
FATAL
(
"Use
\"
-fcompound-names
\"
flag to asn1c to resolve name clashes"
);
if
(
arg
->
flags
&
A1C_PRINT_COMPILED
)
{
/* Proceed further for better debugging. */
}
else
{
return
-
1
;
}
}
}
DEBUG
(
"Saving compiled data"
);
DEBUG
(
"Saving compiled data"
);
/*
/*
...
...
libasn1parser/asn1p_expr.h
View file @
5efafc56
...
@@ -250,7 +250,8 @@ typedef struct asn1p_expr_s {
...
@@ -250,7 +250,8 @@ typedef struct asn1p_expr_s {
TM_RECURSION
=
(
1
<<
0
),
/* Used to break recursion */
TM_RECURSION
=
(
1
<<
0
),
/* Used to break recursion */
TM_BROKEN
=
(
1
<<
1
),
/* A warning was already issued */
TM_BROKEN
=
(
1
<<
1
),
/* A warning was already issued */
TM_PERFROMCT
=
(
1
<<
2
),
/* PER FROM() constraint tables emitted */
TM_PERFROMCT
=
(
1
<<
2
),
/* PER FROM() constraint tables emitted */
TM_NAMECLASH
=
(
1
<<
3
)
/* Name clash found, need to add module name to resolve */
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
;
}
_mark
;
/*
/*
...
...
tests/tests-asn1c-compiler/110-param-3-OK.asn1.-Pf
wide-typ
es
→
tests/tests-asn1c-compiler/110-param-3-OK.asn1.-Pf
compound-nam
es
View file @
5efafc56
/*** <<< INCLUDES [Flag] >>> ***/
/*** <<< INCLUDES [Flag] >>> ***/
#include <
INTEGER
.h>
#include <
NativeInteger
.h>
#include <constr_SEQUENCE.h>
#include <constr_SEQUENCE.h>
#include <
ENUMERATED
.h>
#include <
NativeEnumerated
.h>
/*** <<< DEPS [Flag] >>> ***/
/*** <<< DEPS [Flag] >>> ***/
typedef enum field {
typedef enum
Flag_16P0__
field {
field_red = 0,
Flag_16P0__
field_red = 0,
field_green = 1,
Flag_16P0__
field_green = 1,
field_blue = 5
Flag_16P0__
field_blue = 5
} e_field;
} e_
Flag_16P0__
field;
typedef enum field {
typedef enum
Flag_16P1__
field {
field_red = 3,
Flag_16P1__
field_red = 3,
field_green = 4,
Flag_16P1__
field_green = 4,
field_blue = 5
Flag_16P1__
field_blue = 5
} e_field;
} e_
Flag_16P1__
field;
/*** <<< TYPE-DECLS [Flag] >>> ***/
/*** <<< TYPE-DECLS [Flag] >>> ***/
typedef struct Flag_16P0 {
typedef struct Flag_16P0 {
INTEGER_t
*field /* DEFAULT 5 */;
long
*field /* DEFAULT 5 */;
/* Context for parsing across buffer boundaries */
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
asn_struct_ctx_t _asn_ctx;
} Flag_16P0_t;
} Flag_16P0_t;
typedef struct Flag_16P1 {
typedef struct Flag_16P1 {
ENUMERATED_t
*field /* DEFAULT 5 */;
long
*field /* DEFAULT 5 */;
/* Context for parsing across buffer boundaries */
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
asn_struct_ctx_t _asn_ctx;
...
@@ -46,14 +46,14 @@ extern asn_TYPE_member_t asn_MBR_Flag_16P1_6[1];
...
@@ -46,14 +46,14 @@ extern asn_TYPE_member_t asn_MBR_Flag_16P1_6[1];
/*** <<< CODE [Flag] >>> ***/
/*** <<< CODE [Flag] >>> ***/
/*
/*
* This type is implemented using
ENUMERATED
,
* This type is implemented using
NativeEnumerated
,
* so here we adjust the DEF accordingly.
* so here we adjust the DEF accordingly.
*/
*/
/*** <<< STAT-DEFS [Flag] >>> ***/
/*** <<< STAT-DEFS [Flag] >>> ***/
static int asn_DFL_2_set_5(int set_value, void **sptr) {
static int asn_DFL_2_set_5(int set_value, void **sptr) {
INTEGER_t
*st = *sptr;
long
*st = *sptr;
if(!st) {
if(!st) {
if(!set_value) return -1; /* Not a default value */
if(!set_value) return -1; /* Not a default value */
...
@@ -63,20 +63,18 @@ static int asn_DFL_2_set_5(int set_value, void **sptr) {
...
@@ -63,20 +63,18 @@ static int asn_DFL_2_set_5(int set_value, void **sptr) {
if(set_value) {
if(set_value) {
/* Install default value 5 */
/* Install default value 5 */
return asn_long2INTEGER(st, 5);
*st = 5;
return 0;
} else {
} else {
/* Test default value 5 */
/* Test default value 5 */
long value;
return (*st == 5);
if(asn_INTEGER2long(st, &value))
return -1;
return (value == 5);
}
}
}
}
asn_TYPE_member_t asn_MBR_Flag_16P0_1[] = {
asn_TYPE_member_t asn_MBR_Flag_16P0_1[] = {
{ ATF_POINTER, 1, offsetof(struct Flag_16P0, field),
{ ATF_POINTER, 1, offsetof(struct Flag_16P0, field),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.tag_mode = 0,
.type = &asn_DEF_
INTEGER
,
.type = &asn_DEF_
NativeInteger
,
.type_selector = 0,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
...
@@ -119,7 +117,7 @@ asn_TYPE_descriptor_t asn_DEF_Flag_16P0 = {
...
@@ -119,7 +117,7 @@ asn_TYPE_descriptor_t asn_DEF_Flag_16P0 = {
};
};
static int asn_DFL_7_set_5(int set_value, void **sptr) {
static int asn_DFL_7_set_5(int set_value, void **sptr) {
ENUMERATED_t
*st = *sptr;
long
*st = *sptr;
if(!st) {
if(!st) {
if(!set_value) return -1; /* Not a default value */
if(!set_value) return -1; /* Not a default value */
...
@@ -129,13 +127,11 @@ static int asn_DFL_7_set_5(int set_value, void **sptr) {
...
@@ -129,13 +127,11 @@ static int asn_DFL_7_set_5(int set_value, void **sptr) {
if(set_value) {
if(set_value) {
/* Install default value 5 */
/* Install default value 5 */
return asn_long2INTEGER(st, 5);
*st = 5;
return 0;
} else {
} else {
/* Test default value 5 */
/* Test default value 5 */
long value;
return (*st == 5);
if(asn_INTEGER2long(st, &value))
return -1;
return (value == 5);
}
}
}
}
static const asn_INTEGER_enum_map_t asn_MAP_field_value2enum_7[] = {
static const asn_INTEGER_enum_map_t asn_MAP_field_value2enum_7[] = {
...
@@ -164,8 +160,8 @@ static /* Use -fall-defs-global to expose */
...
@@ -164,8 +160,8 @@ static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_field_7 = {
asn_TYPE_descriptor_t asn_DEF_field_7 = {
"field",
"field",
"field",
"field",
&asn_OP_
ENUMERATED
,
&asn_OP_
NativeEnumerated
,
ENUMERATED
_constraint,
NativeEnumerated
_constraint,
asn_DEF_field_tags_7,
asn_DEF_field_tags_7,
sizeof(asn_DEF_field_tags_7)
sizeof(asn_DEF_field_tags_7)
/sizeof(asn_DEF_field_tags_7[0]), /* 1 */
/sizeof(asn_DEF_field_tags_7[0]), /* 1 */
...
...
tests/tests-asn1c-compiler/142-anonymous-types-deco-OK.asn1.-P
→
tests/tests-asn1c-compiler/142-anonymous-types-deco-OK.asn1.-P
fcompound-names
View file @
5efafc56
...
@@ -105,7 +105,7 @@ typedef enum Type1_PR {
...
@@ -105,7 +105,7 @@ typedef enum Type1_PR {
typedef struct Type1 {
typedef struct Type1 {
Type1_PR present;
Type1_PR present;
union Type1_u {
union Type1_u {
struct anonType {
struct
Type1__
anonType {
OCTET_STRING_t x;
OCTET_STRING_t x;
OCTET_STRING_t y;
OCTET_STRING_t y;
...
@@ -182,7 +182,7 @@ memb_y_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -182,7 +182,7 @@ memb_y_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr,
/*** <<< STAT-DEFS [Type1] >>> ***/
/*** <<< STAT-DEFS [Type1] >>> ***/
static asn_TYPE_member_t asn_MBR_anonType_2[] = {
static asn_TYPE_member_t asn_MBR_anonType_2[] = {
{ ATF_NOFLAGS, 0, offsetof(struct anonType, x),
{ ATF_NOFLAGS, 0, offsetof(struct
Type1__
anonType, x),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_OCTET_STRING,
.type = &asn_DEF_OCTET_STRING,
...
@@ -193,7 +193,7 @@ static asn_TYPE_member_t asn_MBR_anonType_2[] = {
...
@@ -193,7 +193,7 @@ static asn_TYPE_member_t asn_MBR_anonType_2[] = {
.default_value = 0,
.default_value = 0,
.name = "x"
.name = "x"
},
},
{ ATF_NOFLAGS, 0, offsetof(struct anonType, y),
{ ATF_NOFLAGS, 0, offsetof(struct
Type1__
anonType, y),
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_OCTET_STRING,
.type = &asn_DEF_OCTET_STRING,
...
@@ -214,8 +214,8 @@ static const asn_TYPE_tag2member_t asn_MAP_anonType_tag2el_2[] = {
...
@@ -214,8 +214,8 @@ static const asn_TYPE_tag2member_t asn_MAP_anonType_tag2el_2[] = {
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* y */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* y */
};
};
static asn_SEQUENCE_specifics_t asn_SPC_anonType_specs_2 = {
static asn_SEQUENCE_specifics_t asn_SPC_anonType_specs_2 = {
sizeof(struct anonType),
sizeof(struct
Type1__
anonType),
offsetof(struct anonType, _asn_ctx),
offsetof(struct
Type1__
anonType, _asn_ctx),
.tag2el = asn_MAP_anonType_tag2el_2,
.tag2el = asn_MAP_anonType_tag2el_2,
.tag2el_count = 2, /* Count of tags in the map */
.tag2el_count = 2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
0, 0, 0, /* Optional elements (not needed) */
...
@@ -302,7 +302,7 @@ typedef enum Type2_PR {
...
@@ -302,7 +302,7 @@ typedef enum Type2_PR {
typedef struct Type2 {
typedef struct Type2 {
Type2_PR present;
Type2_PR present;
union Type2_u {
union Type2_u {
struct anonType {
struct
Type2__
anonType {
OCTET_STRING_t x;
OCTET_STRING_t x;
OCTET_STRING_t y;
OCTET_STRING_t y;
...
@@ -379,7 +379,7 @@ memb_y_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr,
...
@@ -379,7 +379,7 @@ memb_y_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr,
/*** <<< STAT-DEFS [Type2] >>> ***/
/*** <<< STAT-DEFS [Type2] >>> ***/
static asn_TYPE_member_t asn_MBR_anonType_2[] = {
static asn_TYPE_member_t asn_MBR_anonType_2[] = {
{ ATF_NOFLAGS, 0, offsetof(struct anonType, x),
{ ATF_NOFLAGS, 0, offsetof(struct
Type2__
anonType, x),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_OCTET_STRING,
.type = &asn_DEF_OCTET_STRING,
...
@@ -390,7 +390,7 @@ static asn_TYPE_member_t asn_MBR_anonType_2[] = {
...
@@ -390,7 +390,7 @@ static asn_TYPE_member_t asn_MBR_anonType_2[] = {
.default_value = 0,
.default_value = 0,
.name = "x"
.name = "x"
},
},
{ ATF_NOFLAGS, 0, offsetof(struct anonType, y),
{ ATF_NOFLAGS, 0, offsetof(struct
Type2__
anonType, y),
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_OCTET_STRING,
.type = &asn_DEF_OCTET_STRING,
...
@@ -411,8 +411,8 @@ static const asn_TYPE_tag2member_t asn_MAP_anonType_tag2el_2[] = {
...
@@ -411,8 +411,8 @@ static const asn_TYPE_tag2member_t asn_MAP_anonType_tag2el_2[] = {
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* y */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* y */
};
};
static asn_SEQUENCE_specifics_t asn_SPC_anonType_specs_2 = {
static asn_SEQUENCE_specifics_t asn_SPC_anonType_specs_2 = {
sizeof(struct anonType),
sizeof(struct
Type2__
anonType),
offsetof(struct anonType, _asn_ctx),
offsetof(struct
Type2__
anonType, _asn_ctx),
.tag2el = asn_MAP_anonType_tag2el_2,
.tag2el = asn_MAP_anonType_tag2el_2,
.tag2el_count = 2, /* Count of tags in the map */
.tag2el_count = 2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
0, 0, 0, /* Optional elements (not needed) */
...
...
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