1 /* valactype.c generated by valac, the Vala compiler
2 * generated from valactype.vala, do not modify */
3
4 /* valactype.vala
5 *
6 * Copyright (C) 2009 Mark Lee
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 * Mark Lee <marklee@src.gnome.org>
24 */
25
26 #include "valacodegen.h"
27 #include <stdlib.h>
28 #include <string.h>
29 #include <glib.h>
30 #include <vala.h>
31
32 #define _g_free0(var) (var = (g_free (var), NULL))
33
34 struct _ValaCTypePrivate {
35 gchar* _ctype_name;
36 gchar* _cdefault_value;
37 };
38
39 static gint ValaCType_private_offset;
40 static gpointer vala_ctype_parent_class = NULL;
41
42 static ValaDataType* vala_ctype_real_copy (ValaDataType* base);
43 static void vala_ctype_finalize (ValaCodeNode * obj);
44 static GType vala_ctype_get_type_once (void);
45
46 static inline gpointer
vala_ctype_get_instance_private(ValaCType * self)47 vala_ctype_get_instance_private (ValaCType* self)
48 {
49 return G_STRUCT_MEMBER_P (self, ValaCType_private_offset);
50 }
51
52 const gchar*
vala_ctype_get_ctype_name(ValaCType * self)53 vala_ctype_get_ctype_name (ValaCType* self)
54 {
55 const gchar* result;
56 const gchar* _tmp0_;
57 g_return_val_if_fail (self != NULL, NULL);
58 _tmp0_ = self->priv->_ctype_name;
59 result = _tmp0_;
60 return result;
61 }
62
63 void
vala_ctype_set_ctype_name(ValaCType * self,const gchar * value)64 vala_ctype_set_ctype_name (ValaCType* 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->_ctype_name);
71 self->priv->_ctype_name = _tmp0_;
72 }
73
74 const gchar*
vala_ctype_get_cdefault_value(ValaCType * self)75 vala_ctype_get_cdefault_value (ValaCType* self)
76 {
77 const gchar* result;
78 const gchar* _tmp0_;
79 g_return_val_if_fail (self != NULL, NULL);
80 _tmp0_ = self->priv->_cdefault_value;
81 result = _tmp0_;
82 return result;
83 }
84
85 void
vala_ctype_set_cdefault_value(ValaCType * self,const gchar * value)86 vala_ctype_set_cdefault_value (ValaCType* self,
87 const gchar* value)
88 {
89 gchar* _tmp0_;
90 g_return_if_fail (self != NULL);
91 _tmp0_ = g_strdup (value);
92 _g_free0 (self->priv->_cdefault_value);
93 self->priv->_cdefault_value = _tmp0_;
94 }
95
96 ValaCType*
vala_ctype_construct(GType object_type,const gchar * ctype_name,const gchar * cdefault_value)97 vala_ctype_construct (GType object_type,
98 const gchar* ctype_name,
99 const gchar* cdefault_value)
100 {
101 ValaCType* self = NULL;
102 g_return_val_if_fail (ctype_name != NULL, NULL);
103 g_return_val_if_fail (cdefault_value != NULL, NULL);
104 self = (ValaCType*) vala_data_type_construct (object_type);
105 vala_ctype_set_ctype_name (self, ctype_name);
106 vala_ctype_set_cdefault_value (self, cdefault_value);
107 return self;
108 }
109
110 ValaCType*
vala_ctype_new(const gchar * ctype_name,const gchar * cdefault_value)111 vala_ctype_new (const gchar* ctype_name,
112 const gchar* cdefault_value)
113 {
114 return vala_ctype_construct (VALA_TYPE_CTYPE, ctype_name, cdefault_value);
115 }
116
117 static ValaDataType*
vala_ctype_real_copy(ValaDataType * base)118 vala_ctype_real_copy (ValaDataType* base)
119 {
120 ValaCType * self;
121 const gchar* _tmp0_;
122 const gchar* _tmp1_;
123 ValaCType* _tmp2_;
124 ValaDataType* result = NULL;
125 self = (ValaCType*) base;
126 _tmp0_ = self->priv->_ctype_name;
127 _tmp1_ = self->priv->_cdefault_value;
128 _tmp2_ = vala_ctype_new (_tmp0_, _tmp1_);
129 result = (ValaDataType*) _tmp2_;
130 return result;
131 }
132
133 static void
vala_ctype_class_init(ValaCTypeClass * klass,gpointer klass_data)134 vala_ctype_class_init (ValaCTypeClass * klass,
135 gpointer klass_data)
136 {
137 vala_ctype_parent_class = g_type_class_peek_parent (klass);
138 ((ValaCodeNodeClass *) klass)->finalize = vala_ctype_finalize;
139 g_type_class_adjust_private_offset (klass, &ValaCType_private_offset);
140 ((ValaDataTypeClass *) klass)->copy = (ValaDataType* (*) (ValaDataType*)) vala_ctype_real_copy;
141 }
142
143 static void
vala_ctype_instance_init(ValaCType * self,gpointer klass)144 vala_ctype_instance_init (ValaCType * self,
145 gpointer klass)
146 {
147 self->priv = vala_ctype_get_instance_private (self);
148 }
149
150 static void
vala_ctype_finalize(ValaCodeNode * obj)151 vala_ctype_finalize (ValaCodeNode * obj)
152 {
153 ValaCType * self;
154 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CTYPE, ValaCType);
155 _g_free0 (self->priv->_ctype_name);
156 _g_free0 (self->priv->_cdefault_value);
157 VALA_CODE_NODE_CLASS (vala_ctype_parent_class)->finalize (obj);
158 }
159
160 /**
161 * A C type, used only for code generation purposes.
162 */
163 static GType
vala_ctype_get_type_once(void)164 vala_ctype_get_type_once (void)
165 {
166 static const GTypeInfo g_define_type_info = { sizeof (ValaCTypeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ctype_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCType), 0, (GInstanceInitFunc) vala_ctype_instance_init, NULL };
167 GType vala_ctype_type_id;
168 vala_ctype_type_id = g_type_register_static (VALA_TYPE_DATA_TYPE, "ValaCType", &g_define_type_info, 0);
169 ValaCType_private_offset = g_type_add_instance_private (vala_ctype_type_id, sizeof (ValaCTypePrivate));
170 return vala_ctype_type_id;
171 }
172
173 GType
vala_ctype_get_type(void)174 vala_ctype_get_type (void)
175 {
176 static volatile gsize vala_ctype_type_id__volatile = 0;
177 if (g_once_init_enter (&vala_ctype_type_id__volatile)) {
178 GType vala_ctype_type_id;
179 vala_ctype_type_id = vala_ctype_get_type_once ();
180 g_once_init_leave (&vala_ctype_type_id__volatile, vala_ctype_type_id);
181 }
182 return vala_ctype_type_id__volatile;
183 }
184
185