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
414b0783
Commit
414b0783
authored
Aug 13, 2005
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generating enumeration tables for INTEGER types
parent
2e9bd5c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
9 deletions
+156
-9
ChangeLog
ChangeLog
+2
-1
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+13
-8
tests/88-integer-enum-OK.asn1
tests/88-integer-enum-OK.asn1
+16
-0
tests/88-integer-enum-OK.asn1.-P
tests/88-integer-enum-OK.asn1.-P
+125
-0
No files found.
ChangeLog
View file @
414b0783
0.9.1
7
: 2005-Aug-13
0.9.1
8
: 2005-Aug-13
* The obsolete X.208 syntax is handled gracefully now (compound types'
* The obsolete X.208 syntax is handled gracefully now (compound types'
member names are invented on the fly). (Test case 87).
member names are invented on the fly). (Test case 87).
* Generating enumeration tables for INTEGER types (Test case 88).
0.9.17: 2005-Aug-07
0.9.17: 2005-Aug-07
...
...
libasn1compiler/asn1c_C.c
View file @
414b0783
...
@@ -105,19 +105,16 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
...
@@ -105,19 +105,16 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
int
el_count
=
expr_elements_count
(
arg
,
expr
);
int
el_count
=
expr_elements_count
(
arg
,
expr
);
struct
value2enum
*
v2e
;
struct
value2enum
*
v2e
;
int
map_is_extensible
=
(
expr
->
expr_type
==
ASN_BASIC_INTEGER
);
int
map_is_extensible
=
(
expr
->
expr_type
==
ASN_BASIC_INTEGER
);
int
eidx
;
v2e
=
alloca
((
el_count
+
1
)
*
sizeof
(
*
v2e
));
v2e
=
alloca
((
el_count
+
1
)
*
sizeof
(
*
v2e
));
/*
/*
* For all ENUMERATED types [and for those INTEGER types which
* For all ENUMERATED types and for those INTEGER types which
* have identifiers -- prohibited by X.693:8.3.4],
* have identifiers, print out an enumeration table.
* print out an enumeration table and a mapping
* between identifiers and associated values.
*/
*/
if
(
expr
->
expr_type
==
ASN_BASIC_ENUMERATED
if
(
expr
->
expr_type
==
ASN_BASIC_ENUMERATED
||
el_count
)
{
||
(
0
&&
el_count
/* -- prohibited by X.693:8.3.4 */
))
{
eidx
=
0
;
int
eidx
=
0
;
REDIR
(
OT_DEPS
);
REDIR
(
OT_DEPS
);
OUT
(
"typedef enum "
);
OUT
(
"typedef enum "
);
out_name_chain
(
arg
,
1
);
out_name_chain
(
arg
,
1
);
...
@@ -149,6 +146,14 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
...
@@ -149,6 +146,14 @@ asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
out_name_chain
(
arg
,
0
);
out_name_chain
(
arg
,
0
);
OUT
(
"_e;
\n
"
);
OUT
(
"_e;
\n
"
);
assert
(
eidx
==
el_count
);
assert
(
eidx
==
el_count
);
}
/*
* For all ENUMERATED types print out a mapping table
* between identifiers and associated values.
* This is prohibited for INTEGER types by by X.693:8.3.4.
*/
if
(
expr
->
expr_type
==
ASN_BASIC_ENUMERATED
)
{
/*
/*
* Generate a enumerationName<->value map for XER codec.
* Generate a enumerationName<->value map for XER codec.
...
...
tests/88-integer-enum-OK.asn1
0 → 100644
View file @
414b0783
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .88
ModuleIntegerEnumeration
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 88 }
DEFINITIONS ::=
BEGIN
T ::= INTEGER { a(1), b(2) }
END
tests/88-integer-enum-OK.asn1.-P
0 → 100644
View file @
414b0783
/*** <<< INCLUDES [T] >>> ***/
#include <INTEGER.h>
/*** <<< DEPS [T] >>> ***/
typedef enum T {
T_a = 1,
T_b = 2
} T_e;
/*** <<< TYPE-DECLS [T] >>> ***/
typedef INTEGER_t T_t;
/*** <<< FUNC-DECLS [T] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_T;
asn_struct_free_f T_free;
asn_struct_print_f T_print;
asn_constr_check_f T_constraint;
ber_type_decoder_f T_decode_ber;
der_type_encoder_f T_encode_der;
xer_type_decoder_f T_decode_xer;
xer_type_encoder_f T_encode_xer;
/*** <<< CODE [T] >>> ***/
int
T_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
/* Replace with underlying type checker */
td->check_constraints = asn_DEF_INTEGER.check_constraints;
return td->check_constraints(td, sptr, app_errlog, app_key);
}
/*
* This type is implemented using INTEGER,
* so here we adjust the DEF accordingly.
*/
static void
T_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
td->free_struct = asn_DEF_INTEGER.free_struct;
td->print_struct = asn_DEF_INTEGER.print_struct;
td->ber_decoder = asn_DEF_INTEGER.ber_decoder;
td->der_encoder = asn_DEF_INTEGER.der_encoder;
td->xer_decoder = asn_DEF_INTEGER.xer_decoder;
td->xer_encoder = asn_DEF_INTEGER.xer_encoder;
td->elements = asn_DEF_INTEGER.elements;
td->elements_count = asn_DEF_INTEGER.elements_count;
td->specifics = asn_DEF_INTEGER.specifics;
}
void
T_free(asn_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
T_1_inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
}
int
T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
T_1_inherit_TYPE_descriptor(td);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
asn_dec_rval_t
T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const void *bufptr, size_t size, int tag_mode) {
T_1_inherit_TYPE_descriptor(td);
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
}
asn_enc_rval_t
T_encode_der(asn_TYPE_descriptor_t *td,
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
T_1_inherit_TYPE_descriptor(td);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
asn_dec_rval_t
T_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **structure, const char *opt_mname, const void *bufptr, size_t size) {
T_1_inherit_TYPE_descriptor(td);
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
}
asn_enc_rval_t
T_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
int ilevel, enum xer_encoder_flags_e flags,
asn_app_consume_bytes_f *cb, void *app_key) {
T_1_inherit_TYPE_descriptor(td);
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
}
/*** <<< STAT-DEFS [T] >>> ***/
static ber_tlv_tag_t asn_DEF_T_1_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_T = {
"T",
"T",
T_free,
T_print,
T_constraint,
T_decode_ber,
T_encode_der,
T_decode_xer,
T_encode_xer,
0, /* Use generic outmost tag fetcher */
asn_DEF_T_1_tags,
sizeof(asn_DEF_T_1_tags)
/sizeof(asn_DEF_T_1_tags[0]), /* 1 */
asn_DEF_T_1_tags, /* Same as above */
sizeof(asn_DEF_T_1_tags)
/sizeof(asn_DEF_T_1_tags[0]), /* 1 */
0, 0, /* Defined elsewhere */
0 /* No specifics */
};
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