]> git.draconx.ca Git - gob-dx.git/blob - src/tree.c
414ba43cabcd3764dcd1a38e14541b3916c72130
[gob-dx.git] / src / tree.c
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 #include "config.h"
23 #include <glib.h>
24 #include "tree.h"
25
26 Node *
27 new_ccode(int header, char *cbuf, int line_no)
28 {
29         CCode *node = (CCode *)g_new(Node,1);
30         node->type = CCODE_NODE;
31         node->header = header;
32         node->cbuf = cbuf;
33         node->line_no = line_no;
34         return (Node *)node;
35 }
36
37 Node *
38 new_class(char *otype, char *ptype, GList *nodes)
39 {
40         Class *node = (Class *)g_new(Node,1);
41         node->type = CLASS_NODE;
42         node->otype = otype;
43         node->ptype = ptype;
44         node->nodes = nodes;
45         return (Node *)node;
46 }
47
48 Node *
49 new_type(int stars, char *name, char *postfix)
50 {
51         Type *node = (Type *)g_new(Node,1);
52         node->type = TYPE_NODE;
53         node->stars = stars;
54         node->name = name;
55         node->postfix = postfix;
56         return (Node *)node;
57 }
58
59 Node *
60 new_check(int chtype, char *number)
61 {
62         Check *node = (Check *)g_new(Node,1);
63         node->type = CHECK_NODE;
64         node->chtype = chtype;
65         node->number = number;
66         return (Node *)node;
67 }
68
69 Node *
70 new_funcarg(Type *atype, char *name, GList *checks)
71 {
72         FuncArg *node = (FuncArg *)g_new(Node,1);
73         node->type = FUNCARG_NODE;
74         node->atype = atype;
75         node->name = name;
76         node->checks = checks;
77         return (Node *)node;
78 }
79
80 Node *
81 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)
82 {
83         Method *node = (Method *)g_new(Node,1);
84         node->type = METHOD_NODE;
85         node->scope = scope;
86         node->method = method;
87         node->mtype = mtype;
88         node->otype = otype;
89         node->gtktypes = gtktypes;
90         node->id = id;
91         node->args = args;
92         node->onerror = onerror;
93         node->cbuf = cbuf;
94         node->line_no = line_no;
95         node->ccode_line = ccode_line;
96         node->vararg = vararg;
97         return (Node *)node;
98 }
99
100 Node *
101 new_argument(char *gtktype, Type *atype, GList *flags, char *name, char *get, int get_line, char *set, int set_line, int line_no)
102 {
103         Argument *node = (Argument *)g_new(Node,1);
104         node->type = ARGUMENT_NODE;
105         node->gtktype = gtktype;
106         node->atype = atype;
107         node->flags = flags;
108         node->name = name;
109         node->get = get;
110         node->get_line = get_line;
111         node->set = set;
112         node->set_line = set_line;
113         node->line_no = line_no;
114         return (Node *)node;
115 }
116
117 Node *
118 new_variable(int scope, Type *vtype, char *id, int line_no)
119 {
120         Variable *node = (Variable *)g_new(Node,1);
121         node->type = VARIABLE_NODE;
122         node->scope = scope;
123         node->vtype = vtype;
124         node->id = id;
125         node->line_no = line_no;
126         return (Node *)node;
127 }