Sunday, February 10, 2008

The C being generated from this for the constrained BIT STRINGs is incorrect. The unused bits look distinctly squiffy.


FooBar {1 2 3 4 5 6} DEFINITIONS ::=
BEGIN
Type1 ::= CHOICE {element0 INTEGER}
value1 Type1 ::= element0:1
Type2 ::= BIT STRING (SIZE (1..2)) (SIZE (2..2))
value2 Type2 ::= '01'B
Type3 ::= INTEGER
value3 Type3 ::= 3
Type4 ::= BIT STRING
value4 Type4 ::= '001'B
Type5 ::= BIT STRING (SIZE (3..6)) (SIZE (6..6)) (SIZE (6..6))
value5 Type5 ::= '010101'B
Type6 ::= SEQUENCE {element1 BIT STRING (SIZE (3..3)) (SIZE (3..3)) (SIZE (3..3)),
element2 SEQUENCE {},
element3 CHOICE {element4 INTEGER}}
value6 Type6 ::= {element1 '000'B,
element2 {},
element3 element4:0}
Type7 ::= SEQUENCE {}
value7 Type7 ::= {}
Type8 ::= CHOICE {element5 [0] IMPLICIT SEQUENCE {element6 [1] IMPLICIT INTEGER},
element7 INTEGER}
value8 Type8 ::= element5:{element6 2}
Type9 ::= INTEGER
value9 Type9 ::= -2
Type10 ::= BIT STRING
value10 Type10 ::= '0011'B
END



(*type1).present = Type1_PR_element0;
(*type1).choice.element0 = 1;


(*type2).buf = calloc (1, 1); /* 1 bytes */
assert((*type2).buf);
(*type2).size = 1;
(*type2).buf[0] = 64;
(*type2).bits_unused = 2; /* Trim unused bits */

(*type3) = 3;


(*type4).buf = calloc (1, 1); /* 1 bytes */
assert((*type4).buf);
(*type4).size = 1;
(*type4).buf[0] = 32;
(*type4).bits_unused = 3; /* Trim unused bits */


(*type5).buf = calloc (1, 1); /* 1 bytes */
assert((*type5).buf);
(*type5).size = 1;
(*type5).buf[0] = 84;
(*type5).bits_unused = 6; /* Trim unused bits */


(*type6).element1.buf = calloc (1, 1); /* 1 bytes */
assert((*type6).element1.buf);
(*type6).element1.size = 1;
(*type6).element1.buf[0] = 0;
(*type6).element1.bits_unused = 3; /* Trim unused bits */
(*type6).element3.present = element3_PR_element4;
(*type6).element3.choice.element4 = 0;


(*type8).present = Type8_PR_element5;
(*type8).choice.element5.element6 = 2;

(*type9) = -2;


(*type10).buf = calloc (1, 1); /* 1 bytes */
assert((*type10).buf);
(*type10).size = 1;
(*type10).buf[0] = 48;
(*type10).bits_unused = 4; /* Trim unused bits */

No comments: