1 /* traversable.c generated by valac 0.18.0, the Vala compiler
2 * generated from traversable.vala, do not modify */
6 * Copyright (C) 2011-2012 Maciej Piechotka
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.
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.
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
23 * Maciej Piechotka <uzytkownik2@gmail.com>
27 #include <glib-object.h>
30 #define GEE_TYPE_LAZY (gee_lazy_get_type ())
31 #define GEE_LAZY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_LAZY, GeeLazy))
32 #define GEE_LAZY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_LAZY, GeeLazyClass))
33 #define GEE_IS_LAZY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_LAZY))
34 #define GEE_IS_LAZY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_LAZY))
35 #define GEE_LAZY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_LAZY, GeeLazyClass))
37 typedef struct _GeeLazy GeeLazy;
38 typedef struct _GeeLazyClass GeeLazyClass;
40 #define GEE_TRAVERSABLE_TYPE_STREAM (gee_traversable_stream_get_type ())
42 #define GEE_TYPE_TRAVERSABLE (gee_traversable_get_type ())
43 #define GEE_TRAVERSABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_TRAVERSABLE, GeeTraversable))
44 #define GEE_IS_TRAVERSABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_TRAVERSABLE))
45 #define GEE_TRAVERSABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_TRAVERSABLE, GeeTraversableIface))
47 typedef struct _GeeTraversable GeeTraversable;
48 typedef struct _GeeTraversableIface GeeTraversableIface;
50 #define GEE_TYPE_ITERATOR (gee_iterator_get_type ())
51 #define GEE_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERATOR, GeeIterator))
52 #define GEE_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERATOR))
53 #define GEE_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERATOR, GeeIteratorIface))
55 typedef struct _GeeIterator GeeIterator;
56 typedef struct _GeeIteratorIface GeeIteratorIface;
57 typedef struct _Block7Data Block7Data;
58 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
60 #define GEE_TYPE_ITERABLE (gee_iterable_get_type ())
61 #define GEE_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERABLE, GeeIterable))
62 #define GEE_IS_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERABLE))
63 #define GEE_ITERABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERABLE, GeeIterableIface))
65 typedef struct _GeeIterable GeeIterable;
66 typedef struct _GeeIterableIface GeeIterableIface;
67 typedef struct _Block8Data Block8Data;
68 #define _gee_lazy_unref0(var) ((var == NULL) ? NULL : (var = (gee_lazy_unref (var), NULL)))
69 typedef struct _Block9Data Block9Data;
70 #define _a_destroy_func0(var) (((var == NULL) || (a_destroy_func == NULL)) ? NULL : (var = (a_destroy_func (var), NULL)))
71 typedef struct _Block10Data Block10Data;
72 typedef struct _Block11Data Block11Data;
73 typedef struct _Block12Data Block12Data;
74 typedef struct _Block13Data Block13Data;
75 typedef struct _Block14Data Block14Data;
76 typedef struct _Block15Data Block15Data;
77 typedef struct _Block16Data Block16Data;
78 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
80 typedef gpointer (*GeeFoldFunc) (gpointer g, gpointer a, void* user_data);
81 typedef gboolean (*GeeForallFunc) (gpointer g, void* user_data);
82 typedef GeeLazy* (*GeeUnfoldFunc) (void* user_data);
84 GEE_TRAVERSABLE_STREAM_YIELD,
85 GEE_TRAVERSABLE_STREAM_CONTINUE,
86 GEE_TRAVERSABLE_STREAM_END
87 } GeeTraversableStream;
89 typedef GeeTraversableStream (*GeeStreamFunc) (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, void* user_data);
90 typedef gpointer (*GeeMapFunc) (gpointer g, void* user_data);
91 typedef gboolean (*GeePredicate) (gconstpointer g, void* user_data);
92 struct _GeeIteratorIface {
93 GTypeInterface parent_iface;
94 gboolean (*next) (GeeIterator* self);
95 gboolean (*has_next) (GeeIterator* self);
96 gpointer (*get) (GeeIterator* self);
97 void (*remove) (GeeIterator* self);
98 gboolean (*get_valid) (GeeIterator* self);
99 gboolean (*get_read_only) (GeeIterator* self);
102 struct _GeeTraversableIface {
103 GTypeInterface parent_iface;
104 GType (*get_g_type) (GeeTraversable* self);
105 GBoxedCopyFunc (*get_g_dup_func) (GeeTraversable* self);
106 GDestroyNotify (*get_g_destroy_func) (GeeTraversable* self);
107 gboolean (*foreach) (GeeTraversable* self, GeeForallFunc f, void* f_target);
108 GeeIterator* (*stream) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeStreamFunc f, void* f_target, GDestroyNotify f_target_destroy_notify);
109 gpointer (*fold) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
110 GeeIterator* (*map) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeMapFunc f, void* f_target);
111 GeeIterator* (*scan) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
112 GeeIterator* (*filter) (GeeTraversable* self, GeePredicate pred, void* pred_target, GDestroyNotify pred_target_destroy_notify);
113 GeeIterator* (*chop) (GeeTraversable* self, gint offset, gint length);
114 GType (*get_element_type) (GeeTraversable* self);
119 GeeTraversable * self;
121 GBoxedCopyFunc a_dup_func;
122 GDestroyNotify a_destroy_func;
126 GDestroyNotify f_target_destroy_notify;
129 struct _GeeIterableIface {
130 GTypeInterface parent_iface;
131 GType (*get_g_type) (GeeIterable* self);
132 GBoxedCopyFunc (*get_g_dup_func) (GeeIterable* self);
133 GDestroyNotify (*get_g_destroy_func) (GeeIterable* self);
134 GeeIterator* (*iterator) (GeeIterable* self);
139 Block7Data * _data7_;
140 GeeTraversableStream str;
144 typedef gpointer (*GeeLazyFunc) (void* user_data);
147 Block8Data * _data8_;
150 struct _Block10Data {
152 GeeTraversable * self;
154 GBoxedCopyFunc a_dup_func;
155 GDestroyNotify a_destroy_func;
161 struct _Block11Data {
163 GeeTraversable * self;
165 GBoxedCopyFunc a_dup_func;
166 GDestroyNotify a_destroy_func;
171 struct _Block12Data {
173 Block11Data * _data11_;
177 struct _Block13Data {
179 GeeTraversable * self;
181 GBoxedCopyFunc a_dup_func;
182 GDestroyNotify a_destroy_func;
183 gboolean seed_emitted;
189 struct _Block14Data {
191 Block13Data * _data13_;
195 struct _Block15Data {
197 GeeTraversable * self;
199 gpointer pred_target;
200 GDestroyNotify pred_target_destroy_notify;
203 struct _Block16Data {
205 GeeTraversable * self;
212 gpointer gee_lazy_ref (gpointer instance);
213 void gee_lazy_unref (gpointer instance);
214 GParamSpec* gee_param_spec_lazy (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
215 void gee_value_set_lazy (GValue* value, gpointer v_object);
216 void gee_value_take_lazy (GValue* value, gpointer v_object);
217 gpointer gee_value_get_lazy (const GValue* value);
218 GType gee_lazy_get_type (void) G_GNUC_CONST;
219 GType gee_traversable_stream_get_type (void) G_GNUC_CONST;
220 GType gee_iterator_get_type (void) G_GNUC_CONST;
221 GType gee_traversable_get_type (void) G_GNUC_CONST;
222 gboolean gee_traversable_foreach (GeeTraversable* self, GeeForallFunc f, void* f_target);
223 GeeIterator* gee_traversable_stream (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeStreamFunc f, void* f_target, GDestroyNotify f_target_destroy_notify);
224 static GeeIterator* gee_traversable_real_stream (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeStreamFunc f, void* f_target, GDestroyNotify f_target_destroy_notify);
225 static Block7Data* block7_data_ref (Block7Data* _data7_);
226 static void block7_data_unref (void * _userdata_);
227 GType gee_iterable_get_type (void) G_GNUC_CONST;
228 static Block8Data* block8_data_ref (Block8Data* _data8_);
229 static void block8_data_unref (void * _userdata_);
230 gboolean gee_iterator_get_valid (GeeIterator* self);
231 static gpointer _____lambda3_ (Block8Data* _data8_);
232 gpointer gee_iterator_get (GeeIterator* self);
233 static gpointer ______lambda3__gee_lazy_func (gpointer self);
234 GeeLazy* gee_lazy_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeLazyFunc func, void* func_target, GDestroyNotify func_target_destroy_notify);
235 GeeLazy* gee_lazy_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeLazyFunc func, void* func_target, GDestroyNotify func_target_destroy_notify);
236 GeeIterator* gee_iterator_unfold (GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeUnfoldFunc f, void* f_target, GDestroyNotify f_target_destroy_notify, GeeLazy* current);
237 static GeeLazy* ______lambda4_ (Block8Data* _data8_);
238 static GeeLazy* _______lambda4__gee_unfold_func (gpointer self);
239 static GeeLazy* ____lambda5_ (Block8Data* _data8_);
240 static GeeLazy* _____lambda5__gee_unfold_func (gpointer self);
241 static GeeLazy* ___lambda6_ (Block8Data* _data8_);
242 static Block9Data* block9_data_ref (Block9Data* _data9_);
243 static void block9_data_unref (void * _userdata_);
244 gboolean gee_iterator_next (GeeIterator* self);
245 static gpointer ___lambda7_ (Block9Data* _data9_);
246 static gpointer ____lambda7__gee_lazy_func (gpointer self);
247 static GeeLazy* ____lambda6__gee_unfold_func (gpointer self);
248 GeeIterator* gee_iterable_iterator (GeeIterable* self);
249 gpointer gee_traversable_fold (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
250 static gpointer gee_traversable_real_fold (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
251 static Block10Data* block10_data_ref (Block10Data* _data10_);
252 static void block10_data_unref (void * _userdata_);
253 static gboolean __lambda8_ (Block10Data* _data10_, gpointer item);
254 static gboolean ___lambda8__gee_forall_func (gpointer g, gpointer self);
255 GeeIterator* gee_traversable_map (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeMapFunc f, void* f_target);
256 static GeeIterator* gee_traversable_real_map (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeMapFunc f, void* f_target);
257 static Block11Data* block11_data_ref (Block11Data* _data11_);
258 static void block11_data_unref (void * _userdata_);
259 static GeeTraversableStream __lambda9_ (Block11Data* _data11_, GeeTraversableStream state, GeeLazy* item, GeeLazy** val);
260 static Block12Data* block12_data_ref (Block12Data* _data12_);
261 static void block12_data_unref (void * _userdata_);
262 static gpointer ___lambda10_ (Block12Data* _data12_);
263 gpointer gee_lazy_get (GeeLazy* self);
264 static gpointer ____lambda10__gee_lazy_func (gpointer self);
265 static GeeTraversableStream ___lambda9__gee_stream_func (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, gpointer self);
266 GeeIterator* gee_traversable_scan (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
267 static GeeIterator* gee_traversable_real_scan (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
268 static Block13Data* block13_data_ref (Block13Data* _data13_);
269 static void block13_data_unref (void * _userdata_);
270 static GeeTraversableStream __lambda11_ (Block13Data* _data13_, GeeTraversableStream state, GeeLazy* item, GeeLazy** val);
271 static Block14Data* block14_data_ref (Block14Data* _data14_);
272 static void block14_data_unref (void * _userdata_);
273 GeeLazy* gee_lazy_new_from_value (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer item);
274 GeeLazy* gee_lazy_construct_from_value (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer item);
275 static gpointer ___lambda12_ (Block14Data* _data14_);
276 static gpointer ____lambda12__gee_lazy_func (gpointer self);
277 static GeeTraversableStream ___lambda11__gee_stream_func (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, gpointer self);
278 GeeIterator* gee_traversable_filter (GeeTraversable* self, GeePredicate pred, void* pred_target, GDestroyNotify pred_target_destroy_notify);
279 static GeeIterator* gee_traversable_real_filter (GeeTraversable* self, GeePredicate pred, void* pred_target, GDestroyNotify pred_target_destroy_notify);
280 static Block15Data* block15_data_ref (Block15Data* _data15_);
281 static void block15_data_unref (void * _userdata_);
282 static GeeTraversableStream __lambda13_ (Block15Data* _data15_, GeeTraversableStream state, GeeLazy* item, GeeLazy** val);
283 static GeeTraversableStream ___lambda13__gee_stream_func (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, gpointer self);
284 GeeIterator* gee_traversable_chop (GeeTraversable* self, gint offset, gint length);
285 static GeeIterator* gee_traversable_real_chop (GeeTraversable* self, gint offset, gint length);
286 static Block16Data* block16_data_ref (Block16Data* _data16_);
287 static void block16_data_unref (void * _userdata_);
288 static GeeTraversableStream __lambda14_ (Block16Data* _data16_, GeeTraversableStream state, GeeLazy* item, GeeLazy** val);
289 static GeeTraversableStream ___lambda14__gee_stream_func (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, gpointer self);
290 GType gee_traversable_get_element_type (GeeTraversable* self);
293 GType gee_traversable_stream_get_type (void) {
294 static volatile gsize gee_traversable_stream_type_id__volatile = 0;
295 if (g_once_init_enter (&gee_traversable_stream_type_id__volatile)) {
296 static const GEnumValue values[] = {{GEE_TRAVERSABLE_STREAM_YIELD, "GEE_TRAVERSABLE_STREAM_YIELD", "yield"}, {GEE_TRAVERSABLE_STREAM_CONTINUE, "GEE_TRAVERSABLE_STREAM_CONTINUE", "continue"}, {GEE_TRAVERSABLE_STREAM_END, "GEE_TRAVERSABLE_STREAM_END", "end"}, {0, NULL, NULL}};
297 GType gee_traversable_stream_type_id;
298 gee_traversable_stream_type_id = g_enum_register_static ("GeeTraversableStream", values);
299 g_once_init_leave (&gee_traversable_stream_type_id__volatile, gee_traversable_stream_type_id);
301 return gee_traversable_stream_type_id__volatile;
306 * Apply function to each element returned by iterator untill last element
307 * or function return ''false''.
309 * ''{@link Iterator} implementation:'' Operation moves the iterator
310 * to last element in iteration or the first element that returned ''false''.
311 * If iterator points at some element it will be included in iteration.
313 * @param f function applied to every element of the collection
315 * @return ''false'' if the argument returned ''false'' at last invocation and
316 * ''true'' otherwise.
318 gboolean gee_traversable_foreach (GeeTraversable* self, GeeForallFunc f, void* f_target) {
319 g_return_val_if_fail (self != NULL, FALSE);
320 return GEE_TRAVERSABLE_GET_INTERFACE (self)->foreach (self, f, f_target);
325 * Stream function is an abstract function allowing writing many
328 * The stream function accepts three parameter:
330 * 1. state. It is usually the last returned value from function but
331 * it may be {@link Stream.END} when {@link Stream.CONTINUE} was
332 * returned and there was no more elements.
333 * 1. input. It is valid only if first argument is
334 * {@link Stream.CONTINUE}
335 * 1. output. It is valid only if result is Stream.YIELD
337 * It may return one of 3 results:
339 * 1. {@link Stream.YIELD}. It means that value was yielded and can
340 * be passed to outgoing iterator.
341 * 1. {@link Stream.CONTINUE}. It means that the function needs to be
342 * called with next element or with {@link Stream.END} if it is
343 * end of stream). If the state element was Stream.END during the
344 * current iteration function ''must not'' return {@link Stream.CONTINUE}
345 * 1. Stream.END. It means that the last argument was yielded.
347 * If the function yields the value immediately then the returning iterator
348 * is {@link Iterator.valid} and points to this value as well as in case when the
349 * parent iterator is {@link Iterator.valid} and function yields
350 * after consuming 1 input. In other case returned iterator is invalid.
352 * Note: In {@link Iterator} implementation: if iterator is
353 * {@link Iterator.valid} the current value should be fed
354 * immediately to function if during initial call function returns
355 * {@link Stream.CONTINUE}. The parent iterator cannot be used before
356 * the functions return {@link Stream.END} afterwards it points on the
357 * last element consumed.
359 * @param f function generating stream
360 * @return iterator containing values yielded by stream
362 static Block7Data* block7_data_ref (Block7Data* _data7_) {
363 g_atomic_int_inc (&_data7_->_ref_count_);
368 static void block7_data_unref (void * _userdata_) {
370 _data7_ = (Block7Data*) _userdata_;
371 if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
372 GeeTraversable * self;
374 GBoxedCopyFunc a_dup_func;
375 GDestroyNotify a_destroy_func;
376 self = _data7_->self;
377 a_type = _data7_->a_type;
378 a_dup_func = _data7_->a_dup_func;
379 a_destroy_func = _data7_->a_destroy_func;
380 _g_object_unref0 (_data7_->_self_);
381 (_data7_->f_target_destroy_notify == NULL) ? NULL : (_data7_->f_target_destroy_notify (_data7_->f_target), NULL);
383 _data7_->f_target = NULL;
384 _data7_->f_target_destroy_notify = NULL;
385 _g_object_unref0 (self);
386 g_slice_free (Block7Data, _data7_);
391 static gpointer _g_object_ref0 (gpointer self) {
392 return self ? g_object_ref (self) : NULL;
396 static Block8Data* block8_data_ref (Block8Data* _data8_) {
397 g_atomic_int_inc (&_data8_->_ref_count_);
402 static void block8_data_unref (void * _userdata_) {
404 _data8_ = (Block8Data*) _userdata_;
405 if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
406 GeeTraversable * self;
408 GBoxedCopyFunc a_dup_func;
409 GDestroyNotify a_destroy_func;
410 self = _data8_->_data7_->self;
411 a_type = _data8_->_data7_->a_type;
412 a_dup_func = _data8_->_data7_->a_dup_func;
413 a_destroy_func = _data8_->_data7_->a_destroy_func;
414 block7_data_unref (_data8_->_data7_);
415 _data8_->_data7_ = NULL;
416 g_slice_free (Block8Data, _data8_);
421 static gpointer _____lambda3_ (Block8Data* _data8_) {
423 GeeTraversable * self;
425 GBoxedCopyFunc a_dup_func;
426 GDestroyNotify a_destroy_func;
427 gpointer result = NULL;
429 gpointer _tmp1_ = NULL;
430 _data7_ = _data8_->_data7_;
431 self = _data7_->self;
432 a_type = _data7_->a_type;
433 a_dup_func = _data7_->a_dup_func;
434 a_destroy_func = _data7_->a_destroy_func;
435 _tmp0_ = _data7_->_self_;
436 _tmp1_ = gee_iterator_get (_tmp0_);
442 static gpointer ______lambda3__gee_lazy_func (gpointer self) {
444 result = _____lambda3_ (self);
449 static GeeLazy* ______lambda4_ (Block8Data* _data8_) {
451 GeeTraversable * self;
453 GBoxedCopyFunc a_dup_func;
454 GDestroyNotify a_destroy_func;
455 GeeLazy* result = NULL;
456 _data7_ = _data8_->_data7_;
457 self = _data7_->self;
458 a_type = _data7_->a_type;
459 a_dup_func = _data7_->a_dup_func;
460 a_destroy_func = _data7_->a_destroy_func;
466 static GeeLazy* _______lambda4__gee_unfold_func (gpointer self) {
468 result = ______lambda4_ (self);
473 static GeeLazy* ____lambda5_ (Block8Data* _data8_) {
475 GeeTraversable * self;
477 GBoxedCopyFunc a_dup_func;
478 GDestroyNotify a_destroy_func;
479 GeeLazy* result = NULL;
480 _data7_ = _data8_->_data7_;
481 self = _data7_->self;
482 a_type = _data7_->a_type;
483 a_dup_func = _data7_->a_dup_func;
484 a_destroy_func = _data7_->a_destroy_func;
490 static GeeLazy* _____lambda5__gee_unfold_func (gpointer self) {
492 result = ____lambda5_ (self);
497 static Block9Data* block9_data_ref (Block9Data* _data9_) {
498 g_atomic_int_inc (&_data9_->_ref_count_);
503 static void block9_data_unref (void * _userdata_) {
505 _data9_ = (Block9Data*) _userdata_;
506 if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
507 GeeTraversable * self;
509 GBoxedCopyFunc a_dup_func;
510 GDestroyNotify a_destroy_func;
511 self = _data9_->_data8_->_data7_->self;
512 a_type = _data9_->_data8_->_data7_->a_type;
513 a_dup_func = _data9_->_data8_->_data7_->a_dup_func;
514 a_destroy_func = _data9_->_data8_->_data7_->a_destroy_func;
515 block8_data_unref (_data9_->_data8_);
516 _data9_->_data8_ = NULL;
517 g_slice_free (Block9Data, _data9_);
522 static gpointer ___lambda7_ (Block9Data* _data9_) {
525 GeeTraversable * self;
527 GBoxedCopyFunc a_dup_func;
528 GDestroyNotify a_destroy_func;
529 gpointer result = NULL;
531 gpointer _tmp1_ = NULL;
532 _data8_ = _data9_->_data8_;
533 _data7_ = _data8_->_data7_;
534 self = _data7_->self;
535 a_type = _data7_->a_type;
536 a_dup_func = _data7_->a_dup_func;
537 a_destroy_func = _data7_->a_destroy_func;
538 _tmp0_ = _data7_->_self_;
539 _tmp1_ = gee_iterator_get (_tmp0_);
545 static gpointer ____lambda7__gee_lazy_func (gpointer self) {
547 result = ___lambda7_ (self);
552 static GeeLazy* ___lambda6_ (Block8Data* _data8_) {
554 GeeTraversable * self;
556 GBoxedCopyFunc a_dup_func;
557 GDestroyNotify a_destroy_func;
558 GeeLazy* result = NULL;
561 GeeTraversableStream _tmp0_;
562 GeeTraversableStream _tmp16_;
563 _data7_ = _data8_->_data7_;
564 self = _data7_->self;
565 a_type = _data7_->a_type;
566 a_dup_func = _data7_->a_dup_func;
567 a_destroy_func = _data7_->a_destroy_func;
568 _data9_ = g_slice_new0 (Block9Data);
569 _data9_->_ref_count_ = 1;
570 _data9_->_data8_ = block8_data_ref (_data8_);
572 _tmp0_ = _data8_->str;
573 if (_tmp0_ != GEE_TRAVERSABLE_STREAM_CONTINUE) {
574 GeeStreamFunc _tmp1_;
576 GeeLazy* _tmp2_ = NULL;
577 GeeTraversableStream _tmp3_ = 0;
579 _tmp1__target = _data7_->f_target;
580 _tmp3_ = _tmp1_ (GEE_TRAVERSABLE_STREAM_YIELD, NULL, &_tmp2_, _tmp1__target);
581 _gee_lazy_unref0 (val);
583 _data8_->str = _tmp3_;
586 GeeTraversableStream _tmp4_;
588 GeeStreamFunc _tmp12_;
589 void* _tmp12__target;
591 GeeLazy* _tmp14_ = NULL;
592 GeeTraversableStream _tmp15_ = 0;
593 _tmp4_ = _data8_->str;
594 if (!(_tmp4_ == GEE_TRAVERSABLE_STREAM_CONTINUE)) {
597 _tmp5_ = _data8_->need_next;
600 gboolean _tmp7_ = FALSE;
601 _tmp6_ = _data7_->_self_;
602 _tmp7_ = gee_iterator_next (_tmp6_);
604 GeeStreamFunc _tmp8_;
606 GeeLazy* _tmp9_ = NULL;
607 GeeTraversableStream _tmp10_ = 0;
608 GeeTraversableStream _tmp11_;
610 _tmp8__target = _data7_->f_target;
611 _tmp10_ = _tmp8_ (GEE_TRAVERSABLE_STREAM_END, NULL, &_tmp9_, _tmp8__target);
612 _gee_lazy_unref0 (val);
614 _data8_->str = _tmp10_;
615 _tmp11_ = _data8_->str;
616 _vala_assert (_tmp11_ != GEE_TRAVERSABLE_STREAM_CONTINUE, "str != Traversable.Stream.CONTINUE");
620 _data8_->need_next = TRUE;
622 _tmp12_ = _data7_->f;
623 _tmp12__target = _data7_->f_target;
624 _tmp13_ = gee_lazy_new (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_type (self), (GBoxedCopyFunc) GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_dup_func (self), GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self), ____lambda7__gee_lazy_func, block9_data_ref (_data9_), block9_data_unref);
625 _tmp15_ = _tmp12_ (GEE_TRAVERSABLE_STREAM_CONTINUE, _tmp13_, &_tmp14_, _tmp12__target);
626 _gee_lazy_unref0 (val);
628 _data8_->str = _tmp15_;
630 _tmp16_ = _data8_->str;
632 case GEE_TRAVERSABLE_STREAM_YIELD:
635 block9_data_unref (_data9_);
639 case GEE_TRAVERSABLE_STREAM_END:
642 _gee_lazy_unref0 (val);
643 block9_data_unref (_data9_);
649 g_assert_not_reached ();
652 _gee_lazy_unref0 (val);
653 block9_data_unref (_data9_);
658 static GeeLazy* ____lambda6__gee_unfold_func (gpointer self) {
660 result = ___lambda6_ (self);
665 static gpointer _gee_lazy_ref0 (gpointer self) {
666 return self ? gee_lazy_ref (self) : NULL;
670 static GeeIterator* gee_traversable_real_stream (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeStreamFunc f, void* f_target, GDestroyNotify f_target_destroy_notify) {
671 GeeIterator* result = NULL;
673 GeeStreamFunc _tmp0_;
675 GeeIterable* iself = NULL;
678 _data7_ = g_slice_new0 (Block7Data);
679 _data7_->_ref_count_ = 1;
680 _data7_->self = g_object_ref (self);
681 _data7_->a_type = a_type;
682 _data7_->a_dup_func = a_dup_func;
683 _data7_->a_destroy_func = a_destroy_func;
685 _tmp0__target = f_target;
686 (_data7_->f_target_destroy_notify == NULL) ? NULL : (_data7_->f_target_destroy_notify (_data7_->f_target), NULL);
688 _data7_->f_target = NULL;
689 _data7_->f_target_destroy_notify = NULL;
691 _data7_->f_target = _tmp0__target;
692 _data7_->f_target_destroy_notify = f_target_destroy_notify;
693 _tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (self, GEE_TYPE_ITERATOR) ? ((GeeIterator*) self) : NULL);
694 _g_object_unref0 (_data7_->_self_);
695 _data7_->_self_ = _tmp1_;
696 _tmp2_ = _data7_->_self_;
697 if (_tmp2_ != NULL) {
700 GeeStreamFunc _tmp3_;
702 GeeLazy* _tmp4_ = NULL;
703 GeeTraversableStream _tmp5_ = 0;
704 GeeTraversableStream _tmp6_;
707 GeeIterator* _tmp22_ = NULL;
708 _data8_ = g_slice_new0 (Block8Data);
709 _data8_->_ref_count_ = 1;
710 _data8_->_data7_ = block7_data_ref (_data7_);
712 _data8_->need_next = TRUE;
714 _tmp3__target = _data7_->f_target;
715 _tmp5_ = _tmp3_ (GEE_TRAVERSABLE_STREAM_YIELD, NULL, &_tmp4_, _tmp3__target);
716 _gee_lazy_unref0 (initial);
718 _data8_->str = _tmp5_;
719 _tmp6_ = _data8_->str;
721 case GEE_TRAVERSABLE_STREAM_CONTINUE:
726 _tmp7_ = _data7_->_self_;
727 _tmp8_ = gee_iterator_get_valid (_tmp7_);
730 GeeStreamFunc _tmp10_;
731 void* _tmp10__target;
733 GeeLazy* _tmp12_ = NULL;
734 GeeTraversableStream _tmp13_ = 0;
735 GeeTraversableStream _tmp14_;
736 _tmp10_ = _data7_->f;
737 _tmp10__target = _data7_->f_target;
738 _tmp11_ = gee_lazy_new (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_type (self), (GBoxedCopyFunc) GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_dup_func (self), GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self), ______lambda3__gee_lazy_func, block8_data_ref (_data8_), block8_data_unref);
739 _tmp13_ = _tmp10_ (GEE_TRAVERSABLE_STREAM_CONTINUE, _tmp11_, &_tmp12_, _tmp10__target);
740 _gee_lazy_unref0 (initial);
742 _data8_->str = _tmp13_;
743 _tmp14_ = _data8_->str;
745 case GEE_TRAVERSABLE_STREAM_YIELD:
746 case GEE_TRAVERSABLE_STREAM_CONTINUE:
750 case GEE_TRAVERSABLE_STREAM_END:
752 GeeIterator* _tmp15_ = NULL;
753 _tmp15_ = gee_iterator_unfold (a_type, (GBoxedCopyFunc) a_dup_func, a_destroy_func, _______lambda4__gee_unfold_func, block8_data_ref (_data8_), block8_data_unref, NULL);
755 _gee_lazy_unref0 (initial);
756 block8_data_unref (_data8_);
758 _g_object_unref0 (iself);
759 block7_data_unref (_data7_);
765 g_assert_not_reached ();
771 case GEE_TRAVERSABLE_STREAM_YIELD:
773 GeeIterator* _tmp16_;
776 _tmp16_ = _data7_->_self_;
777 _tmp17_ = gee_iterator_get_valid (_tmp16_);
780 _data8_->need_next = FALSE;
784 case GEE_TRAVERSABLE_STREAM_END:
786 GeeIterator* _tmp19_ = NULL;
787 _tmp19_ = gee_iterator_unfold (a_type, (GBoxedCopyFunc) a_dup_func, a_destroy_func, _____lambda5__gee_unfold_func, block8_data_ref (_data8_), block8_data_unref, NULL);
789 _gee_lazy_unref0 (initial);
790 block8_data_unref (_data8_);
792 _g_object_unref0 (iself);
793 block7_data_unref (_data7_);
799 g_assert_not_reached ();
803 _tmp21_ = _gee_lazy_ref0 (_tmp20_);
804 _tmp22_ = gee_iterator_unfold (a_type, (GBoxedCopyFunc) a_dup_func, a_destroy_func, ____lambda6__gee_unfold_func, block8_data_ref (_data8_), block8_data_unref, _tmp21_);
806 _gee_lazy_unref0 (initial);
807 block8_data_unref (_data8_);
809 _g_object_unref0 (iself);
810 block7_data_unref (_data7_);
814 GeeIterable* _tmp23_;
815 GeeIterable* _tmp24_;
816 _tmp23_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (self, GEE_TYPE_ITERABLE) ? ((GeeIterable*) self) : NULL);
817 _g_object_unref0 (iself);
820 if (_tmp24_ != NULL) {
821 GeeIterable* _tmp25_;
822 GeeIterator* _tmp26_ = NULL;
823 GeeIterator* _tmp27_;
824 GeeStreamFunc _tmp28_;
825 void* _tmp28__target;
826 GDestroyNotify _tmp28__target_destroy_notify;
827 GeeIterator* _tmp29_ = NULL;
828 GeeIterator* _tmp30_;
830 _tmp26_ = gee_iterable_iterator (_tmp25_);
832 _tmp28_ = _data7_->f;
833 _tmp28__target = _data7_->f_target;
834 _tmp28__target_destroy_notify = _data7_->f_target_destroy_notify;
835 _data7_->f_target_destroy_notify = NULL;
836 _tmp29_ = gee_traversable_stream ((GeeTraversable*) _tmp27_, a_type, (GBoxedCopyFunc) a_dup_func, a_destroy_func, _tmp28_, _tmp28__target, _tmp28__target_destroy_notify);
838 _g_object_unref0 (_tmp27_);
840 _g_object_unref0 (iself);
841 block7_data_unref (_data7_);
845 g_assert_not_reached ();
848 _g_object_unref0 (iself);
849 block7_data_unref (_data7_);
854 GeeIterator* gee_traversable_stream (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeStreamFunc f, void* f_target, GDestroyNotify f_target_destroy_notify) {
855 g_return_val_if_fail (self != NULL, NULL);
856 return GEE_TRAVERSABLE_GET_INTERFACE (self)->stream (self, a_type, a_dup_func, a_destroy_func, f, f_target, f_target_destroy_notify);
861 * Standard aggregation function.
863 * It takes a function, seed and first element, returns the new seed and
864 * progress to next element when the operation repeats.
866 * Note: Default implementation uses {@link foreach}.
868 * Note: In {@link Iterator} implementation operation moves the
869 * iterator to last element in iteration. If iterator is
870 * {@link Iterator.valid} the current element will be considered
874 static Block10Data* block10_data_ref (Block10Data* _data10_) {
875 g_atomic_int_inc (&_data10_->_ref_count_);
880 static void block10_data_unref (void * _userdata_) {
881 Block10Data* _data10_;
882 _data10_ = (Block10Data*) _userdata_;
883 if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
884 GeeTraversable * self;
886 GBoxedCopyFunc a_dup_func;
887 GDestroyNotify a_destroy_func;
888 self = _data10_->self;
889 a_type = _data10_->a_type;
890 a_dup_func = _data10_->a_dup_func;
891 a_destroy_func = _data10_->a_destroy_func;
892 _a_destroy_func0 (_data10_->seed);
893 _g_object_unref0 (self);
894 g_slice_free (Block10Data, _data10_);
899 static gboolean __lambda8_ (Block10Data* _data10_, gpointer item) {
900 GeeTraversable * self;
902 GBoxedCopyFunc a_dup_func;
903 GDestroyNotify a_destroy_func;
904 gboolean result = FALSE;
909 gpointer _tmp3_ = NULL;
910 self = _data10_->self;
911 a_type = _data10_->a_type;
912 a_dup_func = _data10_->a_dup_func;
913 a_destroy_func = _data10_->a_destroy_func;
914 _tmp0_ = _data10_->f;
915 _tmp0__target = _data10_->f_target;
918 _tmp2_ = _data10_->seed;
919 _data10_->seed = NULL;
920 _tmp3_ = _tmp0_ (_tmp1_, _tmp2_, _tmp0__target);
921 _a_destroy_func0 (_data10_->seed);
922 _data10_->seed = _tmp3_;
924 ((item == NULL) || (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self) == NULL)) ? NULL : (item = (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self) (item), NULL));
929 static gboolean ___lambda8__gee_forall_func (gpointer g, gpointer self) {
931 result = __lambda8_ (self, g);
936 static gpointer gee_traversable_real_fold (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed) {
937 gpointer result = NULL;
938 Block10Data* _data10_;
941 gconstpointer _tmp1_;
943 _data10_ = g_slice_new0 (Block10Data);
944 _data10_->_ref_count_ = 1;
945 _data10_->self = g_object_ref (self);
946 _data10_->a_type = a_type;
947 _data10_->a_dup_func = a_dup_func;
948 _data10_->a_destroy_func = a_destroy_func;
950 _tmp0__target = f_target;
951 _data10_->f = _tmp0_;
952 _data10_->f_target = _tmp0__target;
954 _a_destroy_func0 (_data10_->seed);
955 _data10_->seed = _tmp1_;
956 gee_traversable_foreach (self, ___lambda8__gee_forall_func, _data10_);
957 _tmp2_ = _data10_->seed;
958 _data10_->seed = NULL;
960 block10_data_unref (_data10_);
966 gpointer gee_traversable_fold (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed) {
967 g_return_val_if_fail (self != NULL, NULL);
968 return GEE_TRAVERSABLE_GET_INTERFACE (self)->fold (self, a_type, a_dup_func, a_destroy_func, f, f_target, seed);
973 * Produces an iterator pointing at elements generated by function passed.
975 * Iterator is lazy evaluated but value is force-evaluated when
976 * iterator moves to next element. ({@link Iterator.next})
978 * Note: Default implementation uses {@link stream}.
980 * Note: In {@link Iterator} implementation if the parent iterator is
981 * {@link Iterator.valid} so is the returned one. Using the parent
982 * iterator is not allowed before the inner iterator {@link Iterator.next}
983 * return false and then it points on its last element.
984 * The resulting iterator is {@link Iterator.valid} if the parent
987 * @param f Mapping function
988 * @return Iterator listing mapped value
990 static Block11Data* block11_data_ref (Block11Data* _data11_) {
991 g_atomic_int_inc (&_data11_->_ref_count_);
996 static void block11_data_unref (void * _userdata_) {
997 Block11Data* _data11_;
998 _data11_ = (Block11Data*) _userdata_;
999 if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
1000 GeeTraversable * self;
1002 GBoxedCopyFunc a_dup_func;
1003 GDestroyNotify a_destroy_func;
1004 self = _data11_->self;
1005 a_type = _data11_->a_type;
1006 a_dup_func = _data11_->a_dup_func;
1007 a_destroy_func = _data11_->a_destroy_func;
1008 _g_object_unref0 (self);
1009 g_slice_free (Block11Data, _data11_);
1014 static Block12Data* block12_data_ref (Block12Data* _data12_) {
1015 g_atomic_int_inc (&_data12_->_ref_count_);
1020 static void block12_data_unref (void * _userdata_) {
1021 Block12Data* _data12_;
1022 _data12_ = (Block12Data*) _userdata_;
1023 if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
1024 GeeTraversable * self;
1026 GBoxedCopyFunc a_dup_func;
1027 GDestroyNotify a_destroy_func;
1028 self = _data12_->_data11_->self;
1029 a_type = _data12_->_data11_->a_type;
1030 a_dup_func = _data12_->_data11_->a_dup_func;
1031 a_destroy_func = _data12_->_data11_->a_destroy_func;
1032 _gee_lazy_unref0 (_data12_->item);
1033 block11_data_unref (_data12_->_data11_);
1034 _data12_->_data11_ = NULL;
1035 g_slice_free (Block12Data, _data12_);
1040 static gpointer ___lambda10_ (Block12Data* _data12_) {
1041 Block11Data* _data11_;
1042 GeeTraversable * self;
1044 GBoxedCopyFunc a_dup_func;
1045 GDestroyNotify a_destroy_func;
1046 gpointer result = NULL;
1048 gpointer _tmp1_ = NULL;
1051 void* _tmp2__target;
1053 gpointer _tmp4_ = NULL;
1054 _data11_ = _data12_->_data11_;
1055 self = _data11_->self;
1056 a_type = _data11_->a_type;
1057 a_dup_func = _data11_->a_dup_func;
1058 a_destroy_func = _data11_->a_destroy_func;
1059 _tmp0_ = _data12_->item;
1060 _tmp1_ = gee_lazy_get (_tmp0_);
1062 _gee_lazy_unref0 (_data12_->item);
1063 _data12_->item = NULL;
1064 _tmp2_ = _data11_->f;
1065 _tmp2__target = _data11_->f_target;
1068 _tmp4_ = _tmp2_ (_tmp3_, _tmp2__target);
1070 _a_destroy_func0 (tmp);
1075 static gpointer ____lambda10__gee_lazy_func (gpointer self) {
1077 result = ___lambda10_ (self);
1082 static GeeTraversableStream __lambda9_ (Block11Data* _data11_, GeeTraversableStream state, GeeLazy* item, GeeLazy** val) {
1083 GeeTraversable * self;
1085 GBoxedCopyFunc a_dup_func;
1086 GDestroyNotify a_destroy_func;
1087 GeeLazy* _vala_val = NULL;
1088 GeeTraversableStream result = 0;
1089 Block12Data* _data12_;
1091 GeeTraversableStream _tmp1_;
1092 self = _data11_->self;
1093 a_type = _data11_->a_type;
1094 a_dup_func = _data11_->a_dup_func;
1095 a_destroy_func = _data11_->a_destroy_func;
1096 _data12_ = g_slice_new0 (Block12Data);
1097 _data12_->_ref_count_ = 1;
1098 _data12_->_data11_ = block11_data_ref (_data11_);
1100 _gee_lazy_unref0 (_data12_->item);
1101 _data12_->item = _tmp0_;
1104 case GEE_TRAVERSABLE_STREAM_YIELD:
1106 _gee_lazy_unref0 (_vala_val);
1108 result = GEE_TRAVERSABLE_STREAM_CONTINUE;
1109 block12_data_unref (_data12_);
1114 _gee_lazy_unref0 (_vala_val);
1118 case GEE_TRAVERSABLE_STREAM_CONTINUE:
1121 _tmp2_ = gee_lazy_new (a_type, (GBoxedCopyFunc) a_dup_func, a_destroy_func, ____lambda10__gee_lazy_func, block12_data_ref (_data12_), block12_data_unref);
1122 _gee_lazy_unref0 (_vala_val);
1124 result = GEE_TRAVERSABLE_STREAM_YIELD;
1125 block12_data_unref (_data12_);
1130 _gee_lazy_unref0 (_vala_val);
1134 case GEE_TRAVERSABLE_STREAM_END:
1136 _gee_lazy_unref0 (_vala_val);
1138 result = GEE_TRAVERSABLE_STREAM_END;
1139 block12_data_unref (_data12_);
1144 _gee_lazy_unref0 (_vala_val);
1150 g_assert_not_reached ();
1156 _gee_lazy_unref0 (_vala_val);
1158 block12_data_unref (_data12_);
1163 static GeeTraversableStream ___lambda9__gee_stream_func (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, gpointer self) {
1164 GeeTraversableStream result;
1165 result = __lambda9_ (self, state, g, lazy);
1170 static GeeIterator* gee_traversable_real_map (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeMapFunc f, void* f_target) {
1171 GeeIterator* result = NULL;
1172 Block11Data* _data11_;
1174 void* _tmp0__target;
1175 GeeIterator* _tmp1_ = NULL;
1176 _data11_ = g_slice_new0 (Block11Data);
1177 _data11_->_ref_count_ = 1;
1178 _data11_->self = g_object_ref (self);
1179 _data11_->a_type = a_type;
1180 _data11_->a_dup_func = a_dup_func;
1181 _data11_->a_destroy_func = a_destroy_func;
1183 _tmp0__target = f_target;
1184 _data11_->f = _tmp0_;
1185 _data11_->f_target = _tmp0__target;
1186 _tmp1_ = gee_traversable_stream (self, a_type, (GBoxedCopyFunc) a_dup_func, a_destroy_func, ___lambda9__gee_stream_func, block11_data_ref (_data11_), block11_data_unref);
1188 block11_data_unref (_data11_);
1194 GeeIterator* gee_traversable_map (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeMapFunc f, void* f_target) {
1195 g_return_val_if_fail (self != NULL, NULL);
1196 return GEE_TRAVERSABLE_GET_INTERFACE (self)->map (self, a_type, a_dup_func, a_destroy_func, f, f_target);
1201 * Creates a new iterator that is initially pointing to seed. Then
1202 * subsequent values are obtained after applying the function to previous
1203 * value and the subsequent items.
1205 * The resulting iterator is always valid and it contains the seed value.
1207 * Note: Default implementation uses {@link stream}.
1209 * Note: When the method is called on {@link Iterator} using the parent
1210 * iterator is not allowed befor the inner iterator
1211 * {@link Iterator.next} return false and then it points on its last
1212 * element. The resulting iterator is {@link Iterator.valid}.
1214 * @param f Folding function
1215 * @param seed original seed value
1216 * @return Iterator containing values of subsequent values of seed
1218 static Block13Data* block13_data_ref (Block13Data* _data13_) {
1219 g_atomic_int_inc (&_data13_->_ref_count_);
1224 static void block13_data_unref (void * _userdata_) {
1225 Block13Data* _data13_;
1226 _data13_ = (Block13Data*) _userdata_;
1227 if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
1228 GeeTraversable * self;
1230 GBoxedCopyFunc a_dup_func;
1231 GDestroyNotify a_destroy_func;
1232 self = _data13_->self;
1233 a_type = _data13_->a_type;
1234 a_dup_func = _data13_->a_dup_func;
1235 a_destroy_func = _data13_->a_destroy_func;
1236 _a_destroy_func0 (_data13_->seed);
1237 _g_object_unref0 (self);
1238 g_slice_free (Block13Data, _data13_);
1243 static Block14Data* block14_data_ref (Block14Data* _data14_) {
1244 g_atomic_int_inc (&_data14_->_ref_count_);
1249 static void block14_data_unref (void * _userdata_) {
1250 Block14Data* _data14_;
1251 _data14_ = (Block14Data*) _userdata_;
1252 if (g_atomic_int_dec_and_test (&_data14_->_ref_count_)) {
1253 GeeTraversable * self;
1255 GBoxedCopyFunc a_dup_func;
1256 GDestroyNotify a_destroy_func;
1257 self = _data14_->_data13_->self;
1258 a_type = _data14_->_data13_->a_type;
1259 a_dup_func = _data14_->_data13_->a_dup_func;
1260 a_destroy_func = _data14_->_data13_->a_destroy_func;
1261 _gee_lazy_unref0 (_data14_->item);
1262 block13_data_unref (_data14_->_data13_);
1263 _data14_->_data13_ = NULL;
1264 g_slice_free (Block14Data, _data14_);
1269 static gpointer ___lambda12_ (Block14Data* _data14_) {
1270 Block13Data* _data13_;
1271 GeeTraversable * self;
1273 GBoxedCopyFunc a_dup_func;
1274 GDestroyNotify a_destroy_func;
1275 gpointer result = NULL;
1277 gpointer _tmp1_ = NULL;
1280 void* _tmp2__target;
1283 gpointer _tmp5_ = NULL;
1284 gconstpointer _tmp6_;
1286 _data13_ = _data14_->_data13_;
1287 self = _data13_->self;
1288 a_type = _data13_->a_type;
1289 a_dup_func = _data13_->a_dup_func;
1290 a_destroy_func = _data13_->a_destroy_func;
1291 _tmp0_ = _data14_->item;
1292 _tmp1_ = gee_lazy_get (_tmp0_);
1294 _gee_lazy_unref0 (_data14_->item);
1295 _data14_->item = NULL;
1296 _tmp2_ = _data13_->f;
1297 _tmp2__target = _data13_->f_target;
1300 _tmp4_ = _data13_->seed;
1301 _data13_->seed = NULL;
1302 _tmp5_ = _tmp2_ (_tmp3_, _tmp4_, _tmp2__target);
1303 _a_destroy_func0 (_data13_->seed);
1304 _data13_->seed = _tmp5_;
1305 _tmp6_ = _data13_->seed;
1306 _tmp7_ = ((_tmp6_ != NULL) && (a_dup_func != NULL)) ? a_dup_func ((gpointer) _tmp6_) : ((gpointer) _tmp6_);
1308 _a_destroy_func0 (tmp);
1313 static gpointer ____lambda12__gee_lazy_func (gpointer self) {
1315 result = ___lambda12_ (self);
1320 static GeeTraversableStream __lambda11_ (Block13Data* _data13_, GeeTraversableStream state, GeeLazy* item, GeeLazy** val) {
1321 GeeTraversable * self;
1323 GBoxedCopyFunc a_dup_func;
1324 GDestroyNotify a_destroy_func;
1325 GeeLazy* _vala_val = NULL;
1326 GeeTraversableStream result = 0;
1327 Block14Data* _data14_;
1329 GeeTraversableStream _tmp1_;
1330 self = _data13_->self;
1331 a_type = _data13_->a_type;
1332 a_dup_func = _data13_->a_dup_func;
1333 a_destroy_func = _data13_->a_destroy_func;
1334 _data14_ = g_slice_new0 (Block14Data);
1335 _data14_->_ref_count_ = 1;
1336 _data14_->_data13_ = block13_data_ref (_data13_);
1338 _gee_lazy_unref0 (_data14_->item);
1339 _data14_->item = _tmp0_;
1342 case GEE_TRAVERSABLE_STREAM_YIELD:
1344 if (_data13_->seed_emitted) {
1345 _gee_lazy_unref0 (_vala_val);
1347 result = GEE_TRAVERSABLE_STREAM_CONTINUE;
1348 block14_data_unref (_data14_);
1353 _gee_lazy_unref0 (_vala_val);
1357 gconstpointer _tmp2_;
1359 _tmp2_ = _data13_->seed;
1360 _tmp3_ = gee_lazy_new_from_value (a_type, (GBoxedCopyFunc) a_dup_func, a_destroy_func, _tmp2_);
1361 _gee_lazy_unref0 (_vala_val);
1363 _data13_->seed_emitted = TRUE;
1364 result = GEE_TRAVERSABLE_STREAM_YIELD;
1365 block14_data_unref (_data14_);
1370 _gee_lazy_unref0 (_vala_val);
1375 case GEE_TRAVERSABLE_STREAM_CONTINUE:
1378 _tmp4_ = gee_lazy_new (a_type, (GBoxedCopyFunc) a_dup_func, a_destroy_func, ____lambda12__gee_lazy_func, block14_data_ref (_data14_), block14_data_unref);
1379 _gee_lazy_unref0 (_vala_val);
1381 result = GEE_TRAVERSABLE_STREAM_YIELD;
1382 block14_data_unref (_data14_);
1387 _gee_lazy_unref0 (_vala_val);
1391 case GEE_TRAVERSABLE_STREAM_END:
1393 _gee_lazy_unref0 (_vala_val);
1395 result = GEE_TRAVERSABLE_STREAM_END;
1396 block14_data_unref (_data14_);
1401 _gee_lazy_unref0 (_vala_val);
1407 g_assert_not_reached ();
1413 _gee_lazy_unref0 (_vala_val);
1415 block14_data_unref (_data14_);
1420 static GeeTraversableStream ___lambda11__gee_stream_func (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, gpointer self) {
1421 GeeTraversableStream result;
1422 result = __lambda11_ (self, state, g, lazy);
1427 static GeeIterator* gee_traversable_real_scan (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed) {
1428 GeeIterator* result = NULL;
1429 Block13Data* _data13_;
1431 void* _tmp0__target;
1432 gconstpointer _tmp1_;
1433 GeeIterator* _tmp2_ = NULL;
1434 _data13_ = g_slice_new0 (Block13Data);
1435 _data13_->_ref_count_ = 1;
1436 _data13_->self = g_object_ref (self);
1437 _data13_->a_type = a_type;
1438 _data13_->a_dup_func = a_dup_func;
1439 _data13_->a_destroy_func = a_destroy_func;
1441 _tmp0__target = f_target;
1442 _data13_->f = _tmp0_;
1443 _data13_->f_target = _tmp0__target;
1445 _a_destroy_func0 (_data13_->seed);
1446 _data13_->seed = _tmp1_;
1447 _data13_->seed_emitted = FALSE;
1448 _tmp2_ = gee_traversable_stream (self, a_type, (GBoxedCopyFunc) a_dup_func, a_destroy_func, ___lambda11__gee_stream_func, block13_data_ref (_data13_), block13_data_unref);
1450 block13_data_unref (_data13_);
1456 GeeIterator* gee_traversable_scan (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed) {
1457 g_return_val_if_fail (self != NULL, NULL);
1458 return GEE_TRAVERSABLE_GET_INTERFACE (self)->scan (self, a_type, a_dup_func, a_destroy_func, f, f_target, seed);
1463 * Creates a new iterator that contains only values that fullfills the
1466 * Note: When the method is called on {@link Iterator} using the parent
1467 * iterator is not allowed befor the inner iterator
1468 * {@link Iterator.next} return false and then it points on its last
1469 * element. The resulting iterator is {@link Iterator.valid} if parent
1470 * iterator is {@link Iterator.valid} and value it is pointing on
1471 * fullfills the predicate.
1473 * @param pred predicate to check should the value be retained
1474 * @return Iterator containing values of subsequent values of seed
1476 static Block15Data* block15_data_ref (Block15Data* _data15_) {
1477 g_atomic_int_inc (&_data15_->_ref_count_);
1482 static void block15_data_unref (void * _userdata_) {
1483 Block15Data* _data15_;
1484 _data15_ = (Block15Data*) _userdata_;
1485 if (g_atomic_int_dec_and_test (&_data15_->_ref_count_)) {
1486 GeeTraversable * self;
1487 self = _data15_->self;
1488 (_data15_->pred_target_destroy_notify == NULL) ? NULL : (_data15_->pred_target_destroy_notify (_data15_->pred_target), NULL);
1489 _data15_->pred = NULL;
1490 _data15_->pred_target = NULL;
1491 _data15_->pred_target_destroy_notify = NULL;
1492 _g_object_unref0 (self);
1493 g_slice_free (Block15Data, _data15_);
1498 static GeeTraversableStream __lambda13_ (Block15Data* _data15_, GeeTraversableStream state, GeeLazy* item, GeeLazy** val) {
1499 GeeTraversable * self;
1500 GeeLazy* _vala_val = NULL;
1501 GeeTraversableStream result = 0;
1502 GeeTraversableStream _tmp0_;
1503 self = _data15_->self;
1506 case GEE_TRAVERSABLE_STREAM_YIELD:
1508 _gee_lazy_unref0 (_vala_val);
1510 result = GEE_TRAVERSABLE_STREAM_CONTINUE;
1511 _gee_lazy_unref0 (item);
1515 _gee_lazy_unref0 (_vala_val);
1519 case GEE_TRAVERSABLE_STREAM_CONTINUE:
1522 gpointer _tmp2_ = NULL;
1524 GeePredicate _tmp3_;
1525 void* _tmp3__target;
1526 gconstpointer _tmp4_;
1527 gboolean _tmp5_ = FALSE;
1529 _tmp2_ = gee_lazy_get (_tmp1_);
1531 _tmp3_ = _data15_->pred;
1532 _tmp3__target = _data15_->pred_target;
1534 _tmp5_ = _tmp3_ (_tmp4_, _tmp3__target);
1539 _tmp7_ = _gee_lazy_ref0 (_tmp6_);
1540 _gee_lazy_unref0 (_vala_val);
1542 result = GEE_TRAVERSABLE_STREAM_YIELD;
1543 ((g == NULL) || (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self) == NULL)) ? NULL : (g = (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self) (g), NULL));
1544 _gee_lazy_unref0 (item);
1548 _gee_lazy_unref0 (_vala_val);
1552 _gee_lazy_unref0 (_vala_val);
1554 result = GEE_TRAVERSABLE_STREAM_CONTINUE;
1555 ((g == NULL) || (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self) == NULL)) ? NULL : (g = (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self) (g), NULL));
1556 _gee_lazy_unref0 (item);
1560 _gee_lazy_unref0 (_vala_val);
1564 ((g == NULL) || (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self) == NULL)) ? NULL : (g = (GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self) (g), NULL));
1566 case GEE_TRAVERSABLE_STREAM_END:
1568 _gee_lazy_unref0 (_vala_val);
1570 result = GEE_TRAVERSABLE_STREAM_END;
1571 _gee_lazy_unref0 (item);
1575 _gee_lazy_unref0 (_vala_val);
1581 g_assert_not_reached ();
1584 _gee_lazy_unref0 (item);
1588 _gee_lazy_unref0 (_vala_val);
1593 static GeeTraversableStream ___lambda13__gee_stream_func (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, gpointer self) {
1594 GeeTraversableStream result;
1595 result = __lambda13_ (self, state, g, lazy);
1600 static GeeIterator* gee_traversable_real_filter (GeeTraversable* self, GeePredicate pred, void* pred_target, GDestroyNotify pred_target_destroy_notify) {
1601 GeeIterator* result = NULL;
1602 Block15Data* _data15_;
1603 GeePredicate _tmp0_;
1604 void* _tmp0__target;
1605 GeeIterator* _tmp1_ = NULL;
1606 _data15_ = g_slice_new0 (Block15Data);
1607 _data15_->_ref_count_ = 1;
1608 _data15_->self = g_object_ref (self);
1610 _tmp0__target = pred_target;
1611 (_data15_->pred_target_destroy_notify == NULL) ? NULL : (_data15_->pred_target_destroy_notify (_data15_->pred_target), NULL);
1612 _data15_->pred = NULL;
1613 _data15_->pred_target = NULL;
1614 _data15_->pred_target_destroy_notify = NULL;
1615 _data15_->pred = _tmp0_;
1616 _data15_->pred_target = _tmp0__target;
1617 _data15_->pred_target_destroy_notify = pred_target_destroy_notify;
1618 _tmp1_ = gee_traversable_stream (self, GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_type (self), (GBoxedCopyFunc) GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_dup_func (self), GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self), ___lambda13__gee_stream_func, block15_data_ref (_data15_), block15_data_unref);
1620 block15_data_unref (_data15_);
1626 GeeIterator* gee_traversable_filter (GeeTraversable* self, GeePredicate pred, void* pred_target, GDestroyNotify pred_target_destroy_notify) {
1627 g_return_val_if_fail (self != NULL, NULL);
1628 return GEE_TRAVERSABLE_GET_INTERFACE (self)->filter (self, pred, pred_target, pred_target_destroy_notify);
1633 * Creates a new iterator which contains elements from iterable. The
1634 * first argument states the offset i.e. number of elements the iterator
1637 * Note: In {@link Iterator} implementation resulting iterator is
1638 * {@link Iterator.valid} when parent iterator is
1639 * {@link Iterator.valid} and the offset is 0. Using the parent
1640 * iterator is not allowed before the inner iterator
1641 * {@link Iterator.next} return false and then it points on its last
1644 * @param offset the offset to first element the iterator is pointing to
1645 * @param length maximum number of elements iterator may return. Negative
1646 * value means that the number is unbounded
1648 static Block16Data* block16_data_ref (Block16Data* _data16_) {
1649 g_atomic_int_inc (&_data16_->_ref_count_);
1654 static void block16_data_unref (void * _userdata_) {
1655 Block16Data* _data16_;
1656 _data16_ = (Block16Data*) _userdata_;
1657 if (g_atomic_int_dec_and_test (&_data16_->_ref_count_)) {
1658 GeeTraversable * self;
1659 self = _data16_->self;
1660 _g_object_unref0 (self);
1661 g_slice_free (Block16Data, _data16_);
1666 static GeeTraversableStream __lambda14_ (Block16Data* _data16_, GeeTraversableStream state, GeeLazy* item, GeeLazy** val) {
1667 GeeTraversable * self;
1668 GeeLazy* _vala_val = NULL;
1669 GeeTraversableStream result = 0;
1670 GeeTraversableStream _tmp0_;
1671 self = _data16_->self;
1674 case GEE_TRAVERSABLE_STREAM_YIELD:
1677 _gee_lazy_unref0 (_vala_val);
1679 _tmp1_ = _data16_->offset;
1681 result = GEE_TRAVERSABLE_STREAM_CONTINUE;
1682 _gee_lazy_unref0 (item);
1686 _gee_lazy_unref0 (_vala_val);
1691 _tmp2_ = _data16_->length;
1693 GeeTraversableStream _tmp3_ = 0;
1695 GeeTraversableStream _tmp5_;
1696 _tmp4_ = _data16_->length;
1698 _tmp3_ = GEE_TRAVERSABLE_STREAM_CONTINUE;
1700 _tmp3_ = GEE_TRAVERSABLE_STREAM_END;
1704 _gee_lazy_unref0 (item);
1708 _gee_lazy_unref0 (_vala_val);
1713 _tmp6_ = _data16_->length;
1715 result = GEE_TRAVERSABLE_STREAM_END;
1716 _gee_lazy_unref0 (item);
1720 _gee_lazy_unref0 (_vala_val);
1724 result = GEE_TRAVERSABLE_STREAM_CONTINUE;
1725 _gee_lazy_unref0 (item);
1729 _gee_lazy_unref0 (_vala_val);
1736 case GEE_TRAVERSABLE_STREAM_CONTINUE:
1739 _tmp7_ = _data16_->offset;
1745 _tmp9_ = _gee_lazy_ref0 (_tmp8_);
1746 _gee_lazy_unref0 (_vala_val);
1748 _tmp10_ = _data16_->length;
1749 _data16_->length = _tmp10_ - 1;
1750 result = GEE_TRAVERSABLE_STREAM_YIELD;
1751 _gee_lazy_unref0 (item);
1755 _gee_lazy_unref0 (_vala_val);
1760 _gee_lazy_unref0 (_vala_val);
1762 _tmp11_ = _data16_->offset;
1763 _data16_->offset = _tmp11_ - 1;
1764 result = GEE_TRAVERSABLE_STREAM_CONTINUE;
1765 _gee_lazy_unref0 (item);
1769 _gee_lazy_unref0 (_vala_val);
1774 case GEE_TRAVERSABLE_STREAM_END:
1776 _gee_lazy_unref0 (_vala_val);
1778 result = GEE_TRAVERSABLE_STREAM_END;
1779 _gee_lazy_unref0 (item);
1783 _gee_lazy_unref0 (_vala_val);
1789 g_assert_not_reached ();
1792 _gee_lazy_unref0 (item);
1796 _gee_lazy_unref0 (_vala_val);
1801 static GeeTraversableStream ___lambda14__gee_stream_func (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, gpointer self) {
1802 GeeTraversableStream result;
1803 result = __lambda14_ (self, state, g, lazy);
1808 static GeeIterator* gee_traversable_real_chop (GeeTraversable* self, gint offset, gint length) {
1809 GeeIterator* result = NULL;
1810 Block16Data* _data16_;
1814 GeeIterator* _tmp3_ = NULL;
1815 _data16_ = g_slice_new0 (Block16Data);
1816 _data16_->_ref_count_ = 1;
1817 _data16_->self = g_object_ref (self);
1819 _data16_->offset = _tmp0_;
1821 _data16_->length = _tmp1_;
1822 _tmp2_ = _data16_->offset;
1823 _vala_assert (_tmp2_ >= 0, "offset >= 0");
1824 _tmp3_ = gee_traversable_stream (self, GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_type (self), (GBoxedCopyFunc) GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_dup_func (self), GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_destroy_func (self), ___lambda14__gee_stream_func, block16_data_ref (_data16_), block16_data_unref);
1826 block16_data_unref (_data16_);
1832 GeeIterator* gee_traversable_chop (GeeTraversable* self, gint offset, gint length) {
1833 g_return_val_if_fail (self != NULL, NULL);
1834 return GEE_TRAVERSABLE_GET_INTERFACE (self)->chop (self, offset, length);
1838 GType gee_traversable_get_element_type (GeeTraversable* self) {
1839 g_return_val_if_fail (self != NULL, 0UL);
1840 return GEE_TRAVERSABLE_GET_INTERFACE (self)->get_element_type (self);
1844 static GType gee_traversable_real_get_element_type (GeeTraversable* base) {
1846 GeeTraversable* self;
1848 result = GEE_TRAVERSABLE_GET_INTERFACE (self)->get_g_type (self);
1853 static void gee_traversable_base_init (GeeTraversableIface * iface) {
1854 static gboolean initialized = FALSE;
1857 iface->stream = gee_traversable_real_stream;
1858 iface->fold = gee_traversable_real_fold;
1859 iface->map = gee_traversable_real_map;
1860 iface->scan = gee_traversable_real_scan;
1861 iface->filter = gee_traversable_real_filter;
1862 iface->chop = gee_traversable_real_chop;
1863 iface->get_element_type = gee_traversable_real_get_element_type;
1869 * It's a common interface for {@link Iterator} and {@link Iterable}. It
1870 * provides a fast, high level functions.
1872 * ''{@link Iterator} implementation:'' Please note that most of the functions
1873 * affect the state of the iterator by moving it forward.
1874 * Even if the iterator is {@link BidirIterator} it ''must not''
1877 * ''{@link Iterable} implementation:'' validy ({@link Iterator.valid})
1878 * of returned iterator is the same as for invalid
1879 * iterator. In other words the following code is semantically equivalent:
1882 * var x = iterable.function (args);
1883 * var x = iterable.iterator ().function(args);
1888 GType gee_traversable_get_type (void) {
1889 static volatile gsize gee_traversable_type_id__volatile = 0;
1890 if (g_once_init_enter (&gee_traversable_type_id__volatile)) {
1891 static const GTypeInfo g_define_type_info = { sizeof (GeeTraversableIface), (GBaseInitFunc) gee_traversable_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
1892 GType gee_traversable_type_id;
1893 gee_traversable_type_id = g_type_register_static (G_TYPE_INTERFACE, "GeeTraversable", &g_define_type_info, 0);
1894 g_type_interface_add_prerequisite (gee_traversable_type_id, G_TYPE_OBJECT);
1895 g_once_init_leave (&gee_traversable_type_id__volatile, gee_traversable_type_id);
1897 return gee_traversable_type_id__volatile;