1 /* valaccodeincludedirective.c generated by valac, the Vala compiler
2  * generated from valaccodeincludedirective.vala, do not modify */
3 
4 /* valaccodeincludedirective.vala
5  *
6  * Copyright (C) 2006  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 "valaccode.h"
27 #include <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 
31 #define _g_free0(var) (var = (g_free (var), NULL))
32 
33 struct _ValaCCodeIncludeDirectivePrivate {
34 	gchar* _filename;
35 	gboolean _local;
36 };
37 
38 static gint ValaCCodeIncludeDirective_private_offset;
39 static gpointer vala_ccode_include_directive_parent_class = NULL;
40 
41 static void vala_ccode_include_directive_real_write (ValaCCodeNode* base,
42                                               ValaCCodeWriter* writer);
43 static void vala_ccode_include_directive_finalize (ValaCCodeNode * obj);
44 static GType vala_ccode_include_directive_get_type_once (void);
45 
46 static inline gpointer
vala_ccode_include_directive_get_instance_private(ValaCCodeIncludeDirective * self)47 vala_ccode_include_directive_get_instance_private (ValaCCodeIncludeDirective* self)
48 {
49 	return G_STRUCT_MEMBER_P (self, ValaCCodeIncludeDirective_private_offset);
50 }
51 
52 const gchar*
vala_ccode_include_directive_get_filename(ValaCCodeIncludeDirective * self)53 vala_ccode_include_directive_get_filename (ValaCCodeIncludeDirective* self)
54 {
55 	const gchar* result;
56 	const gchar* _tmp0_;
57 	g_return_val_if_fail (self != NULL, NULL);
58 	_tmp0_ = self->priv->_filename;
59 	result = _tmp0_;
60 	return result;
61 }
62 
63 void
vala_ccode_include_directive_set_filename(ValaCCodeIncludeDirective * self,const gchar * value)64 vala_ccode_include_directive_set_filename (ValaCCodeIncludeDirective* self,
65                                            const gchar* value)
66 {
67 	gchar* _tmp0_;
68 	g_return_if_fail (self != NULL);
69 	_tmp0_ = g_strdup (value);
70 	_g_free0 (self->priv->_filename);
71 	self->priv->_filename = _tmp0_;
72 }
73 
74 gboolean
vala_ccode_include_directive_get_local(ValaCCodeIncludeDirective * self)75 vala_ccode_include_directive_get_local (ValaCCodeIncludeDirective* self)
76 {
77 	gboolean result;
78 	g_return_val_if_fail (self != NULL, FALSE);
79 	result = self->priv->_local;
80 	return result;
81 }
82 
83 void
vala_ccode_include_directive_set_local(ValaCCodeIncludeDirective * self,gboolean value)84 vala_ccode_include_directive_set_local (ValaCCodeIncludeDirective* self,
85                                         gboolean value)
86 {
87 	g_return_if_fail (self != NULL);
88 	self->priv->_local = value;
89 }
90 
91 ValaCCodeIncludeDirective*
vala_ccode_include_directive_construct(GType object_type,const gchar * _filename,gboolean _local)92 vala_ccode_include_directive_construct (GType object_type,
93                                         const gchar* _filename,
94                                         gboolean _local)
95 {
96 	ValaCCodeIncludeDirective* self = NULL;
97 	g_return_val_if_fail (_filename != NULL, NULL);
98 	self = (ValaCCodeIncludeDirective*) vala_ccode_node_construct (object_type);
99 	vala_ccode_include_directive_set_filename (self, _filename);
100 	vala_ccode_include_directive_set_local (self, _local);
101 	return self;
102 }
103 
104 ValaCCodeIncludeDirective*
vala_ccode_include_directive_new(const gchar * _filename,gboolean _local)105 vala_ccode_include_directive_new (const gchar* _filename,
106                                   gboolean _local)
107 {
108 	return vala_ccode_include_directive_construct (VALA_TYPE_CCODE_INCLUDE_DIRECTIVE, _filename, _local);
109 }
110 
111 static void
vala_ccode_include_directive_real_write(ValaCCodeNode * base,ValaCCodeWriter * writer)112 vala_ccode_include_directive_real_write (ValaCCodeNode* base,
113                                          ValaCCodeWriter* writer)
114 {
115 	ValaCCodeIncludeDirective * self;
116 	gboolean _tmp0_;
117 	self = (ValaCCodeIncludeDirective*) base;
118 	g_return_if_fail (writer != NULL);
119 	vala_ccode_writer_write_indent (writer, NULL);
120 	vala_ccode_writer_write_string (writer, "#include ");
121 	_tmp0_ = self->priv->_local;
122 	if (_tmp0_) {
123 		const gchar* _tmp1_;
124 		vala_ccode_writer_write_string (writer, "\"");
125 		_tmp1_ = self->priv->_filename;
126 		vala_ccode_writer_write_string (writer, _tmp1_);
127 		vala_ccode_writer_write_string (writer, "\"");
128 	} else {
129 		const gchar* _tmp2_;
130 		vala_ccode_writer_write_string (writer, "<");
131 		_tmp2_ = self->priv->_filename;
132 		vala_ccode_writer_write_string (writer, _tmp2_);
133 		vala_ccode_writer_write_string (writer, ">");
134 	}
135 	vala_ccode_writer_write_newline (writer);
136 }
137 
138 static void
vala_ccode_include_directive_class_init(ValaCCodeIncludeDirectiveClass * klass,gpointer klass_data)139 vala_ccode_include_directive_class_init (ValaCCodeIncludeDirectiveClass * klass,
140                                          gpointer klass_data)
141 {
142 	vala_ccode_include_directive_parent_class = g_type_class_peek_parent (klass);
143 	((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_include_directive_finalize;
144 	g_type_class_adjust_private_offset (klass, &ValaCCodeIncludeDirective_private_offset);
145 	((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode*, ValaCCodeWriter*)) vala_ccode_include_directive_real_write;
146 }
147 
148 static void
vala_ccode_include_directive_instance_init(ValaCCodeIncludeDirective * self,gpointer klass)149 vala_ccode_include_directive_instance_init (ValaCCodeIncludeDirective * self,
150                                             gpointer klass)
151 {
152 	self->priv = vala_ccode_include_directive_get_instance_private (self);
153 }
154 
155 static void
vala_ccode_include_directive_finalize(ValaCCodeNode * obj)156 vala_ccode_include_directive_finalize (ValaCCodeNode * obj)
157 {
158 	ValaCCodeIncludeDirective * self;
159 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_INCLUDE_DIRECTIVE, ValaCCodeIncludeDirective);
160 	_g_free0 (self->priv->_filename);
161 	VALA_CCODE_NODE_CLASS (vala_ccode_include_directive_parent_class)->finalize (obj);
162 }
163 
164 /**
165  * Represents an include preprocessor directive in the C code.
166  */
167 static GType
vala_ccode_include_directive_get_type_once(void)168 vala_ccode_include_directive_get_type_once (void)
169 {
170 	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeIncludeDirectiveClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_include_directive_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeIncludeDirective), 0, (GInstanceInitFunc) vala_ccode_include_directive_instance_init, NULL };
171 	GType vala_ccode_include_directive_type_id;
172 	vala_ccode_include_directive_type_id = g_type_register_static (VALA_TYPE_CCODE_NODE, "ValaCCodeIncludeDirective", &g_define_type_info, 0);
173 	ValaCCodeIncludeDirective_private_offset = g_type_add_instance_private (vala_ccode_include_directive_type_id, sizeof (ValaCCodeIncludeDirectivePrivate));
174 	return vala_ccode_include_directive_type_id;
175 }
176 
177 GType
vala_ccode_include_directive_get_type(void)178 vala_ccode_include_directive_get_type (void)
179 {
180 	static volatile gsize vala_ccode_include_directive_type_id__volatile = 0;
181 	if (g_once_init_enter (&vala_ccode_include_directive_type_id__volatile)) {
182 		GType vala_ccode_include_directive_type_id;
183 		vala_ccode_include_directive_type_id = vala_ccode_include_directive_get_type_once ();
184 		g_once_init_leave (&vala_ccode_include_directive_type_id__volatile, vala_ccode_include_directive_type_id);
185 	}
186 	return vala_ccode_include_directive_type_id__volatile;
187 }
188 
189