source: trunk/idl-compiler/include/parser.h@ 277

Last change on this file since 277 was 277, checked in by cinc, 18 years ago

IDL compiler: improved outfile handling.

File size: 6.5 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2* Version: CDDL 1.0/LGPL 2.1
3*
4* The contents of this file are subject to the COMMON DEVELOPMENT AND
5* DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6* this file except in compliance with the License. You may obtain a copy of
7* the License at http://www.sun.com/cddl/
8*
9* Software distributed under the License is distributed on an "AS IS" basis,
10* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11* for the specific language governing rights and limitations under the
12* License.
13*
14* The Original Code is "NOM" Netlabs Object Model
15*
16* The Initial Developer of the Original Code is
17* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
18* Portions created by the Initial Developer are Copyright (C) 2007
19* the Initial Developer. All Rights Reserved.
20*
21* Contributor(s):
22*
23* Alternatively, the contents of this file may be used under the terms of
24* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
25* case the provisions of the LGPL are applicable instead of those above. If
26* you wish to allow use of your version of this file only under the terms of
27* the LGPL, and not to allow others to use your version of this file under
28* the terms of the CDDL, indicate your decision by deleting the provisions
29* above and replace them with the notice and other provisions required by the
30* LGPL. If you do not delete the provisions above, a recipient may use your
31* version of this file under the terms of any one of the CDDL or the LGPL.
32*
33* ***** END LICENSE BLOCK ***** */
34
35/* in token.c */
36void getNextToken(void);
37gboolean matchCur(GTokenType token);
38gboolean matchNext(GTokenType token);
39guint queryCurTokensKind(void);
40void printToken(GTokenType token);
41gboolean matchNextKind(guint uiKind);
42
43
44#define IDL_COMPILER_STRING "IDL compiler" /* Used inside warnings and errors */
45#define ID_SCOPE 0
46
47/* Holding an overriden method */
48typedef struct
49{
50 gchar* chrName; /* Name of this instance variable */
51 gchar* chrIntroducingIFace;
52}OVERMETHOD, *POVERMETHOD;
53
54#define PARM_DIRECTION_IN 1
55#define PARM_DIRECTION_OUT 2
56#define PARM_DIRECTION_INOUT 3
57/* Holding a method parameter */
58typedef struct
59{
60 guint uiDirection; /* in|out|inout */
61 gchar* chrType; /* Type e.g. gulong or GtkWidget */
62 guint uiStar; /* incremented for each '*' */
63 gchar* chrName;
64}METHODPARAM, *PMETHODPARAM;
65
66/* Holding a method */
67typedef struct
68{
69 gchar* chrRetType; /* Type e.g. gulong or GtkWidget */
70 gchar* chrName;
71 METHODPARAM mpReturn; /* We don't use all fields of this struct */
72 GPtrArray *pParamArray;
73}METHOD, *PMETHOD;
74
75/* Struct holding all the info of a defined or declared interface */
76typedef struct
77{
78 gchar* chrName; /* Name of this interface */
79 gchar* chrParent; /* Name of parent interface */
80 gulong ulMajor; /* Class version */
81 gulong ulMinor; /* Class version */
82 gboolean fIsForwardDeclaration;
83 gboolean fIsInRootFile;
84 gchar* chrMetaClass; /* Pointer to metaclass name or NULL*/
85 char* chrFileStem; /* Holding output filestem */
86 char* chrSourceFileName; /* The preprocessor includes files for us. This is the info
87 about the file this interface is defined in. */
88 GPtrArray *pMethodArray;
89 GPtrArray *pOverrideArray;
90 GPtrArray *pInstanceVarArray;
91}INTERFACE,*PINTERFACE;
92
93/* Info about a symbol */
94typedef struct
95{
96 gchar* chrSymbolName;
97 guint uiSymbolToken;
98 guint uiKind;
99}SYMBOL, *PSYMBOL;
100
101typedef struct
102{
103 PINTERFACE pCurInterface; /* The interface we are currently parsing. This is a working pointer. */
104 guint uiCurSymbolKind; /* This may be e.g. KIND_TYPESPEC */
105 GTree* pSymbolTree; /* Our introduced symbols */
106 GPtrArray* pInterfaceArray; /* The pointer array holding the interfaces we found */
107 guint uiLineCorrection; /* This is the line number put by the preprocessor into
108 the source file. It's used to calculate proper line numbers
109 for errors. */
110 char* chrRootSourceFile; /* File we are intending to parse. Others may get included. */
111 char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info
112 about their name. */
113 char* chrOutfilePath; /* This is only the path, no filename */
114 FILE* outFile; /* Output file handle */
115}PARSEINFO, *PPARSEINFO;
116
117/* Symbols defined for our IDL language.
118 Keep these enums in sync with the order of the idlSymbols struct! */
119enum
120{
121 IDL_SYMBOL_INTERFACE=G_TOKEN_LAST+1,
122 IDL_SYMBOL_CLSVERSION,
123 IDL_SYMBOL_INSTANCEVAR,
124 IDL_SYMBOL_OVERRIDE,
125 IDL_SYMBOL_REGINTERFACE, /* Used for registered interfaces */
126 IDL_SYMBOL_CLSNAME,
127 IDL_SYMBOL_OLDMETACLASS,
128 IDL_SYMBOL_METACLASS,
129 IDL_SYMBOL_FILESTEM, /* Followed by the file name for output */
130 IDL_SYMBOL_NATIVE,
131 /* Some GLib types */
132 IDL_SYMBOL_GULONG, /* 275 */
133 IDL_SYMBOL_GINT,
134 IDL_SYMBOL_GPOINTER,
135 IDL_SYMBOL_GBOOLEAN,
136 IDL_SYMBOL_GCHAR,
137 IDL_SYMBOL_VOID,
138 /* Legacy support */
139 IDL_SYMBOL_BOOLEAN,
140 IDL_SYMBOL_STRING,
141 IDL_SYMBOL_LONG,
142 IDL_SYMBOL_UNSIGNED,
143 /* Direction of method parameters */
144 IDL_SYMBOL_IN,
145 IDL_SYMBOL_OUT,
146 IDL_SYMBOL_INOUT,
147 /* Preprocessor stuff (not yet supported by the compiler) */
148 IDL_SYMBOL_DEFINE,
149 IDL_SYMBOL_IFDEF,
150 IDL_SYMBOL_ENDIF
151};
152
153/* Specifies the kind of a token we read. For example we must
154 know if a read in indentifier is a type specification when
155 parsing method parameters. */
156enum
157{
158 KIND_UNKNOWN =1,
159 KIND_IDENTIFIER,
160 KIND_TYPESPEC, /* That's something like 'gint', 'gulong'... */
161 KIND_DIRECTION /* in, out, inout */
162};
163
164PINTERFACE findInterfaceFromName(gchar* chrName);
165
166void parseTypeSpec(PMETHODPARAM pMethodParam);
167void parseMethod(void);
168void parseInstanceVar(void);
169void parseInterface(GTokenType token);
170void parseClassVersion(void);
171void parseClassVersion(void);
172void parseOverrideMethod(void);
173void parseHash(void);
174void parsePreprocLineInfo(void);
175void parseMetaClass(void);
176void parseFileStem(void);
177
178/* Emitters */
179void emitHFile(GPtrArray* pInterfaceArray);
180void emitIHFile(GPtrArray* pInterfaceArray);
181
182/* In printdata.c */
183void printInterface(PINTERFACE pif);
184void printAllInterfacec(void);
185
186#ifdef INCL_FILE
187FILE* openOutfile(GScanner *gScanner, gchar* chrOutName);
188void closeOutfile(FILE* pFile);
189#endif
Note: See TracBrowser for help on using the repository browser.