aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2005-07-24 08:28:39 +0000
committerLev Walkin <vlm@lionet.info>2005-07-24 08:28:39 +0000
commit72a0f5a1faa1a5b613f1f979ebd1a89eb744afff (patch)
treef189ac41687c92c3b384bce683d20e397a4710d3
parentd4eb17dbf07c498fb98479b8cbd6c0ec228ec669 (diff)
-findirect-choice
-rw-r--r--asn1c/asn1c.111
-rw-r--r--asn1c/asn1c.c3
-rw-r--r--doc/asn1c-usage.html13
-rw-r--r--doc/asn1c-usage.lyx93
-rw-r--r--doc/asn1c-usage.pdfbin132038 -> 132123 bytes
-rw-r--r--libasn1compiler/asn1c_C.c5
-rw-r--r--libasn1compiler/asn1compiler.h4
7 files changed, 95 insertions, 34 deletions
diff --git a/asn1c/asn1c.1 b/asn1c/asn1c.1
index 408b79f9..893d5995 100644
--- a/asn1c/asn1c.1
+++ b/asn1c/asn1c.1
@@ -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,
diff --git a/asn1c/asn1c.c b/asn1c/asn1c.c
index 3d08c309..11559de3 100644
--- a/asn1c/asn1c.c
+++ b/asn1c/asn1c.c
@@ -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"
diff --git a/doc/asn1c-usage.html b/doc/asn1c-usage.html
index b16e7889..03bfd4bf 100644
--- a/doc/asn1c-usage.html
+++ b/doc/asn1c-usage.html
@@ -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
diff --git a/doc/asn1c-usage.lyx b/doc/asn1c-usage.lyx
index 51445f35..4e9750ff 100644
--- a/doc/asn1c-usage.lyx
+++ b/doc/asn1c-usage.lyx
@@ -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
diff --git a/doc/asn1c-usage.pdf b/doc/asn1c-usage.pdf
index 621c1cb2..bd3f3f62 100644
--- a/doc/asn1c-usage.pdf
+++ b/doc/asn1c-usage.pdf
Binary files differ
diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c
index a8c9f65e..58b76f63 100644
--- a/libasn1compiler/asn1c_C.c
+++ b/libasn1compiler/asn1c_C.c
@@ -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)
diff --git a/libasn1compiler/asn1compiler.h b/libasn1compiler/asn1compiler.h
index 4fa4a9f0..e688018a 100644
--- a/libasn1compiler/asn1compiler.h
+++ b/libasn1compiler/asn1compiler.h
@@ -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,
};
/*