Subversion Repositories tendra.SVN

Rev

Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
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
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 30... Line 60...
30
 
60
 
31
#ifndef OUTPUT_INCLUDED
61
#ifndef OUTPUT_INCLUDED
32
#define OUTPUT_INCLUDED
62
#define OUTPUT_INCLUDED
33
 
63
 
34
 
64
 
35
/*
65
/*
36
    LOOP VARIABLES
66
 * LOOP VARIABLES
37
 
67
 *
38
    These variables are used in the LOOP macros below as loop counters.
68
 * These variables are used in the LOOP macros below as loop counters.
39
    It should not be necessary to access them directly, instead the
69
 * It should not be necessary to access them directly, instead the
40
    CRT macros below should be used.
70
 * CRT macros below should be used.
41
*/
71
 */
42
 
72
 
43
extern LIST ( ECONST_P ) crt_ec ;
73
extern LIST(ECONST_P)crt_ec;
44
extern LIST ( ENUM_P ) crt_en ;
74
extern LIST(ENUM_P)crt_en;
45
extern LIST ( IDENTITY_P ) crt_id ;
75
extern LIST(IDENTITY_P)crt_id;
46
extern LIST ( PRIMITIVE_P ) crt_prim ;
76
extern LIST(PRIMITIVE_P)crt_prim;
47
extern LIST ( STRUCTURE_P ) crt_str ;
77
extern LIST(STRUCTURE_P)crt_str;
48
extern LIST ( UNION_P ) crt_union ;
78
extern LIST(UNION_P)crt_union;
49
extern LIST ( COMPONENT_P ) crt_cmp ;
79
extern LIST(COMPONENT_P)crt_cmp;
50
extern LIST ( FIELD_P ) crt_fld ;
80
extern LIST(FIELD_P)crt_fld;
51
extern LIST ( MAP_P ) crt_map ;
81
extern LIST(MAP_P)crt_map;
52
extern LIST ( ARGUMENT_P ) crt_arg ;
82
extern LIST(ARGUMENT_P)crt_arg;
53
extern LIST ( TYPE_P ) crt_type ;
83
extern LIST(TYPE_P)crt_type;
54
 
84
 
55
 
85
 
56
/*
86
/*
57
    LOOP MACROS
87
 * LOOP MACROS
58
 
88
 *
59
    The LOOP macros are used to scan over all elements of a list.  The
89
 * The LOOP macros are used to scan over all elements of a list.  The
60
    CRT macros give the effective loop counters.  Thus, for example,
90
 * CRT macros give the effective loop counters.  Thus, for example,
61
    LOOP_ENUM is a for statement which makes CRT_ENUM scan over all the
91
 * LOOP_ENUM is a for statement which makes CRT_ENUM scan over all the
62
    enumeration types.
92
 * enumeration types.
63
*/
93
 */
64
 
94
 
65
#define LOOP_LIST( X, Y )\
95
#define LOOP_LIST(X, Y)\
66
    for ( ( X ) = ( Y ) ; !IS_NULL_list ( X ) ; ( X ) = TAIL_list ( X ) )
96
 for ((X) = (Y); !IS_NULL_list(X); (X) = TAIL_list(X))
67
 
97
 
68
#define LOOP_ENUM\
98
#define LOOP_ENUM\
69
    LOOP_LIST ( crt_en, algebra->enumerations )
99
    LOOP_LIST(crt_en, algebra->enumerations)
70
 
100
 
71
#define LOOP_IDENTITY\
101
#define LOOP_IDENTITY\
72
    LOOP_LIST ( crt_id, algebra->identities )
102
    LOOP_LIST(crt_id, algebra->identities)
73
 
103
 
74
#define LOOP_PRIMITIVE\
104
#define LOOP_PRIMITIVE\
75
    LOOP_LIST ( crt_prim, algebra->primitives )
105
    LOOP_LIST(crt_prim, algebra->primitives)
76
 
106
 
77
#define LOOP_STRUCTURE\
107
#define LOOP_STRUCTURE\
78
    LOOP_LIST ( crt_str, algebra->structures )
108
    LOOP_LIST(crt_str, algebra->structures)
79
 
109
 
80
#define LOOP_UNION\
110
#define LOOP_UNION\
81
    LOOP_LIST ( crt_union, algebra->unions )
