1 /* listiterator.c generated by valac 0.18.0, the Vala compiler
2 * generated from listiterator.vala, do not modify */
6 * Copyright (C) 2009 Didier Villevalois
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 * Didier 'Ptitjes Villevalois <ptitjes@free.fr>
27 #include <glib-object.h>
30 #define GEE_TYPE_TRAVERSABLE (gee_traversable_get_type ())
31 #define GEE_TRAVERSABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_TRAVERSABLE, GeeTraversable))
32 #define GEE_IS_TRAVERSABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_TRAVERSABLE))
33 #define GEE_TRAVERSABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_TRAVERSABLE, GeeTraversableIface))
35 typedef struct _GeeTraversable GeeTraversable;
36 typedef struct _GeeTraversableIface GeeTraversableIface;
38 #define GEE_TRAVERSABLE_TYPE_STREAM (gee_traversable_stream_get_type ())
40 #define GEE_TYPE_LAZY (gee_lazy_get_type ())
41 #define GEE_LAZY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_LAZY, GeeLazy))
42 #define GEE_LAZY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_LAZY, GeeLazyClass))
43 #define GEE_IS_LAZY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_LAZY))
44 #define GEE_IS_LAZY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_LAZY))
45 #define GEE_LAZY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_LAZY, GeeLazyClass))
47 typedef struct _GeeLazy GeeLazy;
48 typedef struct _GeeLazyClass GeeLazyClass;
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;
58 #define GEE_TYPE_LIST_ITERATOR (gee_list_iterator_get_type ())
59 #define GEE_LIST_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_LIST_ITERATOR, GeeListIterator))
60 #define GEE_IS_LIST_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_LIST_ITERATOR))
61 #define GEE_LIST_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_LIST_ITERATOR, GeeListIteratorIface))
63 typedef struct _GeeListIterator GeeListIterator;
64 typedef struct _GeeListIteratorIface GeeListIteratorIface;
66 typedef gboolean (*GeeForallFunc) (gpointer g, void* user_data);
68 GEE_TRAVERSABLE_STREAM_YIELD,
69 GEE_TRAVERSABLE_STREAM_CONTINUE,
70 GEE_TRAVERSABLE_STREAM_END
71 } GeeTraversableStream;
73 typedef GeeTraversableStream (*GeeStreamFunc) (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, void* user_data);
74 typedef gpointer (*GeeFoldFunc) (gpointer g, gpointer a, void* user_data);
75 typedef gpointer (*GeeMapFunc) (gpointer g, void* user_data);
76 typedef gboolean (*GeePredicate) (gconstpointer g, void* user_data);
77 struct _GeeTraversableIface {
78 GTypeInterface parent_iface;
79 GType (*get_g_type) (GeeTraversable* self);
80 GBoxedCopyFunc (*get_g_dup_func) (GeeTraversable* self);
81 GDestroyNotify (*get_g_destroy_func) (GeeTraversable* self);
82 gboolean (*foreach) (GeeTraversable* self, GeeForallFunc f, void* f_target);
83 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);
84 gpointer (*fold) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
85 GeeIterator* (*map) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeMapFunc f, void* f_target);
86 GeeIterator* (*scan) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
87 GeeIterator* (*filter) (GeeTraversable* self, GeePredicate pred, void* pred_target, GDestroyNotify pred_target_destroy_notify);
88 GeeIterator* (*chop) (GeeTraversable* self, gint offset, gint length);
89 GType (*get_element_type) (GeeTraversable* self);
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 _GeeListIteratorIface {
103 GTypeInterface parent_iface;
104 void (*set) (GeeListIterator* self, gconstpointer item);
105 void (*add) (GeeListIterator* self, gconstpointer item);
106 gint (*index) (GeeListIterator* self);
111 GType gee_traversable_stream_get_type (void) G_GNUC_CONST;
112 gpointer gee_lazy_ref (gpointer instance);
113 void gee_lazy_unref (gpointer instance);
114 GParamSpec* gee_param_spec_lazy (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
115 void gee_value_set_lazy (GValue* value, gpointer v_object);
116 void gee_value_take_lazy (GValue* value, gpointer v_object);
117 gpointer gee_value_get_lazy (const GValue* value);
118 GType gee_lazy_get_type (void) G_GNUC_CONST;
119 GType gee_traversable_get_type (void) G_GNUC_CONST;
120 GType gee_iterator_get_type (void) G_GNUC_CONST;
121 GType gee_list_iterator_get_type (void) G_GNUC_CONST;
122 void gee_list_iterator_set (GeeListIterator* self, gconstpointer item);
123 void gee_list_iterator_add (GeeListIterator* self, gconstpointer item);
124 gint gee_list_iterator_index (GeeListIterator* self);
128 * Sets the current item in the iteration to the specified new item.
130 void gee_list_iterator_set (GeeListIterator* self, gconstpointer item) {
131 g_return_if_fail (self != NULL);
132 GEE_LIST_ITERATOR_GET_INTERFACE (self)->set (self, item);
137 * Adds the specified item after the current item in the iteration. The
138 * cursor is moved to point to the new added item.
140 void gee_list_iterator_add (GeeListIterator* self, gconstpointer item) {
141 g_return_if_fail (self != NULL);
142 GEE_LIST_ITERATOR_GET_INTERFACE (self)->add (self, item);
147 * Returns the current index in the iteration.
149 * @return the current index
151 gint gee_list_iterator_index (GeeListIterator* self) {
152 g_return_val_if_fail (self != NULL, 0);
153 return GEE_LIST_ITERATOR_GET_INTERFACE (self)->index (self);
157 static void gee_list_iterator_base_init (GeeListIteratorIface * iface) {
158 static gboolean initialized = FALSE;
166 * A list iterator. This supports bi-directionnal and index-based iteration.
168 GType gee_list_iterator_get_type (void) {
169 static volatile gsize gee_list_iterator_type_id__volatile = 0;
170 if (g_once_init_enter (&gee_list_iterator_type_id__volatile)) {
171 static const GTypeInfo g_define_type_info = { sizeof (GeeListIteratorIface), (GBaseInitFunc) gee_list_iterator_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
172 GType gee_list_iterator_type_id;
173 gee_list_iterator_type_id = g_type_register_static (G_TYPE_INTERFACE, "GeeListIterator", &g_define_type_info, 0);
174 g_type_interface_add_prerequisite (gee_list_iterator_type_id, GEE_TYPE_ITERATOR);
175 g_once_init_leave (&gee_list_iterator_type_id__volatile, gee_list_iterator_type_id);
177 return gee_list_iterator_type_id__volatile;