Commit dd32b592 authored by Lev Walkin's avatar Lev Walkin

-fall-defs-global

parent fd71d1e5
...@@ -27,7 +27,7 @@ and other encoding standards. ...@@ -27,7 +27,7 @@ and other encoding standards.
.TP .TP
\fILanguage Options\fR \fILanguage Options\fR
.br .br
\fB\-fbless-SIZE \-fnative-integers \-funnamed-unions \-ftypes88\fR \fB\-fall-defs-global \-fbless-SIZE \-fnative-integers \-funnamed-unions \-ftypes88\fR
.TP .TP
\fIOutput Options\fR \fIOutput Options\fR
.br .br
...@@ -74,6 +74,14 @@ Enable ASN.1 syntax tree fixer debugging during the fixing stage. ...@@ -74,6 +74,14 @@ Enable ASN.1 syntax tree fixer debugging during the fixing stage.
Enable debugging during the actual compile time. Enable debugging during the actual compile time.
.SH LANGUAGE OPTIONS .SH LANGUAGE OPTIONS
.TP .TP
.B \-fall-defs-global
Normally the compiler hides the definitions (asn1_DEF_xxx) of the inner
structure elements (members of SEQUENCE, SET and other types). This option
makes all such definitions global.
Enabling this option may pollute the namespace by making lots of asn1_DEF_xxx
structures globally visible, but will allow you to manipulate
(encode and decode) the individual members of any complex ASN.1 structure.
.TP
.B \-fbless-SIZE .B \-fbless-SIZE
Allow SIZE() constraint for INTEGER, ENUMERATED, and other types for which this Allow SIZE() constraint for INTEGER, ENUMERATED, and other types for which this
constraint is normally prohibited by the standard. This is a violation of constraint is normally prohibited by the standard. This is a violation of
......
...@@ -54,20 +54,20 @@ main(int ac, char **av) { ...@@ -54,20 +54,20 @@ main(int ac, char **av) {
print_arg__fix_n_print = 1; print_arg__fix_n_print = 1;
break; break;
case 'f': case 'f':
if(strcmp(optarg, "types88") == 0) { if(strcmp(optarg, "all-defs-global") == 0) {
asn1_parser_flags |= A1P_TYPES_RESTRICT_TO_1988; asn1_compiler_flags |= A1C_ALL_DEFS_GLOBAL;
} else if(strcmp(optarg, "constr90") == 0) { } else if(strcmp(optarg, "bless-SIZE") == 0) {
asn1_parser_flags |= A1P_CONSTRUCTS_RESTRICT_TO_1990; asn1_fixer_flags |= A1F_EXTENDED_SizeConstraint;
} else if(strcmp(optarg, "native-integers") == 0) {
asn1_compiler_flags |= A1C_USE_NATIVE_INTEGERS;
} else if(strcmp(optarg, "unnamed-unions") == 0) {
asn1_compiler_flags |= A1C_UNNAMED_UNIONS;
} else if(strncmp(optarg, "known-extern-type=", 18) == 0) { } else if(strncmp(optarg, "known-extern-type=", 18) == 0) {
char *known_type = optarg + 18; char *known_type = optarg + 18;
ret = asn1f_make_known_external_type(known_type); ret = asn1f_make_known_external_type(known_type);
assert(ret == 0 || errno == EEXIST); assert(ret == 0 || errno == EEXIST);
} else if(strcmp(optarg, "bless-SIZE") == 0) { } else if(strcmp(optarg, "native-integers") == 0) {
asn1_fixer_flags |= A1F_EXTENDED_SizeConstraint; asn1_compiler_flags |= A1C_USE_NATIVE_INTEGERS;
} else if(strcmp(optarg, "unnamed-unions") == 0) {
asn1_compiler_flags |= A1C_UNNAMED_UNIONS;
} else if(strcmp(optarg, "types88") == 0) {
asn1_parser_flags |= A1P_TYPES_RESTRICT_TO_1988;
} else { } else {
fprintf(stderr, "-f%s: Invalid argument\n", optarg); fprintf(stderr, "-f%s: Invalid argument\n", optarg);
exit(EX_USAGE); exit(EX_USAGE);
...@@ -286,10 +286,8 @@ usage(char *av0) { ...@@ -286,10 +286,8 @@ usage(char *av0) {
" -Wdebug-compiler --//-- compiler\n" " -Wdebug-compiler --//-- compiler\n"
"\n" "\n"
" -fall-defs-global Don't make the asn1_DEF_'s of structure members \"static\"\n"
" -fbless-SIZE Allow SIZE() constraint for INTEGER etc (non-std.)\n" " -fbless-SIZE Allow SIZE() constraint for INTEGER etc (non-std.)\n"
/*
" -fconstr90 Use only ASN.1:1990 constructs (not available)\n"
*/
" -fknown-extern-type=<name> Pretend this type is known\n" " -fknown-extern-type=<name> Pretend this type is known\n"
" -fnative-integers Use int instead of INTEGER_t whenever possible\n" " -fnative-integers Use int instead of INTEGER_t whenever possible\n"
" -funnamed-unions Enable unnamed unions in structures\n" " -funnamed-unions Enable unnamed unions in structures\n"
......
...@@ -1309,13 +1309,13 @@ The Table ...@@ -1309,13 +1309,13 @@ The Table
\begin_inset Float table \begin_inset Float table
wide false wide false
collapsed true collapsed false
\layout Standard \layout Standard
\begin_inset Tabular \begin_inset Tabular
<lyxtabular version="3" rows="20" columns="2"> <lyxtabular version="3" rows="21" columns="2">
<features> <features>
<column alignment="left" valignment="top" leftline="true" width="0"> <column alignment="left" valignment="top" leftline="true" width="0">
<column alignment="block" valignment="top" leftline="true" rightline="true" width="3in"> <column alignment="block" valignment="top" leftline="true" rightline="true" width="3in">
...@@ -1602,6 +1602,29 @@ Description ...@@ -1602,6 +1602,29 @@ Description
\layout Standard \layout Standard
-fall-defs-global
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
Normally the compiler hides the definitions (asn1_DEF_xxx) of the inner
structure elements (members of SEQUENCE, SET and other types).
This option makes all such definitions global.
Enabling this option may pollute the namespace by making lots of asn1_DEF_xxx
structures globally visible, but will allow you to manipulate (encode and
decode) the individual members of any complex ASN.1 structure.
\end_inset
</cell>
</row>
<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-fbless-SIZE -fbless-SIZE
\end_inset \end_inset
</cell> </cell>
......
No preview for this file type
...@@ -45,6 +45,7 @@ static int emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, int tags_count, int tag ...@@ -45,6 +45,7 @@ static int emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, int tags_count, int tag
#define C99_MODE (!(arg->flags & A1C_NO_C99)) #define C99_MODE (!(arg->flags & A1C_NO_C99))
#define UNNAMED_UNIONS (arg->flags & A1C_UNNAMED_UNIONS) #define UNNAMED_UNIONS (arg->flags & A1C_UNNAMED_UNIONS)
#define HIDE_INNER_DEFS (arg->embed && !(arg->flags & A1C_ALL_DEFS_GLOBAL))
#define PCTX_DEF INDENTED( \ #define PCTX_DEF INDENTED( \
OUT("\n"); \ OUT("\n"); \
...@@ -867,7 +868,10 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) { ...@@ -867,7 +868,10 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
REDIR(OT_FUNC_DECLS); REDIR(OT_FUNC_DECLS);
p = MKID(expr->Identifier); p = MKID(expr->Identifier);
OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); if(HIDE_INNER_DEFS) OUT("/* ");
OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;", p);
if(HIDE_INNER_DEFS) OUT(" // (Use -fall-defs-global to expose) */");
OUT("\n");
OUT("asn_constr_check_f %s_constraint;\n", p); OUT("asn_constr_check_f %s_constraint;\n", p);
OUT("ber_type_decoder_f %s_decode_ber;\n", p); OUT("ber_type_decoder_f %s_decode_ber;\n", p);
OUT("der_type_encoder_f %s_encode_der;\n", p); OUT("der_type_encoder_f %s_encode_der;\n", p);
...@@ -1297,6 +1301,8 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, int tags_count, int tags_impl_skip ...@@ -1297,6 +1301,8 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, int tags_count, int tags_impl_skip
char *p; char *p;
p = MKID(expr->Identifier); p = MKID(expr->Identifier);
if(HIDE_INNER_DEFS)
OUT("static /* Use -fall-defs-global to expose */\n");
OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p); OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p);
INDENTED( INDENTED(
OUT("\"%s\",\n", expr->_anonymous_type?"":expr->Identifier); OUT("\"%s\",\n", expr->_anonymous_type?"":expr->Identifier);
......
...@@ -31,6 +31,10 @@ enum asn1c_flags { ...@@ -31,6 +31,10 @@ enum asn1c_flags {
* Enable use of unnamed unions (non-portable feature). * Enable use of unnamed unions (non-portable feature).
*/ */
A1C_UNNAMED_UNIONS = 0x0020, A1C_UNNAMED_UNIONS = 0x0020,
/*
* Don't make the asn1_DEF_'s of structure members "static".
*/
A1C_ALL_DEFS_GLOBAL = 0x0040,
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment