From c3f0b89c0ed97cf34a6a7e7730cb7a6eba540b27 Mon Sep 17 00:00:00 2001 From: Lev Walkin Date: Sun, 14 Aug 2005 02:40:04 +0000 Subject: [PATCH] PER visible constraints are used to select the native representation for INTEGER types --- tests/84-param-tags-OK.asn1.-P | 28 +- tests/90-cond-int-type-OK.asn1 | 14 +- ...cond-int-type-OK.asn1.-EFprint-constraints | 74 ++- tests/90-cond-int-type-OK.asn1.-P | 390 +++++++++++--- .../90-cond-int-type-OK.asn1.-Pfnative-types | 486 +++++++++++++----- 5 files changed, 720 insertions(+), 272 deletions(-) diff --git a/tests/84-param-tags-OK.asn1.-P b/tests/84-param-tags-OK.asn1.-P index b191b564..282dfe40 100644 --- a/tests/84-param-tags-OK.asn1.-P +++ b/tests/84-param-tags-OK.asn1.-P @@ -1,7 +1,7 @@ /*** <<< INCLUDES [TestChoice] >>> ***/ -#include +#include #include #include #include @@ -20,7 +20,7 @@ typedef struct TestChoice { TestChoice_PR present; union { struct type1 { - INTEGER_t *common /* DEFAULT 0 */; + long *common /* DEFAULT 0 */; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; @@ -46,7 +46,6 @@ extern asn_TYPE_descriptor_t asn_DEF_TestChoice; static int memb_common_2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -56,12 +55,7 @@ memb_common_2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= 1 && value <= 10)) { /* Constraint check succeeded */ @@ -81,7 +75,7 @@ static asn_TYPE_member_t asn_MBR_type1_2[] = { { ATF_POINTER, 1, offsetof(struct type1, common), .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), .tag_mode = 0, - .type = (void *)&asn_DEF_INTEGER, + .type = (void *)&asn_DEF_NativeInteger, .memb_constraints = memb_common_2_constraint, .name = "common" }, @@ -222,7 +216,7 @@ asn_TYPE_descriptor_t asn_DEF_TestChoice = { /*** <<< INCLUDES [AutoChoice] >>> ***/ -#include +#include #include #include #include @@ -241,7 +235,7 @@ typedef struct AutoChoice { AutoChoice_PR present; union { struct type1 { - INTEGER_t common; + long common; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; @@ -267,7 +261,6 @@ extern asn_TYPE_descriptor_t asn_DEF_AutoChoice; static int memb_common_2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -277,12 +270,7 @@ memb_common_2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value == 0)) { /* Constraint check succeeded */ @@ -327,7 +315,7 @@ static asn_TYPE_member_t asn_MBR_type1_2[] = { { ATF_NOFLAGS, 0, offsetof(struct type1, common), .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = (void *)&asn_DEF_INTEGER, + .type = (void *)&asn_DEF_NativeInteger, .memb_constraints = memb_common_2_constraint, .name = "common" }, diff --git a/tests/90-cond-int-type-OK.asn1 b/tests/90-cond-int-type-OK.asn1 index e4745150..7fe18e00 100644 --- a/tests/90-cond-int-type-OK.asn1 +++ b/tests/90-cond-int-type-OK.asn1 @@ -14,19 +14,19 @@ BEGIN CN-IntegerUnlimited ::= INTEGER CN-IntegerMinMax ::= INTEGER (MIN..MAX) CN-IntegerMinLow ::= INTEGER (MIN..1) - NO-IntegerMinHigh ::= INTEGER (MIN..5000000000) - NO-IntegerLowHigh ::= INTEGER (1..5000000000) + NO-IntegerMinHigh ::= INTEGER (MIN..3000000000) + NO-IntegerLowHigh ::= INTEGER (1..3000000000) CN-IntegerLowMax ::= INTEGER (1..MAX) - NO-IntegerHighMax ::= INTEGER (5000000000..MAX) - NO-IntegerLowestMax ::= INTEGER (-5000000000..MAX) - NO-IntegerOutRange ::= INTEGER (5000000000..5000000001) - NO-IntegerOutValue ::= INTEGER (5000000000) + NO-IntegerHighMax ::= INTEGER (3000000000..MAX) + NO-IntegerLowestMax ::= INTEGER (-3000000000..MAX) + NO-IntegerOutRange ::= INTEGER (3000000000..3000000001) + NO-IntegerOutValue ::= INTEGER (3000000000) OK-IntegerInRange1 ::= INTEGER (-100..100) OK-IntegerInRange2 ::= INTEGER (-100|100) OK-IntegerInRange3 ::= INTEGER (-2147483648..2147483647) OK-IntegerInRange4 ::= INTEGER (-2147483648|2147483647) OK-IntegerInRange5 ::= INTEGER (-2147483648|2147483647,...) CN-IntegerEnumerated1 ::= INTEGER { a(1), b(2) } - NO-IntegerEnumerated2 ::= INTEGER { a(1), b(5000000000) } + NO-IntegerEnumerated2 ::= INTEGER { a(1), b(3000000000) } END diff --git a/tests/90-cond-int-type-OK.asn1.-EFprint-constraints b/tests/90-cond-int-type-OK.asn1.-EFprint-constraints index 939a1734..62bdad50 100644 --- a/tests/90-cond-int-type-OK.asn1.-EFprint-constraints +++ b/tests/90-cond-int-type-OK.asn1.-EFprint-constraints @@ -17,40 +17,40 @@ CN-IntegerMinLow ::= INTEGER (MIN..1) -- Practical constraints (CN-IntegerMinLow): (MIN..1) -- PER-visible constraints (CN-IntegerMinLow): (MIN..1) -NO-IntegerMinHigh ::= INTEGER (MIN..5000000000) --- Combined constraints: (MIN..5000000000) --- Practical constraints (NO-IntegerMinHigh): (MIN..5000000000) --- PER-visible constraints (NO-IntegerMinHigh): (MIN..5000000000) +NO-IntegerMinHigh ::= INTEGER (MIN..3000000000) +-- Combined constraints: (MIN..3000000000) +-- Practical constraints (NO-IntegerMinHigh): (MIN..3000000000) +-- PER-visible constraints (NO-IntegerMinHigh): (MIN..3000000000) -NO-IntegerLowHigh ::= INTEGER (1..5000000000) --- Combined constraints: (1..5000000000) --- Practical constraints (NO-IntegerLowHigh): (1..5000000000) --- PER-visible constraints (NO-IntegerLowHigh): (1..5000000000) +NO-IntegerLowHigh ::= INTEGER (1..3000000000) +-- Combined constraints: (1..3000000000) +-- Practical constraints (NO-IntegerLowHigh): (1..3000000000) +-- PER-visible constraints (NO-IntegerLowHigh): (1..3000000000) CN-IntegerLowMax ::= INTEGER (1..MAX) -- Combined constraints: (1..MAX) -- Practical constraints (CN-IntegerLowMax): (1..MAX) -- PER-visible constraints (CN-IntegerLowMax): (1..MAX) -NO-IntegerHighMax ::= INTEGER (5000000000..MAX) --- Combined constraints: (5000000000..MAX) --- Practical constraints (NO-IntegerHighMax): (5000000000..MAX) --- PER-visible constraints (NO-IntegerHighMax): (5000000000..MAX) +NO-IntegerHighMax ::= INTEGER (3000000000..MAX) +-- Combined constraints: (3000000000..MAX) +-- Practical constraints (NO-IntegerHighMax): (3000000000..MAX) +-- PER-visible constraints (NO-IntegerHighMax): (3000000000..MAX) -NO-IntegerLowestMax ::= INTEGER (-5000000000..MAX) --- Combined constraints: (-5000000000..MAX) --- Practical constraints (NO-IntegerLowestMax): (-5000000000..MAX) --- PER-visible constraints (NO-IntegerLowestMax): (-5000000000..MAX) +NO-IntegerLowestMax ::= INTEGER (-3000000000..MAX) +-- Combined constraints: (-3000000000..MAX) +-- Practical constraints (NO-IntegerLowestMax): (-3000000000..MAX) +-- PER-visible constraints (NO-IntegerLowestMax): (-3000000000..MAX) -NO-IntegerOutRange ::= INTEGER (5000000000..5000000001) --- Combined constraints: (5000000000..5000000001) --- Practical constraints (NO-IntegerOutRange): (5000000000..5000000001) --- PER-visible constraints (NO-IntegerOutRange): (5000000000..5000000001) +NO-IntegerOutRange ::= INTEGER (3000000000..3000000001) +-- Combined constraints: (3000000000..3000000001) +-- Practical constraints (NO-IntegerOutRange): (3000000000..3000000001) +-- PER-visible constraints (NO-IntegerOutRange): (3000000000..3000000001) -NO-IntegerOutValue ::= INTEGER (5000000000) --- Combined constraints: (5000000000) --- Practical constraints (NO-IntegerOutValue): (5000000000) --- PER-visible constraints (NO-IntegerOutValue): (5000000000) +NO-IntegerOutValue ::= INTEGER (3000000000) +-- Combined constraints: (3000000000) +-- Practical constraints (NO-IntegerOutValue): (3000000000) +-- PER-visible constraints (NO-IntegerOutValue): (3000000000) OK-IntegerInRange1 ::= INTEGER (-100..100) -- Combined constraints: (-100..100) @@ -77,4 +77,30 @@ OK-IntegerInRange5 ::= INTEGER (-2147483648 | 2147483647,...) -- Practical constraints (OK-IntegerInRange5): (-2147483648 | 2147483647,...) -- PER-visible constraints (OK-IntegerInRange5): (-2147483648 | 2147483647,...) +CN-IntegerEnumerated1 ::= INTEGER { + a(1) +-- Practical constraints (a): +-- PER-visible constraints (a): +, + b(2) +-- Practical constraints (b): +-- PER-visible constraints (b): + +} +-- Practical constraints (CN-IntegerEnumerated1): (MIN..MAX) +-- PER-visible constraints (CN-IntegerEnumerated1): (MIN..MAX) + +NO-IntegerEnumerated2 ::= INTEGER { + a(1) +-- Practical constraints (a): +-- PER-visible constraints (a): +, + b(3000000000) +-- Practical constraints (b): +-- PER-visible constraints (b): + +} +-- Practical constraints (NO-IntegerEnumerated2): (MIN..MAX) +-- PER-visible constraints (NO-IntegerEnumerated2): (MIN..MAX) + END diff --git a/tests/90-cond-int-type-OK.asn1.-P b/tests/90-cond-int-type-OK.asn1.-P index 4019fbac..b3f5b631 100644 --- a/tests/90-cond-int-type-OK.asn1.-P +++ b/tests/90-cond-int-type-OK.asn1.-P @@ -431,7 +431,7 @@ NO_IntegerMinHigh_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value <= 5000000000)) { + if((value <= 3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -572,7 +572,7 @@ NO_IntegerLowHigh_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value >= 1 && value <= 5000000000)) { + if((value >= 1 && value <= 3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -854,7 +854,7 @@ NO_IntegerHighMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value >= 5000000000)) { + if((value >= 3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -995,7 +995,7 @@ NO_IntegerLowestMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value >= -5000000000)) { + if((value >= -3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -1136,7 +1136,7 @@ NO_IntegerOutRange_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value >= 5000000000 && value <= 5000000001)) { + if((value >= 3000000000 && value <= 3000000001)) { /* Constraint check succeeded */ return 0; } else { @@ -1277,7 +1277,7 @@ NO_IntegerOutValue_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value == 5000000000)) { + if((value == 3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -1379,11 +1379,11 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerOutValue = { /*** <<< INCLUDES [OK-IntegerInRange1] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [OK-IntegerInRange1] >>> ***/ -typedef INTEGER_t OK_IntegerInRange1_t; +typedef long OK_IntegerInRange1_t; /*** <<< FUNC-DECLS [OK-IntegerInRange1] >>> ***/ @@ -1401,7 +1401,6 @@ xer_type_encoder_f OK_IntegerInRange1_encode_xer; int OK_IntegerInRange1_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -1411,12 +1410,7 @@ OK_IntegerInRange1_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= -100 && value <= 100)) { /* Constraint check succeeded */ @@ -1430,20 +1424,20 @@ OK_IntegerInRange1_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void OK_IntegerInRange1_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -1520,11 +1514,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange1 = { /*** <<< INCLUDES [OK-IntegerInRange2] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [OK-IntegerInRange2] >>> ***/ -typedef INTEGER_t OK_IntegerInRange2_t; +typedef long OK_IntegerInRange2_t; /*** <<< FUNC-DECLS [OK-IntegerInRange2] >>> ***/ @@ -1542,7 +1536,6 @@ xer_type_encoder_f OK_IntegerInRange2_encode_xer; int OK_IntegerInRange2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -1552,12 +1545,7 @@ OK_IntegerInRange2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if(((value == -100) || (value == 100))) { /* Constraint check succeeded */ @@ -1571,20 +1559,20 @@ OK_IntegerInRange2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void OK_IntegerInRange2_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -1661,11 +1649,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange2 = { /*** <<< INCLUDES [OK-IntegerInRange3] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [OK-IntegerInRange3] >>> ***/ -typedef INTEGER_t OK_IntegerInRange3_t; +typedef long OK_IntegerInRange3_t; /*** <<< FUNC-DECLS [OK-IntegerInRange3] >>> ***/ @@ -1683,7 +1671,6 @@ xer_type_encoder_f OK_IntegerInRange3_encode_xer; int OK_IntegerInRange3_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -1693,12 +1680,7 @@ OK_IntegerInRange3_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= -2147483648 && value <= 2147483647)) { /* Constraint check succeeded */ @@ -1712,20 +1694,20 @@ OK_IntegerInRange3_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void OK_IntegerInRange3_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -1802,11 +1784,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange3 = { /*** <<< INCLUDES [OK-IntegerInRange4] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [OK-IntegerInRange4] >>> ***/ -typedef INTEGER_t OK_IntegerInRange4_t; +typedef long OK_IntegerInRange4_t; /*** <<< FUNC-DECLS [OK-IntegerInRange4] >>> ***/ @@ -1824,7 +1806,6 @@ xer_type_encoder_f OK_IntegerInRange4_encode_xer; int OK_IntegerInRange4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -1834,12 +1815,7 @@ OK_IntegerInRange4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if(((value == -2147483648) || (value == 2147483647))) { /* Constraint check succeeded */ @@ -1853,20 +1829,20 @@ OK_IntegerInRange4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void OK_IntegerInRange4_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -2081,3 +2057,253 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange5 = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [CN-IntegerEnumerated1] >>> ***/ + +#include + +/*** <<< DEPS [CN-IntegerEnumerated1] >>> ***/ + +typedef enum CN_IntegerEnumerated1 { + CN_IntegerEnumerated1_a = 1, + CN_IntegerEnumerated1_b = 2 +} CN_IntegerEnumerated1_e; + +/*** <<< TYPE-DECLS [CN-IntegerEnumerated1] >>> ***/ + +typedef INTEGER_t CN_IntegerEnumerated1_t; + +/*** <<< FUNC-DECLS [CN-IntegerEnumerated1] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_CN_IntegerEnumerated1; +asn_struct_free_f CN_IntegerEnumerated1_free; +asn_struct_print_f CN_IntegerEnumerated1_print; +asn_constr_check_f CN_IntegerEnumerated1_constraint; +ber_type_decoder_f CN_IntegerEnumerated1_decode_ber; +der_type_encoder_f CN_IntegerEnumerated1_encode_der; +xer_type_decoder_f CN_IntegerEnumerated1_decode_xer; +xer_type_encoder_f CN_IntegerEnumerated1_encode_xer; + +/*** <<< CODE [CN-IntegerEnumerated1] >>> ***/ + +int +CN_IntegerEnumerated1_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 +CN_IntegerEnumerated1_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 +CN_IntegerEnumerated1_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); +} + +int +CN_IntegerEnumerated1_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +} + +asn_dec_rval_t +CN_IntegerEnumerated1_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) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); +} + +asn_enc_rval_t +CN_IntegerEnumerated1_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) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); +} + +asn_dec_rval_t +CN_IntegerEnumerated1_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) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); +} + +asn_enc_rval_t +CN_IntegerEnumerated1_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) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); +} + + +/*** <<< STAT-DEFS [CN-IntegerEnumerated1] >>> ***/ + +static ber_tlv_tag_t asn_DEF_CN_IntegerEnumerated1_1_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_CN_IntegerEnumerated1 = { + "CN-IntegerEnumerated1", + "CN-IntegerEnumerated1", + CN_IntegerEnumerated1_free, + CN_IntegerEnumerated1_print, + CN_IntegerEnumerated1_constraint, + CN_IntegerEnumerated1_decode_ber, + CN_IntegerEnumerated1_encode_der, + CN_IntegerEnumerated1_decode_xer, + CN_IntegerEnumerated1_encode_xer, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_CN_IntegerEnumerated1_1_tags, + sizeof(asn_DEF_CN_IntegerEnumerated1_1_tags) + /sizeof(asn_DEF_CN_IntegerEnumerated1_1_tags[0]), /* 1 */ + asn_DEF_CN_IntegerEnumerated1_1_tags, /* Same as above */ + sizeof(asn_DEF_CN_IntegerEnumerated1_1_tags) + /sizeof(asn_DEF_CN_IntegerEnumerated1_1_tags[0]), /* 1 */ + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ +}; + + +/*** <<< INCLUDES [NO-IntegerEnumerated2] >>> ***/ + +#include + +/*** <<< DEPS [NO-IntegerEnumerated2] >>> ***/ + +typedef enum NO_IntegerEnumerated2 { + NO_IntegerEnumerated2_a = 1, + NO_IntegerEnumerated2_b = 3000000000 +} NO_IntegerEnumerated2_e; + +/*** <<< TYPE-DECLS [NO-IntegerEnumerated2] >>> ***/ + +typedef INTEGER_t NO_IntegerEnumerated2_t; + +/*** <<< FUNC-DECLS [NO-IntegerEnumerated2] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_NO_IntegerEnumerated2; +asn_struct_free_f NO_IntegerEnumerated2_free; +asn_struct_print_f NO_IntegerEnumerated2_print; +asn_constr_check_f NO_IntegerEnumerated2_constraint; +ber_type_decoder_f NO_IntegerEnumerated2_decode_ber; +der_type_encoder_f NO_IntegerEnumerated2_encode_der; +xer_type_decoder_f NO_IntegerEnumerated2_decode_xer; +xer_type_encoder_f NO_IntegerEnumerated2_encode_xer; + +/*** <<< CODE [NO-IntegerEnumerated2] >>> ***/ + +int +NO_IntegerEnumerated2_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 +NO_IntegerEnumerated2_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 +NO_IntegerEnumerated2_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); +} + +int +NO_IntegerEnumerated2_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +} + +asn_dec_rval_t +NO_IntegerEnumerated2_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) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); +} + +asn_enc_rval_t +NO_IntegerEnumerated2_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) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); +} + +asn_dec_rval_t +NO_IntegerEnumerated2_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) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); +} + +asn_enc_rval_t +NO_IntegerEnumerated2_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) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); +} + + +/*** <<< STAT-DEFS [NO-IntegerEnumerated2] >>> ***/ + +static ber_tlv_tag_t asn_DEF_NO_IntegerEnumerated2_1_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_NO_IntegerEnumerated2 = { + "NO-IntegerEnumerated2", + "NO-IntegerEnumerated2", + NO_IntegerEnumerated2_free, + NO_IntegerEnumerated2_print, + NO_IntegerEnumerated2_constraint, + NO_IntegerEnumerated2_decode_ber, + NO_IntegerEnumerated2_encode_der, + NO_IntegerEnumerated2_decode_xer, + NO_IntegerEnumerated2_encode_xer, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_NO_IntegerEnumerated2_1_tags, + sizeof(asn_DEF_NO_IntegerEnumerated2_1_tags) + /sizeof(asn_DEF_NO_IntegerEnumerated2_1_tags[0]), /* 1 */ + asn_DEF_NO_IntegerEnumerated2_1_tags, /* Same as above */ + sizeof(asn_DEF_NO_IntegerEnumerated2_1_tags) + /sizeof(asn_DEF_NO_IntegerEnumerated2_1_tags[0]), /* 1 */ + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ +}; + diff --git a/tests/90-cond-int-type-OK.asn1.-Pfnative-types b/tests/90-cond-int-type-OK.asn1.-Pfnative-types index 7aebc66c..6de013c3 100644 --- a/tests/90-cond-int-type-OK.asn1.-Pfnative-types +++ b/tests/90-cond-int-type-OK.asn1.-Pfnative-types @@ -250,11 +250,11 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerMinMax = { /*** <<< INCLUDES [CN-IntegerMinLow] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [CN-IntegerMinLow] >>> ***/ -typedef INTEGER_t CN_IntegerMinLow_t; +typedef long CN_IntegerMinLow_t; /*** <<< FUNC-DECLS [CN-IntegerMinLow] >>> ***/ @@ -272,7 +272,6 @@ xer_type_encoder_f CN_IntegerMinLow_encode_xer; int CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -282,12 +281,7 @@ CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value <= 1)) { /* Constraint check succeeded */ @@ -301,20 +295,20 @@ CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void CN_IntegerMinLow_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -430,7 +424,7 @@ NO_IntegerMinHigh_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value <= 5000000000)) { + if((value <= 3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -571,7 +565,7 @@ NO_IntegerLowHigh_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value >= 1 && value <= 5000000000)) { + if((value >= 1 && value <= 3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -673,11 +667,11 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerLowHigh = { /*** <<< INCLUDES [CN-IntegerLowMax] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [CN-IntegerLowMax] >>> ***/ -typedef INTEGER_t CN_IntegerLowMax_t; +typedef long CN_IntegerLowMax_t; /*** <<< FUNC-DECLS [CN-IntegerLowMax] >>> ***/ @@ -695,7 +689,6 @@ xer_type_encoder_f CN_IntegerLowMax_encode_xer; int CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -705,12 +698,7 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= 1)) { /* Constraint check succeeded */ @@ -724,20 +712,20 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void CN_IntegerLowMax_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -853,7 +841,7 @@ NO_IntegerHighMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value >= 5000000000)) { + if((value >= 3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -994,7 +982,7 @@ NO_IntegerLowestMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value >= -5000000000)) { + if((value >= -3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -1135,7 +1123,7 @@ NO_IntegerOutRange_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value >= 5000000000 && value <= 5000000001)) { + if((value >= 3000000000 && value <= 3000000001)) { /* Constraint check succeeded */ return 0; } else { @@ -1276,7 +1264,7 @@ NO_IntegerOutValue_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if((value == 5000000000)) { + if((value == 3000000000)) { /* Constraint check succeeded */ return 0; } else { @@ -1378,11 +1366,11 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerOutValue = { /*** <<< INCLUDES [OK-IntegerInRange1] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [OK-IntegerInRange1] >>> ***/ -typedef INTEGER_t OK_IntegerInRange1_t; +typedef long OK_IntegerInRange1_t; /*** <<< FUNC-DECLS [OK-IntegerInRange1] >>> ***/ @@ -1400,7 +1388,6 @@ xer_type_encoder_f OK_IntegerInRange1_encode_xer; int OK_IntegerInRange1_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -1410,12 +1397,7 @@ OK_IntegerInRange1_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= -100 && value <= 100)) { /* Constraint check succeeded */ @@ -1429,20 +1411,20 @@ OK_IntegerInRange1_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void OK_IntegerInRange1_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -1519,11 +1501,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange1 = { /*** <<< INCLUDES [OK-IntegerInRange2] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [OK-IntegerInRange2] >>> ***/ -typedef INTEGER_t OK_IntegerInRange2_t; +typedef long OK_IntegerInRange2_t; /*** <<< FUNC-DECLS [OK-IntegerInRange2] >>> ***/ @@ -1541,7 +1523,6 @@ xer_type_encoder_f OK_IntegerInRange2_encode_xer; int OK_IntegerInRange2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -1551,12 +1532,7 @@ OK_IntegerInRange2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if(((value == -100) || (value == 100))) { /* Constraint check succeeded */ @@ -1570,20 +1546,20 @@ OK_IntegerInRange2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void OK_IntegerInRange2_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -1660,11 +1636,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange2 = { /*** <<< INCLUDES [OK-IntegerInRange3] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [OK-IntegerInRange3] >>> ***/ -typedef INTEGER_t OK_IntegerInRange3_t; +typedef long OK_IntegerInRange3_t; /*** <<< FUNC-DECLS [OK-IntegerInRange3] >>> ***/ @@ -1682,7 +1658,6 @@ xer_type_encoder_f OK_IntegerInRange3_encode_xer; int OK_IntegerInRange3_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -1692,12 +1667,7 @@ OK_IntegerInRange3_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= -2147483648 && value <= 2147483647)) { /* Constraint check succeeded */ @@ -1711,20 +1681,20 @@ OK_IntegerInRange3_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void OK_IntegerInRange3_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -1801,11 +1771,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange3 = { /*** <<< INCLUDES [OK-IntegerInRange4] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [OK-IntegerInRange4] >>> ***/ -typedef INTEGER_t OK_IntegerInRange4_t; +typedef long OK_IntegerInRange4_t; /*** <<< FUNC-DECLS [OK-IntegerInRange4] >>> ***/ @@ -1823,7 +1793,6 @@ xer_type_encoder_f OK_IntegerInRange4_encode_xer; int OK_IntegerInRange4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -1833,12 +1802,7 @@ OK_IntegerInRange4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if(((value == -2147483648) || (value == 2147483647))) { /* Constraint check succeeded */ @@ -1852,20 +1816,20 @@ OK_IntegerInRange4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void OK_IntegerInRange4_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -1942,11 +1906,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange4 = { /*** <<< INCLUDES [OK-IntegerInRange5] >>> ***/ -#include +#include /*** <<< TYPE-DECLS [OK-IntegerInRange5] >>> ***/ -typedef INTEGER_t OK_IntegerInRange5_t; +typedef long OK_IntegerInRange5_t; /*** <<< FUNC-DECLS [OK-IntegerInRange5] >>> ***/ @@ -1964,7 +1928,6 @@ xer_type_encoder_f OK_IntegerInRange5_encode_xer; int OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -1974,12 +1937,7 @@ OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_ERRLOG(app_errlog, app_key, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if(((value == -2147483648) || (value == 2147483647))) { /* Constraint check succeeded */ @@ -1993,20 +1951,20 @@ OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void OK_IntegerInRange5_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; + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -2080,3 +2038,253 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange5 = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [CN-IntegerEnumerated1] >>> ***/ + +#include + +/*** <<< DEPS [CN-IntegerEnumerated1] >>> ***/ + +typedef enum CN_IntegerEnumerated1 { + CN_IntegerEnumerated1_a = 1, + CN_IntegerEnumerated1_b = 2 +} CN_IntegerEnumerated1_e; + +/*** <<< TYPE-DECLS [CN-IntegerEnumerated1] >>> ***/ + +typedef long CN_IntegerEnumerated1_t; + +/*** <<< FUNC-DECLS [CN-IntegerEnumerated1] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_CN_IntegerEnumerated1; +asn_struct_free_f CN_IntegerEnumerated1_free; +asn_struct_print_f CN_IntegerEnumerated1_print; +asn_constr_check_f CN_IntegerEnumerated1_constraint; +ber_type_decoder_f CN_IntegerEnumerated1_decode_ber; +der_type_encoder_f CN_IntegerEnumerated1_encode_der; +xer_type_decoder_f CN_IntegerEnumerated1_decode_xer; +xer_type_encoder_f CN_IntegerEnumerated1_encode_xer; + +/*** <<< CODE [CN-IntegerEnumerated1] >>> ***/ + +int +CN_IntegerEnumerated1_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_NativeInteger.check_constraints; + return td->check_constraints(td, sptr, app_errlog, app_key); +} + +/* + * This type is implemented using NativeInteger, + * so here we adjust the DEF accordingly. + */ +static void +CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { + td->free_struct = asn_DEF_NativeInteger.free_struct; + td->print_struct = asn_DEF_NativeInteger.print_struct; + td->ber_decoder = asn_DEF_NativeInteger.ber_decoder; + td->der_encoder = asn_DEF_NativeInteger.der_encoder; + td->xer_decoder = asn_DEF_NativeInteger.xer_decoder; + td->xer_encoder = asn_DEF_NativeInteger.xer_encoder; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; +} + +void +CN_IntegerEnumerated1_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); +} + +int +CN_IntegerEnumerated1_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +} + +asn_dec_rval_t +CN_IntegerEnumerated1_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) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); +} + +asn_enc_rval_t +CN_IntegerEnumerated1_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) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); +} + +asn_dec_rval_t +CN_IntegerEnumerated1_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) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); +} + +asn_enc_rval_t +CN_IntegerEnumerated1_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) { + CN_IntegerEnumerated1_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); +} + + +/*** <<< STAT-DEFS [CN-IntegerEnumerated1] >>> ***/ + +static ber_tlv_tag_t asn_DEF_CN_IntegerEnumerated1_1_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_CN_IntegerEnumerated1 = { + "CN-IntegerEnumerated1", + "CN-IntegerEnumerated1", + CN_IntegerEnumerated1_free, + CN_IntegerEnumerated1_print, + CN_IntegerEnumerated1_constraint, + CN_IntegerEnumerated1_decode_ber, + CN_IntegerEnumerated1_encode_der, + CN_IntegerEnumerated1_decode_xer, + CN_IntegerEnumerated1_encode_xer, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_CN_IntegerEnumerated1_1_tags, + sizeof(asn_DEF_CN_IntegerEnumerated1_1_tags) + /sizeof(asn_DEF_CN_IntegerEnumerated1_1_tags[0]), /* 1 */ + asn_DEF_CN_IntegerEnumerated1_1_tags, /* Same as above */ + sizeof(asn_DEF_CN_IntegerEnumerated1_1_tags) + /sizeof(asn_DEF_CN_IntegerEnumerated1_1_tags[0]), /* 1 */ + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ +}; + + +/*** <<< INCLUDES [NO-IntegerEnumerated2] >>> ***/ + +#include + +/*** <<< DEPS [NO-IntegerEnumerated2] >>> ***/ + +typedef enum NO_IntegerEnumerated2 { + NO_IntegerEnumerated2_a = 1, + NO_IntegerEnumerated2_b = 3000000000 +} NO_IntegerEnumerated2_e; + +/*** <<< TYPE-DECLS [NO-IntegerEnumerated2] >>> ***/ + +typedef INTEGER_t NO_IntegerEnumerated2_t; + +/*** <<< FUNC-DECLS [NO-IntegerEnumerated2] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_NO_IntegerEnumerated2; +asn_struct_free_f NO_IntegerEnumerated2_free; +asn_struct_print_f NO_IntegerEnumerated2_print; +asn_constr_check_f NO_IntegerEnumerated2_constraint; +ber_type_decoder_f NO_IntegerEnumerated2_decode_ber; +der_type_encoder_f NO_IntegerEnumerated2_encode_der; +xer_type_decoder_f NO_IntegerEnumerated2_decode_xer; +xer_type_encoder_f NO_IntegerEnumerated2_encode_xer; + +/*** <<< CODE [NO-IntegerEnumerated2] >>> ***/ + +int +NO_IntegerEnumerated2_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 +NO_IntegerEnumerated2_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 +NO_IntegerEnumerated2_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); +} + +int +NO_IntegerEnumerated2_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +} + +asn_dec_rval_t +NO_IntegerEnumerated2_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) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); +} + +asn_enc_rval_t +NO_IntegerEnumerated2_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) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); +} + +asn_dec_rval_t +NO_IntegerEnumerated2_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) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); +} + +asn_enc_rval_t +NO_IntegerEnumerated2_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) { + NO_IntegerEnumerated2_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); +} + + +/*** <<< STAT-DEFS [NO-IntegerEnumerated2] >>> ***/ + +static ber_tlv_tag_t asn_DEF_NO_IntegerEnumerated2_1_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_NO_IntegerEnumerated2 = { + "NO-IntegerEnumerated2", + "NO-IntegerEnumerated2", + NO_IntegerEnumerated2_free, + NO_IntegerEnumerated2_print, + NO_IntegerEnumerated2_constraint, + NO_IntegerEnumerated2_decode_ber, + NO_IntegerEnumerated2_encode_der, + NO_IntegerEnumerated2_decode_xer, + NO_IntegerEnumerated2_encode_xer, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_NO_IntegerEnumerated2_1_tags, + sizeof(asn_DEF_NO_IntegerEnumerated2_1_tags) + /sizeof(asn_DEF_NO_IntegerEnumerated2_1_tags[0]), /* 1 */ + asn_DEF_NO_IntegerEnumerated2_1_tags, /* Same as above */ + sizeof(asn_DEF_NO_IntegerEnumerated2_1_tags) + /sizeof(asn_DEF_NO_IntegerEnumerated2_1_tags[0]), /* 1 */ + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ +}; +