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
Expand all
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 = \
noinst_LTLIBRARIES
=
libasn1compiler.la
libasn1compiler_la_SOURCES
=
\
asn1compiler.c asn1compiler.h
\
asn1c_misc.c asn1c_misc.h
\
asn1c_out.c asn1c_out.h
\
asn1c_lang.c asn1c_lang.h
\
asn1c_save.c asn1c_save.h
\
asn1c_C.c asn1c_C.h
\
asn1c_constraint.c asn1c_constraint.h
\
asn1c_compat.c asn1c_compat.h
\
asn1c_ioc.c asn1c_ioc.h
\
asn1c_fdeps.c asn1c_fdeps.h
\
asn1c_internal.h
libasn1compiler_la_SOURCES
=
\
asn1compiler.c asn1compiler.h
\
asn1c_misc.c asn1c_misc.h
\
asn1c_out.c asn1c_out.h
\
asn1c_lang.c asn1c_lang.h
\
asn1c_naming.c asn1c_naming.h
\
asn1c_save.c asn1c_save.h
\
asn1c_C.c asn1c_C.h
\
asn1c_constraint.c asn1c_constraint.h
\
asn1c_compat.c asn1c_compat.h
\
asn1c_ioc.c asn1c_ioc.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
This diff is collapsed.
Click to expand it.
libasn1compiler/asn1c_misc.c
View file @
b46156d9
...
...
@@ -42,7 +42,7 @@ reserved_keyword(const char *str) {
* Construct identifier from multiple parts.
* Convert unsafe characters to underscores.
*/
char
*
c
onst
c
har
*
asn1c_make_identifier
(
enum
ami_flags_e
flags
,
asn1p_expr_t
*
expr
,
...)
{
static
char
*
storage
;
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 {
AMI_NODELIMITER
=
4
,
/* Do not put delimiter, just concatenate */
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.
...
...
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) {
FILE
*
fp_c
,
*
fp_h
;
char
*
tmpname_c
,
*
tmpname_h
;
char
*
name_buf
;
char
*
header_id
;
c
onst
c
har
*
header_id
;
const
char
*
c_retained
=
""
;
const
char
*
h_retained
=
""
;
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
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