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