2 |
7u83 |
1 |
/*
|
7 |
7u83 |
2 |
* Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
*
|
|
|
5 |
* Redistribution and use in source and binary forms, with or without
|
|
|
6 |
* modification, are permitted provided that the following conditions are met:
|
|
|
7 |
*
|
|
|
8 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
9 |
* this list of conditions and the following disclaimer.
|
|
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
11 |
* this list of conditions and the following disclaimer in the documentation
|
|
|
12 |
* and/or other materials provided with the distribution.
|
|
|
13 |
* 3. Neither the name of The TenDRA Project nor the names of its contributors
|
|
|
14 |
* may be used to endorse or promote products derived from this software
|
|
|
15 |
* without specific, prior written permission.
|
|
|
16 |
*
|
|
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
|
|
18 |
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
19 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
|
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
22 |
* EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
23 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
24 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
25 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
26 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
27 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
28 |
*
|
|
|
29 |
* $Id$
|
|
|
30 |
*/
|
|
|
31 |
/*
|
2 |
7u83 |
32 |
Crown Copyright (c) 1997
|
7 |
7u83 |
33 |
|
2 |
7u83 |
34 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
35 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
36 |
acting through the Defence Evaluation and Research Agency
|
|
|
37 |
(DERA). It is made available to Recipients with a
|
|
|
38 |
royalty-free licence for its use, reproduction, transfer
|
|
|
39 |
to other parties and amendment for any purpose not excluding
|
|
|
40 |
product development provided that any such use et cetera
|
|
|
41 |
shall be deemed to be acceptance of the following conditions:-
|
7 |
7u83 |
42 |
|
2 |
7u83 |
43 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
44 |
reproduced upon any copies or amended versions of it;
|
7 |
7u83 |
45 |
|
2 |
7u83 |
46 |
(2) Any amended version of it shall be clearly marked to
|
|
|
47 |
show both the nature of and the organisation responsible
|
|
|
48 |
for the relevant amendment or amendments;
|
7 |
7u83 |
49 |
|
2 |
7u83 |
50 |
(3) Its onward transfer from a recipient to another
|
|
|
51 |
party shall be deemed to be that party's acceptance of
|
|
|
52 |
these conditions;
|
7 |
7u83 |
53 |
|
2 |
7u83 |
54 |
(4) DERA gives no warranty or assurance as to its
|
|
|
55 |
quality or suitability for any purpose and DERA accepts
|
|
|
56 |
no liability whatsoever in relation to any use to which
|
|
|
57 |
it may be put.
|
|
|
58 |
*/
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
#ifndef OUTPUT_INCLUDED
|
|
|
62 |
#define OUTPUT_INCLUDED
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
/*
|
7 |
7u83 |
66 |
* LOOP VARIABLES
|
|
|
67 |
*
|
|
|
68 |
* These variables are used in the LOOP macros below as loop counters.
|
|
|
69 |
* It should not be necessary to access them directly, instead the
|
|
|
70 |
* CRT macros below should be used.
|
|
|
71 |
*/
|
2 |
7u83 |
72 |
|
7 |
7u83 |
73 |
extern LIST(ECONST_P)crt_ec;
|
|
|
74 |
extern LIST(ENUM_P)crt_en;
|
|
|
75 |
extern LIST(IDENTITY_P)crt_id;
|
|
|
76 |
extern LIST(PRIMITIVE_P)crt_prim;
|
|
|
77 |
extern LIST(STRUCTURE_P)crt_str;
|
|
|
78 |
extern LIST(UNION_P)crt_union;
|
|
|
79 |
extern LIST(COMPONENT_P)crt_cmp;
|
|
|
80 |
extern LIST(FIELD_P)crt_fld;
|
|
|
81 |
extern LIST(MAP_P)crt_map;
|
|
|
82 |
extern LIST(ARGUMENT_P)crt_arg;
|
|
|
83 |
extern LIST(TYPE_P)crt_type;
|
2 |
7u83 |
84 |
|
|
|
85 |
|
|
|
86 |
/*
|
7 |
7u83 |
87 |
* LOOP MACROS
|
|
|
88 |
*
|
|
|
89 |
* The LOOP macros are used to scan over all elements of a list. The
|
|
|
90 |
* CRT macros give the effective loop counters. Thus, for example,
|
|
|
91 |
* LOOP_ENUM is a for statement which makes CRT_ENUM scan over all the
|
|
|
92 |
* enumeration types.
|
|
|
93 |
*/
|
2 |
7u83 |
94 |
|
7 |
7u83 |
95 |
#define LOOP_LIST(X, Y)\
|
|
|
96 |
for ((X) = (Y); !IS_NULL_list(X); (X) = TAIL_list(X))
|
2 |
7u83 |
97 |
|
|
|
98 |
#define LOOP_ENUM\
|
7 |
7u83 |
99 |
LOOP_LIST(crt_en, algebra->enumerations)
|
2 |
7u83 |
100 |
|
|
|
101 |
#define LOOP_IDENTITY\
|
7 |
7u83 |
102 |
LOOP_LIST(crt_id, algebra->identities)
|
2 |
7u83 |
103 |
|
|
|
104 |
#define LOOP_PRIMITIVE\
|
7 |
7u83 |
105 |
LOOP_LIST(crt_prim, algebra->primitives)
|
2 |
7u83 |
106 |
|
|
|
107 |
#define LOOP_STRUCTURE\
|
7 |
7u83 |
108 |
LOOP_LIST(crt_str, algebra->structures)
|
2 |
7u83 |
109 |
|
|
|
110 |
#define LOOP_UNION\
|
7 |
7u83 |
111 |
LOOP_LIST(crt_union, algebra->unions)
|
2 |
7u83 |
112 |
|
|
|
113 |
#define LOOP_ENUM_CONST\
|
7 |
7u83 |
114 |
LOOP_LIST(crt_ec, DEREF_list(en_consts(CRT_ENUM)))
|
2 |
7u83 |
115 |
|
|
|
116 |
#define LOOP_STRUCTURE_COMPONENT\
|
7 |
7u83 |
117 |
LOOP_LIST(crt_cmp, DEREF_list(str_defn(CRT_STRUCTURE)))
|
2 |
7u83 |
118 |
|
|
|
119 |
#define LOOP_UNION_COMPONENT\
|
7 |
7u83 |
120 |
LOOP_LIST(crt_cmp, DEREF_list(un_s_defn(CRT_UNION)))
|
2 |
7u83 |
121 |
|
|
|
122 |
#define LOOP_UNION_FIELD\
|
7 |
7u83 |
123 |
LOOP_LIST(crt_fld, DEREF_list(un_u_defn(CRT_UNION)))
|
2 |
7u83 |
124 |
|
|
|
125 |
#define LOOP_FIELD_COMPONENT\
|
7 |
7u83 |
126 |
LOOP_LIST(crt_cmp, DEREF_list(fld_defn(CRT_FIELD)))
|
2 |
7u83 |
127 |
|
|
|
128 |
#define LOOP_UNION_MAP\
|
7 |
7u83 |
129 |
LOOP_LIST(crt_map, DEREF_list(un_map(CRT_UNION)))
|
2 |
7u83 |
130 |
|
|
|
131 |
#define LOOP_MAP_ARGUMENT\
|
7 |
7u83 |
132 |
LOOP_LIST(crt_arg, DEREF_list(map_args(CRT_MAP)))
|
2 |
7u83 |
133 |
|
|
|
134 |
#define LOOP_TYPE\
|
7 |
7u83 |
135 |
LOOP_LIST(crt_type, algebra->types)
|
2 |
7u83 |
136 |
|
7 |
7u83 |
137 |
#define CRT_ENUM DEREF_ptr(HEAD_list(crt_en))
|
|
|
138 |
#define CRT_IDENTITY DEREF_ptr(HEAD_list(crt_id))
|
|
|
139 |
#define CRT_PRIMITIVE DEREF_ptr(HEAD_list(crt_prim))
|
|
|
140 |
#define CRT_STRUCTURE DEREF_ptr(HEAD_list(crt_str))
|
|
|
141 |
#define CRT_UNION DEREF_ptr(HEAD_list(crt_union))
|
|
|
142 |
#define CRT_ECONST DEREF_ptr(HEAD_list(crt_ec))
|
|
|
143 |
#define CRT_COMPONENT DEREF_ptr(HEAD_list(crt_cmp))
|
|
|
144 |
#define CRT_FIELD DEREF_ptr(HEAD_list(crt_fld))
|
|
|
145 |
#define CRT_MAP DEREF_ptr(HEAD_list(crt_map))
|
|
|
146 |
#define CRT_ARGUMENT DEREF_ptr(HEAD_list(crt_arg))
|
|
|
147 |
#define CRT_TYPE DEREF_ptr(HEAD_list(crt_type))
|
2 |
7u83 |
148 |
|
7 |
7u83 |
149 |
#define HAVE_ENUM (!IS_NULL_list(crt_en))
|
|
|
150 |
#define HAVE_IDENTITY (!IS_NULL_list(crt_id))
|
|
|
151 |
#define HAVE_PRIMITIVE (!IS_NULL_list(crt_prim))
|
|
|
152 |
#define HAVE_STRUCTURE (!IS_NULL_list(crt_str))
|
|
|
153 |
#define HAVE_UNION (!IS_NULL_list(crt_union))
|
|
|
154 |
#define HAVE_ECONST (!IS_NULL_list(crt_ec))
|
|
|
155 |
#define HAVE_COMPONENT (!IS_NULL_list(crt_cmp))
|
|
|
156 |
#define HAVE_FIELD (!IS_NULL_list(crt_fld))
|
|
|
157 |
#define HAVE_MAP (!IS_NULL_list(crt_map))
|
|
|
158 |
#define HAVE_ARGUMENT (!IS_NULL_list(crt_arg))
|
|
|
159 |
#define HAVE_TYPE (!IS_NULL_list(crt_type))
|
2 |
7u83 |
160 |
|
|
|
161 |
|
|
|
162 |
/*
|
7 |
7u83 |
163 |
* DECLARATIONS FOR BASIC OUTPUT ROUTINES
|
|
|
164 |
*/
|
2 |
7u83 |
165 |
|
7 |
7u83 |
166 |
extern int unique;
|
|
|
167 |
extern int const_tokens;
|
|
|
168 |
extern int have_varargs;
|
|
|
169 |
extern int output_c_code;
|
|
|
170 |
extern int verbose_output;
|
|
|
171 |
extern FILE *output_file;
|
|
|
172 |
extern void flush_output(void);
|
|
|
173 |
extern void open_file(char *, char *, char *);
|
|
|
174 |
extern void close_file(void);
|
|
|
175 |
extern void output_type(TYPE_P);
|
38 |
7u83 |
176 |
extern number log_2(number);
|
2 |
7u83 |
177 |
|
|
|
178 |
#if FS_STDARG
|
7 |
7u83 |
179 |
extern void output(char *, ...);
|
2 |
7u83 |
180 |
#else
|
7 |
7u83 |
181 |
extern void output();
|
2 |
7u83 |
182 |
#endif
|
|
|
183 |
|
7 |
7u83 |
184 |
#define comment(X) output("/* %e */\n\n", (X))
|
2 |
7u83 |
185 |
|
|
|
186 |
|
|
|
187 |
#endif
|