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 */
|
---|
36 | void getNextToken(void);
|
---|
37 | gboolean matchCur(GTokenType token);
|
---|
38 | gboolean matchNext(GTokenType token);
|
---|
39 | guint queryCurTokensKind(void);
|
---|
40 | void printToken(GTokenType token);
|
---|
41 | gboolean 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 */
|
---|
48 | typedef 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 */
|
---|
58 | typedef 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 */
|
---|
67 | typedef 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 */
|
---|
76 | typedef 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* chrSourceFileName; /* The preprocessor includes files for us. This is the info
|
---|
86 | about the file this interface is defined in. */
|
---|
87 | GPtrArray *pMethodArray;
|
---|
88 | GPtrArray *pOverrideArray;
|
---|
89 | GPtrArray *pInstanceVarArray;
|
---|
90 | }INTERFACE,*PINTERFACE;
|
---|
91 |
|
---|
92 | /* Info about a symbol */
|
---|
93 | typedef struct
|
---|
94 | {
|
---|
95 | gchar* chrSymbolName;
|
---|
96 | guint uiSymbolToken;
|
---|
97 | guint uiKind;
|
---|
98 | }SYMBOL, *PSYMBOL;
|
---|
99 |
|
---|
100 | typedef struct
|
---|
101 | {
|
---|
102 | PINTERFACE pCurInterface; /* The interface we are currently parsing. This is a working pointer. */
|
---|
103 | guint uiCurSymbolKind; /* This may be e.g. KIND_TYPESPEC */
|
---|
104 | GTree* pSymbolTree; /* Our introduced symbols */
|
---|
105 | GPtrArray* pInterfaceArray; /* The pointer array holding the interfaces we found */
|
---|
106 | guint uiLineCorrection; /* This is the line number put by the preprocessor into
|
---|
107 | the source file. It's used to calculate proper line numbers
|
---|
108 | for errors. */
|
---|
109 | char* chrRootSourceFile; /* File we are intending to parse. Others may get included. */
|
---|
110 | char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info
|
---|
111 | about their name. */
|
---|
112 | FILE* outFile; /* Output file handle */
|
---|
113 | }PARSEINFO, *PPARSEINFO;
|
---|
114 |
|
---|
115 | /* Symbols defined for our IDL language.
|
---|
116 | Keep these enums in sync with the order of the idlSymbols struct! */
|
---|
117 | enum
|
---|
118 | {
|
---|
119 | IDL_SYMBOL_INTERFACE=G_TOKEN_LAST+1,
|
---|
120 | IDL_SYMBOL_CLSVERSION,
|
---|
121 | IDL_SYMBOL_INSTANCEVAR,
|
---|
122 | IDL_SYMBOL_OVERRIDE,
|
---|
123 | IDL_SYMBOL_REGINTERFACE, /* Used for registered interfaces */
|
---|
124 | IDL_SYMBOL_CLSNAME,
|
---|
125 | IDL_SYMBOL_OLDMETACLASS,
|
---|
126 | IDL_SYMBOL_METACLASS,
|
---|
127 | IDL_SYMBOL_NATIVE,
|
---|
128 | /* Some GLib types */
|
---|
129 | IDL_SYMBOL_GULONG, /* 275 */
|
---|
130 | IDL_SYMBOL_GINT,
|
---|
131 | IDL_SYMBOL_GPOINTER,
|
---|
132 | IDL_SYMBOL_GBOOLEAN,
|
---|
133 | IDL_SYMBOL_GCHAR,
|
---|
134 | IDL_SYMBOL_VOID,
|
---|
135 | /* Legacy support */
|
---|
136 | IDL_SYMBOL_BOOLEAN,
|
---|
137 | IDL_SYMBOL_STRING,
|
---|
138 | IDL_SYMBOL_LONG,
|
---|
139 | IDL_SYMBOL_UNSIGNED,
|
---|
140 | /* Direction of method parameters */
|
---|
141 | IDL_SYMBOL_IN,
|
---|
142 | IDL_SYMBOL_OUT,
|
---|
143 | IDL_SYMBOL_INOUT,
|
---|
144 | /* Preprocessor stuff (not yet supported by the compiler) */
|
---|
145 | IDL_SYMBOL_DEFINE,
|
---|
146 | IDL_SYMBOL_IFDEF,
|
---|
147 | IDL_SYMBOL_ENDIF
|
---|
148 | };
|
---|
149 |
|
---|
150 | /* Specifies the kind of a token we read. For example we must
|
---|
151 | know if a read in indentifier is a type specification when
|
---|
152 | parsing method parameters. */
|
---|
153 | enum
|
---|
154 | {
|
---|
155 | KIND_UNKNOWN =1,
|
---|
156 | KIND_IDENTIFIER,
|
---|
157 | KIND_TYPESPEC, /* That's something like 'gint', 'gulong'... */
|
---|
158 | KIND_DIRECTION /* in, out, inout */
|
---|
159 | };
|
---|
160 |
|
---|
161 | PINTERFACE findInterfaceFromName(gchar* chrName);
|
---|
162 |
|
---|
163 | void parseTypeSpec(PMETHODPARAM pMethodParam);
|
---|
164 | void parseMethod(void);
|
---|
165 | void parseInstanceVar(void);
|
---|
166 | void parseInterface(GTokenType token);
|
---|
167 | void parseClassVersion(void);
|
---|
168 | void parseClassVersion(void);
|
---|
169 | void parseOverrideMethod(void);
|
---|
170 | void parseHash(void);
|
---|
171 | void parsePreprocLineInfo(void);
|
---|
172 | void parseMetaClass(void);
|
---|
173 |
|
---|
174 | void emitHFile(GPtrArray* pInterfaceArray);
|
---|
175 |
|
---|
176 | /* In printdata.c */
|
---|
177 | void printInterface(PINTERFACE pif);
|
---|
178 | void printAllInterfacec(void);
|
---|