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