1 /* valausingdirective.c generated by valac, the Vala compiler
2  * generated from valausingdirective.vala, do not modify */
3 
4 /* valausingdirective.vala
5  *
6  * Copyright (C) 2006-2008  Jürg Billeter
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12 
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
21  *
22  * Author:
23  * 	Jürg Billeter <j@bitron.ch>
24  */
25 
26 #include "vala.h"
27 #include <glib.h>
28 
29 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
30 
31 struct _ValaUsingDirectivePrivate {
32 	ValaSymbol* _namespace_symbol;
33 	ValaUnresolvedSymbol* unresolved_symbol;
34 };
35 
36 static gint ValaUsingDirective_private_offset;
37 static gpointer vala_using_directive_parent_class = NULL;
38 
39 static void vala_using_directive_real_accept (ValaCodeNode* base,
40                                        ValaCodeVisitor* visitor);
41 static void vala_using_directive_finalize (ValaCodeNode * obj);
42 static GType vala_using_directive_get_type_once (void);
43 
44 static inline gpointer
vala_using_directive_get_instance_private(ValaUsingDirective * self)45 vala_using_directive_get_instance_private (ValaUsingDirective* self)
46 {
47 	return G_STRUCT_MEMBER_P (self, ValaUsingDirective_private_offset);
48 }
49 
50 ValaSymbol*
vala_using_directive_get_namespace_symbol(ValaUsingDirective * self)51 vala_using_directive_get_namespace_symbol (ValaUsingDirective* self)
52 {
53 	ValaSymbol* result;
54 	ValaUnresolvedSymbol* _tmp0_;
55 	ValaSymbol* _tmp2_;
56 	g_return_val_if_fail (self != NULL, NULL);
57 	_tmp0_ = self->priv->unresolved_symbol;
58 	if (_tmp0_ != NULL) {
59 		ValaUnresolvedSymbol* _tmp1_;
60 		_tmp1_ = self->priv->unresolved_symbol;
61 		result = (ValaSymbol*) _tmp1_;
62 		return result;
63 	}
64 	_tmp2_ = self->priv->_namespace_symbol;
65 	result = _tmp2_;
66 	return result;
67 }
68 
69 static gpointer
_vala_code_node_ref0(gpointer self)70 _vala_code_node_ref0 (gpointer self)
71 {
72 	return self ? vala_code_node_ref (self) : NULL;
73 }
74 
75 void
vala_using_directive_set_namespace_symbol(ValaUsingDirective * self,ValaSymbol * value)76 vala_using_directive_set_namespace_symbol (ValaUsingDirective* self,
77                                            ValaSymbol* value)
78 {
79 	g_return_if_fail (self != NULL);
80 	if (VALA_IS_UNRESOLVED_SYMBOL (value)) {
81 		ValaUnresolvedSymbol* _tmp0_;
82 		_tmp0_ = _vala_code_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (value, VALA_TYPE_UNRESOLVED_SYMBOL, ValaUnresolvedSymbol));
83 		_vala_code_node_unref0 (self->priv->unresolved_symbol);
84 		self->priv->unresolved_symbol = _tmp0_;
85 		self->priv->_namespace_symbol = NULL;
86 	} else {
87 		self->priv->_namespace_symbol = value;
88 		_vala_code_node_unref0 (self->priv->unresolved_symbol);
89 		self->priv->unresolved_symbol = NULL;
90 	}
91 }
92 
93 /**
94  * Creates a new using directive.
95  *
96  * @param namespace_symbol namespace symbol
97  * @return                 newly created using directive
98  */
99 ValaUsingDirective*
vala_using_directive_construct(GType object_type,ValaSymbol * namespace_symbol,ValaSourceReference * source_reference)100 vala_using_directive_construct (GType object_type,
101                                 ValaSymbol* namespace_symbol,
102                                 ValaSourceReference* source_reference)
103 {
104 	ValaUsingDirective* self = NULL;
105 	g_return_val_if_fail (namespace_symbol != NULL, NULL);
106 	self = (ValaUsingDirective*) vala_code_node_construct (object_type);
107 	vala_using_directive_set_namespace_symbol (self, namespace_symbol);
108 	vala_code_node_set_source_reference ((ValaCodeNode*) self, source_reference);
109 	return self;
110 }
111 
112 ValaUsingDirective*
vala_using_directive_new(ValaSymbol * namespace_symbol,ValaSourceReference * source_reference)113 vala_using_directive_new (ValaSymbol* namespace_symbol,
114                           ValaSourceReference* source_reference)
115 {
116 	return vala_using_directive_construct (VALA_TYPE_USING_DIRECTIVE, namespace_symbol, source_reference);
117 }
118 
119 static void
vala_using_directive_real_accept(ValaCodeNode * base,ValaCodeVisitor * visitor)120 vala_using_directive_real_accept (ValaCodeNode* base,
121                                   ValaCodeVisitor* visitor)
122 {
123 	ValaUsingDirective * self;
124 	self = (ValaUsingDirective*) base;
125 	g_return_if_fail (visitor != NULL);
126 	vala_code_visitor_visit_using_directive (visitor, self);
127 }
128 
129 static void
vala_using_directive_class_init(ValaUsingDirectiveClass * klass,gpointer klass_data)130 vala_using_directive_class_init (ValaUsingDirectiveClass * klass,
131                                  gpointer klass_data)
132 {
133 	vala_using_directive_parent_class = g_type_class_peek_parent (klass);
134 	((ValaCodeNodeClass *) klass)->finalize = vala_using_directive_finalize;
135 	g_type_class_adjust_private_offset (klass, &ValaUsingDirective_private_offset);
136 	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_using_directive_real_accept;
137 }
138 
139 static void
vala_using_directive_instance_init(ValaUsingDirective * self,gpointer klass)140 vala_using_directive_instance_init (ValaUsingDirective * self,
141                                     gpointer klass)
142 {
143 	self->priv = vala_using_directive_get_instance_private (self);
144 }
145 
146 static void
vala_using_directive_finalize(ValaCodeNode * obj)147 vala_using_directive_finalize (ValaCodeNode * obj)
148 {
149 	ValaUsingDirective * self;
150 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_USING_DIRECTIVE, ValaUsingDirective);
151 	_vala_code_node_unref0 (self->priv->unresolved_symbol);
152 	VALA_CODE_NODE_CLASS (vala_using_directive_parent_class)->finalize (obj);
153 }
154 
155 /**
156  * A reference to a namespace symbol.
157  */
158 static GType
vala_using_directive_get_type_once(void)159 vala_using_directive_get_type_once (void)
160 {
161 	static const GTypeInfo g_define_type_info = { sizeof (ValaUsingDirectiveClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_using_directive_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaUsingDirective), 0, (GInstanceInitFunc) vala_using_directive_instance_init, NULL };
162 	GType vala_using_directive_type_id;
163 	vala_using_directive_type_id = g_type_register_static (VALA_TYPE_CODE_NODE, "ValaUsingDirective", &g_define_type_info, 0);
164 	ValaUsingDirective_private_offset = g_type_add_instance_private (vala_using_directive_type_id, sizeof (ValaUsingDirectivePrivate));
165 	return vala_using_directive_type_id;
166 }
167 
168 GType
vala_using_directive_get_type(void)169 vala_using_directive_get_type (void)
170 {
171 	static volatile gsize vala_using_directive_type_id__volatile = 0;
172 	if (g_once_init_enter (&vala_using_directive_type_id__volatile)) {
173 		GType vala_using_directive_type_id;
174 		vala_using_directive_type_id = vala_using_directive_get_type_once ();
175 		g_once_init_leave (&vala_using_directive_type_id__volatile, vala_using_directive_type_id);
176 	}
177 	return vala_using_directive_type_id__volatile;
178 }
179 
180