]> git.draconx.ca Git - gob-dx.git/blob - src/tree.h
Release 0.92.0
[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         GList *flags;
95         char *name;
96         char *get;
97         int get_line;
98         char *set;
99         int set_line;
100         int line_no;
101 };
102         
103 /*scope type*/
104 enum {
105         NO_SCOPE,
106         PUBLIC_SCOPE,
107         PRIVATE_SCOPE,
108         PROTECTED_SCOPE,
109 };
110
111 /* method type */
112 enum {
113         REGULAR_METHOD,
114         INIT_METHOD,
115         CLASS_INIT_METHOD,
116         VIRTUAL_METHOD,
117         SIGNAL_LAST_METHOD,
118         SIGNAL_FIRST_METHOD,
119         OVERRIDE_METHOD
120 };
121
122 typedef struct _Method Method;
123 struct _Method {
124         int type;
125         int scope; /* scope type */
126         int method; /* method type */
127         Type *mtype;
128         char *otype; /*for override methods*/
129         GList *gtktypes; /*GTK types for a signal*/
130         char *id;
131         GList *args;
132         char *onerror;
133         char *cbuf;
134         int line_no;
135         int ccode_line;
136         int vararg;
137 };
138
139 typedef struct _Variable Variable;
140 struct _Variable {
141         int type;
142         int scope;
143         Type *vtype;
144         char *id;
145         int line_no;
146 };
147
148 union _Node {
149         int type;
150         CCode ccode;
151         Class class;
152         Type _type;
153         Check check;
154         Argument argument;
155         Method method;
156         Variable variable;
157 };
158
159 Node *new_ccode(int header, char *cbuf, int line_no);
160 Node *new_class(char *otype, char *ptype, GList *nodes);
161 Node *new_type(int stars, char *name, char *postfix);
162 Node *new_check(int chtype, char *number);
163 Node *new_funcarg(Type *atype, char *name, GList *checks);
164 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);
165 Node *new_argument(char *gtktype, GList *flags, char *name, char *get, int get_line, char *set, int set_line, int line_no);
166 Node *new_variable(int scope, Type *vtype, char *id,int line_no);
167
168 #endif