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