aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2005-03-04 22:38:22 +0000
committerLev Walkin <vlm@lionet.info>2005-03-04 22:38:22 +0000
commitfe7f6ecdddf550f56e7fc20a3e53d420796448e7 (patch)
tree5efcb2bff472c35b1348990e4a9c047043aa5646
parentc8285715f6fb4dac3de7cbec68dd1aa746a34a86 (diff)
*** empty log message ***
-rw-r--r--libasn1compiler/asn1c_C.c4
-rw-r--r--tests/66-ref-simple-OK.asn1.-P2
-rw-r--r--tests/73-circular-OK.asn15
-rw-r--r--tests/73-circular-OK.asn1.-P212
4 files changed, 213 insertions, 10 deletions
diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c
index b8a74288..df02e95b 100644
--- a/libasn1compiler/asn1c_C.c
+++ b/libasn1compiler/asn1c_C.c
@@ -602,7 +602,9 @@ asn1c_lang_C_type_SEx_OF(arg_t *arg) {
arg->embed--;
assert(arg->target->target == OT_TYPE_DECLS);
} else {
- OUT("%s", asn1c_type_name(arg, memb, TNF_RSAFE));
+ OUT("%s", asn1c_type_name(arg, memb,
+ (memb->marker.flags & EM_UNRECURSE)
+ ? TNF_RSAFE : TNF_CTYPE));
}
OUT(") list;\n");
INDENT(-1);
diff --git a/tests/66-ref-simple-OK.asn1.-P b/tests/66-ref-simple-OK.asn1.-P
index 24795360..305d724a 100644
--- a/tests/66-ref-simple-OK.asn1.-P
+++ b/tests/66-ref-simple-OK.asn1.-P
@@ -8,7 +8,7 @@
/*** <<< TYPE-DECLS [T] >>> ***/
typedef struct T {
- A_SET_OF(struct SimpleType) list;
+ A_SET_OF(SimpleType_t) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
diff --git a/tests/73-circular-OK.asn1 b/tests/73-circular-OK.asn1
index 33ed04b2..4b86c0e6 100644
--- a/tests/73-circular-OK.asn1
+++ b/tests/73-circular-OK.asn1
@@ -25,7 +25,10 @@ BEGIN
Ypet ::= SET {
epyt Epyt,
- plain INTEGER DEFAULT 7
+ plain INTEGER DEFAULT 7,
+ senums SET OF EnumType
}
+ EnumType ::= ENUMERATED { one, two }
+
END
diff --git a/tests/73-circular-OK.asn1.-P b/tests/73-circular-OK.asn1.-P
index 6298a94c..de24047f 100644
--- a/tests/73-circular-OK.asn1.-P
+++ b/tests/73-circular-OK.asn1.-P
@@ -263,6 +263,9 @@ asn_TYPE_descriptor_t asn_DEF_Epyt = {
#include <Epyt.h>
#include <INTEGER.h>
+#include <EnumType.h>
+#include <asn_SET_OF.h>
+#include <constr_SET_OF.h>
#include <constr_SET.h>
/*** <<< DEPS [Ypet] >>> ***/
@@ -274,6 +277,7 @@ asn_TYPE_descriptor_t asn_DEF_Epyt = {
typedef enum Ypet_PR {
Ypet_PR_epyt, /* Member epyt is present */
Ypet_PR_plain, /* Member plain is present */
+ Ypet_PR_senums, /* Member senums is present */
} Ypet_PR;
/*** <<< TYPE-DECLS [Ypet] >>> ***/
@@ -281,10 +285,16 @@ typedef enum Ypet_PR {
typedef struct Ypet {
Epyt_t epyt;
INTEGER_t *plain /* DEFAULT 7 */;
+ struct senums {
+ A_SET_OF(EnumType_t) list;
+
+ /* Context for parsing across buffer boundaries */
+ asn_struct_ctx_t _asn_ctx;
+ } senums;
/* Presence bitmask: ASN_SET_ISPRESENT(pYpet, Ypet_PR_x) */
unsigned int _presence_map
- [((2+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))];
+ [((3+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))];
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
@@ -296,6 +306,46 @@ extern asn_TYPE_descriptor_t asn_DEF_Ypet;
/*** <<< STAT-DEFS [Ypet] >>> ***/
+static asn_TYPE_member_t asn_MBR_senums_2[] = {
+ { ATF_NOFLAGS, 0, 0,
+ .tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
+ .tag_mode = 0,
+ .type = (void *)&asn_DEF_EnumType,
+ .memb_constraints = 0, /* Defer constraints checking to the member type */
+ .name = ""
+ },
+};
+static ber_tlv_tag_t asn_DEF_senums_2_tags[] = {
+ (ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
+};
+static asn_SET_OF_specifics_t asn_SPC_senums_2_specs = {
+ sizeof(struct senums),
+ offsetof(struct senums, _asn_ctx),
+ 1, /* XER encoding is XMLValueList */
+};
+static /* Use -fall-defs-global to expose */
+asn_TYPE_descriptor_t asn_DEF_senums_2 = {
+ "senums",
+ "senums",
+ SET_OF_free,
+ SET_OF_print,
+ SET_OF_constraint,
+ SET_OF_decode_ber,
+ SET_OF_encode_der,
+ SET_OF_decode_xer,
+ SET_OF_encode_xer,
+ 0, /* Use generic outmost tag fetcher */
+ asn_DEF_senums_2_tags,
+ sizeof(asn_DEF_senums_2_tags)
+ /sizeof(asn_DEF_senums_2_tags[0]), /* 1 */
+ asn_DEF_senums_2_tags, /* Same as above */
+ sizeof(asn_DEF_senums_2_tags)
+ /sizeof(asn_DEF_senums_2_tags[0]), /* 1 */
+ asn_MBR_senums_2,
+ 1, /* Single element */
+ &asn_SPC_senums_2_specs /* Additional specs */
+};
+
static asn_TYPE_member_t asn_MBR_Ypet_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Ypet, epyt),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
@@ -311,25 +361,33 @@ static asn_TYPE_member_t asn_MBR_Ypet_1[] = {
.memb_constraints = 0, /* Defer constraints checking to the member type */
.name = "plain"
},
+ { ATF_NOFLAGS, 0, offsetof(struct Ypet, senums),
+ .tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
+ .tag_mode = 0,
+ .type = (void *)&asn_DEF_senums_2,
+ .memb_constraints = 0, /* Defer constraints checking to the member type */
+ .name = "senums"
+ },
};
static ber_tlv_tag_t asn_DEF_Ypet_1_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_Ypet_1_tag2el[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* plain at 28 */
- { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* epyt at 27 */
+ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* epyt at 27 */
+ { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 2, 0, 0 } /* senums at 30 */
};
-static uint8_t asn_MAP_Ypet_1_mmap[(2 + (8 * sizeof(unsigned int)) - 1) / 8] = {
- (1 << 7) | (0 << 6)
+static uint8_t asn_MAP_Ypet_1_mmap[(3 + (8 * sizeof(unsigned int)) - 1) / 8] = {
+ (1 << 7) | (0 << 6) | (1 << 5)
};
static asn_SET_specifics_t asn_SPC_Ypet_1_specs = {
sizeof(struct Ypet),
offsetof(struct Ypet, _asn_ctx),
offsetof(struct Ypet, _presence_map),
asn_MAP_Ypet_1_tag2el,
- 2, /* Count of tags in the map */
+ 3, /* Count of tags in the map */
asn_MAP_Ypet_1_tag2el, /* Same as above */
- 2, /* Count of tags in the CXER map */
+ 3, /* Count of tags in the CXER map */
0, /* Whether extensible */
(unsigned int *)asn_MAP_Ypet_1_mmap /* Mandatory elements map */
};
@@ -351,7 +409,147 @@ asn_TYPE_descriptor_t asn_DEF_Ypet = {
sizeof(asn_DEF_Ypet_1_tags)
/sizeof(asn_DEF_Ypet_1_tags[0]), /* 1 */
asn_MBR_Ypet_1,
- 2, /* Elements count */
+ 3, /* Elements count */
&asn_SPC_Ypet_1_specs /* Additional specs */
};
+
+/*** <<< INCLUDES [EnumType] >>> ***/
+
+#include <ENUMERATED.h>
+
+/*** <<< DEPS [EnumType] >>> ***/
+
+typedef enum EnumType {
+ EnumType_one = 0,
+ EnumType_two = 1
+} EnumType_e;
+
+/*** <<< TYPE-DECLS [EnumType] >>> ***/
+
+typedef ENUMERATED_t EnumType_t;
+
+/*** <<< FUNC-DECLS [EnumType] >>> ***/
+
+extern asn_TYPE_descriptor_t asn_DEF_EnumType;
+asn_struct_free_f EnumType_free;
+asn_struct_print_f EnumType_print;
+asn_constr_check_f EnumType_constraint;
+ber_type_decoder_f EnumType_decode_ber;
+der_type_encoder_f EnumType_encode_der;
+xer_type_decoder_f EnumType_decode_xer;
+xer_type_encoder_f EnumType_encode_xer;
+
+/*** <<< CODE [EnumType] >>> ***/
+
+int
+EnumType_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_ENUMERATED.check_constraints;
+ return td->check_constraints(td, sptr, app_errlog, app_key);
+}
+
+/*
+ * This type is implemented using ENUMERATED,
+ * so here we adjust the DEF accordingly.
+ */
+static void
+EnumType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
+ td->free_struct = asn_DEF_ENUMERATED.free_struct;
+ td->print_struct = asn_DEF_ENUMERATED.print_struct;
+ td->ber_decoder = asn_DEF_ENUMERATED.ber_decoder;
+ td->der_encoder = asn_DEF_ENUMERATED.der_encoder;
+ td->xer_decoder = asn_DEF_ENUMERATED.xer_decoder;
+ td->xer_encoder = asn_DEF_ENUMERATED.xer_encoder;
+ td->elements = asn_DEF_ENUMERATED.elements;
+ td->elements_count = asn_DEF_ENUMERATED.elements_count;
+ /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined explicitly */
+}
+
+void
+EnumType_free(asn_TYPE_descriptor_t *td,
+ void *struct_ptr, int contents_only) {
+ EnumType_1_inherit_TYPE_descriptor(td);
+ td->free_struct(td, struct_ptr, contents_only);
+}
+
+int
+EnumType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
+ int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
+ EnumType_1_inherit_TYPE_descriptor(td);
+ return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
+}
+
+asn_dec_rval_t
+EnumType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+ void **structure, void *bufptr, size_t size, int tag_mode) {
+ EnumType_1_inherit_TYPE_descriptor(td);
+ return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
+}
+
+asn_enc_rval_t
+EnumType_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) {
+ EnumType_1_inherit_TYPE_descriptor(td);
+ return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
+}
+
+asn_dec_rval_t
+EnumType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+ void **structure, const char *opt_mname, void *bufptr, size_t size) {
+ EnumType_1_inherit_TYPE_descriptor(td);
+ return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
+}
+
+asn_enc_rval_t
+EnumType_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) {
+ EnumType_1_inherit_TYPE_descriptor(td);
+ return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
+}
+
+
+/*** <<< STAT-DEFS [EnumType] >>> ***/
+
+static asn_INTEGER_enum_map_t asn_MAP_EnumType_1_value2enum[] = {
+ { 0, 3, "one" },
+ { 1, 3, "two" }
+};
+static unsigned int asn_MAP_EnumType_1_enum2value[] = {
+ 0, /* one(0) */
+ 1 /* two(1) */
+};
+static asn_INTEGER_specifics_t asn_SPC_EnumType_1_specs = {
+ asn_MAP_EnumType_1_value2enum, /* "tag" => N; sorted by tag */
+ asn_MAP_EnumType_1_enum2value, /* N => "tag"; sorted by N */
+ 2, /* Number of elements in the maps */
+ 0, /* Enumeration is not extensible */
+ 1 /* Strict enumeration */
+};
+static ber_tlv_tag_t asn_DEF_EnumType_1_tags[] = {
+ (ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
+};
+asn_TYPE_descriptor_t asn_DEF_EnumType = {
+ "EnumType",
+ "EnumType",
+ EnumType_free,
+ EnumType_print,
+ EnumType_constraint,
+ EnumType_decode_ber,
+ EnumType_encode_der,
+ EnumType_decode_xer,
+ EnumType_encode_xer,
+ 0, /* Use generic outmost tag fetcher */
+ asn_DEF_EnumType_1_tags,
+ sizeof(asn_DEF_EnumType_1_tags)
+ /sizeof(asn_DEF_EnumType_1_tags[0]), /* 1 */
+ asn_DEF_EnumType_1_tags, /* Same as above */
+ sizeof(asn_DEF_EnumType_1_tags)
+ /sizeof(asn_DEF_EnumType_1_tags[0]), /* 1 */
+ 0, 0, /* Defined elsewhere */
+ &asn_SPC_EnumType_1_specs /* Additional specs */
+};
+