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