mirror of https://gerrit.osmocom.org/asn1c
compiler directives support; TMF 040-1 compatible
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@982 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
parent
e0fea71cb9
commit
177a5b6fec
|
@ -1,12 +1,12 @@
|
|||
|
||||
0.9.19: 2005-Aug-18
|
||||
0.9.19: 2005-Sep-04
|
||||
|
||||
* A proper solution to circular references. No kludge flags
|
||||
should be necessary anymore to produce reference-free code:
|
||||
recursive dependencies are resolved automatically.
|
||||
* Test cases 73 & 92 keep track of various circular references.
|
||||
* Introduced asn1c-specific modifier to allow finer control over the
|
||||
generated code ("<asn1c:pointer>" in comments), (Test case 93).
|
||||
* Introduced compiler directives to allow finer control over the
|
||||
generated code ("--<ASN1C...>--" in comments), (Test case 93).
|
||||
|
||||
0.9.18: 2005-Aug-14
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -97,32 +97,22 @@ WSP [\t\r\v\f\n ]
|
|||
-{3,} yy_pop_state(); /* Acceptable end of comment */
|
||||
}
|
||||
|
||||
--<[ \t]*ASN1C.RepresentAsPointer[ \t]*>-- asn1p_as_pointer = 1;
|
||||
|
||||
-- yy_push_state(dash_comment);
|
||||
<dash_comment,idash_comment>{
|
||||
|
||||
{NL} yy_pop_state();
|
||||
|
||||
"<asn1c:"[^\r\v\f\n>-]{1,80}">" {
|
||||
if(strcmp(yytext, "<asn1c:pointer>") == 0)
|
||||
asn1p_as_pointer = 1;
|
||||
/* Eat modifier */
|
||||
}
|
||||
"<" /* Eat stand-alone left angle brace */
|
||||
|
||||
-- yy_pop_state(); /* End of comment */
|
||||
- /* Eat single dash */
|
||||
[^\r\v\f\n<-]+ /* Eat */
|
||||
[^\r\v\f\n-]+ /* Eat */
|
||||
}
|
||||
|
||||
<INITIAL,cpp_comment>"/*" yy_push_state(cpp_comment);
|
||||
<cpp_comment>{
|
||||
[^*/<] /* Eat */
|
||||
"*/" yy_pop_state();
|
||||
"<asn1c:"[^\r\v\f\n>-]{1,80}">" {
|
||||
if(strcmp(yytext, "<asn1c:pointer>") == 0)
|
||||
asn1p_as_pointer = 1;
|
||||
/* Eat modifier */
|
||||
}
|
||||
. /* Eat */
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,11 +24,9 @@ void asn1p_lexer_hack_push_encoding_control(void);
|
|||
extern int asn1p_lineno;
|
||||
|
||||
/*
|
||||
* Process modifiers as <asn1c:pointer>
|
||||
* Process directives as <ASN1C:RepresentAsPointer>
|
||||
*/
|
||||
extern int asn1p_as_pointer;
|
||||
static asn1p_expr_t *asn1p_last_type;
|
||||
static void apply_nonstd_mods(void);
|
||||
|
||||
/*
|
||||
* This temporary variable is used to solve the shortcomings of 1-lookahead
|
||||
|
@ -313,6 +311,7 @@ static void _fixup_anonymous_identifier(asn1p_expr_t *expr);
|
|||
%type <a_int> optUnique
|
||||
%type <a_pres> optPresenceConstraint PresenceConstraint
|
||||
%type <tv_str> ComponentIdList
|
||||
%type <a_int> NSTD_IndirectMarker
|
||||
|
||||
|
||||
%%
|
||||
|
@ -897,8 +896,15 @@ ComponentType:
|
|||
$$ = $2;
|
||||
assert($$->Identifier == 0);
|
||||
$$->Identifier = $1;
|
||||
$3.flags |= $$->marker.flags;
|
||||
$$->marker = $3;
|
||||
}
|
||||
| Type optMarker {
|
||||
$$ = $1;
|
||||
$2.flags |= $$->marker.flags;
|
||||
$$->marker = $2;
|
||||
_fixup_anonymous_identifier($$);
|
||||
}
|
||||
| TOK_COMPONENTS TOK_OF Type {
|
||||
$$ = asn1p_expr_new(yylineno);
|
||||
checkmem($$);
|
||||
|
@ -909,11 +915,6 @@ ComponentType:
|
|||
| ExtensionAndException {
|
||||
$$ = $1;
|
||||
}
|
||||
| Type optMarker {
|
||||
$$ = $1;
|
||||
$$->marker = $2;
|
||||
_fixup_anonymous_identifier($$);
|
||||
}
|
||||
;
|
||||
|
||||
AlternativeTypeLists:
|
||||
|
@ -1094,32 +1095,52 @@ Type:
|
|||
$$->constraints = $3;
|
||||
}
|
||||
}
|
||||
asn1p_last_type = $$;
|
||||
}
|
||||
;
|
||||
|
||||
NSTD_IndirectMarker:
|
||||
{
|
||||
$$ = asn1p_as_pointer ? EM_INDIRECT : 0;
|
||||
asn1p_as_pointer = 0;
|
||||
}
|
||||
;
|
||||
|
||||
TypeDeclaration:
|
||||
{apply_nonstd_mods();} TypeDeclarationSet {
|
||||
NSTD_IndirectMarker TypeDeclarationSet {
|
||||
$$ = $2;
|
||||
$$->marker.flags |= $1;
|
||||
|
||||
if(($$->marker.flags & EM_INDIRECT)
|
||||
&& ($$->marker.flags & EM_OPTIONAL) != EM_OPTIONAL) {
|
||||
fprintf(stderr,
|
||||
"INFO: Directive <ASN1C:RepresentAsPointer> "
|
||||
"applied to %s at line %d\n",
|
||||
ASN_EXPR_TYPE2STR($$->expr_type)
|
||||
? ASN_EXPR_TYPE2STR($$->expr_type)
|
||||
: "member",
|
||||
$$->_lineno
|
||||
);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
TypeDeclarationSet:
|
||||
BasicType {
|
||||
$$ = $1;
|
||||
}
|
||||
| TOK_CHOICE '{' AlternativeTypeLists {apply_nonstd_mods();} '}' {
|
||||
| TOK_CHOICE '{' AlternativeTypeLists '}' {
|
||||
$$ = $3;
|
||||
assert($$->expr_type == A1TC_INVALID);
|
||||
$$->expr_type = ASN_CONSTR_CHOICE;
|
||||
$$->meta_type = AMT_TYPE;
|
||||
}
|
||||
| TOK_SEQUENCE '{' optComponentTypeLists {apply_nonstd_mods();} '}' {
|
||||
| TOK_SEQUENCE '{' optComponentTypeLists '}' {
|
||||
$$ = $3;
|
||||
assert($$->expr_type == A1TC_INVALID);
|
||||
$$->expr_type = ASN_CONSTR_SEQUENCE;
|
||||
$$->meta_type = AMT_TYPE;
|
||||
}
|
||||
| TOK_SET '{' optComponentTypeLists {apply_nonstd_mods();} '}' {
|
||||
| TOK_SET '{' optComponentTypeLists '}' {
|
||||
$$ = $3;
|
||||
assert($$->expr_type == A1TC_INVALID);
|
||||
$$->expr_type = ASN_CONSTR_SET;
|
||||
|
@ -2249,22 +2270,6 @@ _fixup_anonymous_identifier(asn1p_expr_t *expr) {
|
|||
expr->Identifier);
|
||||
}
|
||||
|
||||
static void
|
||||
apply_nonstd_mods() {
|
||||
if(!asn1p_as_pointer) return;
|
||||
asn1p_as_pointer = 0;
|
||||
|
||||
if(asn1p_last_type) {
|
||||
asn1p_last_type->marker.flags |= EM_INDIRECT;
|
||||
fprintf(stderr, "INFO: Modifier <asn1c:pointer> "
|
||||
"applied to \"%s\" at line %d\n",
|
||||
asn1p_last_type->Identifier
|
||||
? asn1p_last_type->Identifier : "<anonymous>",
|
||||
asn1p_last_type->_lineno);
|
||||
asn1p_last_type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern char *asn1p_text;
|
||||
|
||||
int
|
||||
|
|
|
@ -508,6 +508,16 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
|
|||
|
||||
if(flags & APF_LINE_COMMENTS && !(flags & APF_NOINDENT))
|
||||
INDENT("-- #line %d\n", tc->_lineno);
|
||||
|
||||
/* Reconstruct compiler directive information */
|
||||
if((tc->marker.flags & EM_INDIRECT)
|
||||
&& (tc->marker.flags & EM_OMITABLE) != EM_OMITABLE) {
|
||||
if((flags & APF_NOINDENT))
|
||||
printf(" --<ASN1C.RepresentAsPointer>-- ");
|
||||
else
|
||||
INDENT("--<ASN1C.RepresentAsPointer>--\n");
|
||||
}
|
||||
|
||||
if(tc->Identifier)
|
||||
INDENT("%s", tc->Identifier);
|
||||
|
||||
|
@ -623,15 +633,11 @@ asn1print_expr(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *tc, enum asn1pri
|
|||
== EM_OPTIONAL) {
|
||||
printf(" OPTIONAL");
|
||||
}
|
||||
if(TQ_NEXT(se, next))
|
||||
if(TQ_NEXT(se, next)) {
|
||||
printf(",");
|
||||
/* Reconstruct modifier information */
|
||||
if((se->marker.flags & EM_OMITABLE)
|
||||
!= EM_OMITABLE
|
||||
&& se->marker.flags & EM_INDIRECT)
|
||||
printf("\t/* <asn1c:pointer> */");
|
||||
if(TQ_NEXT(se, next) && !(flags & APF_NOINDENT))
|
||||
INDENT("\n");
|
||||
if(!(flags & APF_NOINDENT))
|
||||
INDENT("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if(put_braces && TQ_FIRST(&tc->members)) {
|
||||
|
|
|
@ -13,17 +13,21 @@ BEGIN
|
|||
|
||||
Sequence ::= SEQUENCE {
|
||||
ainl INTEGER,
|
||||
aptr INTEGER /* <asn1c:pointer> */
|
||||
--<ASN1C.RepresentAsPointer>--
|
||||
aptr INTEGER
|
||||
}
|
||||
|
||||
Set ::= SET {
|
||||
ainl Sequence,
|
||||
aptr Sequence -- <asn1c:pointer>
|
||||
--<ASN1C.RepresentAsPointer>--
|
||||
aptr Sequence
|
||||
}
|
||||
|
||||
Choice ::= CHOICE {
|
||||
setof SET OF INTEGER, -- <asn1c:pointer>
|
||||
aptr Sequence, -- <asn1c:pointer>
|
||||
--<ASN1C.RepresentAsPointer>--
|
||||
setof SET OF INTEGER,
|
||||
--<ASN1C.RepresentAsPointer>--
|
||||
aptr Sequence,
|
||||
ainl Sequence
|
||||
}
|
||||
|
||||
|
|
|
@ -5,17 +5,21 @@ BEGIN
|
|||
|
||||
Sequence ::= SEQUENCE {
|
||||
ainl [0] IMPLICIT INTEGER,
|
||||
aptr [1] IMPLICIT INTEGER /* <asn1c:pointer> */
|
||||
--<ASN1C.RepresentAsPointer>--
|
||||
aptr [1] IMPLICIT INTEGER
|
||||
}
|
||||
|
||||
Set ::= SET {
|
||||
ainl [0] IMPLICIT Sequence,
|
||||
aptr [1] IMPLICIT Sequence /* <asn1c:pointer> */
|
||||
--<ASN1C.RepresentAsPointer>--
|
||||
aptr [1] IMPLICIT Sequence
|
||||
}
|
||||
|
||||
Choice ::= CHOICE {
|
||||
setof [0] IMPLICIT SET OF INTEGER, /* <asn1c:pointer> */
|
||||
aptr [1] IMPLICIT Sequence, /* <asn1c:pointer> */
|
||||
--<ASN1C.RepresentAsPointer>--
|
||||
setof [0] IMPLICIT SET OF INTEGER,
|
||||
--<ASN1C.RepresentAsPointer>--
|
||||
aptr [1] IMPLICIT Sequence,
|
||||
ainl [2] IMPLICIT Sequence
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ static ber_tlv_tag_t asn_DEF_Sequence_1_tags[] = {
|
|||
};
|
||||
static asn_TYPE_tag2member_t asn_MAP_Sequence_1_tag2el[] = {
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* ainl at 15 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* aptr at 17 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* aptr at 18 */
|
||||
};
|
||||
static asn_SEQUENCE_specifics_t asn_SPC_Sequence_1_specs = {
|
||||
sizeof(struct Sequence),
|
||||
|
@ -138,8 +138,8 @@ static ber_tlv_tag_t asn_DEF_Set_1_tags[] = {
|
|||
(ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
|
||||
};
|
||||
static asn_TYPE_tag2member_t asn_MAP_Set_1_tag2el[] = {
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* ainl at 20 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* aptr at 22 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* ainl at 21 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* aptr at 24 */
|
||||
};
|
||||
static uint8_t asn_MAP_Set_1_mmap[(2 + (8 * sizeof(unsigned int)) - 1) / 8] = {
|
||||
(1 << 7) | (1 << 6)
|
||||
|
@ -293,9 +293,9 @@ static asn_TYPE_member_t asn_MBR_Choice_1[] = {
|
|||
},
|
||||
};
|
||||
static asn_TYPE_tag2member_t asn_MAP_Choice_1_tag2el[] = {
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* setof at 25 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* aptr at 26 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* ainl at 28 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* setof at 28 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* aptr at 30 */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* ainl at 32 */
|
||||
};
|
||||
static asn_CHOICE_specifics_t asn_SPC_Choice_1_specs = {
|
||||
sizeof(struct Choice),
|
||||
|
|
Loading…
Reference in New Issue