1 /* stubrule.c generated by valac, the Vala compiler
2  * generated from stubrule.vala, do not modify */
3 
4 /* stubrule.vala
5  *
6  * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
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  * 	Didier 'Ptitjes Villevalois <ptitjes@free.fr>
24  */
25 
26 #include "valadoc.h"
27 #include <glib.h>
28 #include <glib-object.h>
29 #include <stdlib.h>
30 #include <string.h>
31 
32 enum  {
33 	VALADOC_STUB_RULE_0_PROPERTY,
34 	VALADOC_STUB_RULE_NUM_PROPERTIES
35 };
36 static GParamSpec* valadoc_stub_rule_properties[VALADOC_STUB_RULE_NUM_PROPERTIES];
37 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
38 
39 struct _ValadocStubRulePrivate {
40 	ValadocRule* _rule;
41 };
42 
43 static gint ValadocStubRule_private_offset;
44 static gpointer valadoc_stub_rule_parent_class = NULL;
45 
46 static gboolean valadoc_stub_rule_real_is_optional (ValadocRule* base);
47 static gboolean valadoc_stub_rule_real_starts_with_token (ValadocRule* base,
48                                                    ValadocToken* token);
49 static gboolean valadoc_stub_rule_real_accept_token (ValadocRule* base,
50                                               ValadocToken* token,
51                                               ValadocParserCallback* parser,
52                                               ValadocRuleForward forward,
53                                               GError** error);
54 static gboolean valadoc_stub_rule_real_would_accept_token (ValadocRule* base,
55                                                     ValadocToken* token,
56                                                     GObject* state);
57 static gboolean valadoc_stub_rule_real_would_reduce (ValadocRule* base,
58                                               ValadocToken* token,
59                                               GObject* state);
60 static gchar* valadoc_stub_rule_real_to_string (ValadocRule* base,
61                                          GObject* state);
62 static void valadoc_stub_rule_finalize (GObject * obj);
63 static GType valadoc_stub_rule_get_type_once (void);
64 
65 static inline gpointer
valadoc_stub_rule_get_instance_private(ValadocStubRule * self)66 valadoc_stub_rule_get_instance_private (ValadocStubRule* self)
67 {
68 	return G_STRUCT_MEMBER_P (self, ValadocStubRule_private_offset);
69 }
70 
71 ValadocStubRule*
valadoc_stub_rule_construct(GType object_type)72 valadoc_stub_rule_construct (GType object_type)
73 {
74 	ValadocStubRule * self = NULL;
75 	self = (ValadocStubRule*) valadoc_rule_construct (object_type);
76 	return self;
77 }
78 
79 ValadocStubRule*
valadoc_stub_rule_new(void)80 valadoc_stub_rule_new (void)
81 {
82 	return valadoc_stub_rule_construct (VALADOC_TYPE_STUB_RULE);
83 }
84 
85 static gpointer
_g_object_ref0(gpointer self)86 _g_object_ref0 (gpointer self)
87 {
88 	return self ? g_object_ref (self) : NULL;
89 }
90 
91 ValadocRule*
valadoc_stub_rule_set_rule(ValadocStubRule * self,ValadocRule * rule)92 valadoc_stub_rule_set_rule (ValadocStubRule* self,
93                             ValadocRule* rule)
94 {
95 	ValadocRule* _tmp0_;
96 	ValadocRule* _tmp1_;
97 	ValadocRule* result = NULL;
98 	g_return_val_if_fail (self != NULL, NULL);
99 	g_return_val_if_fail (rule != NULL, NULL);
100 	_tmp0_ = _g_object_ref0 (rule);
101 	_g_object_unref0 (self->priv->_rule);
102 	self->priv->_rule = _tmp0_;
103 	_tmp1_ = _g_object_ref0 ((ValadocRule*) self);
104 	result = _tmp1_;
105 	return result;
106 }
107 
108 static gboolean
valadoc_stub_rule_real_is_optional(ValadocRule * base)109 valadoc_stub_rule_real_is_optional (ValadocRule* base)
110 {
111 	ValadocStubRule * self;
112 	ValadocRule* _tmp0_;
113 	gboolean result = FALSE;
114 	self = (ValadocStubRule*) base;
115 	_tmp0_ = self->priv->_rule;
116 	result = valadoc_rule_is_optional (_tmp0_);
117 	return result;
118 }
119 
120 static gboolean
valadoc_stub_rule_real_starts_with_token(ValadocRule * base,ValadocToken * token)121 valadoc_stub_rule_real_starts_with_token (ValadocRule* base,
122                                           ValadocToken* token)
123 {
124 	ValadocStubRule * self;
125 	ValadocRule* _tmp0_;
126 	gboolean result = FALSE;
127 	self = (ValadocStubRule*) base;
128 	g_return_val_if_fail (token != NULL, FALSE);
129 	_tmp0_ = self->priv->_rule;
130 	result = valadoc_rule_starts_with_token (_tmp0_, token);
131 	return result;
132 }
133 
134 static gboolean
valadoc_stub_rule_real_accept_token(ValadocRule * base,ValadocToken * token,ValadocParserCallback * parser,ValadocRuleForward forward,GError ** error)135 valadoc_stub_rule_real_accept_token (ValadocRule* base,
136                                      ValadocToken* token,
137                                      ValadocParserCallback* parser,
138                                      ValadocRuleForward forward,
139                                      GError** error)
140 {
141 	ValadocStubRule * self;
142 	gboolean _tmp0_ = FALSE;
143 	ValadocRule* _tmp1_;
144 	GError* _inner_error0_ = NULL;
145 	gboolean result = FALSE;
146 	self = (ValadocStubRule*) base;
147 	g_return_val_if_fail (token != NULL, FALSE);
148 	g_return_val_if_fail (parser != NULL, FALSE);
149 	_tmp1_ = self->priv->_rule;
150 	_tmp0_ = valadoc_rule_accept_token (_tmp1_, token, parser, forward, &_inner_error0_);
151 	if (G_UNLIKELY (_inner_error0_ != NULL)) {
152 		if (_inner_error0_->domain == VALADOC_PARSER_ERROR) {
153 			gboolean _tmp2_ = FALSE;
154 			g_propagate_error (error, _inner_error0_);
155 			return _tmp2_;
156 		} else {
157 			gboolean _tmp3_ = FALSE;
158 			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
159 			g_clear_error (&_inner_error0_);
160 			return _tmp3_;
161 		}
162 	}
163 	result = _tmp0_;
164 	return result;
165 }
166 
167 static gboolean
valadoc_stub_rule_real_would_accept_token(ValadocRule * base,ValadocToken * token,GObject * state)168 valadoc_stub_rule_real_would_accept_token (ValadocRule* base,
169                                            ValadocToken* token,
170                                            GObject* state)
171 {
172 	ValadocStubRule * self;
173 	ValadocRule* _tmp0_;
174 	gboolean result = FALSE;
175 	self = (ValadocStubRule*) base;
176 	g_return_val_if_fail (token != NULL, FALSE);
177 	_tmp0_ = self->priv->_rule;
178 	result = valadoc_rule_would_accept_token (_tmp0_, token, state);
179 	return result;
180 }
181 
182 static gboolean
valadoc_stub_rule_real_would_reduce(ValadocRule * base,ValadocToken * token,GObject * state)183 valadoc_stub_rule_real_would_reduce (ValadocRule* base,
184                                      ValadocToken* token,
185                                      GObject* state)
186 {
187 	ValadocStubRule * self;
188 	ValadocRule* _tmp0_;
189 	gboolean result = FALSE;
190 	self = (ValadocStubRule*) base;
191 	g_return_val_if_fail (token != NULL, FALSE);
192 	_tmp0_ = self->priv->_rule;
193 	result = valadoc_rule_would_reduce (_tmp0_, token, state);
194 	return result;
195 }
196 
197 static gchar*
valadoc_stub_rule_real_to_string(ValadocRule * base,GObject * state)198 valadoc_stub_rule_real_to_string (ValadocRule* base,
199                                   GObject* state)
200 {
201 	ValadocStubRule * self;
202 	ValadocRule* _tmp0_;
203 	gchar* _tmp1_;
204 	gchar* result = NULL;
205 	self = (ValadocStubRule*) base;
206 	_tmp0_ = self->priv->_rule;
207 	_tmp1_ = valadoc_rule_to_string (_tmp0_, state);
208 	result = _tmp1_;
209 	return result;
210 }
211 
212 static void
valadoc_stub_rule_class_init(ValadocStubRuleClass * klass,gpointer klass_data)213 valadoc_stub_rule_class_init (ValadocStubRuleClass * klass,
214                               gpointer klass_data)
215 {
216 	valadoc_stub_rule_parent_class = g_type_class_peek_parent (klass);
217 	g_type_class_adjust_private_offset (klass, &ValadocStubRule_private_offset);
218 	((ValadocRuleClass *) klass)->is_optional = (gboolean (*) (ValadocRule*)) valadoc_stub_rule_real_is_optional;
219 	((ValadocRuleClass *) klass)->starts_with_token = (gboolean (*) (ValadocRule*, ValadocToken*)) valadoc_stub_rule_real_starts_with_token;
220 	((ValadocRuleClass *) klass)->accept_token = (gboolean (*) (ValadocRule*, ValadocToken*, ValadocParserCallback*, ValadocRuleForward, GError**)) valadoc_stub_rule_real_accept_token;
221 	((ValadocRuleClass *) klass)->would_accept_token = (gboolean (*) (ValadocRule*, ValadocToken*, GObject*)) valadoc_stub_rule_real_would_accept_token;
222 	((ValadocRuleClass *) klass)->would_reduce = (gboolean (*) (ValadocRule*, ValadocToken*, GObject*)) valadoc_stub_rule_real_would_reduce;
223 	((ValadocRuleClass *) klass)->to_string = (gchar* (*) (ValadocRule*, GObject*)) valadoc_stub_rule_real_to_string;
224 	G_OBJECT_CLASS (klass)->finalize = valadoc_stub_rule_finalize;
225 }
226 
227 static void
valadoc_stub_rule_instance_init(ValadocStubRule * self,gpointer klass)228 valadoc_stub_rule_instance_init (ValadocStubRule * self,
229                                  gpointer klass)
230 {
231 	self->priv = valadoc_stub_rule_get_instance_private (self);
232 }
233 
234 static void
valadoc_stub_rule_finalize(GObject * obj)235 valadoc_stub_rule_finalize (GObject * obj)
236 {
237 	ValadocStubRule * self;
238 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_TYPE_STUB_RULE, ValadocStubRule);
239 	_g_object_unref0 (self->priv->_rule);
240 	G_OBJECT_CLASS (valadoc_stub_rule_parent_class)->finalize (obj);
241 }
242 
243 static GType
valadoc_stub_rule_get_type_once(void)244 valadoc_stub_rule_get_type_once (void)
245 {
246 	static const GTypeInfo g_define_type_info = { sizeof (ValadocStubRuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_stub_rule_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocStubRule), 0, (GInstanceInitFunc) valadoc_stub_rule_instance_init, NULL };
247 	GType valadoc_stub_rule_type_id;
248 	valadoc_stub_rule_type_id = g_type_register_static (VALADOC_TYPE_RULE, "ValadocStubRule", &g_define_type_info, 0);
249 	ValadocStubRule_private_offset = g_type_add_instance_private (valadoc_stub_rule_type_id, sizeof (ValadocStubRulePrivate));
250 	return valadoc_stub_rule_type_id;
251 }
252 
253 GType
valadoc_stub_rule_get_type(void)254 valadoc_stub_rule_get_type (void)
255 {
256 	static volatile gsize valadoc_stub_rule_type_id__volatile = 0;
257 	if (g_once_init_enter (&valadoc_stub_rule_type_id__volatile)) {
258 		GType valadoc_stub_rule_type_id;
259 		valadoc_stub_rule_type_id = valadoc_stub_rule_get_type_once ();
260 		g_once_init_leave (&valadoc_stub_rule_type_id__volatile, valadoc_stub_rule_type_id);
261 	}
262 	return valadoc_stub_rule_type_id__volatile;
263 }
264 
265