1 /* valadynamicproperty.c generated by valac, the Vala compiler
2 * generated from valadynamicproperty.vala, do not modify */
3
4 /* valadynamicproperty.vala
5 *
6 * Copyright (C) 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 #include <stdlib.h>
29 #include <string.h>
30
31 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
32
33 struct _ValaDynamicPropertyPrivate {
34 ValaDataType* _dynamic_type;
35 };
36
37 static gint ValaDynamicProperty_private_offset;
38 static gpointer vala_dynamic_property_parent_class = NULL;
39
40 static gboolean vala_dynamic_property_real_check (ValaCodeNode* base,
41 ValaCodeContext* context);
42 static void vala_dynamic_property_finalize (ValaCodeNode * obj);
43 static GType vala_dynamic_property_get_type_once (void);
44
45 static inline gpointer
vala_dynamic_property_get_instance_private(ValaDynamicProperty * self)46 vala_dynamic_property_get_instance_private (ValaDynamicProperty* self)
47 {
48 return G_STRUCT_MEMBER_P (self, ValaDynamicProperty_private_offset);
49 }
50
51 ValaDataType*
vala_dynamic_property_get_dynamic_type(ValaDynamicProperty * self)52 vala_dynamic_property_get_dynamic_type (ValaDynamicProperty* self)
53 {
54 ValaDataType* result;
55 ValaDataType* _tmp0_;
56 g_return_val_if_fail (self != NULL, NULL);
57 _tmp0_ = self->priv->_dynamic_type;
58 result = _tmp0_;
59 return result;
60 }
61
62 static gpointer
_vala_code_node_ref0(gpointer self)63 _vala_code_node_ref0 (gpointer self)
64 {
65 return self ? vala_code_node_ref (self) : NULL;
66 }
67
68 void
vala_dynamic_property_set_dynamic_type(ValaDynamicProperty * self,ValaDataType * value)69 vala_dynamic_property_set_dynamic_type (ValaDynamicProperty* self,
70 ValaDataType* value)
71 {
72 ValaDataType* _tmp0_;
73 g_return_if_fail (self != NULL);
74 _tmp0_ = _vala_code_node_ref0 (value);
75 _vala_code_node_unref0 (self->priv->_dynamic_type);
76 self->priv->_dynamic_type = _tmp0_;
77 }
78
79 ValaDynamicProperty*
vala_dynamic_property_construct(GType object_type,ValaDataType * dynamic_type,const gchar * name,ValaSourceReference * source_reference,ValaComment * comment)80 vala_dynamic_property_construct (GType object_type,
81 ValaDataType* dynamic_type,
82 const gchar* name,
83 ValaSourceReference* source_reference,
84 ValaComment* comment)
85 {
86 ValaDynamicProperty* self = NULL;
87 g_return_val_if_fail (dynamic_type != NULL, NULL);
88 g_return_val_if_fail (name != NULL, NULL);
89 self = (ValaDynamicProperty*) vala_property_construct (object_type, name, NULL, NULL, NULL, source_reference, comment);
90 vala_dynamic_property_set_dynamic_type (self, dynamic_type);
91 return self;
92 }
93
94 ValaDynamicProperty*
vala_dynamic_property_new(ValaDataType * dynamic_type,const gchar * name,ValaSourceReference * source_reference,ValaComment * comment)95 vala_dynamic_property_new (ValaDataType* dynamic_type,
96 const gchar* name,
97 ValaSourceReference* source_reference,
98 ValaComment* comment)
99 {
100 return vala_dynamic_property_construct (VALA_TYPE_DYNAMIC_PROPERTY, dynamic_type, name, source_reference, comment);
101 }
102
103 static gboolean
vala_dynamic_property_real_check(ValaCodeNode * base,ValaCodeContext * context)104 vala_dynamic_property_real_check (ValaCodeNode* base,
105 ValaCodeContext* context)
106 {
107 ValaDynamicProperty * self;
108 gboolean result = FALSE;
109 self = (ValaDynamicProperty*) base;
110 g_return_val_if_fail (context != NULL, FALSE);
111 result = TRUE;
112 return result;
113 }
114
115 static void
vala_dynamic_property_class_init(ValaDynamicPropertyClass * klass,gpointer klass_data)116 vala_dynamic_property_class_init (ValaDynamicPropertyClass * klass,
117 gpointer klass_data)
118 {
119 vala_dynamic_property_parent_class = g_type_class_peek_parent (klass);
120 ((ValaCodeNodeClass *) klass)->finalize = vala_dynamic_property_finalize;
121 g_type_class_adjust_private_offset (klass, &ValaDynamicProperty_private_offset);
122 ((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_dynamic_property_real_check;
123 }
124
125 static void
vala_dynamic_property_instance_init(ValaDynamicProperty * self,gpointer klass)126 vala_dynamic_property_instance_init (ValaDynamicProperty * self,
127 gpointer klass)
128 {
129 self->priv = vala_dynamic_property_get_instance_private (self);
130 }
131
132 static void
vala_dynamic_property_finalize(ValaCodeNode * obj)133 vala_dynamic_property_finalize (ValaCodeNode * obj)
134 {
135 ValaDynamicProperty * self;
136 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_DYNAMIC_PROPERTY, ValaDynamicProperty);
137 _vala_code_node_unref0 (self->priv->_dynamic_type);
138 VALA_CODE_NODE_CLASS (vala_dynamic_property_parent_class)->finalize (obj);
139 }
140
141 /**
142 * Represents a late bound property.
143 */
144 static GType
vala_dynamic_property_get_type_once(void)145 vala_dynamic_property_get_type_once (void)
146 {
147 static const GTypeInfo g_define_type_info = { sizeof (ValaDynamicPropertyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_dynamic_property_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaDynamicProperty), 0, (GInstanceInitFunc) vala_dynamic_property_instance_init, NULL };
148 GType vala_dynamic_property_type_id;
149 vala_dynamic_property_type_id = g_type_register_static (VALA_TYPE_PROPERTY, "ValaDynamicProperty", &g_define_type_info, 0);
150 ValaDynamicProperty_private_offset = g_type_add_instance_private (vala_dynamic_property_type_id, sizeof (ValaDynamicPropertyPrivate));
151 return vala_dynamic_property_type_id;
152 }
153
154 GType
vala_dynamic_property_get_type(void)155 vala_dynamic_property_get_type (void)
156 {
157 static volatile gsize vala_dynamic_property_type_id__volatile = 0;
158 if (g_once_init_enter (&vala_dynamic_property_type_id__volatile)) {
159 GType vala_dynamic_property_type_id;
160 vala_dynamic_property_type_id = vala_dynamic_property_get_type_once ();
161 g_once_init_leave (&vala_dynamic_property_type_id__volatile, vala_dynamic_property_type_id);
162 }
163 return vala_dynamic_property_type_id__volatile;
164 }
165
166