]> git.draconx.ca Git - gob-dx.git/blob - src/tree.h
Release 0.93.1
[gob-dx.git] / src / tree.h
1 /* GOB C Preprocessor
2  * Copyright (C) 1999 the Free Software Foundation.
3  *
4  * Author: George Lebl
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the  Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19  * USA.
20  */
21
22 #ifndef _TREE_H_
23 #define _TREE_H_
24
25 #include <glib.h>
26
27 enum {
28         CCODE_NODE,
29         CLASS_NODE,
30         TYPE_NODE,
31         CHECK_NODE,
32         FUNCARG_NODE,
33         METHOD_NODE,
34         ARGUMENT_NODE,
35         VARIABLE_NODE
36 };
37
38 /* for ccode type */
39 enum {
40         A_CCODE,
41         AT_CCODE,
42         C_CCODE,
43         H_CCODE,
44         HT_CCODE,
45         PH_CCODE
46 };
47
48 typedef union _Node Node;
49
50 typedef struct _CCode CCode;
51 struct _CCode {
52         int type;
53         int cctype;
54         char *cbuf;
55         int line_no;
56 };
57
58 typedef struct _Class Class;
59 struct _Class {
60         int type;
61         char *otype; /*this object class type*/
62         char *ptype; /*parent class type*/
63         GList *nodes;
64 };
65
66 typedef struct _Type Type;
67 struct _Type {
68         int type;
69         int stars;
70         char *name;
71         char *postfix;
72 };
73
74 enum {
75         NULL_CHECK,
76         TYPE_CHECK,
77         LT_CHECK,
78         GT_CHECK,
79         LE_CHECK,
80         GE_CHECK,
81         EQ_CHECK,
82         NE_CHECK
83 };
84
85 typedef struct _Check Check;
86 struct _Check {
87         int type;
88         int chtype;
89         char *number;
90 };
91
92 typedef struct _FuncArg FuncArg;
93 struct _FuncArg {
94         int type;
95         Type *atype;
96         char *name;
97         GList *checks;
98 };
99
100 typedef struct _Argument Argument;
101 struct _Argument {
102         int type;
103         char *gtktype;
104         Type *atype;
105         GList *flags;
106         char *name;
107         char *get;
108         int get_line;
109         char *set;
110         int set_line;
111         int line_no;
112 };
113         
114 /*scope type*/
115 enum {
116         NO_SCOPE,
117         PUBLIC_SCOPE,
118         PRIVATE_SCOPE,
119         PROTECTED_SCOPE
120 };
121
122 /* method type */
123 enum {
124         REGULAR_METHOD,
125         INIT_METHOD,
126         CLASS_INIT_METHOD,
127         VIRTUAL_METHOD,
128         SIGNAL_LAST_METHOD,
129         SIGNAL_FIRST_METHOD,
130         OVERRIDE_METHOD
131 };
132
133 typedef struct _Method Method;
134 struct _Method {
135         int type;
136         int scope; /* scope type */
137         int method; /* method type */
138         Type *mtype;
139         char *otype; /*for override methods*/
140         GList *gtktypes; /*GTK types for a signal*/
141         GList *flags; /* GTK_RUN_* flags for a signal */
142         char *id;
143         GList *args;
144         char *onerror;
145         char *cbuf;
146         int line_no;
147         int ccode_line;
148         gboolean vararg;
149 };
150
151 typedef struct _Variable Variable;
152 struct _Variable {
153         int type;
154         int scope;
155         Type *vtype;
156         char *id;
157         int line_no;
158         char *destructor;
159         int destructor_line;
160         gboolean destructor_simple;
161         char *initializer;
162         int initializer_line;
163 };
164
165 union _Node {
166         int type;
167         CCode ccode;
168         Class class;
169         Type _type;
170         Check check;
171         Argument argument;
172         Method method;
173         Variable variable;
174 };
175
176 Node *new_ccode(int cctype, char *cbuf, int line_no);
177 Node *new_class(char *otype, char *ptype, GList *nodes);
178 Node *new_type(int stars, char *name, char *postfix);
179 Node *new_check(int chtype, char *number);
180 Node *new_funcarg(Type *atype, char *name, GList *checks);
181 Node *new_method(int scope, int method, Type *mtype, char *otype,
182                  GList *gtktypes, GList *flags, char *id, GList *args,
183                  char *onerror, char *cbuf, int line_no, int ccode_line,
184                  gboolean vararg);
185 Node *new_argument(char *gtktype, Type *atype, GList *flags, char *name,
186                    char *get, int get_line, char *set, int set_line,
187                    int line_no);
188 Node *new_variable(int scope, Type *vtype, char *id, int line_no,
189                    char *destructor, int destructor_line,
190                    gboolean destructor_simple,
191                    char *initializer, int initializer_line);
192
193 Type *copy_type(Type *type);
194
195 #endif