111
    LOOP_LIST(crt_union, algebra->unions)
82
 
112
 
83
#define LOOP_ENUM_CONST\
113
#define LOOP_ENUM_CONST\
84
    LOOP_LIST ( crt_ec, DEREF_list ( en_consts ( CRT_ENUM ) ) )
114
    LOOP_LIST(crt_ec, DEREF_list(en_consts(CRT_ENUM)))
85
 
115
 
86
#define LOOP_STRUCTURE_COMPONENT\
116
#define LOOP_STRUCTURE_COMPONENT\
87
    LOOP_LIST ( crt_cmp, DEREF_list ( str_defn ( CRT_STRUCTURE ) ) )
117
    LOOP_LIST(crt_cmp, DEREF_list(str_defn(CRT_STRUCTURE)))
88
 
118
 
89
#define LOOP_UNION_COMPONENT\
119
#define LOOP_UNION_COMPONENT\
90
    LOOP_LIST ( crt_cmp, DEREF_list ( un_s_defn ( CRT_UNION ) ) )
120
    LOOP_LIST(crt_cmp, DEREF_list(un_s_defn(CRT_UNION)))
91
 
121
 
92
#define LOOP_UNION_FIELD\
122
#define LOOP_UNION_FIELD\
93
    LOOP_LIST ( crt_fld, DEREF_list ( un_u_defn ( CRT_UNION ) ) )
123
    LOOP_LIST(crt_fld, DEREF_list(un_u_defn(CRT_UNION)))
94
 
124
 
95
#define LOOP_FIELD_COMPONENT\
125
#define LOOP_FIELD_COMPONENT\
96
    LOOP_LIST ( crt_cmp, DEREF_list ( fld_defn ( CRT_FIELD ) ) )
126
    LOOP_LIST(crt_cmp, DEREF_list(fld_defn(CRT_FIELD)))
97
 
127
 
98
#define LOOP_UNION_MAP\
128
#define LOOP_UNION_MAP\
99
    LOOP_LIST ( crt_map, DEREF_list ( un_map ( CRT_UNION ) ) )
129
    LOOP_LIST(crt_map, DEREF_list(un_map(CRT_UNION)))
100
 
130
 
101
#define LOOP_MAP_ARGUMENT\
131
#define LOOP_MAP_ARGUMENT\
102
    LOOP_LIST ( crt_arg, DEREF_list ( map_args ( CRT_MAP ) ) )
132
    LOOP_LIST(crt_arg, DEREF_list(map_args(CRT_MAP)))
103
 
133
 
104
#define LOOP_TYPE\
134
#define LOOP_TYPE\
105
    LOOP_LIST ( crt_type, algebra->types )
135
    LOOP_LIST(crt_type, algebra->types)
106
 
136
 
107
#define CRT_ENUM	DEREF_ptr ( HEAD_list ( crt_en ) )
137
#define CRT_ENUM	DEREF_ptr(HEAD_list(crt_en))
108
#define CRT_IDENTITY	DEREF_ptr ( HEAD_list ( crt_id ) )
138
#define CRT_IDENTITY	DEREF_ptr(HEAD_list(crt_id))
109
#define CRT_PRIMITIVE	DEREF_ptr ( HEAD_list ( crt_prim ) )
139
#define CRT_PRIMITIVE	DEREF_ptr(HEAD_list(crt_prim))
110
#define CRT_STRUCTURE	DEREF_ptr ( HEAD_list ( crt_str ) )
140
#define CRT_STRUCTURE	DEREF_ptr(HEAD_list(crt_str))
111
#define CRT_UNION	DEREF_ptr ( HEAD_list ( crt_union ) )
141
#define CRT_UNION	DEREF_ptr(HEAD_list(crt_union))
112
#define CRT_ECONST	DEREF_ptr ( HEAD_list ( crt_ec ) )
142
#define CRT_ECONST	DEREF_ptr(HEAD_list(crt_ec))
113
#define CRT_COMPONENT	DEREF_ptr ( HEAD_list ( crt_cmp ) )
143
#define CRT_COMPONENT	DEREF_ptr(HEAD_list(crt_cmp))
114
#define CRT_FIELD	DEREF_ptr ( HEAD_list ( crt_fld ) )
144
#define CRT_FIELD	DEREF_ptr(HEAD_list(crt_fld))
115
#define CRT_MAP		DEREF_ptr ( HEAD_list ( crt_map ) )
145
#define CRT_MAP		DEREF_ptr(HEAD_list(crt_map))
116
#define CRT_ARGUMENT	DEREF_ptr ( HEAD_list ( crt_arg ) )
146
#define CRT_ARGUMENT	DEREF_ptr(HEAD_list(crt_arg))
117
#define CRT_TYPE	DEREF_ptr ( HEAD_list ( crt_type ) )
147
#define CRT_TYPE	DEREF_ptr(HEAD_list(crt_type))
118
 
