-findirect-choice

git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@942 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2005-07-24 08:28:39 +00:00
parent dae8e61278
commit 4cc4572eb5
7 changed files with 95 additions and 34 deletions

View File

@ -23,7 +23,7 @@ and other encoding standards.
.TP
\fILanguage Options\fR
.br
\fB\-fall-defs-global \-fbless-SIZE \-fcompound-names
\fB\-fall-defs-global \-fbless-SIZE \-fcompound-names \-findirect-choice
.BI "\-fknown-extern-type="<name>
\fB\-fnative-types \-fno-constraints \-fno-include-deps \-funnamed-unions \-ftypes88\fR
.TP
@ -90,9 +90,16 @@ by using complex names for target language structures. (Name collisions
may occur if the ASN.1 module reuses the same identifiers in multiple
contexts).
.TP
.B \-findirect-choice
When generating code for a CHOICE type, compile the CHOICE members as indirect
pointers instead of declaring them inline. Consider using this option
together with
.B \-fno-include-deps
to prevent circular references.
.TP
.BI "\-fknown-extern-type="<name>
Pretend the specified type is known. The compiler will assume the target
language source files for the given type are provided manually.
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,

View File

@ -77,6 +77,8 @@ main(int ac, char **av) {
asn1_fixer_flags |= A1F_EXTENDED_SizeConstraint;
} else if(strcmp(optarg, "compound-names") == 0) {
asn1_compiler_flags |= A1C_COMPOUND_NAMES;
} else if(strcmp(optarg, "indirect-choice") == 0) {
asn1_compiler_flags |= A1C_INDIRECT_CHOICE;
} else if(strncmp(optarg, "known-extern-type=", 18) == 0) {
char *known_type = optarg + 18;
ret = asn1f_make_known_external_type(known_type);
@ -313,6 +315,7 @@ usage(const char *av0) {
" -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"
" -fcompound-names Disambiguate C's struct NAME's inside top-level types\n"
" -findirect-choice Compile members of CHOICE as indirect pointers\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"

View File

@ -400,6 +400,19 @@ produce the meaningful code.</FONT></TD></TR>
name clashes in case the module reuses the same identifiers in multiple
contexts.</FONT></TD></TR>
</TBODY><TBODY>
<TR><TD VALIGN=BASELINE ALIGN=LEFT NOWRAP><FONT SIZE="-1">-findirect-choice</FONT></TD><TD VALIGN=BASELINE ALIGN=LEFT WIDTH="216">
<FONT SIZE="-1">When generating code for a CHOICE type, compile
the CHOICE members as indirect pointers instead of
declaring them inline. Consider using this option
together with <B>-fno-include-deps</B> to prevent circular references.
</FONT></TD></TR>
</TBODY><TBODY>
<TR><TD VALIGN=BASELINE ALIGN=LEFT NOWRAP><FONT SIZE="-1">-fknown-extern-type=<I>&lt;name&gt;</I></FONT></TD><TD VALIGN=BASELINE ALIGN=LEFT WIDTH="216">
<FONT SIZE="-1">Pretend the specified type is known. The compiler will
assume the target language source files for the given
type have been provided manually.
</FONT></TD></TR>
</TBODY><TBODY>
<TR><TD VALIGN=BASELINE ALIGN=LEFT NOWRAP><FONT SIZE="-1">-fnative-types</FONT></TD><TD VALIGN=BASELINE ALIGN=LEFT WIDTH="216">
<FONT SIZE="-1">Use the native machine's data types (int, double) whenever
possible, instead of the compound INTEGER_t, ENUMERATED_t and REAL_t

View File

@ -71,7 +71,7 @@ status Open
\backslash
lhead{This document describes
\backslash
href{http://lionet.info/asn1c}{asn1c-0.9.11}}
href{http://lionet.info/asn1c}{asn1c-0.9.17}}
\layout Standard
\backslash
@ -169,7 +169,7 @@ END
The compiler would read this ASN.1 definition and produce the following C
type
\begin_inset Foot
collapsed true
collapsed false
\layout Standard
@ -182,8 +182,8 @@ collapsed true
int
\emph default
types instead of infinite width INTEGER_t structures.
See Table
\begin_inset LatexCommand \vref{cap:asn1c-cmdopts}
See Section
\begin_inset LatexCommand \vref{sec:Command-line-options}
\end_inset
@ -240,7 +240,7 @@ ell
\emph default
command may be used to compile the ASN.1 module
\begin_inset Foot
collapsed true
collapsed false
\layout Standard
@ -249,8 +249,8 @@ This is probably
not
\series default
what you want to try out right now -- read through the rest of this chapter
and check the Table
\begin_inset LatexCommand \vref{cap:asn1c-cmdopts}
and check the Section
\begin_inset LatexCommand \vref{sec:Command-line-options}
\end_inset
@ -438,28 +438,20 @@ int main()
routine.
\layout Section
Command line options
\layout Standard
The Table
\begin_inset LatexCommand \vref{cap:asn1c-cmdopts}
\begin_inset LatexCommand \label{sec:Command-line-options}
\end_inset
summarizes various options affecting the compiler's behavior.
Command line options
\layout Standard
\begin_inset Float table
placement h
wide false
collapsed false
The following table summarizes the asn1c command line options.
\layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="24" columns="2">
<lyxtabular version="3" rows="26" columns="2">
<features islongtable="true">
<column alignment="left" valignment="top" leftline="true" width="0">
<column alignment="block" valignment="top" leftline="true" rightline="true" width="3in">
@ -716,7 +708,7 @@ Enable lexer debugging during the ASN.1 parsing stage.
\end_inset
</cell>
</row>
<row topline="true" bottomline="true">
<row topline="true" bottomline="true" newpage="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
@ -844,6 +836,54 @@ Use complex names for C structures.
\layout Standard
-findirect-choice
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
When generating code for a CHOICE type, compile the CHOICE members as indirect
pointers instead of declaring them inline.
Consider using this option together with
\series bold
-fno-include-deps
\series default
to prevent circular references.
\end_inset
</cell>
</row>
<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
-fknown-extern-type=
\emph on
<name>
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\layout Standard
Pretend the specified type is known.
The compiler will assume the target language source files for the given
type have been provided manually.
\end_inset
</cell>
</row>
<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\layout Standard
\size small
-fnative-types
@ -953,7 +993,7 @@ Pretend to support only ASN.1:1988 embedded types.
\end_inset
</cell>
</row>
<row topline="true" newpage="true">
<row topline="true">
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
@ -1027,17 +1067,6 @@ Generate "-- #line" comments in -E output.
\end_inset
\layout Caption
\begin_inset LatexCommand \label{cap:asn1c-cmdopts}
\end_inset
The list of asn1c command line options
\end_inset
\layout Chapter
Using the ASN.1 Compiler

Binary file not shown.

View File

@ -1865,6 +1865,11 @@ expr_better_indirect(arg_t *arg, asn1p_expr_t *expr) {
if(expr->expr_type != A1TC_REFERENCE)
return 0;
/* -findirect-choice compiles members of CHOICE as indirect pointers */
if((arg->flags & A1C_INDIRECT_CHOICE)
&& arg->expr->expr_type == ASN_CONSTR_CHOICE)
return 1;
/* Rewind to the topmost parent expression */
if((top_parent = expr->parent_expr)) {
while(top_parent->parent_expr)

View File

@ -47,6 +47,10 @@ enum asn1c_flags {
* Do not generate courtesy #includes for external dependencies.
*/
A1C_NO_INCLUDE_DEPS = 0x0200,
/*
* Compile members of CHOICE as indirect pointers.
*/
A1C_INDIRECT_CHOICE = 0x0400,
};
/*