]> git.draconx.ca Git - gob-dx.git/blob - src/tree.h
Release 0.92.2
[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         C_CCODE,
41         H_CCODE,
42         HT_CCODE,
43         PH_CCODE
44 };
45
46 typedef union _Node Node;
47
48 typedef struct _CCode CCode;
49 struct _CCode {
50         int type;
51         int cctype;
52         char *cbuf;
53         int line_no;
54 };
55
56 typedef struct _Class Class;
57 struct _Class {
58         int type;
59         char *otype; /*this object class type*/
60         char *ptype; /*parent class type*/
61         GList *nodes;
62 };
63
64 typedef struct _Type Type;
65 struct _Type {
66         int type;
67         int stars;
68         char *name;
69         char *postfix;
70 };
71
72 enum {
73         NULL_CHECK,
74         TYPE_CHECK,
75         LT_CHECK,
76         GT_CHECK,
77         LE_CHECK,
78         GE_CHECK,
79         EQ_CHECK,
80         NE_CHECK
81 };
82
83 typedef struct _Check Check;
84 struct _Check {
85         int type;
86         int chtype;
87         char *number;
88 };
89
90 typedef struct _FuncArg FuncArg;
91 struct _FuncArg {
92         int type;
93         Type *atype;
94         char *name;
95         GList *checks;
96 };
97
98 typedef struct _Argument Argument;
99 struct _Argument {
100         int type;
101         char *gtktype;
102         Type *atype;
103         GList *flags;
104         char *name;
105         char *get;
106         int get_line;
107         char *set;
108         int set_line;
109         int line_no;
110 };
111         
112 /*scope type*/
113 enum {
114         NO_SCOPE,
115         PUBLIC_SCOPE,
116         PRIVATE_SCOPE,
117         PROTECTED_SCOPE,
118 };
119
120 /* method type */
121 enum {
122         REGULAR_METHOD,
123         INIT_METHOD,
124         CLASS_INIT_METHOD,
125         VIRTUAL_METHOD,
126         SIGNAL_LAST_METHOD,
127         SIGNAL_FIRST_METHOD,
128         OVERRIDE_METHOD
129 };
130
131 typedef struct _Method Method;
132 struct _Method {
133         int type;
134         int scope; /* scope type */
135         int method; /* method type */
136         Type *mtype;
137         char *otype; /*for override methods*/
138         GList *gtktypes; /*GTK types for a signal*/
139         char *id;
140         GList *args;
141         char *onerror;
142         char *cbuf;
143         int line_no;
144         int ccode_line;
145         gboolean vararg;
146 };
147
148 typedef struct _Variable Variable;
149 struct _Variable {
150         int type;
151         int scope;
152         Type *vtype;
153         char *id;
154         int line_no;
155 };
156
157 union _Node {
158         int type;
159         CCode ccode;
160         Class class;
161         Type _type;
162         Check check;
163         Argument argument;
164         Method method;
165         Variable variable;
166 };
167
168 Node *new_ccode(int cctype, char *cbuf, int line_no);
169 Node *new_class(char *otype, char *ptype, GList *nodes);
170 Node *new_type(int stars, char *name, char *postfix);
171 Node *new_check(int chtype, char *number);
172 Node *new_funcarg(Type *atype, char *name, GList *checks);
173 Node *new_method(int scope, int method, Type *mtype, char *otype, GList *gtktypes, char *id, GList *args, char *onerror, char *cbuf, int line_no, int ccode_line, gboolean vararg);
174 Node *new_argument(char *gtktype, Type *atype, GList *flags, char *name, char *get, int get_line, char *set, int set_line, int line_no);
175 Node *new_variable(int scope, Type *vtype, char *id,int line_no);
176
177 #endif