148
 
119
#define HAVE_ENUM	( !IS_NULL_list ( crt_en ) )
149
#define HAVE_ENUM	(!IS_NULL_list(crt_en))
120
#define HAVE_IDENTITY	( !IS_NULL_list ( crt_id ) )
150
#define HAVE_IDENTITY	(!IS_NULL_list(crt_id))
121
#define HAVE_PRIMITIVE	( !IS_NULL_list ( crt_prim ) )
151
#define HAVE_PRIMITIVE	(!IS_NULL_list(crt_prim))
122
#define HAVE_STRUCTURE	( !IS_NULL_list ( crt_str ) )
152
#define HAVE_STRUCTURE	(!IS_NULL_list(crt_str))
123
#define HAVE_UNION	( !IS_NULL_list ( crt_union ) )
153
#define HAVE_UNION	(!IS_NULL_list(crt_union))
124
#define HAVE_ECONST	( !IS_NULL_list ( crt_ec ) )
154
#define HAVE_ECONST	(!IS_NULL_list(crt_ec))
125
#define HAVE_COMPONENT	( !IS_NULL_list ( crt_cmp ) )
155
#define HAVE_COMPONENT	(!IS_NULL_list(crt_cmp))
126
#define HAVE_FIELD	( !IS_NULL_list ( crt_fld ) )
156
#define HAVE_FIELD	(!IS_NULL_list(crt_fld))
127
#define HAVE_MAP	( !IS_NULL_list ( crt_map ) )
157
#define HAVE_MAP	(!IS_NULL_list(crt_map))
128
#define HAVE_ARGUMENT	( !IS_NULL_list ( crt_arg ) )
158
#define HAVE_ARGUMENT	(!IS_NULL_list(crt_arg))
129
#define HAVE_TYPE	( !IS_NULL_list ( crt_type ) )
159
#define HAVE_TYPE	(!IS_NULL_list(crt_type))
130
 
160
 
131
 
161
 
132
/*
162
/*
133
    DECLARATIONS FOR BASIC OUTPUT ROUTINES
163
 * DECLARATIONS FOR BASIC OUTPUT ROUTINES
134
*/
164
 */
135
 
165
 
136
extern int unique ;
166
extern int unique;
137
extern int const_tokens ;
167
extern int const_tokens;
138
extern int have_varargs ;
168
extern int have_varargs;
139
extern int output_c_code ;
169
extern int output_c_code;
140
extern int verbose_output ;
170
extern int verbose_output;
141
extern FILE *output_file ;
171
extern FILE *output_file;
142
extern void flush_output PROTO_S ( ( void ) ) ;
172
extern void flush_output(void);
143
extern void open_file PROTO_S ( ( char *, char *, char * ) ) ;
173
extern void open_file(char *, char *, char *);
144
extern void close_file PROTO_S ( ( void ) ) ;
174
extern void close_file(void);
145
extern void output_type PROTO_S ( ( TYPE_P ) ) ;
175
extern void output_type(TYPE_P);
146
extern number log2 PROTO_S ( ( number ) ) ;
176
extern number log2(number);
147
 
177
 
148
#if FS_STDARG
178
#if FS_STDARG
149
extern void output ( char *, ... ) ;
179
extern void output(char *, ...);
150
#else
180
#else
151
extern void output () ;
181
extern void output();
152
#endif
182
#endif
153
 
183
 
154
#define comment( X )	output ( "/* %e */\n\n", ( X ) )
184
#define comment(X)	output("/* %e */\n\n", (X))
155
 
185
 
156
 
186
 
157
#endif
187
#endif