Commit c3f0b89c authored by Lev Walkin's avatar Lev Walkin

PER visible constraints are used to select the native representation for INTEGER types

parent 082cadca
/*** <<< INCLUDES [TestChoice] >>> ***/
#include <INTEGER.h>
#include <NativeInteger.h>
#include <constr_SEQUENCE.h>
#include <BOOLEAN.h>
#include <constr_CHOICE.h>
......@@ -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 <INTEGER.h>
#include <NativeInteger.h>
#include <constr_SEQUENCE.h>
#include <BOOLEAN.h>
#include <constr_CHOICE.h>
......@@ -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"
},
......
......@@ -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
......@@ -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
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment