merge the formfield patch from ooo-build
[ooovba.git] / idlc / source / preproc / cpp.h
blob361295bb3325a1d842cceac0b94124d41f3111c1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cpp.h,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #define INS 32768 /* input buffer */
32 #define OBS 8092 /* outbut buffer */
33 #define NARG 32 /* Max number arguments to a macro */
34 #define NINCLUDE 32 /* Max number of include directories (-I) */
35 #define NIF 64 /* depth of nesting of #if */
36 #define NINC 32 /* depth of nesting of #include */
38 #ifndef EOF
39 #define EOF (-1)
40 #endif
42 #ifndef NULL
43 #define NULL 0
44 #endif
46 #ifndef __alpha
47 typedef unsigned char uchar;
49 #endif
51 enum toktype
53 END, UNCLASS, NAME, NUMBER, STRING, CCON, NL, WS, DSHARP,
54 EQ, NEQ, LEQ, GEQ, LSH, RSH, LAND, LOR, PPLUS, MMINUS,
55 ARROW, SBRA, SKET, LP, RP, DOT, AND, STAR, PLUS, MINUS,
56 TILDE, NOT, SLASH, PCT, LT, GT, CIRC, OR, QUEST,
57 COLON, ASGN, COMMA, SHARP, SEMIC, CBRA, CKET,
58 ASPLUS, ASMINUS, ASSTAR, ASSLASH, ASPCT, ASCIRC, ASLSH,
59 ASRSH, ASOR, ASAND, ELLIPS,
60 DSHARP1, NAME1, NAME2, DEFINED, UMINUS, ARCHITECTURE, IDENT,
61 COMMENT
64 enum kwtype
66 KIF, KIFDEF, KIFNDEF, KELIF, KELSE, KENDIF, KINCLUDE, KINCLUDENEXT,
67 KIMPORT, KDEFINE, KUNDEF, KLINE, KERROR, KPRAGMA, KIDENT, KDEFINED,
68 KMACHINE, KLINENO, KFILE, KDATE, KTIME, KSTDC, KEVAL
71 #define ISDEFINED 0x01 /* has #defined value */
72 #define ISKW 0x02 /* is PP keyword */
73 #define ISUNCHANGE 0x04 /* can't be #defined in PP */
74 #define ISMAC 0x08 /* builtin macro, e.g. __LINE__ */
75 #define ISARCHITECTURE 0x10 /* architecture */
76 #define ISACTIVE 0x80 /* is macro currently expanded */
78 #define EOB 0xFE /* sentinel for end of input buffer */
79 #define EOFC 0xFD /* sentinel for end of input file */
80 #define XPWS 1 /* token flag: white space to assure token sep. */
81 #define XTWS 2
83 typedef struct token
85 unsigned char type;
86 unsigned char flag;
87 unsigned int wslen;
88 unsigned int len;
89 uchar *t;
90 } Token;
92 typedef struct tokenrow
94 Token *tp; /* current one to scan */
95 Token *bp; /* base (allocated value) */
96 Token *lp; /* last+1 token used */
97 int max; /* number allocated */
98 } Tokenrow;
100 typedef struct source
102 char *filename; /* name of file of the source */
103 int line; /* current line number */
104 int lineinc; /* adjustment for \\n lines */
105 uchar *inb; /* input buffer */
106 uchar *inp; /* input pointer */
107 uchar *inl; /* end of input */
108 int fd; /* input source */
109 int ifdepth; /* conditional nesting in include */
110 int pathdepth;
111 int wrap;
112 struct source *next; /* stack for #include */
113 } Source;
115 typedef struct nlist
117 struct nlist *next;
118 uchar *name;
119 int len;
120 Tokenrow *vp; /* value as macro */
121 Tokenrow *ap; /* list of argument names, if any */
122 char val; /* value as preprocessor name */
123 char flag; /* is defined, is pp name */
124 uchar *loc; /* location of definition */
125 } Nlist;
127 typedef struct includelist
129 char deleted;
130 char always;
131 char *file;
132 } Includelist;
134 typedef struct wraplist
136 char *file;
137 } Wraplist;
139 #define new(t) (t *)domalloc(sizeof(t))
140 #define quicklook(a,b) (namebit[(a)&077] & (1<<((b)&037)))
141 #define quickset(a,b) namebit[(a)&077] |= (1<<((b)&037))
142 extern unsigned long namebit[077 + 1];
144 enum errtype
146 INFO, WARNING, ERROR, FATAL
149 void expandlex(void);
150 void setup(int, char **);
151 int gettokens(Tokenrow *, int);
152 int comparetokens(Tokenrow *, Tokenrow *);
153 Source *setsource(char *, int, int, char *, int);
154 void unsetsource(void);
155 void puttokens(Tokenrow *);
156 void process(Tokenrow *);
157 void *domalloc(int);
158 void dofree(void *);
159 void error(enum errtype, char *,...);
160 void flushout(void);
161 int fillbuf(Source *);
162 int trigraph(Source *);
163 int foldline(Source *);
164 Nlist *lookup(Token *, int);
165 void control(Tokenrow *);
166 void dodefine(Tokenrow *);
167 void doadefine(Tokenrow *, int);
168 void doinclude(Tokenrow *, int, int);
169 void doif(Tokenrow *, enum kwtype);
170 void expand(Tokenrow *, Nlist *);
171 void builtin(Tokenrow *, int);
172 int gatherargs(Tokenrow *, Tokenrow **, int *);
173 void substargs(Nlist *, Tokenrow *, Tokenrow **);
174 void expandrow(Tokenrow *, char *);
175 void maketokenrow(int, Tokenrow *);
176 Tokenrow *copytokenrow(Tokenrow *, Tokenrow *);
177 Token *growtokenrow(Tokenrow *);
178 Tokenrow *normtokenrow(Tokenrow *);
179 void adjustrow(Tokenrow *, int);
180 void movetokenrow(Tokenrow *, Tokenrow *);
181 void insertrow(Tokenrow *, int, Tokenrow *);
182 void peektokens(Tokenrow *, char *);
183 void doconcat(Tokenrow *);
184 Tokenrow *stringify(Tokenrow *);
185 int lookuparg(Nlist *, Token *);
186 long eval(Tokenrow *, int);
187 void genline(void);
188 void genimport(char *, int, char *, int);
189 void genwrap(int);
190 void setempty(Tokenrow *);
191 void makespace(Tokenrow *, Token *);
192 char *outnum(char *, int);
193 int digit(int);
194 uchar *newstring(uchar *, int, int);
196 #define rowlen(tokrow) ((tokrow)->lp - (tokrow)->bp)
198 extern char *outptr;
199 extern Token nltoken;
200 extern Source *cursource;
201 extern char *curtime;
202 extern int incdepth;
203 extern int ifdepth;
204 extern int ifsatisfied[NIF];
205 extern int Mflag;
206 extern int Iflag;
207 extern int Pflag;
208 extern int Aflag;
209 extern int Lflag;
210 extern int Xflag;
211 extern int Vflag;
212 extern int Cflag;
213 extern int Cplusplus;
214 extern int skipping;
215 extern Nlist *kwdefined;
216 extern Includelist includelist[NINCLUDE];
217 extern Wraplist wraplist[NINCLUDE];
218 extern char wd[];