diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | asn1c/Makefile.am | 2 | ||||
-rw-r--r-- | asn1c/Makefile.in | 2 | ||||
-rw-r--r-- | asn1c/asn1c.1 | 10 | ||||
-rw-r--r-- | asn1c/asn1c.c | 8 | ||||
-rw-r--r-- | asn1c/tests/check-03.-fwide-types.c (renamed from asn1c/tests/check-03.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-119.-fwide-types.-gen-PER.c (renamed from asn1c/tests/check-119.-fnative-types.-gen-PER.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-127.-gen-PER.c (renamed from asn1c/tests/check-127.-fnative-types.-gen-PER.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-132.-gen-PER.c (renamed from asn1c/tests/check-132.-fnative-types.-gen-PER.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-22.-fwide-types.c (renamed from asn1c/tests/check-22.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-24.-fwide-types.c (renamed from asn1c/tests/check-24.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-25.-fwide-types.c (renamed from asn1c/tests/check-25.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-30.-fwide-types.c (renamed from asn1c/tests/check-30.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-31.-fwide-types.c (renamed from asn1c/tests/check-31.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-41.-fnative-types.c | 219 | ||||
-rw-r--r-- | asn1c/tests/check-41.-fwide-types.c | 322 | ||||
-rw-r--r-- | asn1c/tests/check-41.c | 217 | ||||
-rw-r--r-- | asn1c/tests/check-42.c (renamed from asn1c/tests/check-42.-fnative-types.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-60.c (renamed from asn1c/tests/check-60.-fnative-types.c) | 0 | ||||
-rw-r--r-- | asn1c/tests/check-70.-fwide-types.c (renamed from asn1c/tests/check-70.-fnative-types.c) | 46 | ||||
-rw-r--r-- | asn1c/tests/check-70.c | 44 | ||||
-rw-r--r-- | doc/asn1c-usage.pdf | bin | 200175 -> 199756 bytes | |||
-rw-r--r-- | doc/docsrc/asn1c-usage.tex | 26 | ||||
-rw-r--r-- | libasn1compiler/asn1c_constraint.c | 8 | ||||
-rw-r--r-- | libasn1compiler/asn1c_misc.c | 18 | ||||
-rw-r--r-- | libasn1compiler/asn1c_misc.h | 4 | ||||
-rw-r--r-- | libasn1compiler/asn1compiler.h | 4 | ||||
-rw-r--r-- | tests/03-enum-OK.asn1.-Pfwide-types (renamed from tests/03-enum-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/104-param-1-OK.asn1.-Pfwide-types (renamed from tests/104-param-1-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/105-param-2-OK.asn1.-Pfwide-types (renamed from tests/105-param-2-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/108-param-constr-3-OK.asn1.-Pfwide-types (renamed from tests/108-param-constr-3-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/110-param-3-OK.asn1.-Pfwide-types (renamed from tests/110-param-3-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/119-per-strings-OK.asn1.-Pgen-PER | 6 | ||||
-rw-r--r-- | tests/125-bitstring-constraint-OK.asn1.-X | 2 | ||||
-rw-r--r-- | tests/126-per-extensions-OK.asn1.-Pgen-PER | 14 | ||||
-rw-r--r-- | tests/127-per-long-OK.asn1.-Pgen-PER | 4 | ||||
-rw-r--r-- | tests/19-param-OK.asn1.-Pfwide-types (renamed from tests/19-param-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/22-tags-OK.asn1.-Pfwide-types (renamed from tests/22-tags-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/30-set-OK.asn1.-Pfwide-types (renamed from tests/30-set-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/31-set-of-OK.asn1.-Pfwide-types (renamed from tests/31-set-of-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/37-indirect-choice-OK.asn1.-Pfwide-types (renamed from tests/37-indirect-choice-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/39-sequence-of-OK.asn1.-Pfwide-types (renamed from tests/39-sequence-of-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/42-real-life-OK.asn1.-PR | 32 | ||||
-rw-r--r-- | tests/43-recursion-OK.asn1.-Pfwide-types (renamed from tests/43-recursion-OK.asn1.-P) | 18 | ||||
-rw-r--r-- | tests/47-set-ext-OK.asn1.-Pfwide-types (renamed from tests/47-set-ext-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/50-constraint-OK.asn1.-Pfwide-types (renamed from tests/50-constraint-OK.asn1.-P) | 4 | ||||
-rw-r--r-- | tests/50-constraint-OK.asn1.-Pgen-PER | 198 | ||||
-rw-r--r-- | tests/59-choice-extended-OK.asn1.-Pfwide-types (renamed from tests/59-choice-extended-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/60-any-OK.asn1.-Pfwide-types (renamed from tests/60-any-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/65-multi-tag-OK.asn1.-Pfwide-types (renamed from tests/65-multi-tag-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/66-ref-simple-OK.asn1.-Pfwide-types (renamed from tests/66-ref-simple-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/69-reserved-words-OK.asn1.-Pfwide-types (renamed from tests/69-reserved-words-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/70-xer-test-OK.asn1.-Pfwide-types (renamed from tests/70-xer-test-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/72-same-names-OK.asn1.-Pfwide-types (renamed from tests/72-same-names-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/73-circular-OK.asn1.-Pfwide-types (renamed from tests/73-circular-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/84-param-tags-OK.asn1.-Pfwide-types (renamed from tests/84-param-tags-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/88-integer-enum-OK.asn1.-Pfwide-types (renamed from tests/88-integer-enum-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/89-bit-string-enum-OK.asn1.-Pfwide-types (renamed from tests/89-bit-string-enum-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/90-cond-int-type-OK.asn1.-P | 213 | ||||
-rw-r--r-- | tests/90-cond-int-type-OK.asn1.-Pfwide-types (renamed from tests/90-cond-int-type-OK.asn1.-Pfnative-types) | 213 | ||||
-rw-r--r-- | tests/90-cond-int-type-OK.asn1.-Pgen-PER | 213 | ||||
-rw-r--r-- | tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE | 33 | ||||
-rw-r--r-- | tests/92-circular-loops-OK.asn1.-Pfindirect-choice | 16 | ||||
-rw-r--r-- | tests/92-circular-loops-OK.asn1.-Pfwide-types (renamed from tests/92-circular-loops-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/93-asn1c-controls-OK.asn1.-Pfwide-types (renamed from tests/93-asn1c-controls-OK.asn1.-P) | 0 | ||||
-rw-r--r-- | tests/95-choice-per-order-OK.asn1.-Pfwide-types (renamed from tests/95-choice-per-order-OK.asn1.-P) | 4 | ||||
-rw-r--r-- | tests/95-choice-per-order-OK.asn1.-Pgen-PER | 10 |
67 files changed, 918 insertions, 996 deletions
@@ -1,7 +1,9 @@ ???: - * Made -fskeletons-copy a default one; removed cmdline option. * Updated asn1c-usage.pdf. + * Made -fskeletons-copy a default option; removed cmdline option. + * Made -fnative-types a default options; removed cmdline option. + Added -fwide-types for backwards compatibility. 0.9.24: 2013-Mar-16 diff --git a/asn1c/Makefile.am b/asn1c/Makefile.am index 1c31f9c3..01258986 100644 --- a/asn1c/Makefile.am +++ b/asn1c/Makefile.am @@ -23,5 +23,5 @@ noinst_HEADERS = sys-common.h dist_man1_MANS = asn1c.1 unber.1 enber.1 dist_check_SCRIPTS = check-xxber.sh check-parsing.sh -TESTS = $(check_SCRIPTS) +TESTS = $(dist_check_SCRIPTS) CLEANFILES = .check-xxber.*.tmp .check-parsing.*.tmp diff --git a/asn1c/Makefile.in b/asn1c/Makefile.in index 17aeced6..14645869 100644 --- a/asn1c/Makefile.in +++ b/asn1c/Makefile.in @@ -36,7 +36,6 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = asn1c$(EXEEXT) unber$(EXEEXT) enber$(EXEEXT) -TESTS = subdir = asn1c DIST_COMMON = README $(dist_check_SCRIPTS) $(dist_man1_MANS) \ $(noinst_HEADERS) $(srcdir)/Makefile.am $(srcdir)/Makefile.in @@ -282,6 +281,7 @@ asn1c_LDADD = \ noinst_HEADERS = sys-common.h dist_man1_MANS = asn1c.1 unber.1 enber.1 dist_check_SCRIPTS = check-xxber.sh check-parsing.sh +TESTS = $(dist_check_SCRIPTS) CLEANFILES = .check-xxber.*.tmp .check-parsing.*.tmp all: all-recursive diff --git a/asn1c/asn1c.1 b/asn1c/asn1c.1 index 2fbea68f..debfa405 100644 --- a/asn1c/asn1c.1 +++ b/asn1c/asn1c.1 @@ -26,7 +26,7 @@ and other encoding rules. .br \fB\-fbless-SIZE \-fcompound-names \-findirect-choice .BI "\-fknown-extern-type="<name> -\fB\-fnative-types \-fno-constraints \-fno-include-deps \-funnamed-unions +\fB\-fno-constraints \-fno-include-deps \-funnamed-unions \-fwide-types .TP \fICodecs Generation Options\fR .br @@ -98,10 +98,6 @@ to prevent circular references. Pretend the specified type is known. The compiler will assume the target language source files for the given type have been provided manually. .TP -.B \-fnative-types -Use the native machine's data types (int, double) whenever possible, -instead of the compound INTEGER_t, ENUMERATED_t and REAL_t types. -.TP .B \-fno-constraints Do not generate ASN.1 subtype constraint checking code. This may make a shorter executable. .TP @@ -111,6 +107,10 @@ Helps prevent namespace collisions. .TP .B \-funnamed-unions Enable unnamed unions in the definitions of target language's structures. +.TP +.B \-fwide-types +Use the unbounded size data types (INTEGER_t, ENUMERATED_t, REAL_t) by default, +instead of the native machine's data types (long, double). .SH CODECS GENERATION OPTIONS .TP .B \-gen-PER diff --git a/asn1c/asn1c.c b/asn1c/asn1c.c index b849a528..b4fcba1d 100644 --- a/asn1c/asn1c.c +++ b/asn1c/asn1c.c @@ -92,7 +92,10 @@ main(int ac, char **av) { ret = asn1f_make_known_external_type(known_type); assert(ret == 0 || errno == EEXIST); } else if(strcmp(optarg, "native-types") == 0) { - asn1_compiler_flags |= A1C_USE_NATIVE_TYPES; + fprintf(stderr, "-f%s: Deprecated option\n", optarg); + asn1_compiler_flags &= ~A1C_USE_WIDE_TYPES; + } else if(strcmp(optarg, "wide-types") == 0) { + asn1_compiler_flags |= A1C_USE_WIDE_TYPES; } else if(strcmp(optarg, "no-constraints") == 0) { asn1_compiler_flags |= A1C_NO_CONSTRAINTS; } else if(strcmp(optarg, "no-include-deps") == 0) { @@ -103,6 +106,7 @@ main(int ac, char **av) { asn1_compiler_flags |= A1C_UNNAMED_UNIONS; } else if(strcmp(optarg, "skeletons-copy") == 0) { fprintf(stderr, "-f%s: Deprecated option\n", optarg); + asn1_compiler_flags &= ~A1C_LINK_SKELETONS; } else if(strcmp(optarg, "link-skeletons") == 0) { asn1_compiler_flags |= A1C_LINK_SKELETONS; } else { @@ -460,10 +464,10 @@ usage(const char *av0) { " -findirect-choice Compile members of CHOICE as indirect pointers\n" " -fincludes-quoted Generate #includes in \"double\" instead of <angle> quotes\n" " -fknown-extern-type=<name> Pretend the specified type is known\n" -" -fnative-types Use \"long\" instead of INTEGER_t whenever possible, etc.\n" " -fno-constraints Do not generate constraint checking code\n" " -fno-include-deps Do not generate courtesy #includes for dependencies\n" " -funnamed-unions Enable unnamed unions in structures\n" +" -fwide-types Use INTEGER_t instead of \"long\" by default, etc.\n" "\n" " -gen-PER Generate PER support code\n" diff --git a/asn1c/tests/check-03.c b/asn1c/tests/check-03.-fwide-types.c index a821675e..a821675e 100644 --- a/asn1c/tests/check-03.c +++ b/asn1c/tests/check-03.-fwide-types.c diff --git a/asn1c/tests/check-119.-fnative-types.-gen-PER.c b/asn1c/tests/check-119.-fwide-types.-gen-PER.c index d5ffdc6b..d5ffdc6b 100644 --- a/asn1c/tests/check-119.-fnative-types.-gen-PER.c +++ b/asn1c/tests/check-119.-fwide-types.-gen-PER.c diff --git a/asn1c/tests/check-127.-fnative-types.-gen-PER.c b/asn1c/tests/check-127.-gen-PER.c index 34b6d748..34b6d748 100644 --- a/asn1c/tests/check-127.-fnative-types.-gen-PER.c +++ b/asn1c/tests/check-127.-gen-PER.c diff --git a/asn1c/tests/check-132.-fnative-types.-gen-PER.c b/asn1c/tests/check-132.-gen-PER.c index d4037a54..d4037a54 100644 --- a/asn1c/tests/check-132.-fnative-types.-gen-PER.c +++ b/asn1c/tests/check-132.-gen-PER.c diff --git a/asn1c/tests/check-22.c b/asn1c/tests/check-22.-fwide-types.c index 6cfdd7ab..6cfdd7ab 100644 --- a/asn1c/tests/check-22.c +++ b/asn1c/tests/check-22.-fwide-types.c diff --git a/asn1c/tests/check-24.c b/asn1c/tests/check-24.-fwide-types.c index a60e7c13..a60e7c13 100644 --- a/asn1c/tests/check-24.c +++ b/asn1c/tests/check-24.-fwide-types.c diff --git a/asn1c/tests/check-25.c b/asn1c/tests/check-25.-fwide-types.c index 38c3580f..38c3580f 100644 --- a/asn1c/tests/check-25.c +++ b/asn1c/tests/check-25.-fwide-types.c diff --git a/asn1c/tests/check-30.c b/asn1c/tests/check-30.-fwide-types.c index e013b385..e013b385 100644 --- a/asn1c/tests/check-30.c +++ b/asn1c/tests/check-30.-fwide-types.c diff --git a/asn1c/tests/check-31.c b/asn1c/tests/check-31.-fwide-types.c index 53ccf5ab..53ccf5ab 100644 --- a/asn1c/tests/check-31.c +++ b/asn1c/tests/check-31.-fwide-types.c diff --git a/asn1c/tests/check-41.-fnative-types.c b/asn1c/tests/check-41.-fnative-types.c deleted file mode 100644 index 3b735ccf..00000000 --- a/asn1c/tests/check-41.-fnative-types.c +++ /dev/null @@ -1,219 +0,0 @@ -#undef NDEBUG -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <string.h> -#include <assert.h> - -#include <T.h> - - -uint8_t buf1[] = { - 32 | (2 << 6), /* [0], constructed */ - 25, /* L */ - - /* string [0] IMPLICIT UTF8String, */ - (2 << 6), /* [0] */ - 16, /* L */ - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - - /* beta [2] IMPLICIT INTEGER OPTIONAL */ - (2 << 6) + 2, /* [2] */ - 5, /* L */ - 0, - 75, - 0x4b, - 75, - 75, -}; - -uint8_t buf1_reconstr[] = { - 32 | (2 << 6), /* [0], constructed */ - 24, /* L */ - - /* string [0] IMPLICIT UTF8String, */ - (2 << 6), /* [0] */ - 16, /* L */ - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - - /* beta [2] IMPLICIT INTEGER OPTIONAL */ - (2 << 6) + 2, /* [2] */ - 4, /* L */ - 75, - 75, - 75, - 0x4b, -}; - - -static void -check(T_t *tp, uint8_t *buf, int size, size_t consumed) { - asn_dec_rval_t rval; - - tp = memset(tp, 0, sizeof(*tp)); - - fprintf(stderr, "Buf %p (%d)\n", buf, size); - rval = ber_decode(0, &asn_DEF_T, (void **)&tp, buf, size); - fprintf(stderr, "Returned code %d, consumed %d\n", - (int)rval.code, (int)rval.consumed); - - assert(rval.code == RC_OK); - assert(rval.consumed == consumed); - - assert(tp->choice.seq.string.size == 16); - assert(strcmp(tp->choice.seq.string.buf, "zzzzzzzzzzzzzzzz") == 0); - assert(tp->choice.seq.alpha == NULL); - assert(tp->choice.seq.beta); - assert(*tp->choice.seq.beta == 0x4b4b4b4b); -} - -size_t buf_pos; -size_t buf_size; -uint8_t *buf; - -static int -buf_fill(const void *buffer, size_t size, void *app_key) { - - (void)app_key; /* Unused argument */ - - if(buf_pos + size > buf_size) { - fprintf(stderr, "%d + %d > %d\n", - (int)buf_pos, (int)size, (int)buf_size); - return -1; - } - - memcpy(buf + buf_pos, buffer, size); - buf_pos += size; - fprintf(stderr, " written %d (%d)\n", (int)size, (int)buf_pos); - - return 0; -} - -static void -compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) { - asn_enc_rval_t erval; - int i; - - buf_size = cmp_buf_size + 100; - buf = alloca(buf_size); - buf_pos = 0; - - /* - * Try to re-create using DER encoding. - */ - erval = der_encode(&asn_DEF_T, tp, buf_fill, 0); - assert(erval.encoded != -1); - if(erval.encoded != cmp_buf_size) { - printf("%d != %d\n", erval.encoded, cmp_buf_size); - } - assert(erval.encoded == cmp_buf_size); - for(i = 0; i < cmp_buf_size; i++) { - if(buf[i] != cmp_buf[i]) { - fprintf(stderr, "Recreated buffer content mismatch:\n"); - fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", - i, - buf[i], cmp_buf[i], - buf[i], cmp_buf[i] - ); - } - assert(buf[i] == cmp_buf[i]); - } -} - -static void -partial_read(uint8_t *buf_0, size_t size) { - T_t t, *tp; - asn_dec_rval_t rval; - size_t i1, i2; - uint8_t *buf_1 = alloca(size); - uint8_t *buf_2 = alloca(size); - uint8_t *buf_3 = alloca(size); - - fprintf(stderr, "\nPartial read sequence...\n"); - - /* - * Divide the space (size) into three blocks in various combinations: - * |<----->i1<----->i2<----->| - * ^ buf_0 ^ buf_0+size - * Try to read block by block. - */ - for(i1 = 0; i1 < size; i1++) { - for(i2 = i1; i2 < size; i2++) { - uint8_t *chunk1 = buf_0; - size_t size1 = i1; - uint8_t *chunk2 = buf_0 + size1; - size_t size2 = i2 - i1; - uint8_t *chunk3 = buf_0 + size1 + size2; - size_t size3 = size - size1 - size2; - - fprintf(stderr, "\n%d:{%d, %d, %d}...\n", - (int)size, (int)size1, (int)size2, (int)size3); - - memset(buf_1, 0, size); - memset(buf_2, 0, size); - memset(buf_3, 0, size); - memcpy(buf_1, chunk1, size1); - memcpy(buf_2, chunk2, size2); - memcpy(buf_3, chunk3, size3); - - tp = memset(&t, 0, sizeof(t)); - - fprintf(stderr, "=> Chunk 1 (%d):\n", (int)size1); - rval = ber_decode(0, &asn_DEF_T, (void **)&tp, - buf_1, size1); - assert(rval.code == RC_WMORE); - assert(rval.consumed <= size1); - if(rval.consumed < size1) { - int leftover = size1 - rval.consumed; - memcpy(buf_2, buf_1 + rval.consumed, leftover); - memcpy(buf_2 + leftover, chunk2, size2); - size2 += leftover; - } - - fprintf(stderr, "=> Chunk 2 (%d):\n", (int)size2); - rval = ber_decode(0, &asn_DEF_T, (void **)&tp, - buf_2, size2); - assert(rval.code == RC_WMORE); - assert(rval.consumed <= size2); - if(rval.consumed < size2) { - int leftover = size2 - rval.consumed; - memcpy(buf_3, buf_2 + rval.consumed, leftover); - memcpy(buf_3 + leftover, chunk3, size3); - size3 += leftover; - } - - fprintf(stderr, "=> Chunk 3 (%d):\n", (int)size3); - rval = ber_decode(0, &asn_DEF_T, (void **)&tp, - buf_3, size3); - assert(rval.code == RC_OK); - assert(rval.consumed == size3); - - asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); - } - } -} - -int -main(int ac, char **av) { - T_t t; - - (void)ac; /* Unused argument */ - (void)av; /* Unused argument */ - - /* Check exact buf1 */ - check(&t, buf1, sizeof(buf1), sizeof(buf1)); - compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); - asn_fprint(stderr, &asn_DEF_T, &t); - asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); - - /* Check slightly more than buf1 */ - check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1)); - compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); - asn_fprint(stderr, &asn_DEF_T, &t); - asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); - - /* Split the buffer in parts and check decoder restartability */ - partial_read(buf1, sizeof(buf1)); - - return 0; -} diff --git a/asn1c/tests/check-41.-fwide-types.c b/asn1c/tests/check-41.-fwide-types.c new file mode 100644 index 00000000..21717581 --- /dev/null +++ b/asn1c/tests/check-41.-fwide-types.c @@ -0,0 +1,322 @@ +#undef NDEBUG +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <string.h> +#include <assert.h> + +#include <T.h> + +uint8_t buf0[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 18, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 16, /* L */ + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', +}; + +uint8_t buf0_reconstr[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 18, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 16, /* L */ + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', +}; + + + +uint8_t buf1[] = { + 32 | (2 << 6), /* [0], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* alpha [1] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 1, /* [1] */ + 1, /* L */ + 75, +}; + +uint8_t buf1_reconstr[] = { + 32 | (2 << 6), /* [0], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* alpha [1] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 1, /* [1] */ + 1, /* L */ + 75, +}; + +uint8_t buf2[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* beta [2] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 2, /* [2] */ + 1, /* L */ + 75, +}; + +uint8_t buf2_reconstr[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* beta [2] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 2, /* [2] */ + 1, /* L */ + 75, +}; + + + + + +static void +check(T_t *tp, uint8_t *buf, int size, size_t consumed) { + asn_dec_rval_t rval; + int ret; + + tp = memset(tp, 0, sizeof(*tp)); + + fprintf(stderr, "Buf %p (%d)\n", (int)buf, (int)size); + rval = ber_decode(0, &asn_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + fprintf(stderr, "=== asn_fprint() ===\n"); + ret = asn_fprint(stderr, &asn_DEF_T, tp); + assert(ret == 0); + fprintf(stderr, "=== xer_fprint() ===\n"); + ret = xer_fprint(stderr, &asn_DEF_T, tp); + fprintf(stderr, "=== END ===\n"); + assert(ret == 0); + + /* + assert(tp->string.size == 128); + assert(strncmp(tp->string.buf, "zz") == 0); + assert(strcmp(tp->b.choice.b1.buf, "z") == 0 + && strcmp(tp->b.choice.b2.buf, "z") == 0); + */ +} + +size_t buf_pos; +size_t buf_size; +uint8_t *buffer; + +static int +buf_fill(const void *bufp, size_t size, void *app_key) { + + (void)app_key; /* Unused argument */ + + if(buf_pos + size > buf_size) { + fprintf(stderr, "%d + %d > %d\n", + (int)buf_pos, (int)size, (int)buf_size); + return -1; + } + + memcpy(buffer + buf_pos, bufp, size); + buf_pos += size; + fprintf(stderr, " written %d (%d)\n", (int)size, (int)buf_pos); + + return 0; +} + +static void +compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) { + asn_enc_rval_t erval; + int i; + + buf_size = cmp_buf_size + 100; + buffer = alloca(buf_size); + buf_pos = 0; + + /* + * Try to re-create using DER encoding. + */ + erval = der_encode(&asn_DEF_T, tp, buf_fill, 0); + assert(erval.encoded != -1); + if(erval.encoded != cmp_buf_size) { + printf("%d != %d\n", (int)erval.encoded, (int)cmp_buf_size); + } + assert(erval.encoded == cmp_buf_size); + for(i = 0; i < cmp_buf_size; i++) { + if(buffer[i] != cmp_buf[i]) { + fprintf(stderr, "Recreated buffer content mismatch:\n"); + fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", + i, + buffer[i], cmp_buf[i], + buffer[i], cmp_buf[i] + ); + } + assert(buffer[i] == cmp_buf[i]); + } +} + +static void +partial_read(uint8_t *buf, size_t size) { + T_t t, *tp; + asn_dec_rval_t rval; + size_t i1, i2; + uint8_t *buf1 = alloca(size); + uint8_t *buf2 = alloca(size); + uint8_t *buf3 = alloca(size); + + fprintf(stderr, "\nPartial read sequence...\n"); + + /* + * Divide the space (size) into three blocks in various combinations: + * |<----->i1<----->i2<----->| + * ^ buf ^ buf+size + * Try to read block by block. + */ + for(i1 = 0; i1 < size; i1++) { + for(i2 = i1; i2 < size; i2++) { + uint8_t *chunk1 = buf; + size_t size1 = i1; + uint8_t *chunk2 = buf + size1; + size_t size2 = i2 - i1; + uint8_t *chunk3 = buf + size1 + size2; + size_t size3 = size - size1 - size2; + + fprintf(stderr, "\n%d:{%d, %d, %d}...\n", + (int)size, (int)size1, (int)size2, (int)size3); + + memset(buf1, 0, size); + memset(buf2, 0, size); + memset(buf3, 0, size); + memcpy(buf1, chunk1, size1); + memcpy(buf2, chunk2, size2); + memcpy(buf3, chunk3, size3); + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "=> Chunk 1 (%d):\n", (int)size1); + rval = ber_decode(0, &asn_DEF_T, (void **)&tp, + buf1, size1); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size1); + if(rval.consumed < size1) { + int leftover = size1 - rval.consumed; + memcpy(buf2, buf1 + rval.consumed, leftover); + memcpy(buf2 + leftover, chunk2, size2); + size2 += leftover; + } + + fprintf(stderr, "=> Chunk 2 (%d):\n", (int)size2); + rval = ber_decode(0, &asn_DEF_T, (void **)&tp, + buf2, size2); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size2); + if(rval.consumed < size2) { + int leftover = size2 - rval.consumed; + memcpy(buf3, buf2 + rval.consumed, leftover); + memcpy(buf3 + leftover, chunk3, size3); + size3 += leftover; + } + + fprintf(stderr, "=> Chunk 3 (%d):\n", (int)size3); + rval = ber_decode(0, &asn_DEF_T, (void **)&tp, + buf3, size3); + assert(rval.code == RC_OK); + assert(rval.consumed == size3); + + asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); + } + } +} + +int +main() { + T_t t; + + /* Check exact buf0 */ + check(&t, buf0, sizeof(buf0), sizeof(buf0)); + compare(&t, buf0_reconstr, sizeof(buf0_reconstr)); + asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); + + /* Check exact buf1 */ + check(&t, buf1, sizeof(buf1), sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); + + /* Check slightly more than buf1 */ + check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); + + /* Check exact buf2 */ + check(&t, buf2, sizeof(buf2), sizeof(buf2)); + compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); + asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); + + /* Check slightly more than buf2 */ + check(&t, buf2, sizeof(buf2) + 10, sizeof(buf2)); + compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); + asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); + + /* Split the buffer in parts and check decoder restartability */ + partial_read(buf0, sizeof(buf0)); + + return 0; +} diff --git a/asn1c/tests/check-41.c b/asn1c/tests/check-41.c index 21717581..3b735ccf 100644 --- a/asn1c/tests/check-41.c +++ b/asn1c/tests/check-41.c @@ -7,136 +7,52 @@ #include <T.h> -uint8_t buf0[] = { - 32 | ((2 << 6) + 1), /* [1], constructed */ - 18, - - /* string [0] IMPLICIT UTF8String, */ - (2 << 6), /* [0] */ - 16, /* L */ - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', -}; - -uint8_t buf0_reconstr[] = { - 32 | ((2 << 6) + 1), /* [1], constructed */ - 18, - - /* string [0] IMPLICIT UTF8String, */ - (2 << 6), /* [0] */ - 16, /* L */ - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', -}; - - uint8_t buf1[] = { 32 | (2 << 6), /* [0], constructed */ - 0x80 | 1, /* L */ - 134, + 25, /* L */ /* string [0] IMPLICIT UTF8String, */ (2 << 6), /* [0] */ - 0x80 | 1, /* L */ - 128, - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 16, /* L */ 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - /* alpha [1] IMPLICIT INTEGER OPTIONAL */ - (2 << 6) + 1, /* [1] */ - 1, /* L */ + /* beta [2] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 2, /* [2] */ + 5, /* L */ + 0, + 75, + 0x4b, 75, -}; - -uint8_t buf1_reconstr[] = { - 32 | (2 << 6), /* [0], constructed */ - 0x80 | 1, /* L */ - 134, - - /* string [0] IMPLICIT UTF8String, */ - (2 << 6), /* [0] */ - 0x80 | 1, /* L */ - 128, - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - - /* alpha [1] IMPLICIT INTEGER OPTIONAL */ - (2 << 6) + 1, /* [1] */ - 1, /* L */ 75, }; -uint8_t buf2[] = { - 32 | ((2 << 6) + 1), /* [1], constructed */ - 0x80 | 1, /* L */ - 134, +uint8_t buf1_reconstr[] = { + 32 | (2 << 6), /* [0], constructed */ + 24, /* L */ /* string [0] IMPLICIT UTF8String, */ (2 << 6), /* [0] */ - 0x80 | 1, /* L */ - 128, - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 16, /* L */ 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', /* beta [2] IMPLICIT INTEGER OPTIONAL */ (2 << 6) + 2, /* [2] */ - 1, /* L */ + 4, /* L */ + 75, 75, -}; - -uint8_t buf2_reconstr[] = { - 32 | ((2 << 6) + 1), /* [1], constructed */ - 0x80 | 1, /* L */ - 134, - - /* string [0] IMPLICIT UTF8String, */ - (2 << 6), /* [0] */ - 0x80 | 1, /* L */ - 128, - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', - - /* beta [2] IMPLICIT INTEGER OPTIONAL */ - (2 << 6) + 2, /* [2] */ - 1, /* L */ 75, + 0x4b, }; - - - static void check(T_t *tp, uint8_t *buf, int size, size_t consumed) { asn_dec_rval_t rval; - int ret; tp = memset(tp, 0, sizeof(*tp)); - fprintf(stderr, "Buf %p (%d)\n", (int)buf, (int)size); + fprintf(stderr, "Buf %p (%d)\n", buf, size); rval = ber_decode(0, &asn_DEF_T, (void **)&tp, buf, size); fprintf(stderr, "Returned code %d, consumed %d\n", (int)rval.code, (int)rval.consumed); @@ -144,28 +60,19 @@ check(T_t *tp, uint8_t *buf, int size, size_t consumed) { assert(rval.code == RC_OK); assert(rval.consumed == consumed); - fprintf(stderr, "=== asn_fprint() ===\n"); - ret = asn_fprint(stderr, &asn_DEF_T, tp); - assert(ret == 0); - fprintf(stderr, "=== xer_fprint() ===\n"); - ret = xer_fprint(stderr, &asn_DEF_T, tp); - fprintf(stderr, "=== END ===\n"); - assert(ret == 0); - - /* - assert(tp->string.size == 128); - assert(strncmp(tp->string.buf, "zz") == 0); - assert(strcmp(tp->b.choice.b1.buf, "z") == 0 - && strcmp(tp->b.choice.b2.buf, "z") == 0); - */ + assert(tp->choice.seq.string.size == 16); + assert(strcmp(tp->choice.seq.string.buf, "zzzzzzzzzzzzzzzz") == 0); + assert(tp->choice.seq.alpha == NULL); + assert(tp->choice.seq.beta); + assert(*tp->choice.seq.beta == 0x4b4b4b4b); } size_t buf_pos; size_t buf_size; -uint8_t *buffer; +uint8_t *buf; static int -buf_fill(const void *bufp, size_t size, void *app_key) { +buf_fill(const void *buffer, size_t size, void *app_key) { (void)app_key; /* Unused argument */ @@ -175,7 +82,7 @@ buf_fill(const void *bufp, size_t size, void *app_key) { return -1; } - memcpy(buffer + buf_pos, bufp, size); + memcpy(buf + buf_pos, buffer, size); buf_pos += size; fprintf(stderr, " written %d (%d)\n", (int)size, (int)buf_pos); @@ -188,7 +95,7 @@ compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) { int i; buf_size = cmp_buf_size + 100; - buffer = alloca(buf_size); + buf = alloca(buf_size); buf_pos = 0; /* @@ -197,87 +104,87 @@ compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) { erval = der_encode(&asn_DEF_T, tp, buf_fill, 0); assert(erval.encoded != -1); if(erval.encoded != cmp_buf_size) { - printf("%d != %d\n", (int)erval.encoded, (int)cmp_buf_size); + printf("%d != %d\n", erval.encoded, cmp_buf_size); } assert(erval.encoded == cmp_buf_size); for(i = 0; i < cmp_buf_size; i++) { - if(buffer[i] != cmp_buf[i]) { + if(buf[i] != cmp_buf[i]) { fprintf(stderr, "Recreated buffer content mismatch:\n"); fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", i, - buffer[i], cmp_buf[i], - buffer[i], cmp_buf[i] + buf[i], cmp_buf[i], + buf[i], cmp_buf[i] ); } - assert(buffer[i] == cmp_buf[i]); + assert(buf[i] == cmp_buf[i]); } } static void -partial_read(uint8_t *buf, size_t size) { +partial_read(uint8_t *buf_0, size_t size) { T_t t, *tp; asn_dec_rval_t rval; size_t i1, i2; - uint8_t *buf1 = alloca(size); - uint8_t *buf2 = alloca(size); - uint8_t *buf3 = alloca(size); + uint8_t *buf_1 = alloca(size); + uint8_t *buf_2 = alloca(size); + uint8_t *buf_3 = alloca(size); fprintf(stderr, "\nPartial read sequence...\n"); /* * Divide the space (size) into three blocks in various combinations: * |<----->i1<----->i2<----->| - * ^ buf ^ buf+size + * ^ buf_0 ^ buf_0+size * Try to read block by block. */ for(i1 = 0; i1 < size; i1++) { for(i2 = i1; i2 < size; i2++) { - uint8_t *chunk1 = buf; + uint8_t *chunk1 = buf_0; size_t size1 = i1; - uint8_t *chunk2 = buf + size1; + uint8_t *chunk2 = buf_0 + size1; size_t size2 = i2 - i1; - uint8_t *chunk3 = buf + size1 + size2; + uint8_t *chunk3 = buf_0 + size1 + size2; size_t size3 = size - size1 - size2; fprintf(stderr, "\n%d:{%d, %d, %d}...\n", (int)size, (int)size1, (int)size2, (int)size3); - memset(buf1, 0, size); - memset(buf2, 0, size); - memset(buf3, 0, size); - memcpy(buf1, chunk1, size1); - memcpy(buf2, chunk2, size2); - memcpy(buf3, chunk3, size3); + memset(buf_1, 0, size); + memset(buf_2, 0, size); + memset(buf_3, 0, size); + memcpy(buf_1, chunk1, size1); + memcpy(buf_2, chunk2, size2); + memcpy(buf_3, chunk3, size3); tp = memset(&t, 0, sizeof(t)); fprintf(stderr, "=> Chunk 1 (%d):\n", (int)size1); rval = ber_decode(0, &asn_DEF_T, (void **)&tp, - buf1, size1); + buf_1, size1); assert(rval.code == RC_WMORE); assert(rval.consumed <= size1); if(rval.consumed < size1) { int leftover = size1 - rval.consumed; - memcpy(buf2, buf1 + rval.consumed, leftover); - memcpy(buf2 + leftover, chunk2, size2); + memcpy(buf_2, buf_1 + rval.consumed, leftover); + memcpy(buf_2 + leftover, chunk2, size2); size2 += leftover; } fprintf(stderr, "=> Chunk 2 (%d):\n", (int)size2); rval = ber_decode(0, &asn_DEF_T, (void **)&tp, - buf2, size2); + buf_2, size2); assert(rval.code == RC_WMORE); assert(rval.consumed <= size2); if(rval.consumed < size2) { int leftover = size2 - rval.consumed; - memcpy(buf3, buf2 + rval.consumed, leftover); - memcpy(buf3 + leftover, chunk3, size3); + memcpy(buf_3, buf_2 + rval.consumed, leftover); + memcpy(buf_3 + leftover, chunk3, size3); size3 += leftover; } fprintf(stderr, "=> Chunk 3 (%d):\n", (int)size3); rval = ber_decode(0, &asn_DEF_T, (void **)&tp, - buf3, size3); + buf_3, size3); assert(rval.code == RC_OK); assert(rval.consumed == size3); @@ -287,36 +194,26 @@ partial_read(uint8_t *buf, size_t size) { } int -main() { +main(int ac, char **av) { T_t t; - /* Check exact buf0 */ - check(&t, buf0, sizeof(buf0), sizeof(buf0)); - compare(&t, buf0_reconstr, sizeof(buf0_reconstr)); - asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); + (void)ac; /* Unused argument */ + (void)av; /* Unused argument */ /* Check exact buf1 */ check(&t, buf1, sizeof(buf1), sizeof(buf1)); compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_fprint(stderr, &asn_DEF_T, &t); asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); /* Check slightly more than buf1 */ check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1)); compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); - asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); - - /* Check exact buf2 */ - check(&t, buf2, sizeof(buf2), sizeof(buf2)); - compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); - asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); - - /* Check slightly more than buf2 */ - check(&t, buf2, sizeof(buf2) + 10, sizeof(buf2)); - compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); + asn_fprint(stderr, &asn_DEF_T, &t); asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); /* Split the buffer in parts and check decoder restartability */ - partial_read(buf0, sizeof(buf0)); + partial_read(buf1, sizeof(buf1)); return 0; } diff --git a/asn1c/tests/check-42.-fnative-types.c b/asn1c/tests/check-42.c index 9afa800a..9afa800a 100644 --- a/asn1c/tests/check-42.-fnative-types.c +++ b/asn1c/tests/check-42.c diff --git a/asn1c/tests/check-60.-fnative-types.c b/asn1c/tests/check-60.c index 3dc8e539..3dc8e539 100644 --- a/asn1c/tests/check-60.-fnative-types.c +++ b/asn1c/tests/check-60.c diff --git a/asn1c/tests/check-70.-fnative-types.c b/asn1c/tests/check-70.-fwide-types.c index 8538f5eb..46a974a1 100644 --- a/asn1c/tests/check-70.-fnative-types.c +++ b/asn1c/tests/check-70.-fwide-types.c @@ -2,7 +2,7 @@ * Mode of operation: * Each of the *.in files is XER-decoded, then converted into DER, * then decoded from DER and encoded into XER again. The resulting - * stream is compared with the corresponding .out file. + * stream is checked against rules specified in ../data-70/README file. */ #undef NDEBUG #include <stdio.h> @@ -11,7 +11,6 @@ #include <unistd.h> /* for chdir(2) */ #include <string.h> #include <dirent.h> -#include <ctype.h> /* for isspace(3) */ #include <assert.h> #include <errno.h> @@ -19,6 +18,8 @@ enum expectation { EXP_OK, /* Encoding/decoding must succeed */ + EXP_CXER_EXACT, /* Encoding/decoding using CXER must be exact */ + EXP_CXER_DIFF, /* Encoding/decoding using CXER must be different */ EXP_BROKEN, /* Decoding must fail */ EXP_DIFFERENT, /* Reconstruction will yield different encoding */ }; @@ -35,8 +36,12 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { b = buf + buf_offset; bend = b + size; fprintf(stderr, "=> ["); - for(; b < bend; b++) - fprintf(stderr, "%c", *b); + for(; b < bend; b++) { + if(*b >= 32 && *b < 127 && *b != '%') + fprintf(stderr, "%c", *b); + else + fprintf(stderr, "%%%02x", *b); + } fprintf(stderr, "]:%ld\n", (long)size); buf_offset += size; return 0; @@ -45,6 +50,7 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { enum der_or_xer { AS_DER, AS_XER, + AS_CXER, }; static void @@ -65,6 +71,10 @@ save_object_as(PDU_t *st, enum der_or_xer how) { rval = xer_encode(&asn_DEF_PDU, st, XER_F_BASIC, _buf_writer, 0); break; + case AS_CXER: + rval = xer_encode(&asn_DEF_PDU, st, XER_F_CANONICAL, + _buf_writer, 0); + break; } if (rval.encoded == -1) { fprintf(stderr, @@ -188,6 +198,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) { static void process_XER_data(enum expectation expectation, char *fbuf, int size) { PDU_t *st; + int ret; st = load_object_from(expectation, fbuf, size, AS_XER); if(!st) return; @@ -197,7 +208,10 @@ process_XER_data(enum expectation expectation, char *fbuf, int size) { st = load_object_from(expectation, buf, buf_offset, AS_DER); assert(st); - save_object_as(st, AS_XER); + save_object_as(st, + (expectation == EXP_CXER_EXACT + || expectation == EXP_CXER_DIFF) + ? AS_CXER : AS_XER); fprintf(stderr, "=== original ===\n"); fwrite(fbuf, 1, size, stderr); fprintf(stderr, "=== re-encoded ===\n"); @@ -211,6 +225,16 @@ process_XER_data(enum expectation expectation, char *fbuf, int size) { case EXP_BROKEN: assert(!xer_encoding_equal(fbuf, size, buf, buf_offset)); break; + case EXP_CXER_EXACT: + buf[buf_offset++] = '\n'; + assert(size == buf_offset); + assert(memcmp(fbuf, buf, size) == 0); + break; + case EXP_CXER_DIFF: + buf[buf_offset++] = '\n'; + assert(size != buf_offset + || memcmp(fbuf, buf, size)); + break; case EXP_OK: assert(xer_encoding_equal(fbuf, size, buf, buf_offset)); break; @@ -237,10 +261,12 @@ process(const char *fname) { switch(ext[-1]) { case 'B': /* The file is intentionally broken */ expectation = EXP_BROKEN; break; - case 'X': case 'D': /* Reconstructing should yield different data */ expectation = EXP_DIFFERENT; break; - case 'E': + case 'E': /* Byte to byte exact reconstruction */ + expectation = EXP_CXER_EXACT; break; + case 'X': /* Should fail byte-to-byte comparison */ + expectation = EXP_CXER_DIFF; break; default: expectation = EXP_OK; break; } @@ -250,7 +276,7 @@ process(const char *fname) { ret = chdir("../data-70"); assert(ret == 0); fp = fopen(fname, "r"); - ret = chdir("../test-check-70.-fnative-types"); + ret = chdir("../test-check-70.-fwide-types"); assert(ret == 0); assert(fp); @@ -273,8 +299,10 @@ main() { /* Process a specific test file */ str = getenv("DATA_70_FILE"); - if(str && strncmp(str, "data-70-", 8) == 0) + if(str && strncmp(str, "data-70-", 8) == 0) { process(str); + return 0; + } dir = opendir("../data-70"); assert(dir); diff --git a/asn1c/tests/check-70.c b/asn1c/tests/check-70.c index f21d659a..7f681661 100644 --- a/asn1c/tests/check-70.c +++ b/asn1c/tests/check-70.c @@ -2,7 +2,7 @@ * Mode of operation: * Each of the *.in files is XER-decoded, then converted into DER, * then decoded from DER and encoded into XER again. The resulting - * stream is checked against rules specified in ../data-70/README file. + * stream is compared with the corresponding .out file. */ #undef NDEBUG #include <stdio.h> @@ -11,6 +11,7 @@ #include <unistd.h> /* for chdir(2) */ #include <string.h> #include <dirent.h> +#include <ctype.h> /* for isspace(3) */ #include <assert.h> #include <errno.h> @@ -18,8 +19,6 @@ enum expectation { EXP_OK, /* Encoding/decoding must succeed */ - EXP_CXER_EXACT, /* Encoding/decoding using CXER must be exact */ - EXP_CXER_DIFF, /* Encoding/decoding using CXER must be different */ EXP_BROKEN, /* Decoding must fail */ EXP_DIFFERENT, /* Reconstruction will yield different encoding */ }; @@ -36,12 +35,8 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { b = buf + buf_offset; bend = b + size; fprintf(stderr, "=> ["); - for(; b < bend; b++) { - if(*b >= 32 && *b < 127 && *b != '%') - fprintf(stderr, "%c", *b); - else - fprintf(stderr, "%%%02x", *b); - } + for(; b < bend; b++) + fprintf(stderr, "%c", *b); fprintf(stderr, "]:%ld\n", (long)size); buf_offset += size; return 0; @@ -50,7 +45,6 @@ _buf_writer(const void *buffer, size_t size, void *app_key) { enum der_or_xer { AS_DER, AS_XER, - AS_CXER, }; static void @@ -71,10 +65,6 @@ save_object_as(PDU_t *st, enum der_or_xer how) { rval = xer_encode(&asn_DEF_PDU, st, XER_F_BASIC, _buf_writer, 0); break; - case AS_CXER: - rval = xer_encode(&asn_DEF_PDU, st, XER_F_CANONICAL, - _buf_writer, 0); - break; } if (rval.encoded == -1) { fprintf(stderr, @@ -198,7 +188,6 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) { static void process_XER_data(enum expectation expectation, char *fbuf, int size) { PDU_t *st; - int ret; st = load_object_from(expectation, fbuf, size, AS_XER); if(!st) return; @@ -208,10 +197,7 @@ process_XER_data(enum expectation expectation, char *fbuf, int size) { st = load_object_from(expectation, buf, buf_offset, AS_DER); assert(st); - save_object_as(st, - (expectation == EXP_CXER_EXACT - || expectation == EXP_CXER_DIFF) - ? AS_CXER : AS_XER); + save_object_as(st, AS_XER); fprintf(stderr, "=== original ===\n"); fwrite(fbuf, 1, size, stderr); fprintf(stderr, "=== re-encoded ===\n"); @@ -225,16 +211,6 @@ process_XER_data(enum expectation expectation, char *fbuf, int size) { case EXP_BROKEN: assert(!xer_encoding_equal(fbuf, size, buf, buf_offset)); break; - case EXP_CXER_EXACT: - buf[buf_offset++] = '\n'; - assert(size == buf_offset); - assert(memcmp(fbuf, buf, size) == 0); - break; - case EXP_CXER_DIFF: - buf[buf_offset++] = '\n'; - assert(size != buf_offset - || memcmp(fbuf, buf, size)); - break; case EXP_OK: assert(xer_encoding_equal(fbuf, size, buf, buf_offset)); break; @@ -261,12 +237,10 @@ process(const char *fname) { switch(ext[-1]) { case 'B': /* The file is intentionally broken */ expectation = EXP_BROKEN; break; + case 'X': case 'D': /* Reconstructing should yield different data */ expectation = EXP_DIFFERENT; break; - case 'E': /* Byte to byte exact reconstruction */ - expectation = EXP_CXER_EXACT; break; - case 'X': /* Should fail byte-to-byte comparison */ - expectation = EXP_CXER_DIFF; break; + case 'E': default: expectation = EXP_OK; break; } @@ -299,10 +273,8 @@ main() { /* Process a specific test file */ str = getenv("DATA_70_FILE"); - if(str && strncmp(str, "data-70-", 8) == 0) { + if(str && strncmp(str, "data-70-", 8) == 0) process(str); - return 0; - } dir = opendir("../data-70"); assert(dir); diff --git a/doc/asn1c-usage.pdf b/doc/asn1c-usage.pdf Binary files differindex 9e677948..9cc2ee31 100644 --- a/doc/asn1c-usage.pdf +++ b/doc/asn1c-usage.pdf diff --git a/doc/docsrc/asn1c-usage.tex b/doc/docsrc/asn1c-usage.tex index b0a6d848..73221028 100644 --- a/doc/docsrc/asn1c-usage.tex +++ b/doc/docsrc/asn1c-usage.tex @@ -64,7 +64,7 @@ } \lstnewenvironment{codesample}[1][]{\lstset{style=listingStyle,language=C,#1}}{} -\lstnewenvironment{bash}[1][]{\lstset{style=listingStyle,morekeywords={-fnative-types},language=bash,#1}}{} +\lstnewenvironment{bash}[1][]{\lstset{style=listingStyle,language=bash,#1}}{} \lstnewenvironment{asn}[1][]{\lstset{style=listingStyle,language=asn1,#1}}{} \def\code{lstinline} @@ -155,12 +155,6 @@ to find out about \textbf{-P} and \textbf{-R} options.% \begin{bash} asn1c %\emph{<modules.asn1>}% \end{bash} -The asn1c takes a number of command line options, -such as an option to produce native long types -for integers instead of infinite width INTEGER\_t structures: -\begin{bash} -asn1c %\textbf{-fnative-types} \emph{<modules.asn1>}% -\end{bash} If several ASN.1 modules contain interdependencies, all of the files must be specified altogether: \begin{bash} @@ -169,7 +163,7 @@ asn1c %\emph{<module1.asn1> <module2.asn1> ...}% The compiler \textbf{-E} and \textbf{-EF} options are used for testing the parser and the semantic fixer, respectively. These options will instruct the compiler to dump out the parsed (and fixed, if \textbf{-F} -is involved) ASN.1 specification as it was ``understood'' +is involved) ASN.1 specification as it was understood by the compiler. It might be useful to check whether a particular syntactic construct is properly supported by the compiler. \begin{bash} @@ -188,6 +182,7 @@ Print the compiled output instead of creating multiple source files: asn1c %\textbf{-P} \emph{<module-to-compile-and-print.asn1>}% \end{bash} +\clearpage{} \section{Recognizing compiler output} The asn1c compiler produces a number of files: @@ -207,12 +202,12 @@ or the plain `make` utility. Just rename it into \emph{Makefile}. \end{itemize} It is possible to compile everything with just a couple of instructions: \begin{bash} -asn1c -fnative-types -pdu=%\emph{Rectangle}% *.asn1 +asn1c -pdu=%\emph{Rectangle}% *.asn1 make -f Makefile.am.sample # If you use `make` \end{bash} or \begin{bash} -asn1c -fnative-types *.asn1 +asn1c *.asn1 cc -I. -DPDU=%\emph{Rectangle}% -o rectangle.exe *.c # ... or like this \end{bash} Refer to the Chapter \vref{cha:Step-by-step-examples} for a sample @@ -261,15 +256,12 @@ to prevent circular references. }\\ {-fknown-extern-type=}\emph{<name>} & {\small Pretend the specified type is known. The compiler will assume the target language source files for the given type have been provided manually. }\\ -{-fnative-types} & {\small Use the native machine's data types (long, double) whenever -possible, instead of the compound INTEGER\_t, ENUMERATED\_t and REAL\_t -types. }\\ {-fno-constraints} & {\small Do not generate ASN.1 subtype constraint checking code. This may produce a shorter executable.}\\ {-fno-include-deps} & {\small Do not generate courtesy \#include lines for non-critical dependencies.}\\ -{-funnamed-unions} & {\small Enable unnamed unions in the definitions of target language's -structures.}\\\\ +{-funnamed-unions} & {\small Enable unnamed unions in the definitions of target language's structures.}\\ +{-fwide-types} & {\small Use the wide integer types (INTEGER\_t, REAL\_t) instead of machine's native data types (long, double). }\\\\ \textbf{Codecs Generation Options} & \textbf{Description}\\ \midrule {-gen-PER} & {\small Generate Packed Encoding Rules (PER) support code.}\\ @@ -702,7 +694,7 @@ END \item Compile it into the set of .c and .h files using asn1c compiler \cite{ASN1C}: \begin{bash} -asn1c -fnative-types %\textbf{rectangle.asn1}% +asn1c %\textbf{rectangle.asn1}% \end{bash} \item Alternatively, use the Online ASN.1 compiler \cite{AONL} by uploading the \textbf{rectangle.asn1} file into the Web form and unpacking the @@ -799,7 +791,7 @@ END \item Compile it into the set of .c and .h files using asn1c compiler \cite{ASN1C}: \begin{bash} -asn1c -fnative-types %\textbf{rectangle.asn1}% +asn1c %\textbf{rectangle.asn1}% \end{bash} \item Alternatively, use the Online ASN.1 compiler \cite{AONL} by uploading the \textbf{rectangle.asn1} file into the Web form and unpacking the diff --git a/libasn1compiler/asn1c_constraint.c b/libasn1compiler/asn1c_constraint.c index e9d796de..c957623e 100644 --- a/libasn1compiler/asn1c_constraint.c +++ b/libasn1compiler/asn1c_constraint.c @@ -78,7 +78,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) { produce_st = 1; break; case ASN_BASIC_REAL: - if(!(arg->flags & A1C_USE_NATIVE_TYPES)) + if((arg->flags & A1C_USE_WIDE_TYPES)) produce_st = 1; break; case ASN_BASIC_BIT_STRING: @@ -656,9 +656,7 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_rang } break; case ASN_BASIC_REAL: - if(arg->flags & A1C_USE_NATIVE_TYPES) { - OUT("value = *(const double *)sptr;\n"); - } else { + if(arg->flags & A1C_USE_WIDE_TYPES) { OUT("if(asn_REAL2double(st, &value)) {\n"); INDENT(+1); OUT("_ASN_CTFAIL(app_key, td, sptr,\n"); @@ -667,6 +665,8 @@ emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_rang OUT("return -1;\n"); INDENT(-1); OUT("}\n"); + } else { + OUT("value = *(const double *)sptr;\n"); } break; case ASN_BASIC_BOOLEAN: diff --git a/libasn1compiler/asn1c_misc.c b/libasn1compiler/asn1c_misc.c index dcda8a91..0ccd3362 100644 --- a/libasn1compiler/asn1c_misc.c +++ b/libasn1compiler/asn1c_misc.c @@ -16,7 +16,7 @@ static char *res_kwd[] = { "union", "unsigned", "void", "volatile", "while", "_Bool", "_Complex", "_Imaginary", /* C++ */ - "explicit", "bool", "mutable", + "class", "explicit", "bool", "mutable", "template", "typeid", "typename", "and", "and_eq", "or", "or_eq", "xor", "xor_eq", "not", "not_eq", "bitor", "compl", "bitand", @@ -214,7 +214,7 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { case ASN_BASIC_ENUMERATED: case ASN_BASIC_REAL: if((expr->expr_type == ASN_BASIC_REAL - && (arg->flags & A1C_USE_NATIVE_TYPES)) + && !(arg->flags & A1C_USE_WIDE_TYPES)) || asn1c_type_fits_long(arg, expr)) { switch(_format) { case TNF_CTYPE: @@ -333,8 +333,8 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) { } if(!expr->combined_constraints) - return (arg->flags & A1C_USE_NATIVE_TYPES) - ? FL_FORCED : FL_NOTFIT; + return (arg->flags & A1C_USE_WIDE_TYPES) + ? FL_NOTFIT : FL_PRESUMED; /* * Second, if -fbless-SIZE is given, the (SIZE()) constraint may be @@ -366,8 +366,8 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) { || range->not_PER_visible ) { asn1constraint_range_free(range); - return (arg->flags & A1C_USE_NATIVE_TYPES) - ? FL_FORCED : FL_NOTFIT; + return (arg->flags & A1C_USE_WIDE_TYPES) + ? FL_NOTFIT : FL_PRESUMED; } left = range->left; @@ -391,10 +391,10 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) { && (right.value > RIGHTMAX || right.value < LEFTMIN)) return FL_NOTFIT; - /* If the range is open, fits only if -fnative-types is given */ + /* If the range is open, fits only unless -fwide-types is given */ if(left.type != ARE_VALUE || right.type != ARE_VALUE) { - return (arg->flags & A1C_USE_NATIVE_TYPES) - ? FL_FORCED : FL_NOTFIT; + return (arg->flags & A1C_USE_WIDE_TYPES) + ? FL_NOTFIT : FL_PRESUMED; } return FL_FITS_SIGNED; diff --git a/libasn1compiler/asn1c_misc.h b/libasn1compiler/asn1c_misc.h index 6e2acb51..4cb26acd 100644 --- a/libasn1compiler/asn1c_misc.h +++ b/libasn1compiler/asn1c_misc.h @@ -32,13 +32,13 @@ char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format); * FL_NOTFIT: No, it cannot be represented using long. * FL_FITS_SIGNED: It can be represented using signed long. * FL_FITS_UNSIGN: It can be represented using unsigned long. - * FL_FORCED: Probably can't, but -fnative-types is in force. + * FL_PRESUMED: Probably can't, but -fwide-types is not in effect. */ enum asn1c_fitslong_e { FL_NOTFIT, FL_FITS_SIGNED, FL_FITS_UNSIGN, - FL_FORCED, + FL_PRESUMED, }; enum asn1c_fitslong_e asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr); diff --git a/libasn1compiler/asn1compiler.h b/libasn1compiler/asn1compiler.h index 93755da9..a19f147f 100644 --- a/libasn1compiler/asn1compiler.h +++ b/libasn1compiler/asn1compiler.h @@ -20,9 +20,9 @@ enum asn1c_flags { */ A1C_OMIT_SUPPORT_CODE = 0x0004, /* - * Use native data types instead of INTEGER_t et al. + * Use wide types by default (INTEGER_t etc) instead of native/long. */ - A1C_USE_NATIVE_TYPES = 0x0008, + A1C_USE_WIDE_TYPES = 0x0008, /* * Do not use C99 extensions. */ diff --git a/tests/03-enum-OK.asn1.-P b/tests/03-enum-OK.asn1.-Pfwide-types index d2e8ad0f..d2e8ad0f 100644 --- a/tests/03-enum-OK.asn1.-P +++ b/tests/03-enum-OK.asn1.-Pfwide-types diff --git a/tests/104-param-1-OK.asn1.-P b/tests/104-param-1-OK.asn1.-Pfwide-types index 24f4a64a..24f4a64a 100644 --- a/tests/104-param-1-OK.asn1.-P +++ b/tests/104-param-1-OK.asn1.-Pfwide-types diff --git a/tests/105-param-2-OK.asn1.-P b/tests/105-param-2-OK.asn1.-Pfwide-types index 8a9b9f86..8a9b9f86 100644 --- a/tests/105-param-2-OK.asn1.-P +++ b/tests/105-param-2-OK.asn1.-Pfwide-types diff --git a/tests/108-param-constr-3-OK.asn1.-P b/tests/108-param-constr-3-OK.asn1.-Pfwide-types index b0903001..b0903001 100644 --- a/tests/108-param-constr-3-OK.asn1.-P +++ b/tests/108-param-constr-3-OK.asn1.-Pfwide-types diff --git a/tests/110-param-3-OK.asn1.-P b/tests/110-param-3-OK.asn1.-Pfwide-types index 9bd39a9b..9bd39a9b 100644 --- a/tests/110-param-3-OK.asn1.-P +++ b/tests/110-param-3-OK.asn1.-Pfwide-types diff --git a/tests/119-per-strings-OK.asn1.-Pgen-PER b/tests/119-per-strings-OK.asn1.-Pgen-PER index 3a24fda9..d21d818d 100644 --- a/tests/119-per-strings-OK.asn1.-Pgen-PER +++ b/tests/119-per-strings-OK.asn1.-Pgen-PER @@ -8,7 +8,7 @@ #include <UTF8String.h> #include <BMPString.h> #include <UniversalString.h> -#include <REAL.h> +#include <NativeReal.h> #include <OBJECT_IDENTIFIER.h> #include <asn_SEQUENCE_OF.h> #include <constr_SEQUENCE_OF.h> @@ -55,7 +55,7 @@ typedef struct PDU { UniversalString_t *us_cs /* OPTIONAL */; UniversalString_t *us_ce /* OPTIONAL */; UniversalString_t *us_ir /* OPTIONAL */; - REAL_t *real /* OPTIONAL */; + double *real /* OPTIONAL */; OBJECT_IDENTIFIER_t *oid /* OPTIONAL */; /* Context for parsing across buffer boundaries */ @@ -1492,7 +1492,7 @@ static asn_TYPE_member_t asn_MBR_PDU_1[] = { { ATF_POINTER, 2, offsetof(struct PDU, real), .tag = (ASN_TAG_CLASS_CONTEXT | (29 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = &asn_DEF_REAL, + .type = &asn_DEF_NativeReal, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* No PER visible constraints */ .default_value = 0, diff --git a/tests/125-bitstring-constraint-OK.asn1.-X b/tests/125-bitstring-constraint-OK.asn1.-X index 64a21c41..2cccb90b 100644 --- a/tests/125-bitstring-constraint-OK.asn1.-X +++ b/tests/125-bitstring-constraint-OK.asn1.-X @@ -1,4 +1,4 @@ -<!-- XML DTD generated by asn1c-0.9.22 --> +<!-- XML DTD generated by asn1c-0.9.24 --> <!-- ASN.1 module ModuleBitStringConstraint { iso org(3) dod(6) internet(1) private(4) diff --git a/tests/126-per-extensions-OK.asn1.-Pgen-PER b/tests/126-per-extensions-OK.asn1.-Pgen-PER index 91aac0cc..2bb515f1 100644 --- a/tests/126-per-extensions-OK.asn1.-Pgen-PER +++ b/tests/126-per-extensions-OK.asn1.-Pgen-PER @@ -222,7 +222,7 @@ asn_TYPE_descriptor_t asn_DEF_Singleton = { /*** <<< INCLUDES [PDU-2] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> #include <constr_CHOICE.h> /*** <<< DEPS [PDU-2] >>> ***/ @@ -240,13 +240,13 @@ typedef enum PDU_2_PR { typedef struct PDU_2 { PDU_2_PR present; union PDU_2_u { - INTEGER_t main; + long main; /* * This type is extensible, * possible extensions are below. */ - INTEGER_t ext1; - INTEGER_t ext0; + long ext1; + long ext0; } choice; /* Context for parsing across buffer boundaries */ @@ -271,7 +271,7 @@ static asn_TYPE_member_t asn_MBR_PDU_2_1[] = { { ATF_NOFLAGS, 0, offsetof(struct PDU_2, choice.main), .tag = (ASN_TAG_CLASS_CONTEXT | (3 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = &asn_DEF_INTEGER, + .type = &asn_DEF_NativeInteger, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* No PER visible constraints */ .default_value = 0, @@ -280,7 +280,7 @@ static asn_TYPE_member_t asn_MBR_PDU_2_1[] = { { ATF_NOFLAGS, 0, offsetof(struct PDU_2, choice.ext1), .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = &asn_DEF_INTEGER, + .type = &asn_DEF_NativeInteger, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* No PER visible constraints */ .default_value = 0, @@ -289,7 +289,7 @@ static asn_TYPE_member_t asn_MBR_PDU_2_1[] = { { ATF_NOFLAGS, 0, offsetof(struct PDU_2, choice.ext0), .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = &asn_DEF_INTEGER, + .type = &asn_DEF_NativeInteger, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* No PER visible constraints */ .default_value = 0, diff --git a/tests/127-per-long-OK.asn1.-Pgen-PER b/tests/127-per-long-OK.asn1.-Pgen-PER index 439468bd..ab541953 100644 --- a/tests/127-per-long-OK.asn1.-Pgen-PER +++ b/tests/127-per-long-OK.asn1.-Pgen-PER @@ -27,7 +27,6 @@ extern asn_TYPE_descriptor_t asn_DEF_T; static int unsigned32_4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - unsigned long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, @@ -36,7 +35,6 @@ unsigned32_4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const unsigned long *)sptr; /* Constraint check succeeded */ return 0; @@ -280,7 +278,6 @@ memb_full32range_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, static int memb_unsigned32_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - unsigned long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, @@ -289,7 +286,6 @@ memb_unsigned32_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const unsigned long *)sptr; /* Constraint check succeeded */ return 0; diff --git a/tests/19-param-OK.asn1.-P b/tests/19-param-OK.asn1.-Pfwide-types index eedbc1bf..eedbc1bf 100644 --- a/tests/19-param-OK.asn1.-P +++ b/tests/19-param-OK.asn1.-Pfwide-types diff --git a/tests/22-tags-OK.asn1.-P b/tests/22-tags-OK.asn1.-Pfwide-types index 988e7293..988e7293 100644 --- a/tests/22-tags-OK.asn1.-P +++ b/tests/22-tags-OK.asn1.-Pfwide-types diff --git a/tests/30-set-OK.asn1.-P b/tests/30-set-OK.asn1.-Pfwide-types index c4f65d41..c4f65d41 100644 --- a/tests/30-set-OK.asn1.-P +++ b/tests/30-set-OK.asn1.-Pfwide-types diff --git a/tests/31-set-of-OK.asn1.-P b/tests/31-set-of-OK.asn1.-Pfwide-types index 576f5c45..576f5c45 100644 --- a/tests/31-set-of-OK.asn1.-P +++ b/tests/31-set-of-OK.asn1.-Pfwide-types diff --git a/tests/37-indirect-choice-OK.asn1.-P b/tests/37-indirect-choice-OK.asn1.-Pfwide-types index 48e97aec..48e97aec 100644 --- a/tests/37-indirect-choice-OK.asn1.-P +++ b/tests/37-indirect-choice-OK.asn1.-Pfwide-types diff --git a/tests/39-sequence-of-OK.asn1.-P b/tests/39-sequence-of-OK.asn1.-Pfwide-types index 4e6ed8c8..4e6ed8c8 100644 --- a/tests/39-sequence-of-OK.asn1.-P +++ b/tests/39-sequence-of-OK.asn1.-Pfwide-types diff --git a/tests/42-real-life-OK.asn1.-PR b/tests/42-real-life-OK.asn1.-PR index 0fd30dca..3a2c1b0e 100644 --- a/tests/42-real-life-OK.asn1.-PR +++ b/tests/42-real-life-OK.asn1.-PR @@ -589,7 +589,7 @@ asn_TYPE_descriptor_t asn_DEF_VariablePart = { /*** <<< INCLUDES [ActionItem] >>> ***/ -#include <ENUMERATED.h> +#include <NativeEnumerated.h> #include <BOOLEAN.h> #include <VisibleString.h> #include <asn_SET_OF.h> @@ -610,7 +610,7 @@ typedef enum accept_as { /*** <<< TYPE-DECLS [ActionItem] >>> ***/ typedef struct ActionItem { - ENUMERATED_t accept_as; + long accept_as; struct notify { BOOLEAN_t critical; struct email { @@ -647,29 +647,29 @@ static int accept_as_2_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_ENUMERATED.check_constraints; + td->check_constraints = asn_DEF_NativeEnumerated.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using ENUMERATED, + * This type is implemented using NativeEnumerated, * so here we adjust the DEF accordingly. */ static void accept_as_2_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { - td->free_struct = asn_DEF_ENUMERATED.free_struct; - td->print_struct = asn_DEF_ENUMERATED.print_struct; - td->ber_decoder = asn_DEF_ENUMERATED.ber_decoder; - td->der_encoder = asn_DEF_ENUMERATED.der_encoder; - td->xer_decoder = asn_DEF_ENUMERATED.xer_decoder; - td->xer_encoder = asn_DEF_ENUMERATED.xer_encoder; - td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; - td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; + td->free_struct = asn_DEF_NativeEnumerated.free_struct; + td->print_struct = asn_DEF_NativeEnumerated.print_struct; + td->ber_decoder = asn_DEF_NativeEnumerated.ber_decoder; + td->der_encoder = asn_DEF_NativeEnumerated.der_encoder; + td->xer_decoder = asn_DEF_NativeEnumerated.xer_decoder; + td->xer_encoder = asn_DEF_NativeEnumerated.xer_encoder; + td->uper_decoder = asn_DEF_NativeEnumerated.uper_decoder; + td->uper_encoder = asn_DEF_NativeEnumerated.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; - td->elements = asn_DEF_ENUMERATED.elements; - td->elements_count = asn_DEF_ENUMERATED.elements_count; - /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined explicitly */ + td->per_constraints = asn_DEF_NativeEnumerated.per_constraints; + td->elements = asn_DEF_NativeEnumerated.elements; + td->elements_count = asn_DEF_NativeEnumerated.elements_count; + /* td->specifics = asn_DEF_NativeEnumerated.specifics; // Defined explicitly */ } static void diff --git a/tests/43-recursion-OK.asn1.-P b/tests/43-recursion-OK.asn1.-Pfwide-types index 3f2555c0..7cbc587e 100644 --- a/tests/43-recursion-OK.asn1.-P +++ b/tests/43-recursion-OK.asn1.-Pfwide-types @@ -239,14 +239,14 @@ struct Choice_1; typedef struct Choice_1 { Choice_1_PR present; union Choice_1_u { - struct Choice_1 *and; - struct or { + struct Choice_1 *And; + struct Or { A_SET_OF(struct Choice_1) list; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; - } or; - struct Choice_1 *not; + } Or; + struct Choice_1 *Not; INTEGER_t other; } choice; @@ -280,8 +280,8 @@ static ber_tlv_tag_t asn_DEF_or_tags_3[] = { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) }; static asn_SET_OF_specifics_t asn_SPC_or_specs_3 = { - sizeof(struct or), - offsetof(struct or, _asn_ctx), + sizeof(struct Or), + offsetof(struct Or, _asn_ctx), 2, /* XER encoding is XMLValueList */ }; static /* Use -fall-defs-global to expose */ @@ -310,7 +310,7 @@ asn_TYPE_descriptor_t asn_DEF_or_3 = { }; static asn_TYPE_member_t asn_MBR_Choice_1_1[] = { - { ATF_POINTER, 0, offsetof(struct Choice_1, choice.and), + { ATF_POINTER, 0, offsetof(struct Choice_1, choice.And), .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), .tag_mode = +1, /* EXPLICIT tag at current level */ .type = &asn_DEF_Choice_1, @@ -319,7 +319,7 @@ static asn_TYPE_member_t asn_MBR_Choice_1_1[] = { .default_value = 0, .name = "and" }, - { ATF_NOFLAGS, 0, offsetof(struct Choice_1, choice.or), + { ATF_NOFLAGS, 0, offsetof(struct Choice_1, choice.Or), .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), .tag_mode = 0, .type = &asn_DEF_or_3, @@ -328,7 +328,7 @@ static asn_TYPE_member_t asn_MBR_Choice_1_1[] = { .default_value = 0, .name = "or" }, - { ATF_POINTER, 0, offsetof(struct Choice_1, choice.not), + { ATF_POINTER, 0, offsetof(struct Choice_1, choice.Not), .tag = (ASN_TAG_CLASS_CONTEXT | (3 << 2)), .tag_mode = +1, /* EXPLICIT tag at current level */ .type = &asn_DEF_Choice_1, diff --git a/tests/47-set-ext-OK.asn1.-P b/tests/47-set-ext-OK.asn1.-Pfwide-types index 0f08cd28..0f08cd28 100644 --- a/tests/47-set-ext-OK.asn1.-P +++ b/tests/47-set-ext-OK.asn1.-Pfwide-types diff --git a/tests/50-constraint-OK.asn1.-P b/tests/50-constraint-OK.asn1.-Pfwide-types index 5fcd1a91..36f29446 100644 --- a/tests/50-constraint-OK.asn1.-P +++ b/tests/50-constraint-OK.asn1.-Pfwide-types @@ -3515,7 +3515,7 @@ typedef struct Sequence { Int1_t *int1_c /* DEFAULT 3 */; Int4_t int4; Int4_t int4_c; - BOOLEAN_t *bool /* DEFAULT 1 */; + BOOLEAN_t *Bool /* DEFAULT 1 */; ENUMERATED_t enum_c; NULL_t *null /* OPTIONAL */; /* @@ -3818,7 +3818,7 @@ static asn_TYPE_member_t asn_MBR_Sequence_1[] = { .default_value = 0, .name = "int4-c" }, - { ATF_POINTER, 1, offsetof(struct Sequence, bool), + { ATF_POINTER, 1, offsetof(struct Sequence, Bool), .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), .tag_mode = 0, .type = &asn_DEF_BOOLEAN, diff --git a/tests/50-constraint-OK.asn1.-Pgen-PER b/tests/50-constraint-OK.asn1.-Pgen-PER index 74903a6a..17645532 100644 --- a/tests/50-constraint-OK.asn1.-Pgen-PER +++ b/tests/50-constraint-OK.asn1.-Pgen-PER @@ -1,11 +1,11 @@ /*** <<< INCLUDES [Int1] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [Int1] >>> ***/ -typedef INTEGER_t Int1_t; +typedef long Int1_t; /*** <<< FUNC-DECLS [Int1] >>> ***/ @@ -26,29 +26,29 @@ int Int1_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_INTEGER.check_constraints; + td->check_constraints = asn_DEF_NativeInteger.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void Int1_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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -167,7 +167,6 @@ per_type_encoder_f Int2_encode_uper; int Int2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const Int1_t *st = (const Int1_t *)sptr; long value; if(!sptr) { @@ -177,8 +176,7 @@ Int2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - /* Check if the sign bit is present */ - value = st->buf ? ((st->buf[0] & 0x80) ? -1 : 1) : 0; + value = *(const long *)sptr; if((value >= 0)) { /* Constraint check succeeded */ @@ -336,7 +334,6 @@ per_type_encoder_f Int3_encode_uper; int Int3_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const Int2_t *st = (const Int2_t *)sptr; long value; if(!sptr) { @@ -346,12 +343,7 @@ Int3_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= 0 && value <= 10)) { /* Constraint check succeeded */ @@ -509,7 +501,6 @@ per_type_encoder_f Int4_encode_uper; int Int4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const Int3_t *st = (const Int3_t *)sptr; long value; if(!sptr) { @@ -519,12 +510,7 @@ Int4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= 1 && value <= 10)) { /* Constraint check succeeded */ @@ -682,7 +668,6 @@ per_type_encoder_f Int5_encode_uper; int Int5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const Int4_t *st = (const Int4_t *)sptr; long value; if(!sptr) { @@ -692,12 +677,7 @@ Int5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value == 5)) { /* Constraint check succeeded */ @@ -831,11 +811,11 @@ asn_TYPE_descriptor_t asn_DEF_Int5 = { /*** <<< INCLUDES [ExtensibleExtensions] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [ExtensibleExtensions] >>> ***/ -typedef INTEGER_t ExtensibleExtensions_t; +typedef long ExtensibleExtensions_t; /*** <<< FUNC-DECLS [ExtensibleExtensions] >>> ***/ @@ -855,7 +835,6 @@ per_type_encoder_f ExtensibleExtensions_encode_uper; int ExtensibleExtensions_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -865,12 +844,7 @@ ExtensibleExtensions_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= 1 && value <= 256)) { /* Constraint check succeeded */ @@ -884,24 +858,24 @@ ExtensibleExtensions_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 ExtensibleExtensions_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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -4080,7 +4054,7 @@ asn_TYPE_descriptor_t asn_DEF_VisibleIdentifier = { #include "Int1.h" #include "Int4.h" #include <BOOLEAN.h> -#include <ENUMERATED.h> +#include <NativeEnumerated.h> #include <NULL.h> #include "Int5.h" #include <constr_SEQUENCE.h> @@ -4102,8 +4076,8 @@ typedef struct Sequence { Int1_t *int1_c /* DEFAULT 3 */; Int4_t int4; Int4_t int4_c; - BOOLEAN_t *bool /* DEFAULT 1 */; - ENUMERATED_t enum_c; + BOOLEAN_t *Bool /* DEFAULT 1 */; + long enum_c; NULL_t *null /* OPTIONAL */; /* * This type is extensible, @@ -4126,29 +4100,29 @@ static int enum_c_6_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_ENUMERATED.check_constraints; + td->check_constraints = asn_DEF_NativeEnumerated.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using ENUMERATED, + * This type is implemented using NativeEnumerated, * so here we adjust the DEF accordingly. */ static void enum_c_6_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { - td->free_struct = asn_DEF_ENUMERATED.free_struct; - td->print_struct = asn_DEF_ENUMERATED.print_struct; - td->ber_decoder = asn_DEF_ENUMERATED.ber_decoder; - td->der_encoder = asn_DEF_ENUMERATED.der_encoder; - td->xer_decoder = asn_DEF_ENUMERATED.xer_decoder; - td->xer_encoder = asn_DEF_ENUMERATED.xer_encoder; - td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; - td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; + td->free_struct = asn_DEF_NativeEnumerated.free_struct; + td->print_struct = asn_DEF_NativeEnumerated.print_struct; + td->ber_decoder = asn_DEF_NativeEnumerated.ber_decoder; + td->der_encoder = asn_DEF_NativeEnumerated.der_encoder; + td->xer_decoder = asn_DEF_NativeEnumerated.xer_decoder; + td->xer_encoder = asn_DEF_NativeEnumerated.xer_encoder; + td->uper_decoder = asn_DEF_NativeEnumerated.uper_decoder; + td->uper_encoder = asn_DEF_NativeEnumerated.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; - td->elements = asn_DEF_ENUMERATED.elements; - td->elements_count = asn_DEF_ENUMERATED.elements_count; - /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined explicitly */ + td->per_constraints = asn_DEF_NativeEnumerated.per_constraints; + td->elements = asn_DEF_NativeEnumerated.elements; + td->elements_count = asn_DEF_NativeEnumerated.elements_count; + /* td->specifics = asn_DEF_NativeEnumerated.specifics; // Defined explicitly */ } static void @@ -4213,7 +4187,6 @@ enum_c_6_encode_uper(asn_TYPE_descriptor_t *td, static int memb_int1_c_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const Int1_t *st = (const Int1_t *)sptr; long value; if(!sptr) { @@ -4223,12 +4196,7 @@ memb_int1_c_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= -2)) { /* Constraint check succeeded */ @@ -4244,7 +4212,6 @@ memb_int1_c_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, static int memb_int4_c_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const Int4_t *st = (const Int4_t *)sptr; long value; if(!sptr) { @@ -4254,12 +4221,7 @@ memb_int4_c_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= 5 && value <= 7)) { /* Constraint check succeeded */ @@ -4275,7 +4237,6 @@ memb_int4_c_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, static int memb_int5_c_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const Int5_t *st = (const Int5_t *)sptr; long value; if(!sptr) { @@ -4285,12 +4246,7 @@ memb_int5_c_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value == 5)) { /* Constraint check succeeded */ @@ -4340,13 +4296,11 @@ static int asn_DFL_2_set_3(int set_value, void **sptr) { if(set_value) { /* Install default value 3 */ - return asn_long2INTEGER(st, 3); + *st = 3; + return 0; } else { /* Test default value 3 */ - long value; - if(asn_INTEGER2long(st, &value)) - return -1; - return (value == 3); + return (*st == 3); } } static int asn_DFL_5_set_1(int set_value, void **sptr) { @@ -4444,7 +4398,7 @@ static asn_TYPE_member_t asn_MBR_Sequence_1[] = { .default_value = 0, .name = "int4-c" }, - { ATF_POINTER, 1, offsetof(struct Sequence, bool), + { ATF_POINTER, 1, offsetof(struct Sequence, Bool), .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), .tag_mode = 0, .type = &asn_DEF_BOOLEAN, @@ -4613,7 +4567,7 @@ asn_TYPE_descriptor_t asn_DEF_SequenceOf = { /*** <<< INCLUDES [Enum0] >>> ***/ -#include <ENUMERATED.h> +#include <NativeEnumerated.h> /*** <<< DEPS [Enum0] >>> ***/ @@ -4624,7 +4578,7 @@ typedef enum Enum0 { /*** <<< TYPE-DECLS [Enum0] >>> ***/ -typedef ENUMERATED_t Enum0_t; +typedef long Enum0_t; /*** <<< FUNC-DECLS [Enum0] >>> ***/ @@ -4645,29 +4599,29 @@ int Enum0_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_ENUMERATED.check_constraints; + td->check_constraints = asn_DEF_NativeEnumerated.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using ENUMERATED, + * This type is implemented using NativeEnumerated, * so here we adjust the DEF accordingly. */ static void Enum0_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { - td->free_struct = asn_DEF_ENUMERATED.free_struct; - td->print_struct = asn_DEF_ENUMERATED.print_struct; - td->ber_decoder = asn_DEF_ENUMERATED.ber_decoder; - td->der_encoder = asn_DEF_ENUMERATED.der_encoder; - td->xer_decoder = asn_DEF_ENUMERATED.xer_decoder; - td->xer_encoder = asn_DEF_ENUMERATED.xer_encoder; - td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder; - td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder; + td->free_struct = asn_DEF_NativeEnumerated.free_struct; + td->print_struct = asn_DEF_NativeEnumerated.print_struct; + td->ber_decoder = asn_DEF_NativeEnumerated.ber_decoder; + td->der_encoder = asn_DEF_NativeEnumerated.der_encoder; + td->xer_decoder = asn_DEF_NativeEnumerated.xer_decoder; + td->xer_encoder = asn_DEF_NativeEnumerated.xer_encoder; + td->uper_decoder = asn_DEF_NativeEnumerated.uper_decoder; + td->uper_encoder = asn_DEF_NativeEnumerated.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_ENUMERATED.per_constraints; - td->elements = asn_DEF_ENUMERATED.elements; - td->elements_count = asn_DEF_ENUMERATED.elements_count; - /* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined explicitly */ + td->per_constraints = asn_DEF_NativeEnumerated.per_constraints; + td->elements = asn_DEF_NativeEnumerated.elements; + td->elements_count = asn_DEF_NativeEnumerated.elements_count; + /* td->specifics = asn_DEF_NativeEnumerated.specifics; // Defined explicitly */ } void diff --git a/tests/59-choice-extended-OK.asn1.-P b/tests/59-choice-extended-OK.asn1.-Pfwide-types index 3684a91f..3684a91f 100644 --- a/tests/59-choice-extended-OK.asn1.-P +++ b/tests/59-choice-extended-OK.asn1.-Pfwide-types diff --git a/tests/60-any-OK.asn1.-P b/tests/60-any-OK.asn1.-Pfwide-types index 4b507d1a..4b507d1a 100644 --- a/tests/60-any-OK.asn1.-P +++ b/tests/60-any-OK.asn1.-Pfwide-types diff --git a/tests/65-multi-tag-OK.asn1.-P b/tests/65-multi-tag-OK.asn1.-Pfwide-types index 7547825a..7547825a 100644 --- a/tests/65-multi-tag-OK.asn1.-P +++ b/tests/65-multi-tag-OK.asn1.-Pfwide-types diff --git a/tests/66-ref-simple-OK.asn1.-P b/tests/66-ref-simple-OK.asn1.-Pfwide-types index 9d315e24..9d315e24 100644 --- a/tests/66-ref-simple-OK.asn1.-P +++ b/tests/66-ref-simple-OK.asn1.-Pfwide-types diff --git a/tests/69-reserved-words-OK.asn1.-P b/tests/69-reserved-words-OK.asn1.-Pfwide-types index 4ee72ad4..4ee72ad4 100644 --- a/tests/69-reserved-words-OK.asn1.-P +++ b/tests/69-reserved-words-OK.asn1.-Pfwide-types diff --git a/tests/70-xer-test-OK.asn1.-P b/tests/70-xer-test-OK.asn1.-Pfwide-types index e109a8b3..e109a8b3 100644 --- a/tests/70-xer-test-OK.asn1.-P +++ b/tests/70-xer-test-OK.asn1.-Pfwide-types diff --git a/tests/72-same-names-OK.asn1.-P b/tests/72-same-names-OK.asn1.-Pfwide-types index 43b78130..43b78130 100644 --- a/tests/72-same-names-OK.asn1.-P +++ b/tests/72-same-names-OK.asn1.-Pfwide-types diff --git a/tests/73-circular-OK.asn1.-P b/tests/73-circular-OK.asn1.-Pfwide-types index fe581b66..fe581b66 100644 --- a/tests/73-circular-OK.asn1.-P +++ b/tests/73-circular-OK.asn1.-Pfwide-types diff --git a/tests/84-param-tags-OK.asn1.-P b/tests/84-param-tags-OK.asn1.-Pfwide-types index 66749420..66749420 100644 --- a/tests/84-param-tags-OK.asn1.-P +++ b/tests/84-param-tags-OK.asn1.-Pfwide-types diff --git a/tests/88-integer-enum-OK.asn1.-P b/tests/88-integer-enum-OK.asn1.-Pfwide-types index 38c1a799..38c1a799 100644 --- a/tests/88-integer-enum-OK.asn1.-P +++ b/tests/88-integer-enum-OK.asn1.-Pfwide-types diff --git a/tests/89-bit-string-enum-OK.asn1.-P b/tests/89-bit-string-enum-OK.asn1.-Pfwide-types index 663ec3f3..663ec3f3 100644 --- a/tests/89-bit-string-enum-OK.asn1.-P +++ b/tests/89-bit-string-enum-OK.asn1.-Pfwide-types diff --git a/tests/90-cond-int-type-OK.asn1.-P b/tests/90-cond-int-type-OK.asn1.-P index 08f92d4d..f21ce035 100644 --- a/tests/90-cond-int-type-OK.asn1.-P +++ b/tests/90-cond-int-type-OK.asn1.-P @@ -1,11 +1,11 @@ /*** <<< INCLUDES [CN-IntegerUnlimited] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [CN-IntegerUnlimited] >>> ***/ -typedef INTEGER_t CN_IntegerUnlimited_t; +typedef long CN_IntegerUnlimited_t; /*** <<< FUNC-DECLS [CN-IntegerUnlimited] >>> ***/ @@ -24,29 +24,29 @@ int CN_IntegerUnlimited_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_INTEGER.check_constraints; + td->check_constraints = asn_DEF_NativeInteger.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void CN_IntegerUnlimited_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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -125,11 +125,11 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerUnlimited = { /*** <<< INCLUDES [CN-IntegerMinMax] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [CN-IntegerMinMax] >>> ***/ -typedef INTEGER_t CN_IntegerMinMax_t; +typedef long CN_IntegerMinMax_t; /*** <<< FUNC-DECLS [CN-IntegerMinMax] >>> ***/ @@ -147,7 +147,6 @@ xer_type_encoder_f CN_IntegerMinMax_encode_xer; int CN_IntegerMinMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, @@ -162,29 +161,29 @@ CN_IntegerMinMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* Replace with underlying type checker */ - td->check_constraints = asn_DEF_INTEGER.check_constraints; + td->check_constraints = asn_DEF_NativeInteger.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void CN_IntegerMinMax_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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -263,11 +262,11 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerMinMax = { /*** <<< INCLUDES [CN-IntegerMinLow] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [CN-IntegerMinLow] >>> ***/ -typedef INTEGER_t CN_IntegerMinLow_t; +typedef long CN_IntegerMinLow_t; /*** <<< FUNC-DECLS [CN-IntegerMinLow] >>> ***/ @@ -285,7 +284,6 @@ xer_type_encoder_f CN_IntegerMinLow_encode_xer; int CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -295,12 +293,7 @@ CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value <= 1)) { /* Constraint check succeeded */ @@ -314,24 +307,24 @@ 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -703,11 +696,11 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerLowHigh = { /*** <<< INCLUDES [CN-IntegerLowMax] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [CN-IntegerLowMax] >>> ***/ -typedef INTEGER_t CN_IntegerLowMax_t; +typedef long CN_IntegerLowMax_t; /*** <<< FUNC-DECLS [CN-IntegerLowMax] >>> ***/ @@ -725,7 +718,6 @@ xer_type_encoder_f CN_IntegerLowMax_encode_xer; int CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -735,12 +727,7 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= 1)) { /* Constraint check succeeded */ @@ -754,24 +741,24 @@ 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -2000,11 +1987,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange4 = { /*** <<< INCLUDES [OK-IntegerInRange5] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [OK-IntegerInRange5] >>> ***/ -typedef INTEGER_t OK_IntegerInRange5_t; +typedef long OK_IntegerInRange5_t; /*** <<< FUNC-DECLS [OK-IntegerInRange5] >>> ***/ @@ -2022,7 +2009,6 @@ xer_type_encoder_f OK_IntegerInRange5_encode_xer; int OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -2032,12 +2018,7 @@ OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if(((value == (-2147483647L - 1)) || (value == 2147483647))) { /* Constraint check succeeded */ @@ -2051,24 +2032,24 @@ 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -2169,7 +2150,6 @@ xer_type_encoder_f NO_IntegerInRange6_encode_xer; int NO_IntegerInRange6_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - unsigned long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, @@ -2178,7 +2158,6 @@ NO_IntegerInRange6_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const unsigned long *)sptr; /* Constraint check succeeded */ return 0; @@ -2286,7 +2265,7 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerInRange6 = { /*** <<< INCLUDES [CN-IntegerEnumerated1] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< DEPS [CN-IntegerEnumerated1] >>> ***/ @@ -2297,7 +2276,7 @@ typedef enum CN_IntegerEnumerated1 { /*** <<< TYPE-DECLS [CN-IntegerEnumerated1] >>> ***/ -typedef INTEGER_t CN_IntegerEnumerated1_t; +typedef long CN_IntegerEnumerated1_t; /*** <<< FUNC-DECLS [CN-IntegerEnumerated1] >>> ***/ @@ -2316,29 +2295,29 @@ int CN_IntegerEnumerated1_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_INTEGER.check_constraints; + td->check_constraints = asn_DEF_NativeInteger.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using INTEGER, + * 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_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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void diff --git a/tests/90-cond-int-type-OK.asn1.-Pfnative-types b/tests/90-cond-int-type-OK.asn1.-Pfwide-types index 4c898f8f..29edfe00 100644 --- a/tests/90-cond-int-type-OK.asn1.-Pfnative-types +++ b/tests/90-cond-int-type-OK.asn1.-Pfwide-types @@ -1,11 +1,11 @@ /*** <<< INCLUDES [CN-IntegerUnlimited] >>> ***/ -#include <NativeInteger.h> +#include <INTEGER.h> /*** <<< TYPE-DECLS [CN-IntegerUnlimited] >>> ***/ -typedef long CN_IntegerUnlimited_t; +typedef INTEGER_t CN_IntegerUnlimited_t; /*** <<< FUNC-DECLS [CN-IntegerUnlimited] >>> ***/ @@ -24,29 +24,29 @@ int CN_IntegerUnlimited_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_NativeInteger.check_constraints; + td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using NativeInteger, + * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void CN_IntegerUnlimited_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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; - td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; + 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; + td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; - td->elements = asn_DEF_NativeInteger.elements; - td->elements_count = asn_DEF_NativeInteger.elements_count; - td->specifics = asn_DEF_NativeInteger.specifics; + td->per_constraints = asn_DEF_INTEGER.per_constraints; + td->elements = asn_DEF_INTEGER.elements; + td->elements_count = asn_DEF_INTEGER.elements_count; + td->specifics = asn_DEF_INTEGER.specifics; } void @@ -125,11 +125,11 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerUnlimited = { /*** <<< INCLUDES [CN-IntegerMinMax] >>> ***/ -#include <NativeInteger.h> +#include <INTEGER.h> /*** <<< TYPE-DECLS [CN-IntegerMinMax] >>> ***/ -typedef long CN_IntegerMinMax_t; +typedef INTEGER_t CN_IntegerMinMax_t; /*** <<< FUNC-DECLS [CN-IntegerMinMax] >>> ***/ @@ -147,6 +147,7 @@ xer_type_encoder_f CN_IntegerMinMax_encode_xer; int CN_IntegerMinMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { + const INTEGER_t *st = (const INTEGER_t *)sptr; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, @@ -161,29 +162,29 @@ CN_IntegerMinMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* Replace with underlying type checker */ - td->check_constraints = asn_DEF_NativeInteger.check_constraints; + td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using NativeInteger, + * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */ static void CN_IntegerMinMax_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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; - td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; + 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; + td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; - td->elements = asn_DEF_NativeInteger.elements; - td->elements_count = asn_DEF_NativeInteger.elements_count; - td->specifics = asn_DEF_NativeInteger.specifics; + td->per_constraints = asn_DEF_INTEGER.per_constraints; + td->elements = asn_DEF_INTEGER.elements; + td->elements_count = asn_DEF_INTEGER.elements_count; + td->specifics = asn_DEF_INTEGER.specifics; } void @@ -262,11 +263,11 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerMinMax = { /*** <<< INCLUDES [CN-IntegerMinLow] >>> ***/ -#include <NativeInteger.h> +#include <INTEGER.h> /*** <<< TYPE-DECLS [CN-IntegerMinLow] >>> ***/ -typedef long CN_IntegerMinLow_t; +typedef INTEGER_t CN_IntegerMinLow_t; /*** <<< FUNC-DECLS [CN-IntegerMinLow] >>> ***/ @@ -284,6 +285,7 @@ xer_type_encoder_f CN_IntegerMinLow_encode_xer; int CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { + const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -293,7 +295,12 @@ CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const long *)sptr; + if(asn_INTEGER2long(st, &value)) { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value too large (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } if((value <= 1)) { /* Constraint check succeeded */ @@ -307,24 +314,24 @@ CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using NativeInteger, + * This type is implemented using INTEGER, * 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_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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; - td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; + 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; + td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; - td->elements = asn_DEF_NativeInteger.elements; - td->elements_count = asn_DEF_NativeInteger.elements_count; - td->specifics = asn_DEF_NativeInteger.specifics; + td->per_constraints = asn_DEF_INTEGER.per_constraints; + td->elements = asn_DEF_INTEGER.elements; + td->elements_count = asn_DEF_INTEGER.elements_count; + td->specifics = asn_DEF_INTEGER.specifics; } void @@ -696,11 +703,11 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerLowHigh = { /*** <<< INCLUDES [CN-IntegerLowMax] >>> ***/ -#include <NativeInteger.h> +#include <INTEGER.h> /*** <<< TYPE-DECLS [CN-IntegerLowMax] >>> ***/ -typedef long CN_IntegerLowMax_t; +typedef INTEGER_t CN_IntegerLowMax_t; /*** <<< FUNC-DECLS [CN-IntegerLowMax] >>> ***/ @@ -718,6 +725,7 @@ xer_type_encoder_f CN_IntegerLowMax_encode_xer; int CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { + const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -727,7 +735,12 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const long *)sptr; + if(asn_INTEGER2long(st, &value)) { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value too large (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } if((value >= 1)) { /* Constraint check succeeded */ @@ -741,24 +754,24 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using NativeInteger, + * This type is implemented using INTEGER, * 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_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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; - td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; + 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; + td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; - td->elements = asn_DEF_NativeInteger.elements; - td->elements_count = asn_DEF_NativeInteger.elements_count; - td->specifics = asn_DEF_NativeInteger.specifics; + td->per_constraints = asn_DEF_INTEGER.per_constraints; + td->elements = asn_DEF_INTEGER.elements; + td->elements_count = asn_DEF_INTEGER.elements_count; + td->specifics = asn_DEF_INTEGER.specifics; } void @@ -1987,11 +2000,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange4 = { /*** <<< INCLUDES [OK-IntegerInRange5] >>> ***/ -#include <NativeInteger.h> +#include <INTEGER.h> /*** <<< TYPE-DECLS [OK-IntegerInRange5] >>> ***/ -typedef long OK_IntegerInRange5_t; +typedef INTEGER_t OK_IntegerInRange5_t; /*** <<< FUNC-DECLS [OK-IntegerInRange5] >>> ***/ @@ -2009,6 +2022,7 @@ xer_type_encoder_f OK_IntegerInRange5_encode_xer; int OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { + const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -2018,7 +2032,12 @@ OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const long *)sptr; + if(asn_INTEGER2long(st, &value)) { + _ASN_CTFAIL(app_key, td, sptr, + "%s: value too large (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } if(((value == (-2147483647L - 1)) || (value == 2147483647))) { /* Constraint check succeeded */ @@ -2032,24 +2051,24 @@ OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* - * This type is implemented using NativeInteger, + * This type is implemented using INTEGER, * 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_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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; - td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; + 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; + td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; - td->elements = asn_DEF_NativeInteger.elements; - td->elements_count = asn_DEF_NativeInteger.elements_count; - td->specifics = asn_DEF_NativeInteger.specifics; + td->per_constraints = asn_DEF_INTEGER.per_constraints; + td->elements = asn_DEF_INTEGER.elements; + td->elements_count = asn_DEF_INTEGER.elements_count; + td->specifics = asn_DEF_INTEGER.specifics; } void @@ -2150,7 +2169,6 @@ xer_type_encoder_f NO_IntegerInRange6_encode_xer; int NO_IntegerInRange6_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - unsigned long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, @@ -2159,7 +2177,6 @@ NO_IntegerInRange6_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const unsigned long *)sptr; /* Constraint check succeeded */ return 0; @@ -2267,7 +2284,7 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerInRange6 = { /*** <<< INCLUDES [CN-IntegerEnumerated1] >>> ***/ -#include <NativeInteger.h> +#include <INTEGER.h> /*** <<< DEPS [CN-IntegerEnumerated1] >>> ***/ @@ -2278,7 +2295,7 @@ typedef enum CN_IntegerEnumerated1 { /*** <<< TYPE-DECLS [CN-IntegerEnumerated1] >>> ***/ -typedef long CN_IntegerEnumerated1_t; +typedef INTEGER_t CN_IntegerEnumerated1_t; /*** <<< FUNC-DECLS [CN-IntegerEnumerated1] >>> ***/ @@ -2297,29 +2314,29 @@ int CN_IntegerEnumerated1_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_NativeInteger.check_constraints; + td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using NativeInteger, + * 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_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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; - td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; + 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; + td->uper_encoder = asn_DEF_INTEGER.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_NativeInteger.per_constraints; - td->elements = asn_DEF_NativeInteger.elements; - td->elements_count = asn_DEF_NativeInteger.elements_count; - td->specifics = asn_DEF_NativeInteger.specifics; + td->per_constraints = asn_DEF_INTEGER.per_constraints; + td->elements = asn_DEF_INTEGER.elements; + td->elements_count = asn_DEF_INTEGER.elements_count; + td->specifics = asn_DEF_INTEGER.specifics; } void diff --git a/tests/90-cond-int-type-OK.asn1.-Pgen-PER b/tests/90-cond-int-type-OK.asn1.-Pgen-PER index 5b16f460..01b0abc9 100644 --- a/tests/90-cond-int-type-OK.asn1.-Pgen-PER +++ b/tests/90-cond-int-type-OK.asn1.-Pgen-PER @@ -1,11 +1,11 @@ /*** <<< INCLUDES [CN-IntegerUnlimited] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [CN-IntegerUnlimited] >>> ***/ -typedef INTEGER_t CN_IntegerUnlimited_t; +typedef long CN_IntegerUnlimited_t; /*** <<< FUNC-DECLS [CN-IntegerUnlimited] >>> ***/ @@ -26,29 +26,29 @@ int CN_IntegerUnlimited_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_INTEGER.check_constraints; + td->check_constraints = asn_DEF_NativeInteger.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void CN_IntegerUnlimited_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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -143,11 +143,11 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerUnlimited = { /*** <<< INCLUDES [CN-IntegerMinMax] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [CN-IntegerMinMax] >>> ***/ -typedef INTEGER_t CN_IntegerMinMax_t; +typedef long CN_IntegerMinMax_t; /*** <<< FUNC-DECLS [CN-IntegerMinMax] >>> ***/ @@ -167,7 +167,6 @@ per_type_encoder_f CN_IntegerMinMax_encode_uper; int CN_IntegerMinMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, @@ -182,29 +181,29 @@ CN_IntegerMinMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* Replace with underlying type checker */ - td->check_constraints = asn_DEF_INTEGER.check_constraints; + td->check_constraints = asn_DEF_NativeInteger.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void CN_IntegerMinMax_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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -307,11 +306,11 @@ asn_TYPE_descriptor_t asn_DEF_CN_IntegerMinMax = { /*** <<< INCLUDES [CN-IntegerMinLow] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [CN-IntegerMinLow] >>> ***/ -typedef INTEGER_t CN_IntegerMinLow_t; +typedef long CN_IntegerMinLow_t; /*** <<< FUNC-DECLS [CN-IntegerMinLow] >>> ***/ @@ -331,7 +330,6 @@ per_type_encoder_f CN_IntegerMinLow_encode_uper; int CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -341,12 +339,7 @@ CN_IntegerMinLow_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value <= 1)) { /* Constraint check succeeded */ @@ -360,24 +353,24 @@ 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -825,11 +818,11 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerLowHigh = { /*** <<< INCLUDES [CN-IntegerLowMax] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [CN-IntegerLowMax] >>> ***/ -typedef INTEGER_t CN_IntegerLowMax_t; +typedef long CN_IntegerLowMax_t; /*** <<< FUNC-DECLS [CN-IntegerLowMax] >>> ***/ @@ -849,7 +842,6 @@ per_type_encoder_f CN_IntegerLowMax_encode_uper; int CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -859,12 +851,7 @@ CN_IntegerLowMax_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if((value >= 1)) { /* Constraint check succeeded */ @@ -878,24 +865,24 @@ 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -2356,11 +2343,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_IntegerInRange4 = { /*** <<< INCLUDES [OK-IntegerInRange5] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [OK-IntegerInRange5] >>> ***/ -typedef INTEGER_t OK_IntegerInRange5_t; +typedef long OK_IntegerInRange5_t; /*** <<< FUNC-DECLS [OK-IntegerInRange5] >>> ***/ @@ -2380,7 +2367,6 @@ per_type_encoder_f OK_IntegerInRange5_encode_uper; int OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; long value; if(!sptr) { @@ -2390,12 +2376,7 @@ OK_IntegerInRange5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - if(asn_INTEGER2long(st, &value)) { - _ASN_CTFAIL(app_key, td, sptr, - "%s: value too large (%s:%d)", - td->name, __FILE__, __LINE__); - return -1; - } + value = *(const long *)sptr; if(((value == (-2147483647L - 1)) || (value == 2147483647))) { /* Constraint check succeeded */ @@ -2409,24 +2390,24 @@ 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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void @@ -2553,7 +2534,6 @@ per_type_encoder_f NO_IntegerInRange6_encode_uper; int NO_IntegerInRange6_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - unsigned long value; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, @@ -2562,7 +2542,6 @@ NO_IntegerInRange6_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const unsigned long *)sptr; /* Constraint check succeeded */ return 0; @@ -2694,7 +2673,7 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerInRange6 = { /*** <<< INCLUDES [CN-IntegerEnumerated1] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< DEPS [CN-IntegerEnumerated1] >>> ***/ @@ -2705,7 +2684,7 @@ typedef enum CN_IntegerEnumerated1 { /*** <<< TYPE-DECLS [CN-IntegerEnumerated1] >>> ***/ -typedef INTEGER_t CN_IntegerEnumerated1_t; +typedef long CN_IntegerEnumerated1_t; /*** <<< FUNC-DECLS [CN-IntegerEnumerated1] >>> ***/ @@ -2726,29 +2705,29 @@ int CN_IntegerEnumerated1_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_INTEGER.check_constraints; + td->check_constraints = asn_DEF_NativeInteger.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using INTEGER, + * 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_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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void diff --git a/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE b/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE index 27b3dc2a..a917aca3 100644 --- a/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE +++ b/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE @@ -549,11 +549,11 @@ asn_TYPE_descriptor_t asn_DEF_OK_Integer4 = { /*** <<< INCLUDES [NO-Integer5] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> /*** <<< TYPE-DECLS [NO-Integer5] >>> ***/ -typedef INTEGER_t NO_Integer5_t; +typedef long NO_Integer5_t; /*** <<< FUNC-DECLS [NO-Integer5] >>> ***/ @@ -571,7 +571,6 @@ xer_type_encoder_f NO_Integer5_encode_xer; int NO_Integer5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - const INTEGER_t *st = (const INTEGER_t *)sptr; if(!sptr) { _ASN_CTFAIL(app_key, td, sptr, @@ -586,29 +585,29 @@ NO_Integer5_constraint(asn_TYPE_descriptor_t *td, const void *sptr, } /* Replace with underlying type checker */ - td->check_constraints = asn_DEF_INTEGER.check_constraints; + td->check_constraints = asn_DEF_NativeInteger.check_constraints; return td->check_constraints(td, sptr, ctfailcb, app_key); } /* - * This type is implemented using INTEGER, + * This type is implemented using NativeInteger, * so here we adjust the DEF accordingly. */ static void NO_Integer5_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->uper_decoder = asn_DEF_INTEGER.uper_decoder; - td->uper_encoder = asn_DEF_INTEGER.uper_encoder; + 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->uper_decoder = asn_DEF_NativeInteger.uper_decoder; + td->uper_encoder = asn_DEF_NativeInteger.uper_encoder; if(!td->per_constraints) - td->per_constraints = asn_DEF_INTEGER.per_constraints; - td->elements = asn_DEF_INTEGER.elements; - td->elements_count = asn_DEF_INTEGER.elements_count; - td->specifics = asn_DEF_INTEGER.specifics; + td->per_constraints = asn_DEF_NativeInteger.per_constraints; + td->elements = asn_DEF_NativeInteger.elements; + td->elements_count = asn_DEF_NativeInteger.elements_count; + td->specifics = asn_DEF_NativeInteger.specifics; } void diff --git a/tests/92-circular-loops-OK.asn1.-Pfindirect-choice b/tests/92-circular-loops-OK.asn1.-Pfindirect-choice index 939056ec..94dfbb9c 100644 --- a/tests/92-circular-loops-OK.asn1.-Pfindirect-choice +++ b/tests/92-circular-loops-OK.asn1.-Pfindirect-choice @@ -614,7 +614,7 @@ asn_TYPE_descriptor_t asn_DEF_Choice3 = { /*** <<< INCLUDES [Set] >>> ***/ #include <asn_SET_OF.h> -#include <INTEGER.h> +#include <NativeInteger.h> #include <constr_SEQUENCE.h> #include <constr_SET_OF.h> @@ -627,7 +627,7 @@ struct Sequence; typedef struct Set { A_SET_OF(struct Member { - INTEGER_t Int; + long Int; struct Set *set; struct Sequence *seq; struct Set *set2 /* OPTIONAL */; @@ -660,7 +660,7 @@ static asn_TYPE_member_t asn_MBR_Member_2[] = { { ATF_NOFLAGS, 0, offsetof(struct Member, Int), .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = &asn_DEF_INTEGER, + .type = &asn_DEF_NativeInteger, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* PER is not compiled, use -gen-PER */ .default_value = 0, @@ -793,7 +793,7 @@ asn_TYPE_descriptor_t asn_DEF_Set = { /*** <<< INCLUDES [Sequence] >>> ***/ -#include <INTEGER.h> +#include <NativeInteger.h> #include <constr_SEQUENCE.h> /*** <<< FWD-DECLS [Sequence] >>> ***/ @@ -804,13 +804,13 @@ struct Set; /*** <<< TYPE-DECLS [Sequence] >>> ***/ typedef struct Sequence { - INTEGER_t a; + long a; struct Sequence *seq /* OPTIONAL */; /* * This type is extensible, * possible extensions are below. */ - INTEGER_t *b; + long *b; struct Set *set /* OPTIONAL */; /* Context for parsing across buffer boundaries */ @@ -832,7 +832,7 @@ static 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 */ - .type = &asn_DEF_INTEGER, + .type = &asn_DEF_NativeInteger, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* PER is not compiled, use -gen-PER */ .default_value = 0, @@ -850,7 +850,7 @@ static asn_TYPE_member_t asn_MBR_Sequence_1[] = { { ATF_POINTER, 2, offsetof(struct Sequence, b), .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = &asn_DEF_INTEGER, + .type = &asn_DEF_NativeInteger, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* PER is not compiled, use -gen-PER */ .default_value = 0, diff --git a/tests/92-circular-loops-OK.asn1.-P b/tests/92-circular-loops-OK.asn1.-Pfwide-types index e479edc8..e479edc8 100644 --- a/tests/92-circular-loops-OK.asn1.-P +++ b/tests/92-circular-loops-OK.asn1.-Pfwide-types diff --git a/tests/93-asn1c-controls-OK.asn1.-P b/tests/93-asn1c-controls-OK.asn1.-Pfwide-types index 429b41b4..429b41b4 100644 --- a/tests/93-asn1c-controls-OK.asn1.-P +++ b/tests/93-asn1c-controls-OK.asn1.-Pfwide-types diff --git a/tests/95-choice-per-order-OK.asn1.-P b/tests/95-choice-per-order-OK.asn1.-Pfwide-types index ba97bb8e..e6cb70e1 100644 --- a/tests/95-choice-per-order-OK.asn1.-P +++ b/tests/95-choice-per-order-OK.asn1.-Pfwide-types @@ -45,7 +45,7 @@ typedef struct Choice { * This type is extensible, * possible extensions are below. */ - BOOLEAN_t bool; + BOOLEAN_t Bool; } choice; /* Context for parsing across buffer boundaries */ @@ -143,7 +143,7 @@ static asn_TYPE_member_t asn_MBR_Choice_1[] = { .default_value = 0, .name = "ch" }, - { ATF_NOFLAGS, 0, offsetof(struct Choice, choice.bool), + { ATF_NOFLAGS, 0, offsetof(struct Choice, choice.Bool), .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), .tag_mode = 0, .type = &asn_DEF_BOOLEAN, diff --git a/tests/95-choice-per-order-OK.asn1.-Pgen-PER b/tests/95-choice-per-order-OK.asn1.-Pgen-PER index 515e65b9..f90a8132 100644 --- a/tests/95-choice-per-order-OK.asn1.-Pgen-PER +++ b/tests/95-choice-per-order-OK.asn1.-Pgen-PER @@ -5,7 +5,7 @@ #include <BIT_STRING.h> #include <BOOLEAN.h> #include <NULL.h> -#include <INTEGER.h> +#include <NativeInteger.h> #include <constr_CHOICE.h> /*** <<< DEPS [Choice] >>> ***/ @@ -35,7 +35,7 @@ typedef struct Choice { ch_PR present; union Choice__ch_u { NULL_t null; - INTEGER_t Int; + long Int; } choice; /* Context for parsing across buffer boundaries */ @@ -45,7 +45,7 @@ typedef struct Choice { * This type is extensible, * possible extensions are below. */ - BOOLEAN_t bool; + BOOLEAN_t Bool; } choice; /* Context for parsing across buffer boundaries */ @@ -84,7 +84,7 @@ static asn_TYPE_member_t asn_MBR_ch_4[] = { { ATF_NOFLAGS, 0, offsetof(struct ch, choice.Int), .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), .tag_mode = 0, - .type = &asn_DEF_INTEGER, + .type = &asn_DEF_NativeInteger, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* No PER visible constraints */ .default_value = 0, @@ -158,7 +158,7 @@ static asn_TYPE_member_t asn_MBR_Choice_1[] = { .default_value = 0, .name = "ch" }, - { ATF_NOFLAGS, 0, offsetof(struct Choice, choice.bool), + { ATF_NOFLAGS, 0, offsetof(struct Choice, choice.Bool), .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), .tag_mode = 0, .type = &asn_DEF_BOOLEAN, |