X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=tests%2Ftests-asn1c-compiler%2F84-param-tags-OK.asn1.-Pfwide-types;fp=tests%2Ftests-asn1c-compiler%2F84-param-tags-OK.asn1.-Pfwide-types;h=e1d57219ed56a1c0bd5b0d79a46515e9a9aa7814;hb=70ee6fc793ec8e828067a3569849b6c216054497;hp=0000000000000000000000000000000000000000;hpb=59f84608ec15c016958a6e0e0ddd813f376c0925;p=com%2Fasn1c.git diff --git a/tests/tests-asn1c-compiler/84-param-tags-OK.asn1.-Pfwide-types b/tests/tests-asn1c-compiler/84-param-tags-OK.asn1.-Pfwide-types new file mode 100644 index 0000000..e1d5721 --- /dev/null +++ b/tests/tests-asn1c-compiler/84-param-tags-OK.asn1.-Pfwide-types @@ -0,0 +1,519 @@ + +/*** <<< INCLUDES [TestType] >>> ***/ + +#include +#include +#include + +/*** <<< TYPE-DECLS [TestType] >>> ***/ + +typedef struct TestType_16P0 { + long common; /* DEFAULT 0 */ + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} TestType_16P0_t; +typedef struct TestType_16P1 { + BOOLEAN_t common; /* DEFAULT 0 */ + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} TestType_16P1_t; + +/*** <<< FUNC-DECLS [TestType] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_TestType_16P0; +extern asn_SEQUENCE_specifics_t asn_SPC_TestType_16P0_specs_1; +extern asn_TYPE_member_t asn_MBR_TestType_16P0_1[1]; +extern asn_TYPE_descriptor_t asn_DEF_TestType_16P1; +extern asn_SEQUENCE_specifics_t asn_SPC_TestType_16P1_specs_3; +extern asn_TYPE_member_t asn_MBR_TestType_16P1_3[1]; + +/*** <<< CODE [TestType] >>> ***/ + +static int +memb_common_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) { + long value; + + if(!sptr) { + ASN__CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + value = *(const long *)sptr; + + if((value >= 1 && value <= 10)) { + /* Constraint check succeeded */ + return 0; + } else { + ASN__CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } +} + + +/*** <<< STAT-DEFS [TestType] >>> ***/ + +static int asn_DFL_2_cmp_0(const void *sptr) { + const long *st = sptr; + + if(!st) { + return -1; /* No value is not a default value */ + } + + /* Test default value 0 */ + return (*st != 0); +} +static int asn_DFL_2_set_0(void **sptr) { + long *st = *sptr; + + if(!st) { + st = (*sptr = CALLOC(1, sizeof(*st))); + if(!st) return -1; + } + + /* Install default value 0 */ + *st = 0; + return 0; +} +asn_TYPE_member_t asn_MBR_TestType_16P0_1[] = { + { ATF_NOFLAGS, 1, offsetof(struct TestType_16P0, common), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .type_selector = 0, + { .oer_constraints = 0, .per_constraints = 0, .general_constraints = memb_common_constraint_1 }, + .default_value_cmp = &asn_DFL_2_cmp_0, /* Compare DEFAULT 0 */ + .default_value_set = &asn_DFL_2_set_0, /* Set DEFAULT 0 */ + .name = "common" + }, +}; +static const ber_tlv_tag_t asn_DEF_TestType_16P0_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_TestType_16P0_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* common */ +}; +asn_SEQUENCE_specifics_t asn_SPC_TestType_16P0_specs_1 = { + sizeof(struct TestType_16P0), + offsetof(struct TestType_16P0, _asn_ctx), + .tag2el = asn_MAP_TestType_16P0_tag2el_1, + .tag2el_count = 1, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* First extension addition */ +}; +asn_TYPE_descriptor_t asn_DEF_TestType_16P0 = { + "TestType", + "TestType", + &asn_OP_SEQUENCE, + asn_DEF_TestType_16P0_tags_1, + sizeof(asn_DEF_TestType_16P0_tags_1) + /sizeof(asn_DEF_TestType_16P0_tags_1[0]), /* 1 */ + asn_DEF_TestType_16P0_tags_1, /* Same as above */ + sizeof(asn_DEF_TestType_16P0_tags_1) + /sizeof(asn_DEF_TestType_16P0_tags_1[0]), /* 1 */ + { 0, 0, SEQUENCE_constraint }, + asn_MBR_TestType_16P0_1, + 1, /* Elements count */ + &asn_SPC_TestType_16P0_specs_1 /* Additional specs */ +}; + +static int asn_DFL_4_cmp_0(const void *sptr) { + const BOOLEAN_t *st = sptr; + + if(!st) { + return -1; /* No value is not a default value */ + } + + /* Test default value 0 */ + return (*st != 0); +} +static int asn_DFL_4_set_0(void **sptr) { + BOOLEAN_t *st = *sptr; + + if(!st) { + st = (*sptr = CALLOC(1, sizeof(*st))); + if(!st) return -1; + } + + /* Install default value 0 */ + *st = 0; + return 0; +} +asn_TYPE_member_t asn_MBR_TestType_16P1_3[] = { + { ATF_NOFLAGS, 1, offsetof(struct TestType_16P1, common), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), + .tag_mode = 0, + .type = &asn_DEF_BOOLEAN, + .type_selector = 0, + { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 }, + .default_value_cmp = &asn_DFL_4_cmp_0, /* Compare DEFAULT 0 */ + .default_value_set = &asn_DFL_4_set_0, /* Set DEFAULT 0 */ + .name = "common" + }, +}; +static const ber_tlv_tag_t asn_DEF_TestType_16P1_tags_3[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_TestType_16P1_tag2el_3[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 0, 0, 0 } /* common */ +}; +asn_SEQUENCE_specifics_t asn_SPC_TestType_16P1_specs_3 = { + sizeof(struct TestType_16P1), + offsetof(struct TestType_16P1, _asn_ctx), + .tag2el = asn_MAP_TestType_16P1_tag2el_3, + .tag2el_count = 1, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* First extension addition */ +}; +asn_TYPE_descriptor_t asn_DEF_TestType_16P1 = { + "TestType", + "TestType", + &asn_OP_SEQUENCE, + asn_DEF_TestType_16P1_tags_3, + sizeof(asn_DEF_TestType_16P1_tags_3) + /sizeof(asn_DEF_TestType_16P1_tags_3[0]), /* 1 */ + asn_DEF_TestType_16P1_tags_3, /* Same as above */ + sizeof(asn_DEF_TestType_16P1_tags_3) + /sizeof(asn_DEF_TestType_16P1_tags_3[0]), /* 1 */ + { 0, 0, SEQUENCE_constraint }, + asn_MBR_TestType_16P1_3, + 1, /* Elements count */ + &asn_SPC_TestType_16P1_specs_3 /* Additional specs */ +}; + + +/*** <<< INCLUDES [TestChoice] >>> ***/ + +#include "TestType.h" +#include + +/*** <<< DEPS [TestChoice] >>> ***/ + +typedef enum TestChoice_PR { + TestChoice_PR_NOTHING, /* No components present */ + TestChoice_PR_type1, + TestChoice_PR_type2 +} TestChoice_PR; + +/*** <<< TYPE-DECLS [TestChoice] >>> ***/ + +typedef struct TestChoice { + TestChoice_PR present; + union TestChoice_u { + TestType_16P0_t type1; + TestType_16P1_t type2; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} TestChoice_t; + +/*** <<< FUNC-DECLS [TestChoice] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_TestChoice; + +/*** <<< STAT-DEFS [TestChoice] >>> ***/ + +static asn_TYPE_member_t asn_MBR_TestChoice_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type1), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + .tag_mode = 0, + .type = &asn_DEF_TestType_16P0, + .type_selector = 0, + { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 }, + 0, 0, /* No default value */ + .name = "type1" + }, + { ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type2), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_TestType_16P1, + .type_selector = 0, + { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 }, + 0, 0, /* No default value */ + .name = "type2" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_TestChoice_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* type1 */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 } /* type2 */ +}; +static asn_CHOICE_specifics_t asn_SPC_TestChoice_specs_1 = { + sizeof(struct TestChoice), + offsetof(struct TestChoice, _asn_ctx), + offsetof(struct TestChoice, present), + sizeof(((struct TestChoice *)0)->present), + .tag2el = asn_MAP_TestChoice_tag2el_1, + .tag2el_count = 2, /* Count of tags in the map */ + 0, 0, + .first_extension = -1 /* Extensions start */ +}; +asn_TYPE_descriptor_t asn_DEF_TestChoice = { + "TestChoice", + "TestChoice", + &asn_OP_CHOICE, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + { 0, 0, CHOICE_constraint }, + asn_MBR_TestChoice_1, + 2, /* Elements count */ + &asn_SPC_TestChoice_specs_1 /* Additional specs */ +}; + + +/*** <<< INCLUDES [AutoType] >>> ***/ + +#include +#include +#include + +/*** <<< TYPE-DECLS [AutoType] >>> ***/ + +typedef struct AutoType_34P0 { + long common; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} AutoType_34P0_t; +typedef struct AutoType_34P1 { + BOOLEAN_t common; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} AutoType_34P1_t; + +/*** <<< FUNC-DECLS [AutoType] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_AutoType_34P0; +extern asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P0_specs_1; +extern asn_TYPE_member_t asn_MBR_AutoType_34P0_1[1]; +extern asn_TYPE_descriptor_t asn_DEF_AutoType_34P1; +extern asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P1_specs_3; +extern asn_TYPE_member_t asn_MBR_AutoType_34P1_3[1]; + +/*** <<< CODE [AutoType] >>> ***/ + +static int +memb_common_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) { + long value; + + if(!sptr) { + ASN__CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + value = *(const long *)sptr; + + if((value == 0)) { + /* Constraint check succeeded */ + return 0; + } else { + ASN__CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } +} + +static int +memb_common_constraint_3(const asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) { + BOOLEAN_t value; + + if(!sptr) { + ASN__CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + value = (*(const long *)sptr) ? 1 : 0; + + if((value <= 0)) { + /* Constraint check succeeded */ + return 0; + } else { + ASN__CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } +} + + +/*** <<< STAT-DEFS [AutoType] >>> ***/ + +asn_TYPE_member_t asn_MBR_AutoType_34P0_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct AutoType_34P0, common), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_NativeInteger, + .type_selector = 0, + { .oer_constraints = 0, .per_constraints = 0, .general_constraints = memb_common_constraint_1 }, + 0, 0, /* No default value */ + .name = "common" + }, +}; +static const ber_tlv_tag_t asn_DEF_AutoType_34P0_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_AutoType_34P0_tag2el_1[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common */ +}; +asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P0_specs_1 = { + sizeof(struct AutoType_34P0), + offsetof(struct AutoType_34P0, _asn_ctx), + .tag2el = asn_MAP_AutoType_34P0_tag2el_1, + .tag2el_count = 1, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* First extension addition */ +}; +asn_TYPE_descriptor_t asn_DEF_AutoType_34P0 = { + "AutoType", + "AutoType", + &asn_OP_SEQUENCE, + asn_DEF_AutoType_34P0_tags_1, + sizeof(asn_DEF_AutoType_34P0_tags_1) + /sizeof(asn_DEF_AutoType_34P0_tags_1[0]), /* 1 */ + asn_DEF_AutoType_34P0_tags_1, /* Same as above */ + sizeof(asn_DEF_AutoType_34P0_tags_1) + /sizeof(asn_DEF_AutoType_34P0_tags_1[0]), /* 1 */ + { 0, 0, SEQUENCE_constraint }, + asn_MBR_AutoType_34P0_1, + 1, /* Elements count */ + &asn_SPC_AutoType_34P0_specs_1 /* Additional specs */ +}; + +asn_TYPE_member_t asn_MBR_AutoType_34P1_3[] = { + { ATF_NOFLAGS, 0, offsetof(struct AutoType_34P1, common), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BOOLEAN, + .type_selector = 0, + { .oer_constraints = 0, .per_constraints = 0, .general_constraints = memb_common_constraint_3 }, + 0, 0, /* No default value */ + .name = "common" + }, +}; +static const ber_tlv_tag_t asn_DEF_AutoType_34P1_tags_3[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_AutoType_34P1_tag2el_3[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common */ +}; +asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P1_specs_3 = { + sizeof(struct AutoType_34P1), + offsetof(struct AutoType_34P1, _asn_ctx), + .tag2el = asn_MAP_AutoType_34P1_tag2el_3, + .tag2el_count = 1, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* First extension addition */ +}; +asn_TYPE_descriptor_t asn_DEF_AutoType_34P1 = { + "AutoType", + "AutoType", + &asn_OP_SEQUENCE, + asn_DEF_AutoType_34P1_tags_3, + sizeof(asn_DEF_AutoType_34P1_tags_3) + /sizeof(asn_DEF_AutoType_34P1_tags_3[0]), /* 1 */ + asn_DEF_AutoType_34P1_tags_3, /* Same as above */ + sizeof(asn_DEF_AutoType_34P1_tags_3) + /sizeof(asn_DEF_AutoType_34P1_tags_3[0]), /* 1 */ + { 0, 0, SEQUENCE_constraint }, + asn_MBR_AutoType_34P1_3, + 1, /* Elements count */ + &asn_SPC_AutoType_34P1_specs_3 /* Additional specs */ +}; + + +/*** <<< INCLUDES [AutoChoice] >>> ***/ + +#include "AutoType.h" +#include + +/*** <<< DEPS [AutoChoice] >>> ***/ + +typedef enum AutoChoice_PR { + AutoChoice_PR_NOTHING, /* No components present */ + AutoChoice_PR_type1, + AutoChoice_PR_type2 +} AutoChoice_PR; + +/*** <<< TYPE-DECLS [AutoChoice] >>> ***/ + +typedef struct AutoChoice { + AutoChoice_PR present; + union AutoChoice_u { + AutoType_34P0_t type1; + AutoType_34P1_t type2; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} AutoChoice_t; + +/*** <<< FUNC-DECLS [AutoChoice] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_AutoChoice; + +/*** <<< STAT-DEFS [AutoChoice] >>> ***/ + +static asn_TYPE_member_t asn_MBR_AutoChoice_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type1), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_AutoType_34P0, + .type_selector = 0, + { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 }, + 0, 0, /* No default value */ + .name = "type1" + }, + { ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type2), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_AutoType_34P1, + .type_selector = 0, + { .oer_constraints = 0, .per_constraints = 0, .general_constraints = 0 }, + 0, 0, /* No default value */ + .name = "type2" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_AutoChoice_tag2el_1[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* type1 */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* type2 */ +}; +static asn_CHOICE_specifics_t asn_SPC_AutoChoice_specs_1 = { + sizeof(struct AutoChoice), + offsetof(struct AutoChoice, _asn_ctx), + offsetof(struct AutoChoice, present), + sizeof(((struct AutoChoice *)0)->present), + .tag2el = asn_MAP_AutoChoice_tag2el_1, + .tag2el_count = 2, /* Count of tags in the map */ + 0, 0, + .first_extension = -1 /* Extensions start */ +}; +asn_TYPE_descriptor_t asn_DEF_AutoChoice = { + "AutoChoice", + "AutoChoice", + &asn_OP_CHOICE, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + { 0, 0, CHOICE_constraint }, + asn_MBR_AutoChoice_1, + 2, /* Elements count */ + &asn_SPC_AutoChoice_specs_1 /* Additional specs */ +}; +