1 /* pointer.c generated by valac, the Vala compiler
2 * generated from pointer.vala, do not modify */
3
4 /* pointer.vala
5 *
6 * Copyright (C) 2008 Florian Brosch
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 * Florian Brosch <flo.brosch@gmail.com>
24 */
25
26 #include "valadoc.h"
27 #include <glib.h>
28 #include <vala.h>
29
30 enum {
31 VALADOC_API_POINTER_0_PROPERTY,
32 VALADOC_API_POINTER_DATA_TYPE_PROPERTY,
33 VALADOC_API_POINTER_NUM_PROPERTIES
34 };
35 static GParamSpec* valadoc_api_pointer_properties[VALADOC_API_POINTER_NUM_PROPERTIES];
36 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
37 #define _valadoc_api_signature_builder_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_api_signature_builder_unref (var), NULL)))
38
39 struct _ValadocApiPointerPrivate {
40 ValadocApiItem* _data_type;
41 };
42
43 static gint ValadocApiPointer_private_offset;
44 static gpointer valadoc_api_pointer_parent_class = NULL;
45
46 static ValadocContentInline* valadoc_api_pointer_real_build_signature (ValadocApiItem* base);
47 static void valadoc_api_pointer_finalize (GObject * obj);
48 static GType valadoc_api_pointer_get_type_once (void);
49 static void _vala_valadoc_api_pointer_get_property (GObject * object,
50 guint property_id,
51 GValue * value,
52 GParamSpec * pspec);
53 static void _vala_valadoc_api_pointer_set_property (GObject * object,
54 guint property_id,
55 const GValue * value,
56 GParamSpec * pspec);
57
58 static inline gpointer
valadoc_api_pointer_get_instance_private(ValadocApiPointer * self)59 valadoc_api_pointer_get_instance_private (ValadocApiPointer* self)
60 {
61 return G_STRUCT_MEMBER_P (self, ValadocApiPointer_private_offset);
62 }
63
64 ValadocApiItem*
valadoc_api_pointer_get_data_type(ValadocApiPointer * self)65 valadoc_api_pointer_get_data_type (ValadocApiPointer* self)
66 {
67 ValadocApiItem* result;
68 ValadocApiItem* _tmp0_;
69 g_return_val_if_fail (self != NULL, NULL);
70 _tmp0_ = self->priv->_data_type;
71 result = _tmp0_;
72 return result;
73 }
74
75 static gpointer
_g_object_ref0(gpointer self)76 _g_object_ref0 (gpointer self)
77 {
78 return self ? g_object_ref (self) : NULL;
79 }
80
81 void
valadoc_api_pointer_set_data_type(ValadocApiPointer * self,ValadocApiItem * value)82 valadoc_api_pointer_set_data_type (ValadocApiPointer* self,
83 ValadocApiItem* value)
84 {
85 ValadocApiItem* old_value;
86 g_return_if_fail (self != NULL);
87 old_value = valadoc_api_pointer_get_data_type (self);
88 if (old_value != value) {
89 ValadocApiItem* _tmp0_;
90 _tmp0_ = _g_object_ref0 (value);
91 _g_object_unref0 (self->priv->_data_type);
92 self->priv->_data_type = _tmp0_;
93 g_object_notify_by_pspec ((GObject *) self, valadoc_api_pointer_properties[VALADOC_API_POINTER_DATA_TYPE_PROPERTY]);
94 }
95 }
96
97 ValadocApiPointer*
valadoc_api_pointer_construct(GType object_type,ValadocApiItem * parent,ValaPointerType * data)98 valadoc_api_pointer_construct (GType object_type,
99 ValadocApiItem* parent,
100 ValaPointerType* data)
101 {
102 ValadocApiPointer * self = NULL;
103 g_return_val_if_fail (parent != NULL, NULL);
104 g_return_val_if_fail (data != NULL, NULL);
105 self = (ValadocApiPointer*) valadoc_api_item_construct (object_type, (ValaCodeNode*) data);
106 valadoc_api_item_set_parent ((ValadocApiItem*) self, parent);
107 return self;
108 }
109
110 ValadocApiPointer*
valadoc_api_pointer_new(ValadocApiItem * parent,ValaPointerType * data)111 valadoc_api_pointer_new (ValadocApiItem* parent,
112 ValaPointerType* data)
113 {
114 return valadoc_api_pointer_construct (VALADOC_API_TYPE_POINTER, parent, data);
115 }
116
117 /**
118 * {@inheritDoc}
119 */
120 static ValadocContentInline*
valadoc_api_pointer_real_build_signature(ValadocApiItem * base)121 valadoc_api_pointer_real_build_signature (ValadocApiItem* base)
122 {
123 ValadocApiPointer * self;
124 ValadocApiSignatureBuilder* _tmp0_;
125 ValadocApiSignatureBuilder* _tmp1_;
126 ValadocApiItem* _tmp2_;
127 ValadocContentInline* _tmp3_;
128 ValadocContentInline* _tmp4_;
129 ValadocApiSignatureBuilder* _tmp5_;
130 ValadocApiSignatureBuilder* _tmp6_;
131 ValadocContentRun* _tmp7_;
132 ValadocContentInline* _tmp8_;
133 ValadocContentInline* result = NULL;
134 self = (ValadocApiPointer*) base;
135 _tmp0_ = valadoc_api_signature_builder_new ();
136 _tmp1_ = _tmp0_;
137 _tmp2_ = self->priv->_data_type;
138 _tmp3_ = valadoc_api_item_get_signature (_tmp2_);
139 _tmp4_ = _tmp3_;
140 _tmp5_ = valadoc_api_signature_builder_append_content (_tmp1_, _tmp4_, TRUE);
141 _tmp6_ = valadoc_api_signature_builder_append (_tmp5_, "*", FALSE);
142 _tmp7_ = valadoc_api_signature_builder_get (_tmp6_);
143 _tmp8_ = (ValadocContentInline*) _tmp7_;
144 _valadoc_api_signature_builder_unref0 (_tmp1_);
145 result = _tmp8_;
146 return result;
147 }
148
149 static void
valadoc_api_pointer_class_init(ValadocApiPointerClass * klass,gpointer klass_data)150 valadoc_api_pointer_class_init (ValadocApiPointerClass * klass,
151 gpointer klass_data)
152 {
153 valadoc_api_pointer_parent_class = g_type_class_peek_parent (klass);
154 g_type_class_adjust_private_offset (klass, &ValadocApiPointer_private_offset);
155 ((ValadocApiItemClass *) klass)->build_signature = (ValadocContentInline* (*) (ValadocApiItem*)) valadoc_api_pointer_real_build_signature;
156 G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_api_pointer_get_property;
157 G_OBJECT_CLASS (klass)->set_property = _vala_valadoc_api_pointer_set_property;
158 G_OBJECT_CLASS (klass)->finalize = valadoc_api_pointer_finalize;
159 /**
160 * The type the pointer is referring to.
161 */
162 g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_POINTER_DATA_TYPE_PROPERTY, valadoc_api_pointer_properties[VALADOC_API_POINTER_DATA_TYPE_PROPERTY] = g_param_spec_object ("data-type", "data-type", "data-type", VALADOC_API_TYPE_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
163 }
164
165 static void
valadoc_api_pointer_instance_init(ValadocApiPointer * self,gpointer klass)166 valadoc_api_pointer_instance_init (ValadocApiPointer * self,
167 gpointer klass)
168 {
169 self->priv = valadoc_api_pointer_get_instance_private (self);
170 }
171
172 static void
valadoc_api_pointer_finalize(GObject * obj)173 valadoc_api_pointer_finalize (GObject * obj)
174 {
175 ValadocApiPointer * self;
176 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_POINTER, ValadocApiPointer);
177 _g_object_unref0 (self->priv->_data_type);
178 G_OBJECT_CLASS (valadoc_api_pointer_parent_class)->finalize (obj);
179 }
180
181 /**
182 * Represents a pointer declaration.
183 */
184 static GType
valadoc_api_pointer_get_type_once(void)185 valadoc_api_pointer_get_type_once (void)
186 {
187 static const GTypeInfo g_define_type_info = { sizeof (ValadocApiPointerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_pointer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiPointer), 0, (GInstanceInitFunc) valadoc_api_pointer_instance_init, NULL };
188 GType valadoc_api_pointer_type_id;
189 valadoc_api_pointer_type_id = g_type_register_static (VALADOC_API_TYPE_ITEM, "ValadocApiPointer", &g_define_type_info, 0);
190 ValadocApiPointer_private_offset = g_type_add_instance_private (valadoc_api_pointer_type_id, sizeof (ValadocApiPointerPrivate));
191 return valadoc_api_pointer_type_id;
192 }
193
194 GType
valadoc_api_pointer_get_type(void)195 valadoc_api_pointer_get_type (void)
196 {
197 static volatile gsize valadoc_api_pointer_type_id__volatile = 0;
198 if (g_once_init_enter (&valadoc_api_pointer_type_id__volatile)) {
199 GType valadoc_api_pointer_type_id;
200 valadoc_api_pointer_type_id = valadoc_api_pointer_get_type_once ();
201 g_once_init_leave (&valadoc_api_pointer_type_id__volatile, valadoc_api_pointer_type_id);
202 }
203 return valadoc_api_pointer_type_id__volatile;
204 }
205
206 static void
_vala_valadoc_api_pointer_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)207 _vala_valadoc_api_pointer_get_property (GObject * object,
208 guint property_id,
209 GValue * value,
210 GParamSpec * pspec)
211 {
212 ValadocApiPointer * self;
213 self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_POINTER, ValadocApiPointer);
214 switch (property_id) {
215 case VALADOC_API_POINTER_DATA_TYPE_PROPERTY:
216 g_value_set_object (value, valadoc_api_pointer_get_data_type (self));
217 break;
218 default:
219 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
220 break;
221 }
222 }
223
224 static void
_vala_valadoc_api_pointer_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)225 _vala_valadoc_api_pointer_set_property (GObject * object,
226 guint property_id,
227 const GValue * value,
228 GParamSpec * pspec)
229 {
230 ValadocApiPointer * self;
231 self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_POINTER, ValadocApiPointer);
232 switch (property_id) {
233 case VALADOC_API_POINTER_DATA_TYPE_PROPERTY:
234 valadoc_api_pointer_set_data_type (self, g_value_get_object (value));
235 break;
236 default:
237 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
238 break;
239 }
240 }
241
242