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) 2005-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 | /* In printdata.c */
|
---|
44 | void printInterface(void);
|
---|
45 |
|
---|
46 |
|
---|
47 | #define IDL_COMPILER_STRING "IDL compiler" /* Used inside warnings and errors */
|
---|
48 |
|
---|
49 | /* Holding an overriden method */
|
---|
50 | typedef struct
|
---|
51 | {
|
---|
52 | gchar* chrName; /* Name of this instance variable */
|
---|
53 | }OVERMETHOD, *POVERMETHOD;
|
---|
54 |
|
---|
55 | #define PARM_DIRECTION_IN 1
|
---|
56 | #define PARM_DIRECTION_OUT 2
|
---|
57 | #define PARM_DIRECTION_INOUT 3
|
---|
58 | /* Holding a method parameter */
|
---|
59 | typedef struct
|
---|
60 | {
|
---|
61 | guint uiDirection; /* in|out|inout */
|
---|
62 | gchar* chrType; /* Type e.g. gulong or GtkWidget */
|
---|
63 | guint uiStar; /* incremented for each '*' */
|
---|
64 | gchar* chrName;
|
---|
65 | }METHODPARAM, *PMETHODPARAM;
|
---|
66 |
|
---|
67 | /* Holding a method */
|
---|
68 | typedef struct
|
---|
69 | {
|
---|
70 | gchar* chrRetType; /* Type e.g. gulong or GtkWidget */
|
---|
71 | gchar* chrName;
|
---|
72 | METHODPARAM mpReturn; /* We don't use all fields of this struct */
|
---|
73 | GPtrArray *pParamArray;
|
---|
74 | }METHOD, *PMETHOD;
|
---|
75 |
|
---|
76 | /* Struct holding all the info of a defined or declared interface */
|
---|
77 | typedef struct
|
---|
78 | {
|
---|
79 | gchar* chrName; /* Name of this interface */
|
---|
80 | gchar *chrParent; /* Name of parent interface */
|
---|
81 | gulong ulMajor; /* Class version */
|
---|
82 | gulong ulMinor; /* Class version */
|
---|
83 | gboolean fIsForwardDeclaration;
|
---|
84 | GPtrArray *pMethodArray;
|
---|
85 | GPtrArray *pOverrideArray;
|
---|
86 | GPtrArray *pInstanceVarArray;
|
---|
87 | }INTERFACE,*PINTERFACE;
|
---|
88 |
|
---|
89 | /* Info about a symbol */
|
---|
90 | typedef struct
|
---|
91 | {
|
---|
92 | gchar* chrSymbolName;
|
---|
93 | guint uiSymbolToken;
|
---|
94 | guint uiKind;
|
---|
95 | }SYMBOL, *PSYMBOL;
|
---|
96 |
|
---|
97 | /* Such a struct can be found in GScanner->user_data */
|
---|
98 | typedef struct
|
---|
99 | {
|
---|
100 | const SYMBOL *pSymbols; /* List of our introduced symbols */
|
---|
101 | guint uiCurSymbolKind;
|
---|
102 | }SYMBOLINFO,*PSYMBOLINFO;
|
---|
103 |
|
---|
104 | /* Symbols defined for our IDL language.
|
---|
105 | Keep these enums in sync with the order of the idlSymbols struct! */
|
---|
106 | enum
|
---|
107 | {
|
---|
108 | IDL_SYMBOL_INTERFACE=G_TOKEN_LAST+1,
|
---|
109 | IDL_SYMBOL_CLSVERSION,
|
---|
110 | IDL_SYMBOL_INSTANCEVAR,
|
---|
111 | IDL_SYMBOL_OVERRIDE,
|
---|
112 | /* Some GLib types */
|
---|
113 | IDL_SYMBOL_GULONG, /* 275 */
|
---|
114 | IDL_SYMBOL_GINT,
|
---|
115 | IDL_SYMBOL_GPOINTER,
|
---|
116 | IDL_SYMBOL_GBOOLEAN,
|
---|
117 | /* Direction of method parameters */
|
---|
118 | IDL_SYMBOL_IN,
|
---|
119 | IDL_SYMBOL_OUT,
|
---|
120 | IDL_SYMBOL_INOUT,
|
---|
121 | /* Preprocessor stuff (not yet supported by the compiler) */
|
---|
122 | IDL_SYMBOL_DEFINE,
|
---|
123 | IDL_SYMBOL_IFDEF,
|
---|
124 | IDL_SYMBOL_ENDIF
|
---|
125 | };
|
---|
126 |
|
---|
127 | /* Specifies the kind of a token we read. For example we must
|
---|
128 | know if a read in indentifier is a type specification when
|
---|
129 | parsing method parameters. */
|
---|
130 | enum
|
---|
131 | {
|
---|
132 | KIND_UNKNOWN =1,
|
---|
133 | KIND_IDENTIFIER,
|
---|
134 | KIND_TYPESPEC, /* That's something like 'gint', 'gulong'... */
|
---|
135 | KIND_DIRECTION /* in, out, inout */
|
---|
136 | };
|
---|
137 |
|
---|
138 |
|
---|
139 | void parseTypeSpec(PMETHODPARAM pMethodParam);
|
---|
140 | void parseMethod(void);
|
---|
141 | void parseInstanceVar(void);
|
---|
142 | void parseInterface(GTokenType token);
|
---|
143 | void parseClassVersion(void);
|
---|
144 |
|
---|
145 | void parseClassVersion(void);
|
---|
146 | void parseOverrideMethod(void);
|
---|
147 |
|
---|
148 |
|
---|