Simplify the logic of accessing codec function for specific TYPE
diff --git a/tests/92-circular-loops-OK.asn1.-Pfwide-types b/tests/92-circular-loops-OK.asn1.-Pfwide-types
index 03779e2..8919d9f 100644
--- a/tests/92-circular-loops-OK.asn1.-Pfwide-types
+++ b/tests/92-circular-loops-OK.asn1.-Pfwide-types
@@ -37,6 +37,8 @@
/*** <<< FUNC-DECLS [Everything] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Everything;
+extern asn_SEQUENCE_specifics_t asn_SPC_Everything_specs_1;
+extern asn_TYPE_member_t asn_MBR_Everything_1[10];
/*** <<< POST-INCLUDE [Everything] >>> ***/
@@ -46,7 +48,7 @@
/*** <<< STAT-DEFS [Everything] >>> ***/
-static asn_TYPE_member_t asn_MBR_Everything_1[] = {
+asn_TYPE_member_t asn_MBR_Everything_1[] = {
{ ATF_POINTER, 0, offsetof(struct Everything, ch1),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = +1, /* EXPLICIT tag at current level */
@@ -163,7 +165,7 @@
{ (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 8, 0, 0 }, /* tt */
{ (ASN_TAG_CLASS_CONTEXT | (9 << 2)), 9, 0, 0 } /* to */
};
-static asn_SEQUENCE_specifics_t asn_SPC_Everything_specs_1 = {
+asn_SEQUENCE_specifics_t asn_SPC_Everything_specs_1 = {
sizeof(struct Everything),
offsetof(struct Everything, _asn_ctx),
asn_MAP_Everything_tag2el_1,
@@ -236,6 +238,8 @@
/*** <<< FUNC-DECLS [Choice1] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Choice1;
+extern asn_CHOICE_specifics_t asn_SPC_Choice1_specs_1;
+extern asn_TYPE_member_t asn_MBR_Choice1_1[2];
/*** <<< POST-INCLUDE [Choice1] >>> ***/
@@ -243,7 +247,7 @@
/*** <<< STAT-DEFS [Choice1] >>> ***/
-static asn_TYPE_member_t asn_MBR_Choice1_1[] = {
+asn_TYPE_member_t asn_MBR_Choice1_1[] = {
{ ATF_POINTER, 0, offsetof(struct Choice1, choice.something),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
@@ -269,7 +273,7 @@
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* something */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* some2 */
};
-static asn_CHOICE_specifics_t asn_SPC_Choice1_specs_1 = {
+asn_CHOICE_specifics_t asn_SPC_Choice1_specs_1 = {
sizeof(struct Choice1),
offsetof(struct Choice1, _asn_ctx),
offsetof(struct Choice1, present),
@@ -342,6 +346,8 @@
/*** <<< FUNC-DECLS [Choice2] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Choice2;
+extern asn_CHOICE_specifics_t asn_SPC_Choice2_specs_1;
+extern asn_TYPE_member_t asn_MBR_Choice2_1[2];
/*** <<< POST-INCLUDE [Choice2] >>> ***/
@@ -349,7 +355,7 @@
/*** <<< STAT-DEFS [Choice2] >>> ***/
-static asn_TYPE_member_t asn_MBR_Choice2_1[] = {
+asn_TYPE_member_t asn_MBR_Choice2_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Choice2, choice.typeref),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
@@ -375,7 +381,7 @@
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* typeref */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* some3 */
};
-static asn_CHOICE_specifics_t asn_SPC_Choice2_specs_1 = {
+asn_CHOICE_specifics_t asn_SPC_Choice2_specs_1 = {
sizeof(struct Choice2),
offsetof(struct Choice2, _asn_ctx),
offsetof(struct Choice2, present),
@@ -458,6 +464,8 @@
/*** <<< FUNC-DECLS [Choice3] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Choice3;
+extern asn_CHOICE_specifics_t asn_SPC_Choice3_specs_1;
+extern asn_TYPE_member_t asn_MBR_Choice3_1[3];
/*** <<< POST-INCLUDE [Choice3] >>> ***/
@@ -569,7 +577,7 @@
&asn_SPC_c_specs_5 /* Additional specs */
};
-static asn_TYPE_member_t asn_MBR_Choice3_1[] = {
+asn_TYPE_member_t asn_MBR_Choice3_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Choice3, choice.a),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = 0,
@@ -606,7 +614,7 @@
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* b */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* c */
};
-static asn_CHOICE_specifics_t asn_SPC_Choice3_specs_1 = {
+asn_CHOICE_specifics_t asn_SPC_Choice3_specs_1 = {
sizeof(struct Choice3),
offsetof(struct Choice3, _asn_ctx),
offsetof(struct Choice3, present),
@@ -682,6 +690,8 @@
/*** <<< FUNC-DECLS [Set] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Set;
+extern asn_SET_OF_specifics_t asn_SPC_Set_specs_1;
+extern asn_TYPE_member_t asn_MBR_Set_1[1];
/*** <<< POST-INCLUDE [Set] >>> ***/
@@ -788,7 +798,7 @@
&asn_SPC_Member_specs_2 /* Additional specs */
};
-static asn_TYPE_member_t asn_MBR_Set_1[] = {
+asn_TYPE_member_t asn_MBR_Set_1[] = {
{ ATF_POINTER, 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
@@ -803,7 +813,7 @@
static const ber_tlv_tag_t asn_DEF_Set_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
};
-static asn_SET_OF_specifics_t asn_SPC_Set_specs_1 = {
+asn_SET_OF_specifics_t asn_SPC_Set_specs_1 = {
sizeof(struct Set),
offsetof(struct Set, _asn_ctx),
0, /* XER encoding is XMLDelimitedItemList */
@@ -864,6 +874,8 @@
/*** <<< FUNC-DECLS [Sequence] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Sequence;
+extern asn_SEQUENCE_specifics_t asn_SPC_Sequence_specs_1;
+extern asn_TYPE_member_t asn_MBR_Sequence_1[4];
/*** <<< POST-INCLUDE [Sequence] >>> ***/
@@ -872,7 +884,7 @@
/*** <<< STAT-DEFS [Sequence] >>> ***/
-static asn_TYPE_member_t asn_MBR_Sequence_1[] = {
+asn_TYPE_member_t asn_MBR_Sequence_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Sequence, a),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
@@ -923,7 +935,7 @@
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* b */
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 } /* set */
};
-static asn_SEQUENCE_specifics_t asn_SPC_Sequence_specs_1 = {
+asn_SEQUENCE_specifics_t asn_SPC_Sequence_specs_1 = {
sizeof(struct Sequence),
offsetof(struct Sequence, _asn_ctx),
asn_MAP_Sequence_tag2el_1,
@@ -980,84 +992,10 @@
/*** <<< CODE [TypeRef] >>> ***/
-int
-TypeRef_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
- asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- /* Replace with underlying type checker */
- td->check_constraints = asn_DEF_Sequence.check_constraints;
- return td->check_constraints(td, sptr, ctfailcb, app_key);
-}
-
/*
* This type is implemented using Sequence,
* so here we adjust the DEF accordingly.
*/
-static void
-TypeRef_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
- td->free_struct = asn_DEF_Sequence.free_struct;
- td->print_struct = asn_DEF_Sequence.print_struct;
- td->check_constraints = asn_DEF_Sequence.check_constraints;
- td->ber_decoder = asn_DEF_Sequence.ber_decoder;
- td->der_encoder = asn_DEF_Sequence.der_encoder;
- td->xer_decoder = asn_DEF_Sequence.xer_decoder;
- td->xer_encoder = asn_DEF_Sequence.xer_encoder;
- td->uper_decoder = asn_DEF_Sequence.uper_decoder;
- td->uper_encoder = asn_DEF_Sequence.uper_encoder;
- td->oer_decoder = asn_DEF_Sequence.oer_decoder;
- td->oer_encoder = asn_DEF_Sequence.oer_encoder;
- if(!td->oer_constraints)
- td->oer_constraints = asn_DEF_Sequence.oer_constraints;
- if(!td->per_constraints)
- td->per_constraints = asn_DEF_Sequence.per_constraints;
- td->elements = asn_DEF_Sequence.elements;
- td->elements_count = asn_DEF_Sequence.elements_count;
- td->specifics = asn_DEF_Sequence.specifics;
-}
-
-void
-TypeRef_free(asn_TYPE_descriptor_t *td,
- void *struct_ptr, int contents_only) {
- TypeRef_1_inherit_TYPE_descriptor(td);
- td->free_struct(td, struct_ptr, contents_only);
-}
-
-int
-TypeRef_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
- int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
- TypeRef_1_inherit_TYPE_descriptor(td);
- return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
-}
-
-asn_dec_rval_t
-TypeRef_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) {
- TypeRef_1_inherit_TYPE_descriptor(td);
- return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
-}
-
-asn_enc_rval_t
-TypeRef_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) {
- TypeRef_1_inherit_TYPE_descriptor(td);
- return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
-}
-
-asn_dec_rval_t
-TypeRef_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) {
- TypeRef_1_inherit_TYPE_descriptor(td);
- return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
-}
-
-asn_enc_rval_t
-TypeRef_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) {
- TypeRef_1_inherit_TYPE_descriptor(td);
- return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
-}
-
/*** <<< STAT-DEFS [TypeRef] >>> ***/
@@ -1067,13 +1005,13 @@
asn_TYPE_descriptor_t asn_DEF_TypeRef = {
"TypeRef",
"TypeRef",
- TypeRef_free,
- TypeRef_print,
- TypeRef_constraint,
- TypeRef_decode_ber,
- TypeRef_encode_der,
- TypeRef_decode_xer,
- TypeRef_encode_xer,
+ SEQUENCE_free,
+ SEQUENCE_print,
+ SEQUENCE_constraint,
+ SEQUENCE_decode_ber,
+ SEQUENCE_encode_der,
+ SEQUENCE_decode_xer,
+ SEQUENCE_encode_xer,
0, 0, /* No OER support, use "-gen-OER" to enable */
0, 0, /* No PER support, use "-gen-PER" to enable */
0, /* Use generic outmost tag fetcher */
@@ -1085,8 +1023,9 @@
/sizeof(asn_DEF_TypeRef_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
- 0, 0, /* Defined elsewhere */
- 0 /* No specifics */
+ asn_MBR_Sequence_1,
+ 4, /* Elements count */
+ &asn_SPC_Sequence_specs_1 /* Additional specs */
};
@@ -1116,6 +1055,8 @@
/*** <<< FUNC-DECLS [Alpha] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Alpha;
+extern asn_SEQUENCE_specifics_t asn_SPC_Alpha_specs_1;
+extern asn_TYPE_member_t asn_MBR_Alpha_1[2];
/*** <<< POST-INCLUDE [Alpha] >>> ***/
@@ -1178,7 +1119,7 @@
&asn_SPC_b_specs_3 /* Additional specs */
};
-static asn_TYPE_member_t asn_MBR_Alpha_1[] = {
+asn_TYPE_member_t asn_MBR_Alpha_1[] = {
{ ATF_POINTER, 0, offsetof(struct Alpha, a),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
@@ -1207,7 +1148,7 @@
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* a */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* b */
};
-static asn_SEQUENCE_specifics_t asn_SPC_Alpha_specs_1 = {
+asn_SEQUENCE_specifics_t asn_SPC_Alpha_specs_1 = {
sizeof(struct Alpha),
offsetof(struct Alpha, _asn_ctx),
asn_MAP_Alpha_tag2el_1,
@@ -1265,6 +1206,8 @@
/*** <<< FUNC-DECLS [Beta] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Beta;
+extern asn_SEQUENCE_specifics_t asn_SPC_Beta_specs_1;
+extern asn_TYPE_member_t asn_MBR_Beta_1[2];
/*** <<< POST-INCLUDE [Beta] >>> ***/
@@ -1273,7 +1216,7 @@
/*** <<< STAT-DEFS [Beta] >>> ***/
-static asn_TYPE_member_t asn_MBR_Beta_1[] = {
+asn_TYPE_member_t asn_MBR_Beta_1[] = {
{ ATF_POINTER, 2, offsetof(struct Beta, b),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
@@ -1302,7 +1245,7 @@
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* b */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* g */
};
-static asn_SEQUENCE_specifics_t asn_SPC_Beta_specs_1 = {
+asn_SEQUENCE_specifics_t asn_SPC_Beta_specs_1 = {
sizeof(struct Beta),
offsetof(struct Beta, _asn_ctx),
asn_MAP_Beta_tag2el_1,
@@ -1362,6 +1305,8 @@
/*** <<< FUNC-DECLS [Gamma] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Gamma;
+extern asn_SEQUENCE_specifics_t asn_SPC_Gamma_specs_1;
+extern asn_TYPE_member_t asn_MBR_Gamma_1[3];
/*** <<< POST-INCLUDE [Gamma] >>> ***/
@@ -1371,7 +1316,7 @@
/*** <<< STAT-DEFS [Gamma] >>> ***/
-static asn_TYPE_member_t asn_MBR_Gamma_1[] = {
+asn_TYPE_member_t asn_MBR_Gamma_1[] = {
{ ATF_POINTER, 0, offsetof(struct Gamma, o),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
@@ -1411,7 +1356,7 @@
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* a */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* b */
};
-static asn_SEQUENCE_specifics_t asn_SPC_Gamma_specs_1 = {
+asn_SEQUENCE_specifics_t asn_SPC_Gamma_specs_1 = {
sizeof(struct Gamma),
offsetof(struct Gamma, _asn_ctx),
asn_MAP_Gamma_tag2el_1,
@@ -1481,6 +1426,8 @@
/*** <<< FUNC-DECLS [OneTwo] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_OneTwo;
+extern asn_SET_specifics_t asn_SPC_OneTwo_specs_1;
+extern asn_TYPE_member_t asn_MBR_OneTwo_1[1];
/*** <<< POST-INCLUDE [OneTwo] >>> ***/
@@ -1488,7 +1435,7 @@
/*** <<< STAT-DEFS [OneTwo] >>> ***/
-static asn_TYPE_member_t asn_MBR_OneTwo_1[] = {
+asn_TYPE_member_t asn_MBR_OneTwo_1[] = {
{ ATF_POINTER, 0, offsetof(struct OneTwo, m12),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
@@ -1509,7 +1456,7 @@
static const uint8_t asn_MAP_OneTwo_mmap_1[(1 + (8 * sizeof(unsigned int)) - 1) / 8] = {
(1 << 7)
};
-static asn_SET_specifics_t asn_SPC_OneTwo_specs_1 = {
+asn_SET_specifics_t asn_SPC_OneTwo_specs_1 = {
sizeof(struct OneTwo),
offsetof(struct OneTwo, _asn_ctx),
offsetof(struct OneTwo, _presence_map),
@@ -1581,6 +1528,8 @@
/*** <<< FUNC-DECLS [TwoThree] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_TwoThree;
+extern asn_SET_specifics_t asn_SPC_TwoThree_specs_1;
+extern asn_TYPE_member_t asn_MBR_TwoThree_1[1];
/*** <<< POST-INCLUDE [TwoThree] >>> ***/
@@ -1588,7 +1537,7 @@
/*** <<< STAT-DEFS [TwoThree] >>> ***/
-static asn_TYPE_member_t asn_MBR_TwoThree_1[] = {
+asn_TYPE_member_t asn_MBR_TwoThree_1[] = {
{ ATF_POINTER, 0, offsetof(struct TwoThree, m23),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
@@ -1609,7 +1558,7 @@
static const uint8_t asn_MAP_TwoThree_mmap_1[(1 + (8 * sizeof(unsigned int)) - 1) / 8] = {
(1 << 7)
};
-static asn_SET_specifics_t asn_SPC_TwoThree_specs_1 = {
+asn_SET_specifics_t asn_SPC_TwoThree_specs_1 = {
sizeof(struct TwoThree),
offsetof(struct TwoThree, _asn_ctx),
offsetof(struct TwoThree, _presence_map),
@@ -1684,6 +1633,8 @@
/*** <<< FUNC-DECLS [ThreeOne] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_ThreeOne;
+extern asn_SET_specifics_t asn_SPC_ThreeOne_specs_1;
+extern asn_TYPE_member_t asn_MBR_ThreeOne_1[2];
/*** <<< POST-INCLUDE [ThreeOne] >>> ***/
@@ -1692,7 +1643,7 @@
/*** <<< STAT-DEFS [ThreeOne] >>> ***/
-static asn_TYPE_member_t asn_MBR_ThreeOne_1[] = {
+asn_TYPE_member_t asn_MBR_ThreeOne_1[] = {
{ ATF_POINTER, 0, offsetof(struct ThreeOne, m31),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
@@ -1724,7 +1675,7 @@
static const uint8_t asn_MAP_ThreeOne_mmap_1[(2 + (8 * sizeof(unsigned int)) - 1) / 8] = {
(1 << 7) | (1 << 6)
};
-static asn_SET_specifics_t asn_SPC_ThreeOne_specs_1 = {
+asn_SET_specifics_t asn_SPC_ThreeOne_specs_1 = {
sizeof(struct ThreeOne),
offsetof(struct ThreeOne, _asn_ctx),
offsetof(struct ThreeOne, _presence_map),