1 /* hashmap.c generated by valac, the Vala compiler
2 * generated from hashmap.vala, do not modify */
3
4 /* hashmap.vala
5 *
6 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
7 * Copyright (C) 1997-2000 GLib Team and others
8 * Copyright (C) 2007-2009 Jürg Billeter
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 *
24 * Author:
25 * Jürg Billeter <j@bitron.ch>
26 */
27
28 #include "valagee.h"
29 #include <glib.h>
30 #include <glib-object.h>
31
32 typedef struct _ValaHashMapNode ValaHashMapNode;
33
34 #define VALA_HASH_MAP_TYPE_KEY_SET (vala_hash_map_key_set_get_type ())
35 #define VALA_HASH_MAP_KEY_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_HASH_MAP_TYPE_KEY_SET, ValaHashMapKeySet))
36 #define VALA_HASH_MAP_KEY_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_HASH_MAP_TYPE_KEY_SET, ValaHashMapKeySetClass))
37 #define VALA_HASH_MAP_IS_KEY_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_HASH_MAP_TYPE_KEY_SET))
38 #define VALA_HASH_MAP_IS_KEY_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_HASH_MAP_TYPE_KEY_SET))
39 #define VALA_HASH_MAP_KEY_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_HASH_MAP_TYPE_KEY_SET, ValaHashMapKeySetClass))
40
41 typedef struct _ValaHashMapKeySet ValaHashMapKeySet;
42 typedef struct _ValaHashMapKeySetClass ValaHashMapKeySetClass;
43
44 #define VALA_HASH_MAP_TYPE_VALUE_COLLECTION (vala_hash_map_value_collection_get_type ())
45 #define VALA_HASH_MAP_VALUE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_HASH_MAP_TYPE_VALUE_COLLECTION, ValaHashMapValueCollection))
46 #define VALA_HASH_MAP_VALUE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_HASH_MAP_TYPE_VALUE_COLLECTION, ValaHashMapValueCollectionClass))
47 #define VALA_HASH_MAP_IS_VALUE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_HASH_MAP_TYPE_VALUE_COLLECTION))
48 #define VALA_HASH_MAP_IS_VALUE_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_HASH_MAP_TYPE_VALUE_COLLECTION))
49 #define VALA_HASH_MAP_VALUE_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_HASH_MAP_TYPE_VALUE_COLLECTION, ValaHashMapValueCollectionClass))
50
51 typedef struct _ValaHashMapValueCollection ValaHashMapValueCollection;
52 typedef struct _ValaHashMapValueCollectionClass ValaHashMapValueCollectionClass;
53
54 #define VALA_HASH_MAP_TYPE_MAP_ITERATOR (vala_hash_map_map_iterator_get_type ())
55 #define VALA_HASH_MAP_MAP_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_HASH_MAP_TYPE_MAP_ITERATOR, ValaHashMapMapIterator))
56 #define VALA_HASH_MAP_MAP_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_HASH_MAP_TYPE_MAP_ITERATOR, ValaHashMapMapIteratorClass))
57 #define VALA_HASH_MAP_IS_MAP_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_HASH_MAP_TYPE_MAP_ITERATOR))
58 #define VALA_HASH_MAP_IS_MAP_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_HASH_MAP_TYPE_MAP_ITERATOR))
59 #define VALA_HASH_MAP_MAP_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_HASH_MAP_TYPE_MAP_ITERATOR, ValaHashMapMapIteratorClass))
60
61 typedef struct _ValaHashMapMapIterator ValaHashMapMapIterator;
62 typedef struct _ValaHashMapMapIteratorClass ValaHashMapMapIteratorClass;
63 #define _vala_hash_map_node_free0(var) ((var == NULL) ? NULL : (var = (vala_hash_map_node_free (var), NULL)))
64 typedef struct _ValaHashMapKeySetPrivate ValaHashMapKeySetPrivate;
65 #define _vala_map_unref0(var) ((var == NULL) ? NULL : (var = (vala_map_unref (var), NULL)))
66
67 #define VALA_HASH_MAP_TYPE_KEY_ITERATOR (vala_hash_map_key_iterator_get_type ())
68 #define VALA_HASH_MAP_KEY_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_HASH_MAP_TYPE_KEY_ITERATOR, ValaHashMapKeyIterator))
69 #define VALA_HASH_MAP_KEY_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_HASH_MAP_TYPE_KEY_ITERATOR, ValaHashMapKeyIteratorClass))
70 #define VALA_HASH_MAP_IS_KEY_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_HASH_MAP_TYPE_KEY_ITERATOR))
71 #define VALA_HASH_MAP_IS_KEY_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_HASH_MAP_TYPE_KEY_ITERATOR))
72 #define VALA_HASH_MAP_KEY_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_HASH_MAP_TYPE_KEY_ITERATOR, ValaHashMapKeyIteratorClass))
73
74 typedef struct _ValaHashMapKeyIterator ValaHashMapKeyIterator;
75 typedef struct _ValaHashMapKeyIteratorClass ValaHashMapKeyIteratorClass;
76 typedef struct _ValaHashMapMapIteratorPrivate ValaHashMapMapIteratorPrivate;
77 typedef struct _ValaHashMapKeyIteratorPrivate ValaHashMapKeyIteratorPrivate;
78 typedef struct _ValaHashMapValueCollectionPrivate ValaHashMapValueCollectionPrivate;
79
80 #define VALA_HASH_MAP_TYPE_VALUE_ITERATOR (vala_hash_map_value_iterator_get_type ())
81 #define VALA_HASH_MAP_VALUE_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_HASH_MAP_TYPE_VALUE_ITERATOR, ValaHashMapValueIterator))
82 #define VALA_HASH_MAP_VALUE_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_HASH_MAP_TYPE_VALUE_ITERATOR, ValaHashMapValueIteratorClass))
83 #define VALA_HASH_MAP_IS_VALUE_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_HASH_MAP_TYPE_VALUE_ITERATOR))
84 #define VALA_HASH_MAP_IS_VALUE_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_HASH_MAP_TYPE_VALUE_ITERATOR))
85 #define VALA_HASH_MAP_VALUE_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_HASH_MAP_TYPE_VALUE_ITERATOR, ValaHashMapValueIteratorClass))
86
87 typedef struct _ValaHashMapValueIterator ValaHashMapValueIterator;
88 typedef struct _ValaHashMapValueIteratorClass ValaHashMapValueIteratorClass;
89 #define _vala_iterator_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterator_unref (var), NULL)))
90 typedef struct _ValaHashMapValueIteratorPrivate ValaHashMapValueIteratorPrivate;
91 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
92 #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
93 #define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
94 #define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
95
96 struct _ValaHashMapPrivate {
97 GType k_type;
98 GBoxedCopyFunc k_dup_func;
99 GDestroyNotify k_destroy_func;
100 GType v_type;
101 GBoxedCopyFunc v_dup_func;
102 GDestroyNotify v_destroy_func;
103 gint _array_size;
104 gint _nnodes;
105 ValaHashMapNode** _nodes;
106 gint _nodes_length1;
107 gint __nodes_size_;
108 gint _stamp;
109 GHashFunc _key_hash_func;
110 GEqualFunc _key_equal_func;
111 GEqualFunc _value_equal_func;
112 };
113
114 struct _ValaHashMapNode {
115 gpointer key;
116 gpointer value;
117 ValaHashMapNode* next;
118 guint key_hash;
119 };
120
121 struct _ValaHashMapKeySet {
122 ValaSet parent_instance;
123 ValaHashMapKeySetPrivate * priv;
124 };
125
126 struct _ValaHashMapKeySetClass {
127 ValaSetClass parent_class;
128 };
129
130 struct _ValaHashMapKeySetPrivate {
131 GType k_type;
132 GBoxedCopyFunc k_dup_func;
133 GDestroyNotify k_destroy_func;
134 GType v_type;
135 GBoxedCopyFunc v_dup_func;
136 GDestroyNotify v_destroy_func;
137 ValaHashMap* _map;
138 };
139
140 struct _ValaHashMapMapIterator {
141 ValaMapIterator parent_instance;
142 ValaHashMapMapIteratorPrivate * priv;
143 };
144
145 struct _ValaHashMapMapIteratorClass {
146 ValaMapIteratorClass parent_class;
147 };
148
149 struct _ValaHashMapMapIteratorPrivate {
150 GType k_type;
151 GBoxedCopyFunc k_dup_func;
152 GDestroyNotify k_destroy_func;
153 GType v_type;
154 GBoxedCopyFunc v_dup_func;
155 GDestroyNotify v_destroy_func;
156 ValaHashMap* _map;
157 gint _index;
158 ValaHashMapNode* _node;
159 gint _stamp;
160 };
161
162 struct _ValaHashMapKeyIterator {
163 ValaIterator parent_instance;
164 ValaHashMapKeyIteratorPrivate * priv;
165 };
166
167 struct _ValaHashMapKeyIteratorClass {
168 ValaIteratorClass parent_class;
169 };
170
171 struct _ValaHashMapKeyIteratorPrivate {
172 GType k_type;
173 GBoxedCopyFunc k_dup_func;
174 GDestroyNotify k_destroy_func;
175 GType v_type;
176 GBoxedCopyFunc v_dup_func;
177 GDestroyNotify v_destroy_func;
178 ValaHashMap* _map;
179 gint _index;
180 ValaHashMapNode* _node;
181 ValaHashMapNode* _next;
182 gint _stamp;
183 };
184
185 struct _ValaHashMapValueCollection {
186 ValaCollection parent_instance;
187 ValaHashMapValueCollectionPrivate * priv;
188 };
189
190 struct _ValaHashMapValueCollectionClass {
191 ValaCollectionClass parent_class;
192 };
193
194 struct _ValaHashMapValueCollectionPrivate {
195 GType k_type;
196 GBoxedCopyFunc k_dup_func;
197 GDestroyNotify k_destroy_func;
198 GType v_type;
199 GBoxedCopyFunc v_dup_func;
200 GDestroyNotify v_destroy_func;
201 ValaHashMap* _map;
202 };
203
204 struct _ValaHashMapValueIterator {
205 ValaIterator parent_instance;
206 ValaHashMapValueIteratorPrivate * priv;
207 };
208
209 struct _ValaHashMapValueIteratorClass {
210 ValaIteratorClass parent_class;
211 };
212
213 struct _ValaHashMapValueIteratorPrivate {
214 GType k_type;
215 GBoxedCopyFunc k_dup_func;
216 GDestroyNotify k_destroy_func;
217 GType v_type;
218 GBoxedCopyFunc v_dup_func;
219 GDestroyNotify v_destroy_func;
220 ValaHashMap* _map;
221 gint _index;
222 ValaHashMapNode* _node;
223 ValaHashMapNode* _next;
224 gint _stamp;
225 };
226
227 static gint ValaHashMap_private_offset;
228 static gpointer vala_hash_map_parent_class = NULL;
229 static gint ValaHashMapKeySet_private_offset;
230 static gpointer vala_hash_map_key_set_parent_class = NULL;
231 static gint ValaHashMapMapIterator_private_offset;
232 static gpointer vala_hash_map_map_iterator_parent_class = NULL;
233 static gint ValaHashMapKeyIterator_private_offset;
234 static gpointer vala_hash_map_key_iterator_parent_class = NULL;
235 static gint ValaHashMapValueCollection_private_offset;
236 static gpointer vala_hash_map_value_collection_parent_class = NULL;
237 static gint ValaHashMapValueIterator_private_offset;
238 static gpointer vala_hash_map_value_iterator_parent_class = NULL;
239
240 static void vala_hash_map_node_free (ValaHashMapNode * self);
241 #define VALA_HASH_MAP_MIN_SIZE 11
242 #define VALA_HASH_MAP_MAX_SIZE 13845163
243 static ValaSet* vala_hash_map_real_get_keys (ValaMap* base);
244 static ValaHashMapKeySet* vala_hash_map_key_set_new (GType k_type,
245 GBoxedCopyFunc k_dup_func,
246 GDestroyNotify k_destroy_func,
247 GType v_type,
248 GBoxedCopyFunc v_dup_func,
249 GDestroyNotify v_destroy_func,
250 ValaHashMap* map);
251 static ValaHashMapKeySet* vala_hash_map_key_set_construct (GType object_type,
252 GType k_type,
253 GBoxedCopyFunc k_dup_func,
254 GDestroyNotify k_destroy_func,
255 GType v_type,
256 GBoxedCopyFunc v_dup_func,
257 GDestroyNotify v_destroy_func,
258 ValaHashMap* map);
259 static GType vala_hash_map_key_set_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
260 static ValaCollection* vala_hash_map_real_get_values (ValaMap* base);
261 static ValaHashMapValueCollection* vala_hash_map_value_collection_new (GType k_type,
262 GBoxedCopyFunc k_dup_func,
263 GDestroyNotify k_destroy_func,
264 GType v_type,
265 GBoxedCopyFunc v_dup_func,
266 GDestroyNotify v_destroy_func,
267 ValaHashMap* map);
268 static ValaHashMapValueCollection* vala_hash_map_value_collection_construct (GType object_type,
269 GType k_type,
270 GBoxedCopyFunc k_dup_func,
271 GDestroyNotify k_destroy_func,
272 GType v_type,
273 GBoxedCopyFunc v_dup_func,
274 GDestroyNotify v_destroy_func,
275 ValaHashMap* map);
276 static GType vala_hash_map_value_collection_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
277 static ValaMapIterator* vala_hash_map_real_map_iterator (ValaMap* base);
278 static ValaHashMapMapIterator* vala_hash_map_map_iterator_new (GType k_type,
279 GBoxedCopyFunc k_dup_func,
280 GDestroyNotify k_destroy_func,
281 GType v_type,
282 GBoxedCopyFunc v_dup_func,
283 GDestroyNotify v_destroy_func,
284 ValaHashMap* map);
285 static ValaHashMapMapIterator* vala_hash_map_map_iterator_construct (GType object_type,
286 GType k_type,
287 GBoxedCopyFunc k_dup_func,
288 GDestroyNotify k_destroy_func,
289 GType v_type,
290 GBoxedCopyFunc v_dup_func,
291 GDestroyNotify v_destroy_func,
292 ValaHashMap* map);
293 static GType vala_hash_map_map_iterator_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
294 static ValaHashMapNode** vala_hash_map_lookup_node (ValaHashMap* self,
295 gconstpointer key);
296 static gboolean vala_hash_map_real_contains (ValaMap* base,
297 gconstpointer key);
298 static gpointer vala_hash_map_real_get (ValaMap* base,
299 gconstpointer key);
300 static void vala_hash_map_real_set (ValaMap* base,
301 gconstpointer key,
302 gconstpointer value);
303 static ValaHashMapNode* vala_hash_map_node_new (gpointer k,
304 gpointer v,
305 guint hash);
306 static void vala_hash_map_resize (ValaHashMap* self);
307 static gboolean vala_hash_map_real_remove (ValaMap* base,
308 gconstpointer key);
309 static void vala_hash_map_real_clear (ValaMap* base);
310 static void vala_hash_map_node_instance_init (ValaHashMapNode * self);
311 static void vala_hash_map_key_set_set_map (ValaHashMapKeySet* self,
312 ValaHashMap* value);
313 static GType vala_hash_map_key_set_real_get_element_type (ValaIterable* base);
314 static ValaIterator* vala_hash_map_key_set_real_iterator (ValaIterable* base);
315 static ValaHashMapKeyIterator* vala_hash_map_key_iterator_new (GType k_type,
316 GBoxedCopyFunc k_dup_func,
317 GDestroyNotify k_destroy_func,
318 GType v_type,
319 GBoxedCopyFunc v_dup_func,
320 GDestroyNotify v_destroy_func,
321 ValaHashMap* map);
322 static ValaHashMapKeyIterator* vala_hash_map_key_iterator_construct (GType object_type,
323 GType k_type,
324 GBoxedCopyFunc k_dup_func,
325 GDestroyNotify k_destroy_func,
326 GType v_type,
327 GBoxedCopyFunc v_dup_func,
328 GDestroyNotify v_destroy_func,
329 ValaHashMap* map);
330 static GType vala_hash_map_key_iterator_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
331 static gboolean vala_hash_map_key_set_real_add (ValaCollection* base,
332 gconstpointer key);
333 static void vala_hash_map_key_set_real_clear (ValaCollection* base);
334 static gboolean vala_hash_map_key_set_real_remove (ValaCollection* base,
335 gconstpointer key);
336 static gboolean vala_hash_map_key_set_real_contains (ValaCollection* base,
337 gconstpointer key);
338 static void vala_hash_map_key_set_finalize (ValaIterable * obj);
339 static GType vala_hash_map_key_set_get_type_once (void);
340 static void vala_hash_map_map_iterator_set_map (ValaHashMapMapIterator* self,
341 ValaHashMap* value);
342 static gboolean vala_hash_map_map_iterator_real_next (ValaMapIterator* base);
343 static gpointer vala_hash_map_map_iterator_real_get_key (ValaMapIterator* base);
344 static gpointer vala_hash_map_map_iterator_real_get_value (ValaMapIterator* base);
345 static void vala_hash_map_map_iterator_finalize (ValaMapIterator * obj);
346 static GType vala_hash_map_map_iterator_get_type_once (void);
347 static void vala_hash_map_key_iterator_set_map (ValaHashMapKeyIterator* self,
348 ValaHashMap* value);
349 static gboolean vala_hash_map_key_iterator_real_next (ValaIterator* base);
350 static gboolean vala_hash_map_key_iterator_real_has_next (ValaIterator* base);
351 static gpointer vala_hash_map_key_iterator_real_get (ValaIterator* base);
352 static void vala_hash_map_key_iterator_real_remove (ValaIterator* base);
353 static void vala_hash_map_key_iterator_finalize (ValaIterator * obj);
354 static GType vala_hash_map_key_iterator_get_type_once (void);
355 static void vala_hash_map_value_collection_set_map (ValaHashMapValueCollection* self,
356 ValaHashMap* value);
357 static GType vala_hash_map_value_collection_real_get_element_type (ValaIterable* base);
358 static ValaIterator* vala_hash_map_value_collection_real_iterator (ValaIterable* base);
359 static ValaHashMapValueIterator* vala_hash_map_value_iterator_new (GType k_type,
360 GBoxedCopyFunc k_dup_func,
361 GDestroyNotify k_destroy_func,
362 GType v_type,
363 GBoxedCopyFunc v_dup_func,
364 GDestroyNotify v_destroy_func,
365 ValaHashMap* map);
366 static ValaHashMapValueIterator* vala_hash_map_value_iterator_construct (GType object_type,
367 GType k_type,
368 GBoxedCopyFunc k_dup_func,
369 GDestroyNotify k_destroy_func,
370 GType v_type,
371 GBoxedCopyFunc v_dup_func,
372 GDestroyNotify v_destroy_func,
373 ValaHashMap* map);
374 static GType vala_hash_map_value_iterator_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
375 static gboolean vala_hash_map_value_collection_real_add (ValaCollection* base,
376 gconstpointer value);
377 static void vala_hash_map_value_collection_real_clear (ValaCollection* base);
378 static gboolean vala_hash_map_value_collection_real_remove (ValaCollection* base,
379 gconstpointer value);
380 static gboolean vala_hash_map_value_collection_real_contains (ValaCollection* base,
381 gconstpointer value);
382 static void vala_hash_map_value_collection_finalize (ValaIterable * obj);
383 static GType vala_hash_map_value_collection_get_type_once (void);
384 static void vala_hash_map_value_iterator_set_map (ValaHashMapValueIterator* self,
385 ValaHashMap* value);
386 static gboolean vala_hash_map_value_iterator_real_next (ValaIterator* base);
387 static gboolean vala_hash_map_value_iterator_real_has_next (ValaIterator* base);
388 static gpointer vala_hash_map_value_iterator_real_get (ValaIterator* base);
389 static void vala_hash_map_value_iterator_real_remove (ValaIterator* base);
390 static void vala_hash_map_value_iterator_finalize (ValaIterator * obj);
391 static GType vala_hash_map_value_iterator_get_type_once (void);
392 static void vala_hash_map_finalize (ValaMap * obj);
393 static GType vala_hash_map_get_type_once (void);
394 static void _vala_array_destroy (gpointer array,
395 gint array_length,
396 GDestroyNotify destroy_func);
397 static void _vala_array_free (gpointer array,
398 gint array_length,
399 GDestroyNotify destroy_func);
400
401 static inline gpointer
vala_hash_map_get_instance_private(ValaHashMap * self)402 vala_hash_map_get_instance_private (ValaHashMap* self)
403 {
404 return G_STRUCT_MEMBER_P (self, ValaHashMap_private_offset);
405 }
406
407 static gint
vala_hash_map_real_get_size(ValaMap * base)408 vala_hash_map_real_get_size (ValaMap* base)
409 {
410 gint result;
411 ValaHashMap* self;
412 self = (ValaHashMap*) base;
413 result = self->priv->_nnodes;
414 return result;
415 }
416
417 void
vala_hash_map_set_key_hash_func(ValaHashMap * self,GHashFunc value)418 vala_hash_map_set_key_hash_func (ValaHashMap* self,
419 GHashFunc value)
420 {
421 g_return_if_fail (self != NULL);
422 self->priv->_key_hash_func = value;
423 }
424
425 void
vala_hash_map_set_key_equal_func(ValaHashMap * self,GEqualFunc value)426 vala_hash_map_set_key_equal_func (ValaHashMap* self,
427 GEqualFunc value)
428 {
429 g_return_if_fail (self != NULL);
430 self->priv->_key_equal_func = value;
431 }
432
433 void
vala_hash_map_set_value_equal_func(ValaHashMap * self,GEqualFunc value)434 vala_hash_map_set_value_equal_func (ValaHashMap* self,
435 GEqualFunc value)
436 {
437 g_return_if_fail (self != NULL);
438 self->priv->_value_equal_func = value;
439 }
440
441 ValaHashMap*
vala_hash_map_construct(GType object_type,GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,GHashFunc key_hash_func,GEqualFunc key_equal_func,GEqualFunc value_equal_func)442 vala_hash_map_construct (GType object_type,
443 GType k_type,
444 GBoxedCopyFunc k_dup_func,
445 GDestroyNotify k_destroy_func,
446 GType v_type,
447 GBoxedCopyFunc v_dup_func,
448 GDestroyNotify v_destroy_func,
449 GHashFunc key_hash_func,
450 GEqualFunc key_equal_func,
451 GEqualFunc value_equal_func)
452 {
453 ValaHashMap* self = NULL;
454 ValaHashMapNode** _tmp0_;
455 self = (ValaHashMap*) vala_map_construct (object_type, k_type, (GBoxedCopyFunc) k_dup_func, (GDestroyNotify) k_destroy_func, v_type, (GBoxedCopyFunc) v_dup_func, (GDestroyNotify) v_destroy_func);
456 self->priv->k_type = k_type;
457 self->priv->k_dup_func = k_dup_func;
458 self->priv->k_destroy_func = k_destroy_func;
459 self->priv->v_type = v_type;
460 self->priv->v_dup_func = v_dup_func;
461 self->priv->v_destroy_func = v_destroy_func;
462 vala_hash_map_set_key_hash_func (self, key_hash_func);
463 vala_hash_map_set_key_equal_func (self, key_equal_func);
464 vala_hash_map_set_value_equal_func (self, value_equal_func);
465 self->priv->_array_size = VALA_HASH_MAP_MIN_SIZE;
466 _tmp0_ = g_new0 (ValaHashMapNode*, self->priv->_array_size + 1);
467 self->priv->_nodes = (_vala_array_free (self->priv->_nodes, self->priv->_nodes_length1, (GDestroyNotify) vala_hash_map_node_free), NULL);
468 self->priv->_nodes = _tmp0_;
469 self->priv->_nodes_length1 = self->priv->_array_size;
470 self->priv->__nodes_size_ = self->priv->_nodes_length1;
471 return self;
472 }
473
474 ValaHashMap*
vala_hash_map_new(GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,GHashFunc key_hash_func,GEqualFunc key_equal_func,GEqualFunc value_equal_func)475 vala_hash_map_new (GType k_type,
476 GBoxedCopyFunc k_dup_func,
477 GDestroyNotify k_destroy_func,
478 GType v_type,
479 GBoxedCopyFunc v_dup_func,
480 GDestroyNotify v_destroy_func,
481 GHashFunc key_hash_func,
482 GEqualFunc key_equal_func,
483 GEqualFunc value_equal_func)
484 {
485 return vala_hash_map_construct (VALA_TYPE_HASH_MAP, k_type, k_dup_func, k_destroy_func, v_type, v_dup_func, v_destroy_func, key_hash_func, key_equal_func, value_equal_func);
486 }
487
488 static ValaSet*
vala_hash_map_real_get_keys(ValaMap * base)489 vala_hash_map_real_get_keys (ValaMap* base)
490 {
491 ValaHashMap * self;
492 ValaHashMapKeySet* _tmp0_;
493 ValaSet* result = NULL;
494 self = (ValaHashMap*) base;
495 _tmp0_ = vala_hash_map_key_set_new (self->priv->k_type, (GBoxedCopyFunc) self->priv->k_dup_func, (GDestroyNotify) self->priv->k_destroy_func, self->priv->v_type, (GBoxedCopyFunc) self->priv->v_dup_func, (GDestroyNotify) self->priv->v_destroy_func, self);
496 result = (ValaSet*) _tmp0_;
497 return result;
498 }
499
500 static ValaCollection*
vala_hash_map_real_get_values(ValaMap * base)501 vala_hash_map_real_get_values (ValaMap* base)
502 {
503 ValaHashMap * self;
504 ValaHashMapValueCollection* _tmp0_;
505 ValaCollection* result = NULL;
506 self = (ValaHashMap*) base;
507 _tmp0_ = vala_hash_map_value_collection_new (self->priv->k_type, (GBoxedCopyFunc) self->priv->k_dup_func, (GDestroyNotify) self->priv->k_destroy_func, self->priv->v_type, (GBoxedCopyFunc) self->priv->v_dup_func, (GDestroyNotify) self->priv->v_destroy_func, self);
508 result = (ValaCollection*) _tmp0_;
509 return result;
510 }
511
512 static ValaMapIterator*
vala_hash_map_real_map_iterator(ValaMap * base)513 vala_hash_map_real_map_iterator (ValaMap* base)
514 {
515 ValaHashMap * self;
516 ValaHashMapMapIterator* _tmp0_;
517 ValaMapIterator* result = NULL;
518 self = (ValaHashMap*) base;
519 _tmp0_ = vala_hash_map_map_iterator_new (self->priv->k_type, (GBoxedCopyFunc) self->priv->k_dup_func, (GDestroyNotify) self->priv->k_destroy_func, self->priv->v_type, (GBoxedCopyFunc) self->priv->v_dup_func, (GDestroyNotify) self->priv->v_destroy_func, self);
520 result = (ValaMapIterator*) _tmp0_;
521 return result;
522 }
523
524 static ValaHashMapNode**
vala_hash_map_lookup_node(ValaHashMap * self,gconstpointer key)525 vala_hash_map_lookup_node (ValaHashMap* self,
526 gconstpointer key)
527 {
528 guint hash_value = 0U;
529 GHashFunc _tmp0_;
530 ValaHashMapNode** node = NULL;
531 ValaHashMapNode** _tmp1_;
532 gint _tmp1__length1;
533 ValaHashMapNode** _tmp10_;
534 ValaHashMapNode** result = NULL;
535 g_return_val_if_fail (self != NULL, NULL);
536 _tmp0_ = self->priv->_key_hash_func;
537 hash_value = _tmp0_ (key);
538 _tmp1_ = self->priv->_nodes;
539 _tmp1__length1 = self->priv->_nodes_length1;
540 node = &_tmp1_[hash_value % self->priv->_array_size];
541 while (TRUE) {
542 gboolean _tmp2_ = FALSE;
543 ValaHashMapNode** _tmp3_;
544 ValaHashMapNode** _tmp9_;
545 _tmp3_ = node;
546 if ((*_tmp3_) != NULL) {
547 gboolean _tmp4_ = FALSE;
548 ValaHashMapNode** _tmp5_;
549 _tmp5_ = node;
550 if (hash_value != (*_tmp5_)->key_hash) {
551 _tmp4_ = TRUE;
552 } else {
553 GEqualFunc _tmp6_;
554 ValaHashMapNode** _tmp7_;
555 gconstpointer _tmp8_;
556 _tmp6_ = self->priv->_key_equal_func;
557 _tmp7_ = node;
558 _tmp8_ = (*_tmp7_)->key;
559 _tmp4_ = !_tmp6_ (_tmp8_, key);
560 }
561 _tmp2_ = _tmp4_;
562 } else {
563 _tmp2_ = FALSE;
564 }
565 if (!_tmp2_) {
566 break;
567 }
568 _tmp9_ = node;
569 node = &(*_tmp9_)->next;
570 }
571 _tmp10_ = node;
572 result = _tmp10_;
573 return result;
574 }
575
576 static gboolean
vala_hash_map_real_contains(ValaMap * base,gconstpointer key)577 vala_hash_map_real_contains (ValaMap* base,
578 gconstpointer key)
579 {
580 ValaHashMap * self;
581 ValaHashMapNode** node = NULL;
582 ValaHashMapNode** _tmp0_;
583 gboolean result = FALSE;
584 self = (ValaHashMap*) base;
585 _tmp0_ = vala_hash_map_lookup_node (self, key);
586 node = _tmp0_;
587 result = (*node) != NULL;
588 return result;
589 }
590
591 static gpointer
vala_hash_map_real_get(ValaMap * base,gconstpointer key)592 vala_hash_map_real_get (ValaMap* base,
593 gconstpointer key)
594 {
595 ValaHashMap * self;
596 ValaHashMapNode* node = NULL;
597 ValaHashMapNode** _tmp0_;
598 ValaHashMapNode* _tmp1_;
599 gpointer result = NULL;
600 self = (ValaHashMap*) base;
601 _tmp0_ = vala_hash_map_lookup_node (self, key);
602 node = *_tmp0_;
603 _tmp1_ = node;
604 if (_tmp1_ != NULL) {
605 ValaHashMapNode* _tmp2_;
606 gconstpointer _tmp3_;
607 gpointer _tmp4_;
608 _tmp2_ = node;
609 _tmp3_ = _tmp2_->value;
610 _tmp4_ = ((_tmp3_ != NULL) && (self->priv->v_dup_func != NULL)) ? self->priv->v_dup_func ((gpointer) _tmp3_) : ((gpointer) _tmp3_);
611 result = _tmp4_;
612 return result;
613 } else {
614 result = NULL;
615 return result;
616 }
617 }
618
619 static void
vala_hash_map_real_set(ValaMap * base,gconstpointer key,gconstpointer value)620 vala_hash_map_real_set (ValaMap* base,
621 gconstpointer key,
622 gconstpointer value)
623 {
624 ValaHashMap * self;
625 ValaHashMapNode** node = NULL;
626 ValaHashMapNode** _tmp0_;
627 ValaHashMapNode** _tmp1_;
628 gint _tmp10_;
629 self = (ValaHashMap*) base;
630 _tmp0_ = vala_hash_map_lookup_node (self, key);
631 node = _tmp0_;
632 _tmp1_ = node;
633 if ((*_tmp1_) != NULL) {
634 ValaHashMapNode** _tmp2_;
635 gpointer _tmp3_;
636 _tmp2_ = node;
637 _tmp3_ = ((value != NULL) && (self->priv->v_dup_func != NULL)) ? self->priv->v_dup_func ((gpointer) value) : ((gpointer) value);
638 (((*_tmp2_)->value == NULL) || (self->priv->v_destroy_func == NULL)) ? NULL : ((*_tmp2_)->value = (self->priv->v_destroy_func ((*_tmp2_)->value), NULL));
639 (*_tmp2_)->value = _tmp3_;
640 } else {
641 guint hash_value = 0U;
642 GHashFunc _tmp4_;
643 ValaHashMapNode** _tmp5_;
644 gpointer _tmp6_;
645 gpointer _tmp7_;
646 ValaHashMapNode* _tmp8_;
647 gint _tmp9_;
648 _tmp4_ = self->priv->_key_hash_func;
649 hash_value = _tmp4_ (key);
650 _tmp5_ = node;
651 _tmp6_ = ((key != NULL) && (self->priv->k_dup_func != NULL)) ? self->priv->k_dup_func ((gpointer) key) : ((gpointer) key);
652 _tmp7_ = ((value != NULL) && (self->priv->v_dup_func != NULL)) ? self->priv->v_dup_func ((gpointer) value) : ((gpointer) value);
653 _tmp8_ = vala_hash_map_node_new (_tmp6_, _tmp7_, hash_value);
654 *_tmp5_ = _tmp8_;
655 _tmp9_ = self->priv->_nnodes;
656 self->priv->_nnodes = _tmp9_ + 1;
657 vala_hash_map_resize (self);
658 }
659 _tmp10_ = self->priv->_stamp;
660 self->priv->_stamp = _tmp10_ + 1;
661 }
662
663 static gboolean
vala_hash_map_real_remove(ValaMap * base,gconstpointer key)664 vala_hash_map_real_remove (ValaMap* base,
665 gconstpointer key)
666 {
667 ValaHashMap * self;
668 ValaHashMapNode** node = NULL;
669 ValaHashMapNode** _tmp0_;
670 ValaHashMapNode** _tmp1_;
671 gboolean result = FALSE;
672 self = (ValaHashMap*) base;
673 _tmp0_ = vala_hash_map_lookup_node (self, key);
674 node = _tmp0_;
675 _tmp1_ = node;
676 if ((*_tmp1_) != NULL) {
677 ValaHashMapNode* next = NULL;
678 ValaHashMapNode** _tmp2_;
679 ValaHashMapNode* _tmp3_;
680 ValaHashMapNode** _tmp4_;
681 ValaHashMapNode** _tmp5_;
682 ValaHashMapNode** _tmp6_;
683 ValaHashMapNode** _tmp7_;
684 ValaHashMapNode* _tmp8_;
685 gint _tmp9_;
686 gint _tmp10_;
687 _tmp2_ = node;
688 _tmp3_ = (*_tmp2_)->next;
689 (*_tmp2_)->next = NULL;
690 next = _tmp3_;
691 _tmp4_ = node;
692 (((*_tmp4_)->key == NULL) || (self->priv->k_destroy_func == NULL)) ? NULL : ((*_tmp4_)->key = (self->priv->k_destroy_func ((*_tmp4_)->key), NULL));
693 (*_tmp4_)->key = NULL;
694 _tmp5_ = node;
695 (((*_tmp5_)->value == NULL) || (self->priv->v_destroy_func == NULL)) ? NULL : ((*_tmp5_)->value = (self->priv->v_destroy_func ((*_tmp5_)->value), NULL));
696 (*_tmp5_)->value = NULL;
697 _tmp6_ = node;
698 vala_hash_map_node_free (*_tmp6_);
699 _tmp7_ = node;
700 _tmp8_ = next;
701 next = NULL;
702 *_tmp7_ = _tmp8_;
703 _tmp9_ = self->priv->_nnodes;
704 self->priv->_nnodes = _tmp9_ - 1;
705 vala_hash_map_resize (self);
706 _tmp10_ = self->priv->_stamp;
707 self->priv->_stamp = _tmp10_ + 1;
708 result = TRUE;
709 _vala_hash_map_node_free0 (next);
710 return result;
711 }
712 result = FALSE;
713 return result;
714 }
715
716 static void
vala_hash_map_real_clear(ValaMap * base)717 vala_hash_map_real_clear (ValaMap* base)
718 {
719 ValaHashMap * self;
720 self = (ValaHashMap*) base;
721 {
722 gint i = 0;
723 i = 0;
724 {
725 gboolean _tmp0_ = FALSE;
726 _tmp0_ = TRUE;
727 while (TRUE) {
728 ValaHashMapNode* node = NULL;
729 ValaHashMapNode** _tmp2_;
730 gint _tmp2__length1;
731 ValaHashMapNode* _tmp3_;
732 if (!_tmp0_) {
733 gint _tmp1_;
734 _tmp1_ = i;
735 i = _tmp1_ + 1;
736 }
737 _tmp0_ = FALSE;
738 if (!(i < self->priv->_array_size)) {
739 break;
740 }
741 _tmp2_ = self->priv->_nodes;
742 _tmp2__length1 = self->priv->_nodes_length1;
743 _tmp3_ = _tmp2_[i];
744 _tmp2_[i] = NULL;
745 node = _tmp3_;
746 while (TRUE) {
747 ValaHashMapNode* _tmp4_;
748 ValaHashMapNode* next = NULL;
749 ValaHashMapNode* _tmp5_;
750 ValaHashMapNode* _tmp6_;
751 ValaHashMapNode* _tmp7_;
752 ValaHashMapNode* _tmp8_;
753 ValaHashMapNode* _tmp9_;
754 _tmp4_ = node;
755 if (!(_tmp4_ != NULL)) {
756 break;
757 }
758 _tmp5_ = node;
759 _tmp6_ = _tmp5_->next;
760 _tmp5_->next = NULL;
761 next = _tmp6_;
762 _tmp7_ = node;
763 ((_tmp7_->key == NULL) || (self->priv->k_destroy_func == NULL)) ? NULL : (_tmp7_->key = (self->priv->k_destroy_func (_tmp7_->key), NULL));
764 _tmp7_->key = NULL;
765 _tmp8_ = node;
766 ((_tmp8_->value == NULL) || (self->priv->v_destroy_func == NULL)) ? NULL : (_tmp8_->value = (self->priv->v_destroy_func (_tmp8_->value), NULL));
767 _tmp8_->value = NULL;
768 _tmp9_ = next;
769 next = NULL;
770 _vala_hash_map_node_free0 (node);
771 node = _tmp9_;
772 _vala_hash_map_node_free0 (next);
773 }
774 _vala_hash_map_node_free0 (node);
775 }
776 }
777 }
778 self->priv->_nnodes = 0;
779 vala_hash_map_resize (self);
780 }
781
782 static void
vala_hash_map_resize(ValaHashMap * self)783 vala_hash_map_resize (ValaHashMap* self)
784 {
785 gboolean _tmp0_ = FALSE;
786 gboolean _tmp1_ = FALSE;
787 g_return_if_fail (self != NULL);
788 if (self->priv->_array_size >= (3 * self->priv->_nnodes)) {
789 _tmp1_ = self->priv->_array_size >= VALA_HASH_MAP_MIN_SIZE;
790 } else {
791 _tmp1_ = FALSE;
792 }
793 if (_tmp1_) {
794 _tmp0_ = TRUE;
795 } else {
796 gboolean _tmp2_ = FALSE;
797 if ((3 * self->priv->_array_size) <= self->priv->_nnodes) {
798 _tmp2_ = self->priv->_array_size < VALA_HASH_MAP_MAX_SIZE;
799 } else {
800 _tmp2_ = FALSE;
801 }
802 _tmp0_ = _tmp2_;
803 }
804 if (_tmp0_) {
805 gint new_array_size = 0;
806 ValaHashMapNode** new_nodes = NULL;
807 ValaHashMapNode** _tmp3_;
808 gint new_nodes_length1;
809 gint _new_nodes_size_;
810 ValaHashMapNode** _tmp19_;
811 gint _tmp19__length1;
812 new_array_size = (gint) g_spaced_primes_closest ((guint) self->priv->_nnodes);
813 new_array_size = CLAMP (new_array_size, VALA_HASH_MAP_MIN_SIZE, VALA_HASH_MAP_MAX_SIZE);
814 _tmp3_ = g_new0 (ValaHashMapNode*, new_array_size + 1);
815 new_nodes = _tmp3_;
816 new_nodes_length1 = new_array_size;
817 _new_nodes_size_ = new_nodes_length1;
818 {
819 gint i = 0;
820 i = 0;
821 {
822 gboolean _tmp4_ = FALSE;
823 _tmp4_ = TRUE;
824 while (TRUE) {
825 ValaHashMapNode* node = NULL;
826 ValaHashMapNode* next = NULL;
827 if (!_tmp4_) {
828 gint _tmp5_;
829 _tmp5_ = i;
830 i = _tmp5_ + 1;
831 }
832 _tmp4_ = FALSE;
833 if (!(i < self->priv->_array_size)) {
834 break;
835 }
836 next = NULL;
837 {
838 ValaHashMapNode** _tmp6_;
839 gint _tmp6__length1;
840 ValaHashMapNode* _tmp7_;
841 gboolean _tmp8_ = FALSE;
842 _tmp6_ = self->priv->_nodes;
843 _tmp6__length1 = self->priv->_nodes_length1;
844 _tmp7_ = _tmp6_[i];
845 _tmp6_[i] = NULL;
846 _vala_hash_map_node_free0 (node);
847 node = _tmp7_;
848 _tmp8_ = TRUE;
849 while (TRUE) {
850 ValaHashMapNode* _tmp10_;
851 ValaHashMapNode* _tmp11_;
852 ValaHashMapNode* _tmp12_;
853 guint hash_val = 0U;
854 ValaHashMapNode* _tmp13_;
855 ValaHashMapNode* _tmp14_;
856 ValaHashMapNode** _tmp15_;
857 gint _tmp15__length1;
858 ValaHashMapNode* _tmp16_;
859 ValaHashMapNode** _tmp17_;
860 gint _tmp17__length1;
861 ValaHashMapNode* _tmp18_;
862 if (!_tmp8_) {
863 ValaHashMapNode* _tmp9_;
864 _tmp9_ = next;
865 next = NULL;
866 _vala_hash_map_node_free0 (node);
867 node = _tmp9_;
868 }
869 _tmp8_ = FALSE;
870 _tmp10_ = node;
871 if (!(_tmp10_ != NULL)) {
872 break;
873 }
874 _tmp11_ = node;
875 _tmp12_ = _tmp11_->next;
876 _tmp11_->next = NULL;
877 _vala_hash_map_node_free0 (next);
878 next = _tmp12_;
879 _tmp13_ = node;
880 hash_val = _tmp13_->key_hash % new_array_size;
881 _tmp14_ = node;
882 _tmp15_ = new_nodes;
883 _tmp15__length1 = new_nodes_length1;
884 _tmp16_ = _tmp15_[hash_val];
885 _tmp15_[hash_val] = NULL;
886 _vala_hash_map_node_free0 (_tmp14_->next);
887 _tmp14_->next = _tmp16_;
888 _tmp17_ = new_nodes;
889 _tmp17__length1 = new_nodes_length1;
890 _tmp18_ = node;
891 node = NULL;
892 _vala_hash_map_node_free0 (_tmp17_[hash_val]);
893 _tmp17_[hash_val] = _tmp18_;
894 }
895 }
896 _vala_hash_map_node_free0 (next);
897 _vala_hash_map_node_free0 (node);
898 }
899 }
900 }
901 _tmp19_ = new_nodes;
902 _tmp19__length1 = new_nodes_length1;
903 new_nodes = NULL;
904 new_nodes_length1 = 0;
905 self->priv->_nodes = (_vala_array_free (self->priv->_nodes, self->priv->_nodes_length1, (GDestroyNotify) vala_hash_map_node_free), NULL);
906 self->priv->_nodes = _tmp19_;
907 self->priv->_nodes_length1 = _tmp19__length1;
908 self->priv->__nodes_size_ = self->priv->_nodes_length1;
909 self->priv->_array_size = new_array_size;
910 new_nodes = (_vala_array_free (new_nodes, new_nodes_length1, (GDestroyNotify) vala_hash_map_node_free), NULL);
911 }
912 }
913
914 static ValaHashMapNode*
vala_hash_map_node_new(gpointer k,gpointer v,guint hash)915 vala_hash_map_node_new (gpointer k,
916 gpointer v,
917 guint hash)
918 {
919 ValaHashMapNode* self;
920 gpointer _tmp0_;
921 gpointer _tmp1_;
922 self = g_slice_new0 (ValaHashMapNode);
923 vala_hash_map_node_instance_init (self);
924 _tmp0_ = k;
925 k = NULL;
926 self->key = _tmp0_;
927 _tmp1_ = v;
928 v = NULL;
929 self->value = _tmp1_;
930 self->key_hash = hash;
931 return self;
932 }
933
934 static void
vala_hash_map_node_instance_init(ValaHashMapNode * self)935 vala_hash_map_node_instance_init (ValaHashMapNode * self)
936 {
937 }
938
939 static void
vala_hash_map_node_free(ValaHashMapNode * self)940 vala_hash_map_node_free (ValaHashMapNode * self)
941 {
942 _vala_hash_map_node_free0 (self->next);
943 g_slice_free (ValaHashMapNode, self);
944 }
945
946 static inline gpointer
vala_hash_map_key_set_get_instance_private(ValaHashMapKeySet * self)947 vala_hash_map_key_set_get_instance_private (ValaHashMapKeySet* self)
948 {
949 return G_STRUCT_MEMBER_P (self, ValaHashMapKeySet_private_offset);
950 }
951
952 static gpointer
_vala_map_ref0(gpointer self)953 _vala_map_ref0 (gpointer self)
954 {
955 return self ? vala_map_ref (self) : NULL;
956 }
957
958 static void
vala_hash_map_key_set_set_map(ValaHashMapKeySet * self,ValaHashMap * value)959 vala_hash_map_key_set_set_map (ValaHashMapKeySet* self,
960 ValaHashMap* value)
961 {
962 ValaHashMap* _tmp0_;
963 g_return_if_fail (self != NULL);
964 _tmp0_ = _vala_map_ref0 (value);
965 _vala_map_unref0 (self->priv->_map);
966 self->priv->_map = _tmp0_;
967 }
968
969 static ValaHashMapKeySet*
vala_hash_map_key_set_construct(GType object_type,GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)970 vala_hash_map_key_set_construct (GType object_type,
971 GType k_type,
972 GBoxedCopyFunc k_dup_func,
973 GDestroyNotify k_destroy_func,
974 GType v_type,
975 GBoxedCopyFunc v_dup_func,
976 GDestroyNotify v_destroy_func,
977 ValaHashMap* map)
978 {
979 ValaHashMapKeySet* self = NULL;
980 g_return_val_if_fail (map != NULL, NULL);
981 self = (ValaHashMapKeySet*) vala_set_construct (object_type, k_type, (GBoxedCopyFunc) k_dup_func, (GDestroyNotify) k_destroy_func);
982 self->priv->k_type = k_type;
983 self->priv->k_dup_func = k_dup_func;
984 self->priv->k_destroy_func = k_destroy_func;
985 self->priv->v_type = v_type;
986 self->priv->v_dup_func = v_dup_func;
987 self->priv->v_destroy_func = v_destroy_func;
988 vala_hash_map_key_set_set_map (self, map);
989 return self;
990 }
991
992 static ValaHashMapKeySet*
vala_hash_map_key_set_new(GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)993 vala_hash_map_key_set_new (GType k_type,
994 GBoxedCopyFunc k_dup_func,
995 GDestroyNotify k_destroy_func,
996 GType v_type,
997 GBoxedCopyFunc v_dup_func,
998 GDestroyNotify v_destroy_func,
999 ValaHashMap* map)
1000 {
1001 return vala_hash_map_key_set_construct (VALA_HASH_MAP_TYPE_KEY_SET, k_type, k_dup_func, k_destroy_func, v_type, v_dup_func, v_destroy_func, map);
1002 }
1003
1004 static GType
vala_hash_map_key_set_real_get_element_type(ValaIterable * base)1005 vala_hash_map_key_set_real_get_element_type (ValaIterable* base)
1006 {
1007 ValaHashMapKeySet * self;
1008 GType result = 0UL;
1009 self = (ValaHashMapKeySet*) base;
1010 result = self->priv->k_type;
1011 return result;
1012 }
1013
1014 static ValaIterator*
vala_hash_map_key_set_real_iterator(ValaIterable * base)1015 vala_hash_map_key_set_real_iterator (ValaIterable* base)
1016 {
1017 ValaHashMapKeySet * self;
1018 ValaHashMap* _tmp0_;
1019 ValaHashMapKeyIterator* _tmp1_;
1020 ValaIterator* result = NULL;
1021 self = (ValaHashMapKeySet*) base;
1022 _tmp0_ = self->priv->_map;
1023 _tmp1_ = vala_hash_map_key_iterator_new (self->priv->k_type, (GBoxedCopyFunc) self->priv->k_dup_func, (GDestroyNotify) self->priv->k_destroy_func, self->priv->v_type, (GBoxedCopyFunc) self->priv->v_dup_func, (GDestroyNotify) self->priv->v_destroy_func, _tmp0_);
1024 result = (ValaIterator*) _tmp1_;
1025 return result;
1026 }
1027
1028 static gint
vala_hash_map_key_set_real_get_size(ValaCollection * base)1029 vala_hash_map_key_set_real_get_size (ValaCollection* base)
1030 {
1031 gint result;
1032 ValaHashMapKeySet* self;
1033 ValaHashMap* _tmp0_;
1034 gint _tmp1_;
1035 gint _tmp2_;
1036 self = (ValaHashMapKeySet*) base;
1037 _tmp0_ = self->priv->_map;
1038 _tmp1_ = vala_map_get_size ((ValaMap*) _tmp0_);
1039 _tmp2_ = _tmp1_;
1040 result = _tmp2_;
1041 return result;
1042 }
1043
1044 static gboolean
vala_hash_map_key_set_real_add(ValaCollection * base,gconstpointer key)1045 vala_hash_map_key_set_real_add (ValaCollection* base,
1046 gconstpointer key)
1047 {
1048 ValaHashMapKeySet * self;
1049 self = (ValaHashMapKeySet*) base;
1050 g_assert_not_reached ();
1051 }
1052
1053 static void
vala_hash_map_key_set_real_clear(ValaCollection * base)1054 vala_hash_map_key_set_real_clear (ValaCollection* base)
1055 {
1056 ValaHashMapKeySet * self;
1057 self = (ValaHashMapKeySet*) base;
1058 g_assert_not_reached ();
1059 }
1060
1061 static gboolean
vala_hash_map_key_set_real_remove(ValaCollection * base,gconstpointer key)1062 vala_hash_map_key_set_real_remove (ValaCollection* base,
1063 gconstpointer key)
1064 {
1065 ValaHashMapKeySet * self;
1066 self = (ValaHashMapKeySet*) base;
1067 g_assert_not_reached ();
1068 }
1069
1070 static gboolean
vala_hash_map_key_set_real_contains(ValaCollection * base,gconstpointer key)1071 vala_hash_map_key_set_real_contains (ValaCollection* base,
1072 gconstpointer key)
1073 {
1074 ValaHashMapKeySet * self;
1075 ValaHashMap* _tmp0_;
1076 gboolean result = FALSE;
1077 self = (ValaHashMapKeySet*) base;
1078 _tmp0_ = self->priv->_map;
1079 result = vala_map_contains ((ValaMap*) _tmp0_, key);
1080 return result;
1081 }
1082
1083 static void
vala_hash_map_key_set_class_init(ValaHashMapKeySetClass * klass,gpointer klass_data)1084 vala_hash_map_key_set_class_init (ValaHashMapKeySetClass * klass,
1085 gpointer klass_data)
1086 {
1087 vala_hash_map_key_set_parent_class = g_type_class_peek_parent (klass);
1088 ((ValaIterableClass *) klass)->finalize = vala_hash_map_key_set_finalize;
1089 g_type_class_adjust_private_offset (klass, &ValaHashMapKeySet_private_offset);
1090 ((ValaIterableClass *) klass)->get_element_type = (GType (*) (ValaIterable*)) vala_hash_map_key_set_real_get_element_type;
1091 ((ValaIterableClass *) klass)->iterator = (ValaIterator* (*) (ValaIterable*)) vala_hash_map_key_set_real_iterator;
1092 ((ValaCollectionClass *) klass)->add = (gboolean (*) (ValaCollection*, gconstpointer)) vala_hash_map_key_set_real_add;
1093 ((ValaCollectionClass *) klass)->clear = (void (*) (ValaCollection*)) vala_hash_map_key_set_real_clear;
1094 ((ValaCollectionClass *) klass)->remove = (gboolean (*) (ValaCollection*, gconstpointer)) vala_hash_map_key_set_real_remove;
1095 ((ValaCollectionClass *) klass)->contains = (gboolean (*) (ValaCollection*, gconstpointer)) vala_hash_map_key_set_real_contains;
1096 VALA_COLLECTION_CLASS (klass)->get_size = vala_hash_map_key_set_real_get_size;
1097 }
1098
1099 static void
vala_hash_map_key_set_instance_init(ValaHashMapKeySet * self,gpointer klass)1100 vala_hash_map_key_set_instance_init (ValaHashMapKeySet * self,
1101 gpointer klass)
1102 {
1103 self->priv = vala_hash_map_key_set_get_instance_private (self);
1104 }
1105
1106 static void
vala_hash_map_key_set_finalize(ValaIterable * obj)1107 vala_hash_map_key_set_finalize (ValaIterable * obj)
1108 {
1109 ValaHashMapKeySet * self;
1110 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_HASH_MAP_TYPE_KEY_SET, ValaHashMapKeySet);
1111 _vala_map_unref0 (self->priv->_map);
1112 VALA_ITERABLE_CLASS (vala_hash_map_key_set_parent_class)->finalize (obj);
1113 }
1114
1115 static GType
vala_hash_map_key_set_get_type_once(void)1116 vala_hash_map_key_set_get_type_once (void)
1117 {
1118 static const GTypeInfo g_define_type_info = { sizeof (ValaHashMapKeySetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_hash_map_key_set_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaHashMapKeySet), 0, (GInstanceInitFunc) vala_hash_map_key_set_instance_init, NULL };
1119 GType vala_hash_map_key_set_type_id;
1120 vala_hash_map_key_set_type_id = g_type_register_static (VALA_TYPE_SET, "ValaHashMapKeySet", &g_define_type_info, 0);
1121 ValaHashMapKeySet_private_offset = g_type_add_instance_private (vala_hash_map_key_set_type_id, sizeof (ValaHashMapKeySetPrivate));
1122 return vala_hash_map_key_set_type_id;
1123 }
1124
1125 static GType
vala_hash_map_key_set_get_type(void)1126 vala_hash_map_key_set_get_type (void)
1127 {
1128 static volatile gsize vala_hash_map_key_set_type_id__volatile = 0;
1129 if (g_once_init_enter (&vala_hash_map_key_set_type_id__volatile)) {
1130 GType vala_hash_map_key_set_type_id;
1131 vala_hash_map_key_set_type_id = vala_hash_map_key_set_get_type_once ();
1132 g_once_init_leave (&vala_hash_map_key_set_type_id__volatile, vala_hash_map_key_set_type_id);
1133 }
1134 return vala_hash_map_key_set_type_id__volatile;
1135 }
1136
1137 static inline gpointer
vala_hash_map_map_iterator_get_instance_private(ValaHashMapMapIterator * self)1138 vala_hash_map_map_iterator_get_instance_private (ValaHashMapMapIterator* self)
1139 {
1140 return G_STRUCT_MEMBER_P (self, ValaHashMapMapIterator_private_offset);
1141 }
1142
1143 static void
vala_hash_map_map_iterator_set_map(ValaHashMapMapIterator * self,ValaHashMap * value)1144 vala_hash_map_map_iterator_set_map (ValaHashMapMapIterator* self,
1145 ValaHashMap* value)
1146 {
1147 ValaHashMap* _tmp0_;
1148 ValaHashMap* _tmp1_;
1149 g_return_if_fail (self != NULL);
1150 _tmp0_ = _vala_map_ref0 (value);
1151 _vala_map_unref0 (self->priv->_map);
1152 self->priv->_map = _tmp0_;
1153 _tmp1_ = self->priv->_map;
1154 self->priv->_stamp = _tmp1_->priv->_stamp;
1155 }
1156
1157 static ValaHashMapMapIterator*
vala_hash_map_map_iterator_construct(GType object_type,GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)1158 vala_hash_map_map_iterator_construct (GType object_type,
1159 GType k_type,
1160 GBoxedCopyFunc k_dup_func,
1161 GDestroyNotify k_destroy_func,
1162 GType v_type,
1163 GBoxedCopyFunc v_dup_func,
1164 GDestroyNotify v_destroy_func,
1165 ValaHashMap* map)
1166 {
1167 ValaHashMapMapIterator* self = NULL;
1168 g_return_val_if_fail (map != NULL, NULL);
1169 self = (ValaHashMapMapIterator*) vala_map_iterator_construct (object_type, k_type, (GBoxedCopyFunc) k_dup_func, (GDestroyNotify) k_destroy_func, v_type, (GBoxedCopyFunc) v_dup_func, (GDestroyNotify) v_destroy_func);
1170 self->priv->k_type = k_type;
1171 self->priv->k_dup_func = k_dup_func;
1172 self->priv->k_destroy_func = k_destroy_func;
1173 self->priv->v_type = v_type;
1174 self->priv->v_dup_func = v_dup_func;
1175 self->priv->v_destroy_func = v_destroy_func;
1176 vala_hash_map_map_iterator_set_map (self, map);
1177 return self;
1178 }
1179
1180 static ValaHashMapMapIterator*
vala_hash_map_map_iterator_new(GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)1181 vala_hash_map_map_iterator_new (GType k_type,
1182 GBoxedCopyFunc k_dup_func,
1183 GDestroyNotify k_destroy_func,
1184 GType v_type,
1185 GBoxedCopyFunc v_dup_func,
1186 GDestroyNotify v_destroy_func,
1187 ValaHashMap* map)
1188 {
1189 return vala_hash_map_map_iterator_construct (VALA_HASH_MAP_TYPE_MAP_ITERATOR, k_type, k_dup_func, k_destroy_func, v_type, v_dup_func, v_destroy_func, map);
1190 }
1191
1192 static gboolean
vala_hash_map_map_iterator_real_next(ValaMapIterator * base)1193 vala_hash_map_map_iterator_real_next (ValaMapIterator* base)
1194 {
1195 ValaHashMapMapIterator * self;
1196 ValaHashMapNode* _tmp0_;
1197 ValaHashMapNode* _tmp10_;
1198 gboolean result = FALSE;
1199 self = (ValaHashMapMapIterator*) base;
1200 _tmp0_ = self->priv->_node;
1201 if (_tmp0_ != NULL) {
1202 ValaHashMapNode* _tmp1_;
1203 ValaHashMapNode* _tmp2_;
1204 _tmp1_ = self->priv->_node;
1205 _tmp2_ = _tmp1_->next;
1206 self->priv->_node = _tmp2_;
1207 }
1208 while (TRUE) {
1209 gboolean _tmp3_ = FALSE;
1210 ValaHashMapNode* _tmp4_;
1211 gint _tmp6_;
1212 ValaHashMap* _tmp7_;
1213 ValaHashMapNode** _tmp8_;
1214 gint _tmp8__length1;
1215 ValaHashMapNode* _tmp9_;
1216 _tmp4_ = self->priv->_node;
1217 if (_tmp4_ == NULL) {
1218 ValaHashMap* _tmp5_;
1219 _tmp5_ = self->priv->_map;
1220 _tmp3_ = (self->priv->_index + 1) < _tmp5_->priv->_array_size;
1221 } else {
1222 _tmp3_ = FALSE;
1223 }
1224 if (!_tmp3_) {
1225 break;
1226 }
1227 _tmp6_ = self->priv->_index;
1228 self->priv->_index = _tmp6_ + 1;
1229 _tmp7_ = self->priv->_map;
1230 _tmp8_ = _tmp7_->priv->_nodes;
1231 _tmp8__length1 = _tmp7_->priv->_nodes_length1;
1232 _tmp9_ = _tmp8_[self->priv->_index];
1233 self->priv->_node = _tmp9_;
1234 }
1235 _tmp10_ = self->priv->_node;
1236 result = _tmp10_ != NULL;
1237 return result;
1238 }
1239
1240 static gpointer
vala_hash_map_map_iterator_real_get_key(ValaMapIterator * base)1241 vala_hash_map_map_iterator_real_get_key (ValaMapIterator* base)
1242 {
1243 ValaHashMapMapIterator * self;
1244 ValaHashMap* _tmp0_;
1245 ValaHashMapNode* _tmp1_;
1246 ValaHashMapNode* _tmp2_;
1247 gconstpointer _tmp3_;
1248 gpointer _tmp4_;
1249 gpointer result = NULL;
1250 self = (ValaHashMapMapIterator*) base;
1251 _tmp0_ = self->priv->_map;
1252 _vala_assert (self->priv->_stamp == _tmp0_->priv->_stamp, "_stamp == _map._stamp");
1253 _tmp1_ = self->priv->_node;
1254 _vala_assert (_tmp1_ != NULL, "_node != null");
1255 _tmp2_ = self->priv->_node;
1256 _tmp3_ = _tmp2_->key;
1257 _tmp4_ = ((_tmp3_ != NULL) && (self->priv->k_dup_func != NULL)) ? self->priv->k_dup_func ((gpointer) _tmp3_) : ((gpointer) _tmp3_);
1258 result = _tmp4_;
1259 return result;
1260 }
1261
1262 static gpointer
vala_hash_map_map_iterator_real_get_value(ValaMapIterator * base)1263 vala_hash_map_map_iterator_real_get_value (ValaMapIterator* base)
1264 {
1265 ValaHashMapMapIterator * self;
1266 ValaHashMap* _tmp0_;
1267 ValaHashMapNode* _tmp1_;
1268 ValaHashMapNode* _tmp2_;
1269 gconstpointer _tmp3_;
1270 gpointer _tmp4_;
1271 gpointer result = NULL;
1272 self = (ValaHashMapMapIterator*) base;
1273 _tmp0_ = self->priv->_map;
1274 _vala_assert (self->priv->_stamp == _tmp0_->priv->_stamp, "_stamp == _map._stamp");
1275 _tmp1_ = self->priv->_node;
1276 _vala_assert (_tmp1_ != NULL, "_node != null");
1277 _tmp2_ = self->priv->_node;
1278 _tmp3_ = _tmp2_->value;
1279 _tmp4_ = ((_tmp3_ != NULL) && (self->priv->v_dup_func != NULL)) ? self->priv->v_dup_func ((gpointer) _tmp3_) : ((gpointer) _tmp3_);
1280 result = _tmp4_;
1281 return result;
1282 }
1283
1284 static void
vala_hash_map_map_iterator_class_init(ValaHashMapMapIteratorClass * klass,gpointer klass_data)1285 vala_hash_map_map_iterator_class_init (ValaHashMapMapIteratorClass * klass,
1286 gpointer klass_data)
1287 {
1288 vala_hash_map_map_iterator_parent_class = g_type_class_peek_parent (klass);
1289 ((ValaMapIteratorClass *) klass)->finalize = vala_hash_map_map_iterator_finalize;
1290 g_type_class_adjust_private_offset (klass, &ValaHashMapMapIterator_private_offset);
1291 ((ValaMapIteratorClass *) klass)->next = (gboolean (*) (ValaMapIterator*)) vala_hash_map_map_iterator_real_next;
1292 ((ValaMapIteratorClass *) klass)->get_key = (gpointer (*) (ValaMapIterator*)) vala_hash_map_map_iterator_real_get_key;
1293 ((ValaMapIteratorClass *) klass)->get_value = (gpointer (*) (ValaMapIterator*)) vala_hash_map_map_iterator_real_get_value;
1294 }
1295
1296 static void
vala_hash_map_map_iterator_instance_init(ValaHashMapMapIterator * self,gpointer klass)1297 vala_hash_map_map_iterator_instance_init (ValaHashMapMapIterator * self,
1298 gpointer klass)
1299 {
1300 self->priv = vala_hash_map_map_iterator_get_instance_private (self);
1301 self->priv->_index = -1;
1302 }
1303
1304 static void
vala_hash_map_map_iterator_finalize(ValaMapIterator * obj)1305 vala_hash_map_map_iterator_finalize (ValaMapIterator * obj)
1306 {
1307 ValaHashMapMapIterator * self;
1308 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_HASH_MAP_TYPE_MAP_ITERATOR, ValaHashMapMapIterator);
1309 _vala_map_unref0 (self->priv->_map);
1310 VALA_MAP_ITERATOR_CLASS (vala_hash_map_map_iterator_parent_class)->finalize (obj);
1311 }
1312
1313 static GType
vala_hash_map_map_iterator_get_type_once(void)1314 vala_hash_map_map_iterator_get_type_once (void)
1315 {
1316 static const GTypeInfo g_define_type_info = { sizeof (ValaHashMapMapIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_hash_map_map_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaHashMapMapIterator), 0, (GInstanceInitFunc) vala_hash_map_map_iterator_instance_init, NULL };
1317 GType vala_hash_map_map_iterator_type_id;
1318 vala_hash_map_map_iterator_type_id = g_type_register_static (VALA_TYPE_MAP_ITERATOR, "ValaHashMapMapIterator", &g_define_type_info, 0);
1319 ValaHashMapMapIterator_private_offset = g_type_add_instance_private (vala_hash_map_map_iterator_type_id, sizeof (ValaHashMapMapIteratorPrivate));
1320 return vala_hash_map_map_iterator_type_id;
1321 }
1322
1323 static GType
vala_hash_map_map_iterator_get_type(void)1324 vala_hash_map_map_iterator_get_type (void)
1325 {
1326 static volatile gsize vala_hash_map_map_iterator_type_id__volatile = 0;
1327 if (g_once_init_enter (&vala_hash_map_map_iterator_type_id__volatile)) {
1328 GType vala_hash_map_map_iterator_type_id;
1329 vala_hash_map_map_iterator_type_id = vala_hash_map_map_iterator_get_type_once ();
1330 g_once_init_leave (&vala_hash_map_map_iterator_type_id__volatile, vala_hash_map_map_iterator_type_id);
1331 }
1332 return vala_hash_map_map_iterator_type_id__volatile;
1333 }
1334
1335 static inline gpointer
vala_hash_map_key_iterator_get_instance_private(ValaHashMapKeyIterator * self)1336 vala_hash_map_key_iterator_get_instance_private (ValaHashMapKeyIterator* self)
1337 {
1338 return G_STRUCT_MEMBER_P (self, ValaHashMapKeyIterator_private_offset);
1339 }
1340
1341 static void
vala_hash_map_key_iterator_set_map(ValaHashMapKeyIterator * self,ValaHashMap * value)1342 vala_hash_map_key_iterator_set_map (ValaHashMapKeyIterator* self,
1343 ValaHashMap* value)
1344 {
1345 ValaHashMap* _tmp0_;
1346 ValaHashMap* _tmp1_;
1347 g_return_if_fail (self != NULL);
1348 _tmp0_ = _vala_map_ref0 (value);
1349 _vala_map_unref0 (self->priv->_map);
1350 self->priv->_map = _tmp0_;
1351 _tmp1_ = self->priv->_map;
1352 self->priv->_stamp = _tmp1_->priv->_stamp;
1353 }
1354
1355 static ValaHashMapKeyIterator*
vala_hash_map_key_iterator_construct(GType object_type,GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)1356 vala_hash_map_key_iterator_construct (GType object_type,
1357 GType k_type,
1358 GBoxedCopyFunc k_dup_func,
1359 GDestroyNotify k_destroy_func,
1360 GType v_type,
1361 GBoxedCopyFunc v_dup_func,
1362 GDestroyNotify v_destroy_func,
1363 ValaHashMap* map)
1364 {
1365 ValaHashMapKeyIterator* self = NULL;
1366 g_return_val_if_fail (map != NULL, NULL);
1367 self = (ValaHashMapKeyIterator*) vala_iterator_construct (object_type, k_type, (GBoxedCopyFunc) k_dup_func, (GDestroyNotify) k_destroy_func);
1368 self->priv->k_type = k_type;
1369 self->priv->k_dup_func = k_dup_func;
1370 self->priv->k_destroy_func = k_destroy_func;
1371 self->priv->v_type = v_type;
1372 self->priv->v_dup_func = v_dup_func;
1373 self->priv->v_destroy_func = v_destroy_func;
1374 vala_hash_map_key_iterator_set_map (self, map);
1375 return self;
1376 }
1377
1378 static ValaHashMapKeyIterator*
vala_hash_map_key_iterator_new(GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)1379 vala_hash_map_key_iterator_new (GType k_type,
1380 GBoxedCopyFunc k_dup_func,
1381 GDestroyNotify k_destroy_func,
1382 GType v_type,
1383 GBoxedCopyFunc v_dup_func,
1384 GDestroyNotify v_destroy_func,
1385 ValaHashMap* map)
1386 {
1387 return vala_hash_map_key_iterator_construct (VALA_HASH_MAP_TYPE_KEY_ITERATOR, k_type, k_dup_func, k_destroy_func, v_type, v_dup_func, v_destroy_func, map);
1388 }
1389
1390 static gboolean
vala_hash_map_key_iterator_real_next(ValaIterator * base)1391 vala_hash_map_key_iterator_real_next (ValaIterator* base)
1392 {
1393 ValaHashMapKeyIterator * self;
1394 ValaHashMap* _tmp0_;
1395 ValaHashMapNode* _tmp1_;
1396 ValaHashMapNode* _tmp2_;
1397 gboolean result = FALSE;
1398 self = (ValaHashMapKeyIterator*) base;
1399 _tmp0_ = self->priv->_map;
1400 _vala_assert (self->priv->_stamp == _tmp0_->priv->_stamp, "_stamp == _map._stamp");
1401 if (!vala_iterator_has_next ((ValaIterator*) self)) {
1402 result = FALSE;
1403 return result;
1404 }
1405 _tmp1_ = self->priv->_next;
1406 self->priv->_node = _tmp1_;
1407 self->priv->_next = NULL;
1408 _tmp2_ = self->priv->_node;
1409 result = _tmp2_ != NULL;
1410 return result;
1411 }
1412
1413 static gboolean
vala_hash_map_key_iterator_real_has_next(ValaIterator * base)1414 vala_hash_map_key_iterator_real_has_next (ValaIterator* base)
1415 {
1416 ValaHashMapKeyIterator * self;
1417 ValaHashMap* _tmp0_;
1418 ValaHashMapNode* _tmp1_;
1419 ValaHashMapNode* _tmp13_;
1420 gboolean result = FALSE;
1421 self = (ValaHashMapKeyIterator*) base;
1422 _tmp0_ = self->priv->_map;
1423 _vala_assert (self->priv->_stamp == _tmp0_->priv->_stamp, "_stamp == _map._stamp");
1424 _tmp1_ = self->priv->_next;
1425 if (_tmp1_ == NULL) {
1426 ValaHashMapNode* _tmp2_;
1427 ValaHashMapNode* _tmp3_;
1428 _tmp2_ = self->priv->_node;
1429 self->priv->_next = _tmp2_;
1430 _tmp3_ = self->priv->_next;
1431 if (_tmp3_ != NULL) {
1432 ValaHashMapNode* _tmp4_;
1433 ValaHashMapNode* _tmp5_;
1434 _tmp4_ = self->priv->_next;
1435 _tmp5_ = _tmp4_->next;
1436 self->priv->_next = _tmp5_;
1437 }
1438 while (TRUE) {
1439 gboolean _tmp6_ = FALSE;
1440 ValaHashMapNode* _tmp7_;
1441 gint _tmp9_;
1442 ValaHashMap* _tmp10_;
1443 ValaHashMapNode** _tmp11_;
1444 gint _tmp11__length1;
1445 ValaHashMapNode* _tmp12_;
1446 _tmp7_ = self->priv->_next;
1447 if (_tmp7_ == NULL) {
1448 ValaHashMap* _tmp8_;
1449 _tmp8_ = self->priv->_map;
1450 _tmp6_ = (self->priv->_index + 1) < _tmp8_->priv->_array_size;
1451 } else {
1452 _tmp6_ = FALSE;
1453 }
1454 if (!_tmp6_) {
1455 break;
1456 }
1457 _tmp9_ = self->priv->_index;
1458 self->priv->_index = _tmp9_ + 1;
1459 _tmp10_ = self->priv->_map;
1460 _tmp11_ = _tmp10_->priv->_nodes;
1461 _tmp11__length1 = _tmp10_->priv->_nodes_length1;
1462 _tmp12_ = _tmp11_[self->priv->_index];
1463 self->priv->_next = _tmp12_;
1464 }
1465 }
1466 _tmp13_ = self->priv->_next;
1467 result = _tmp13_ != NULL;
1468 return result;
1469 }
1470
1471 static gpointer
vala_hash_map_key_iterator_real_get(ValaIterator * base)1472 vala_hash_map_key_iterator_real_get (ValaIterator* base)
1473 {
1474 ValaHashMapKeyIterator * self;
1475 ValaHashMap* _tmp0_;
1476 ValaHashMapNode* _tmp1_;
1477 ValaHashMapNode* _tmp2_;
1478 gconstpointer _tmp3_;
1479 gpointer _tmp4_;
1480 gpointer result = NULL;
1481 self = (ValaHashMapKeyIterator*) base;
1482 _tmp0_ = self->priv->_map;
1483 _vala_assert (self->priv->_stamp == _tmp0_->priv->_stamp, "_stamp == _map._stamp");
1484 _tmp1_ = self->priv->_node;
1485 _vala_assert (_tmp1_ != NULL, "_node != null");
1486 _tmp2_ = self->priv->_node;
1487 _tmp3_ = _tmp2_->key;
1488 _tmp4_ = ((_tmp3_ != NULL) && (self->priv->k_dup_func != NULL)) ? self->priv->k_dup_func ((gpointer) _tmp3_) : ((gpointer) _tmp3_);
1489 result = _tmp4_;
1490 return result;
1491 }
1492
1493 static void
vala_hash_map_key_iterator_real_remove(ValaIterator * base)1494 vala_hash_map_key_iterator_real_remove (ValaIterator* base)
1495 {
1496 ValaHashMapKeyIterator * self;
1497 self = (ValaHashMapKeyIterator*) base;
1498 g_assert_not_reached ();
1499 }
1500
1501 static gboolean
vala_hash_map_key_iterator_real_get_valid(ValaIterator * base)1502 vala_hash_map_key_iterator_real_get_valid (ValaIterator* base)
1503 {
1504 gboolean result;
1505 ValaHashMapKeyIterator* self;
1506 ValaHashMapNode* _tmp0_;
1507 self = (ValaHashMapKeyIterator*) base;
1508 _tmp0_ = self->priv->_node;
1509 result = _tmp0_ != NULL;
1510 return result;
1511 }
1512
1513 static void
vala_hash_map_key_iterator_class_init(ValaHashMapKeyIteratorClass * klass,gpointer klass_data)1514 vala_hash_map_key_iterator_class_init (ValaHashMapKeyIteratorClass * klass,
1515 gpointer klass_data)
1516 {
1517 vala_hash_map_key_iterator_parent_class = g_type_class_peek_parent (klass);
1518 ((ValaIteratorClass *) klass)->finalize = vala_hash_map_key_iterator_finalize;
1519 g_type_class_adjust_private_offset (klass, &ValaHashMapKeyIterator_private_offset);
1520 ((ValaIteratorClass *) klass)->next = (gboolean (*) (ValaIterator*)) vala_hash_map_key_iterator_real_next;
1521 ((ValaIteratorClass *) klass)->has_next = (gboolean (*) (ValaIterator*)) vala_hash_map_key_iterator_real_has_next;
1522 ((ValaIteratorClass *) klass)->get = (gpointer (*) (ValaIterator*)) vala_hash_map_key_iterator_real_get;
1523 ((ValaIteratorClass *) klass)->remove = (void (*) (ValaIterator*)) vala_hash_map_key_iterator_real_remove;
1524 VALA_ITERATOR_CLASS (klass)->get_valid = vala_hash_map_key_iterator_real_get_valid;
1525 }
1526
1527 static void
vala_hash_map_key_iterator_instance_init(ValaHashMapKeyIterator * self,gpointer klass)1528 vala_hash_map_key_iterator_instance_init (ValaHashMapKeyIterator * self,
1529 gpointer klass)
1530 {
1531 self->priv = vala_hash_map_key_iterator_get_instance_private (self);
1532 self->priv->_index = -1;
1533 }
1534
1535 static void
vala_hash_map_key_iterator_finalize(ValaIterator * obj)1536 vala_hash_map_key_iterator_finalize (ValaIterator * obj)
1537 {
1538 ValaHashMapKeyIterator * self;
1539 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_HASH_MAP_TYPE_KEY_ITERATOR, ValaHashMapKeyIterator);
1540 _vala_map_unref0 (self->priv->_map);
1541 VALA_ITERATOR_CLASS (vala_hash_map_key_iterator_parent_class)->finalize (obj);
1542 }
1543
1544 static GType
vala_hash_map_key_iterator_get_type_once(void)1545 vala_hash_map_key_iterator_get_type_once (void)
1546 {
1547 static const GTypeInfo g_define_type_info = { sizeof (ValaHashMapKeyIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_hash_map_key_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaHashMapKeyIterator), 0, (GInstanceInitFunc) vala_hash_map_key_iterator_instance_init, NULL };
1548 GType vala_hash_map_key_iterator_type_id;
1549 vala_hash_map_key_iterator_type_id = g_type_register_static (VALA_TYPE_ITERATOR, "ValaHashMapKeyIterator", &g_define_type_info, 0);
1550 ValaHashMapKeyIterator_private_offset = g_type_add_instance_private (vala_hash_map_key_iterator_type_id, sizeof (ValaHashMapKeyIteratorPrivate));
1551 return vala_hash_map_key_iterator_type_id;
1552 }
1553
1554 static GType
vala_hash_map_key_iterator_get_type(void)1555 vala_hash_map_key_iterator_get_type (void)
1556 {
1557 static volatile gsize vala_hash_map_key_iterator_type_id__volatile = 0;
1558 if (g_once_init_enter (&vala_hash_map_key_iterator_type_id__volatile)) {
1559 GType vala_hash_map_key_iterator_type_id;
1560 vala_hash_map_key_iterator_type_id = vala_hash_map_key_iterator_get_type_once ();
1561 g_once_init_leave (&vala_hash_map_key_iterator_type_id__volatile, vala_hash_map_key_iterator_type_id);
1562 }
1563 return vala_hash_map_key_iterator_type_id__volatile;
1564 }
1565
1566 static inline gpointer
vala_hash_map_value_collection_get_instance_private(ValaHashMapValueCollection * self)1567 vala_hash_map_value_collection_get_instance_private (ValaHashMapValueCollection* self)
1568 {
1569 return G_STRUCT_MEMBER_P (self, ValaHashMapValueCollection_private_offset);
1570 }
1571
1572 static void
vala_hash_map_value_collection_set_map(ValaHashMapValueCollection * self,ValaHashMap * value)1573 vala_hash_map_value_collection_set_map (ValaHashMapValueCollection* self,
1574 ValaHashMap* value)
1575 {
1576 ValaHashMap* _tmp0_;
1577 g_return_if_fail (self != NULL);
1578 _tmp0_ = _vala_map_ref0 (value);
1579 _vala_map_unref0 (self->priv->_map);
1580 self->priv->_map = _tmp0_;
1581 }
1582
1583 static ValaHashMapValueCollection*
vala_hash_map_value_collection_construct(GType object_type,GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)1584 vala_hash_map_value_collection_construct (GType object_type,
1585 GType k_type,
1586 GBoxedCopyFunc k_dup_func,
1587 GDestroyNotify k_destroy_func,
1588 GType v_type,
1589 GBoxedCopyFunc v_dup_func,
1590 GDestroyNotify v_destroy_func,
1591 ValaHashMap* map)
1592 {
1593 ValaHashMapValueCollection* self = NULL;
1594 g_return_val_if_fail (map != NULL, NULL);
1595 self = (ValaHashMapValueCollection*) vala_collection_construct (object_type, v_type, (GBoxedCopyFunc) v_dup_func, (GDestroyNotify) v_destroy_func);
1596 self->priv->k_type = k_type;
1597 self->priv->k_dup_func = k_dup_func;
1598 self->priv->k_destroy_func = k_destroy_func;
1599 self->priv->v_type = v_type;
1600 self->priv->v_dup_func = v_dup_func;
1601 self->priv->v_destroy_func = v_destroy_func;
1602 vala_hash_map_value_collection_set_map (self, map);
1603 return self;
1604 }
1605
1606 static ValaHashMapValueCollection*
vala_hash_map_value_collection_new(GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)1607 vala_hash_map_value_collection_new (GType k_type,
1608 GBoxedCopyFunc k_dup_func,
1609 GDestroyNotify k_destroy_func,
1610 GType v_type,
1611 GBoxedCopyFunc v_dup_func,
1612 GDestroyNotify v_destroy_func,
1613 ValaHashMap* map)
1614 {
1615 return vala_hash_map_value_collection_construct (VALA_HASH_MAP_TYPE_VALUE_COLLECTION, k_type, k_dup_func, k_destroy_func, v_type, v_dup_func, v_destroy_func, map);
1616 }
1617
1618 static GType
vala_hash_map_value_collection_real_get_element_type(ValaIterable * base)1619 vala_hash_map_value_collection_real_get_element_type (ValaIterable* base)
1620 {
1621 ValaHashMapValueCollection * self;
1622 GType result = 0UL;
1623 self = (ValaHashMapValueCollection*) base;
1624 result = self->priv->v_type;
1625 return result;
1626 }
1627
1628 static ValaIterator*
vala_hash_map_value_collection_real_iterator(ValaIterable * base)1629 vala_hash_map_value_collection_real_iterator (ValaIterable* base)
1630 {
1631 ValaHashMapValueCollection * self;
1632 ValaHashMap* _tmp0_;
1633 ValaHashMapValueIterator* _tmp1_;
1634 ValaIterator* result = NULL;
1635 self = (ValaHashMapValueCollection*) base;
1636 _tmp0_ = self->priv->_map;
1637 _tmp1_ = vala_hash_map_value_iterator_new (self->priv->k_type, (GBoxedCopyFunc) self->priv->k_dup_func, (GDestroyNotify) self->priv->k_destroy_func, self->priv->v_type, (GBoxedCopyFunc) self->priv->v_dup_func, (GDestroyNotify) self->priv->v_destroy_func, _tmp0_);
1638 result = (ValaIterator*) _tmp1_;
1639 return result;
1640 }
1641
1642 static gint
vala_hash_map_value_collection_real_get_size(ValaCollection * base)1643 vala_hash_map_value_collection_real_get_size (ValaCollection* base)
1644 {
1645 gint result;
1646 ValaHashMapValueCollection* self;
1647 ValaHashMap* _tmp0_;
1648 gint _tmp1_;
1649 gint _tmp2_;
1650 self = (ValaHashMapValueCollection*) base;
1651 _tmp0_ = self->priv->_map;
1652 _tmp1_ = vala_map_get_size ((ValaMap*) _tmp0_);
1653 _tmp2_ = _tmp1_;
1654 result = _tmp2_;
1655 return result;
1656 }
1657
1658 static gboolean
vala_hash_map_value_collection_real_add(ValaCollection * base,gconstpointer value)1659 vala_hash_map_value_collection_real_add (ValaCollection* base,
1660 gconstpointer value)
1661 {
1662 ValaHashMapValueCollection * self;
1663 self = (ValaHashMapValueCollection*) base;
1664 g_assert_not_reached ();
1665 }
1666
1667 static void
vala_hash_map_value_collection_real_clear(ValaCollection * base)1668 vala_hash_map_value_collection_real_clear (ValaCollection* base)
1669 {
1670 ValaHashMapValueCollection * self;
1671 self = (ValaHashMapValueCollection*) base;
1672 g_assert_not_reached ();
1673 }
1674
1675 static gboolean
vala_hash_map_value_collection_real_remove(ValaCollection * base,gconstpointer value)1676 vala_hash_map_value_collection_real_remove (ValaCollection* base,
1677 gconstpointer value)
1678 {
1679 ValaHashMapValueCollection * self;
1680 self = (ValaHashMapValueCollection*) base;
1681 g_assert_not_reached ();
1682 }
1683
1684 static gboolean
vala_hash_map_value_collection_real_contains(ValaCollection * base,gconstpointer value)1685 vala_hash_map_value_collection_real_contains (ValaCollection* base,
1686 gconstpointer value)
1687 {
1688 ValaHashMapValueCollection * self;
1689 ValaIterator* it = NULL;
1690 ValaIterator* _tmp0_;
1691 gboolean result = FALSE;
1692 self = (ValaHashMapValueCollection*) base;
1693 _tmp0_ = vala_iterable_iterator ((ValaIterable*) self);
1694 it = _tmp0_;
1695 while (TRUE) {
1696 ValaIterator* _tmp1_;
1697 ValaHashMap* _tmp2_;
1698 GEqualFunc _tmp3_;
1699 ValaIterator* _tmp4_;
1700 gpointer _tmp5_;
1701 gpointer _tmp6_;
1702 gboolean _tmp7_;
1703 _tmp1_ = it;
1704 if (!vala_iterator_next (_tmp1_)) {
1705 break;
1706 }
1707 _tmp2_ = self->priv->_map;
1708 _tmp3_ = _tmp2_->priv->_value_equal_func;
1709 _tmp4_ = it;
1710 _tmp5_ = vala_iterator_get (_tmp4_);
1711 _tmp6_ = _tmp5_;
1712 _tmp7_ = _tmp3_ (_tmp6_, value);
1713 ((_tmp6_ == NULL) || (self->priv->v_destroy_func == NULL)) ? NULL : (_tmp6_ = (self->priv->v_destroy_func (_tmp6_), NULL));
1714 if (_tmp7_) {
1715 result = TRUE;
1716 _vala_iterator_unref0 (it);
1717 return result;
1718 }
1719 }
1720 result = FALSE;
1721 _vala_iterator_unref0 (it);
1722 return result;
1723 }
1724
1725 static void
vala_hash_map_value_collection_class_init(ValaHashMapValueCollectionClass * klass,gpointer klass_data)1726 vala_hash_map_value_collection_class_init (ValaHashMapValueCollectionClass * klass,
1727 gpointer klass_data)
1728 {
1729 vala_hash_map_value_collection_parent_class = g_type_class_peek_parent (klass);
1730 ((ValaIterableClass *) klass)->finalize = vala_hash_map_value_collection_finalize;
1731 g_type_class_adjust_private_offset (klass, &ValaHashMapValueCollection_private_offset);
1732 ((ValaIterableClass *) klass)->get_element_type = (GType (*) (ValaIterable*)) vala_hash_map_value_collection_real_get_element_type;
1733 ((ValaIterableClass *) klass)->iterator = (ValaIterator* (*) (ValaIterable*)) vala_hash_map_value_collection_real_iterator;
1734 ((ValaCollectionClass *) klass)->add = (gboolean (*) (ValaCollection*, gconstpointer)) vala_hash_map_value_collection_real_add;
1735 ((ValaCollectionClass *) klass)->clear = (void (*) (ValaCollection*)) vala_hash_map_value_collection_real_clear;
1736 ((ValaCollectionClass *) klass)->remove = (gboolean (*) (ValaCollection*, gconstpointer)) vala_hash_map_value_collection_real_remove;
1737 ((ValaCollectionClass *) klass)->contains = (gboolean (*) (ValaCollection*, gconstpointer)) vala_hash_map_value_collection_real_contains;
1738 VALA_COLLECTION_CLASS (klass)->get_size = vala_hash_map_value_collection_real_get_size;
1739 }
1740
1741 static void
vala_hash_map_value_collection_instance_init(ValaHashMapValueCollection * self,gpointer klass)1742 vala_hash_map_value_collection_instance_init (ValaHashMapValueCollection * self,
1743 gpointer klass)
1744 {
1745 self->priv = vala_hash_map_value_collection_get_instance_private (self);
1746 }
1747
1748 static void
vala_hash_map_value_collection_finalize(ValaIterable * obj)1749 vala_hash_map_value_collection_finalize (ValaIterable * obj)
1750 {
1751 ValaHashMapValueCollection * self;
1752 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_HASH_MAP_TYPE_VALUE_COLLECTION, ValaHashMapValueCollection);
1753 _vala_map_unref0 (self->priv->_map);
1754 VALA_ITERABLE_CLASS (vala_hash_map_value_collection_parent_class)->finalize (obj);
1755 }
1756
1757 static GType
vala_hash_map_value_collection_get_type_once(void)1758 vala_hash_map_value_collection_get_type_once (void)
1759 {
1760 static const GTypeInfo g_define_type_info = { sizeof (ValaHashMapValueCollectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_hash_map_value_collection_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaHashMapValueCollection), 0, (GInstanceInitFunc) vala_hash_map_value_collection_instance_init, NULL };
1761 GType vala_hash_map_value_collection_type_id;
1762 vala_hash_map_value_collection_type_id = g_type_register_static (VALA_TYPE_COLLECTION, "ValaHashMapValueCollection", &g_define_type_info, 0);
1763 ValaHashMapValueCollection_private_offset = g_type_add_instance_private (vala_hash_map_value_collection_type_id, sizeof (ValaHashMapValueCollectionPrivate));
1764 return vala_hash_map_value_collection_type_id;
1765 }
1766
1767 static GType
vala_hash_map_value_collection_get_type(void)1768 vala_hash_map_value_collection_get_type (void)
1769 {
1770 static volatile gsize vala_hash_map_value_collection_type_id__volatile = 0;
1771 if (g_once_init_enter (&vala_hash_map_value_collection_type_id__volatile)) {
1772 GType vala_hash_map_value_collection_type_id;
1773 vala_hash_map_value_collection_type_id = vala_hash_map_value_collection_get_type_once ();
1774 g_once_init_leave (&vala_hash_map_value_collection_type_id__volatile, vala_hash_map_value_collection_type_id);
1775 }
1776 return vala_hash_map_value_collection_type_id__volatile;
1777 }
1778
1779 static inline gpointer
vala_hash_map_value_iterator_get_instance_private(ValaHashMapValueIterator * self)1780 vala_hash_map_value_iterator_get_instance_private (ValaHashMapValueIterator* self)
1781 {
1782 return G_STRUCT_MEMBER_P (self, ValaHashMapValueIterator_private_offset);
1783 }
1784
1785 static void
vala_hash_map_value_iterator_set_map(ValaHashMapValueIterator * self,ValaHashMap * value)1786 vala_hash_map_value_iterator_set_map (ValaHashMapValueIterator* self,
1787 ValaHashMap* value)
1788 {
1789 ValaHashMap* _tmp0_;
1790 ValaHashMap* _tmp1_;
1791 g_return_if_fail (self != NULL);
1792 _tmp0_ = _vala_map_ref0 (value);
1793 _vala_map_unref0 (self->priv->_map);
1794 self->priv->_map = _tmp0_;
1795 _tmp1_ = self->priv->_map;
1796 self->priv->_stamp = _tmp1_->priv->_stamp;
1797 }
1798
1799 static ValaHashMapValueIterator*
vala_hash_map_value_iterator_construct(GType object_type,GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)1800 vala_hash_map_value_iterator_construct (GType object_type,
1801 GType k_type,
1802 GBoxedCopyFunc k_dup_func,
1803 GDestroyNotify k_destroy_func,
1804 GType v_type,
1805 GBoxedCopyFunc v_dup_func,
1806 GDestroyNotify v_destroy_func,
1807 ValaHashMap* map)
1808 {
1809 ValaHashMapValueIterator* self = NULL;
1810 g_return_val_if_fail (map != NULL, NULL);
1811 self = (ValaHashMapValueIterator*) vala_iterator_construct (object_type, v_type, (GBoxedCopyFunc) v_dup_func, (GDestroyNotify) v_destroy_func);
1812 self->priv->k_type = k_type;
1813 self->priv->k_dup_func = k_dup_func;
1814 self->priv->k_destroy_func = k_destroy_func;
1815 self->priv->v_type = v_type;
1816 self->priv->v_dup_func = v_dup_func;
1817 self->priv->v_destroy_func = v_destroy_func;
1818 vala_hash_map_value_iterator_set_map (self, map);
1819 return self;
1820 }
1821
1822 static ValaHashMapValueIterator*
vala_hash_map_value_iterator_new(GType k_type,GBoxedCopyFunc k_dup_func,GDestroyNotify k_destroy_func,GType v_type,GBoxedCopyFunc v_dup_func,GDestroyNotify v_destroy_func,ValaHashMap * map)1823 vala_hash_map_value_iterator_new (GType k_type,
1824 GBoxedCopyFunc k_dup_func,
1825 GDestroyNotify k_destroy_func,
1826 GType v_type,
1827 GBoxedCopyFunc v_dup_func,
1828 GDestroyNotify v_destroy_func,
1829 ValaHashMap* map)
1830 {
1831 return vala_hash_map_value_iterator_construct (VALA_HASH_MAP_TYPE_VALUE_ITERATOR, k_type, k_dup_func, k_destroy_func, v_type, v_dup_func, v_destroy_func, map);
1832 }
1833
1834 static gboolean
vala_hash_map_value_iterator_real_next(ValaIterator * base)1835 vala_hash_map_value_iterator_real_next (ValaIterator* base)
1836 {
1837 ValaHashMapValueIterator * self;
1838 ValaHashMap* _tmp0_;
1839 ValaHashMapNode* _tmp1_;
1840 ValaHashMapNode* _tmp2_;
1841 gboolean result = FALSE;
1842 self = (ValaHashMapValueIterator*) base;
1843 _tmp0_ = self->priv->_map;
1844 _vala_assert (self->priv->_stamp == _tmp0_->priv->_stamp, "_stamp == _map._stamp");
1845 if (!vala_iterator_has_next ((ValaIterator*) self)) {
1846 result = FALSE;
1847 return result;
1848 }
1849 _tmp1_ = self->priv->_next;
1850 self->priv->_node = _tmp1_;
1851 self->priv->_next = NULL;
1852 _tmp2_ = self->priv->_node;
1853 result = _tmp2_ != NULL;
1854 return result;
1855 }
1856
1857 static gboolean
vala_hash_map_value_iterator_real_has_next(ValaIterator * base)1858 vala_hash_map_value_iterator_real_has_next (ValaIterator* base)
1859 {
1860 ValaHashMapValueIterator * self;
1861 ValaHashMap* _tmp0_;
1862 ValaHashMapNode* _tmp1_;
1863 ValaHashMapNode* _tmp13_;
1864 gboolean result = FALSE;
1865 self = (ValaHashMapValueIterator*) base;
1866 _tmp0_ = self->priv->_map;
1867 _vala_assert (self->priv->_stamp == _tmp0_->priv->_stamp, "_stamp == _map._stamp");
1868 _tmp1_ = self->priv->_next;
1869 if (_tmp1_ == NULL) {
1870 ValaHashMapNode* _tmp2_;
1871 ValaHashMapNode* _tmp3_;
1872 _tmp2_ = self->priv->_node;
1873 self->priv->_next = _tmp2_;
1874 _tmp3_ = self->priv->_next;
1875 if (_tmp3_ != NULL) {
1876 ValaHashMapNode* _tmp4_;
1877 ValaHashMapNode* _tmp5_;
1878 _tmp4_ = self->priv->_next;
1879 _tmp5_ = _tmp4_->next;
1880 self->priv->_next = _tmp5_;
1881 }
1882 while (TRUE) {
1883 gboolean _tmp6_ = FALSE;
1884 ValaHashMapNode* _tmp7_;
1885 gint _tmp9_;
1886 ValaHashMap* _tmp10_;
1887 ValaHashMapNode** _tmp11_;
1888 gint _tmp11__length1;
1889 ValaHashMapNode* _tmp12_;
1890 _tmp7_ = self->priv->_next;
1891 if (_tmp7_ == NULL) {
1892 ValaHashMap* _tmp8_;
1893 _tmp8_ = self->priv->_map;
1894 _tmp6_ = (self->priv->_index + 1) < _tmp8_->priv->_array_size;
1895 } else {
1896 _tmp6_ = FALSE;
1897 }
1898 if (!_tmp6_) {
1899 break;
1900 }
1901 _tmp9_ = self->priv->_index;
1902 self->priv->_index = _tmp9_ + 1;
1903 _tmp10_ = self->priv->_map;
1904 _tmp11_ = _tmp10_->priv->_nodes;
1905 _tmp11__length1 = _tmp10_->priv->_nodes_length1;
1906 _tmp12_ = _tmp11_[self->priv->_index];
1907 self->priv->_next = _tmp12_;
1908 }
1909 }
1910 _tmp13_ = self->priv->_next;
1911 result = _tmp13_ != NULL;
1912 return result;
1913 }
1914
1915 static gpointer
vala_hash_map_value_iterator_real_get(ValaIterator * base)1916 vala_hash_map_value_iterator_real_get (ValaIterator* base)
1917 {
1918 ValaHashMapValueIterator * self;
1919 ValaHashMap* _tmp0_;
1920 ValaHashMapNode* _tmp1_;
1921 ValaHashMapNode* _tmp2_;
1922 gconstpointer _tmp3_;
1923 gpointer _tmp4_;
1924 gpointer result = NULL;
1925 self = (ValaHashMapValueIterator*) base;
1926 _tmp0_ = self->priv->_map;
1927 _vala_assert (self->priv->_stamp == _tmp0_->priv->_stamp, "_stamp == _map._stamp");
1928 _tmp1_ = self->priv->_node;
1929 _vala_assert (_tmp1_ != NULL, "_node != null");
1930 _tmp2_ = self->priv->_node;
1931 _tmp3_ = _tmp2_->value;
1932 _tmp4_ = ((_tmp3_ != NULL) && (self->priv->v_dup_func != NULL)) ? self->priv->v_dup_func ((gpointer) _tmp3_) : ((gpointer) _tmp3_);
1933 result = _tmp4_;
1934 return result;
1935 }
1936
1937 static void
vala_hash_map_value_iterator_real_remove(ValaIterator * base)1938 vala_hash_map_value_iterator_real_remove (ValaIterator* base)
1939 {
1940 ValaHashMapValueIterator * self;
1941 self = (ValaHashMapValueIterator*) base;
1942 g_assert_not_reached ();
1943 }
1944
1945 static gboolean
vala_hash_map_value_iterator_real_get_valid(ValaIterator * base)1946 vala_hash_map_value_iterator_real_get_valid (ValaIterator* base)
1947 {
1948 gboolean result;
1949 ValaHashMapValueIterator* self;
1950 ValaHashMapNode* _tmp0_;
1951 self = (ValaHashMapValueIterator*) base;
1952 _tmp0_ = self->priv->_node;
1953 result = _tmp0_ != NULL;
1954 return result;
1955 }
1956
1957 static void
vala_hash_map_value_iterator_class_init(ValaHashMapValueIteratorClass * klass,gpointer klass_data)1958 vala_hash_map_value_iterator_class_init (ValaHashMapValueIteratorClass * klass,
1959 gpointer klass_data)
1960 {
1961 vala_hash_map_value_iterator_parent_class = g_type_class_peek_parent (klass);
1962 ((ValaIteratorClass *) klass)->finalize = vala_hash_map_value_iterator_finalize;
1963 g_type_class_adjust_private_offset (klass, &ValaHashMapValueIterator_private_offset);
1964 ((ValaIteratorClass *) klass)->next = (gboolean (*) (ValaIterator*)) vala_hash_map_value_iterator_real_next;
1965 ((ValaIteratorClass *) klass)->has_next = (gboolean (*) (ValaIterator*)) vala_hash_map_value_iterator_real_has_next;
1966 ((ValaIteratorClass *) klass)->get = (gpointer (*) (ValaIterator*)) vala_hash_map_value_iterator_real_get;
1967 ((ValaIteratorClass *) klass)->remove = (void (*) (ValaIterator*)) vala_hash_map_value_iterator_real_remove;
1968 VALA_ITERATOR_CLASS (klass)->get_valid = vala_hash_map_value_iterator_real_get_valid;
1969 }
1970
1971 static void
vala_hash_map_value_iterator_instance_init(ValaHashMapValueIterator * self,gpointer klass)1972 vala_hash_map_value_iterator_instance_init (ValaHashMapValueIterator * self,
1973 gpointer klass)
1974 {
1975 self->priv = vala_hash_map_value_iterator_get_instance_private (self);
1976 self->priv->_index = -1;
1977 }
1978
1979 static void
vala_hash_map_value_iterator_finalize(ValaIterator * obj)1980 vala_hash_map_value_iterator_finalize (ValaIterator * obj)
1981 {
1982 ValaHashMapValueIterator * self;
1983 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_HASH_MAP_TYPE_VALUE_ITERATOR, ValaHashMapValueIterator);
1984 _vala_map_unref0 (self->priv->_map);
1985 VALA_ITERATOR_CLASS (vala_hash_map_value_iterator_parent_class)->finalize (obj);
1986 }
1987
1988 static GType
vala_hash_map_value_iterator_get_type_once(void)1989 vala_hash_map_value_iterator_get_type_once (void)
1990 {
1991 static const GTypeInfo g_define_type_info = { sizeof (ValaHashMapValueIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_hash_map_value_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaHashMapValueIterator), 0, (GInstanceInitFunc) vala_hash_map_value_iterator_instance_init, NULL };
1992 GType vala_hash_map_value_iterator_type_id;
1993 vala_hash_map_value_iterator_type_id = g_type_register_static (VALA_TYPE_ITERATOR, "ValaHashMapValueIterator", &g_define_type_info, 0);
1994 ValaHashMapValueIterator_private_offset = g_type_add_instance_private (vala_hash_map_value_iterator_type_id, sizeof (ValaHashMapValueIteratorPrivate));
1995 return vala_hash_map_value_iterator_type_id;
1996 }
1997
1998 static GType
vala_hash_map_value_iterator_get_type(void)1999 vala_hash_map_value_iterator_get_type (void)
2000 {
2001 static volatile gsize vala_hash_map_value_iterator_type_id__volatile = 0;
2002 if (g_once_init_enter (&vala_hash_map_value_iterator_type_id__volatile)) {
2003 GType vala_hash_map_value_iterator_type_id;
2004 vala_hash_map_value_iterator_type_id = vala_hash_map_value_iterator_get_type_once ();
2005 g_once_init_leave (&vala_hash_map_value_iterator_type_id__volatile, vala_hash_map_value_iterator_type_id);
2006 }
2007 return vala_hash_map_value_iterator_type_id__volatile;
2008 }
2009
2010 static void
vala_hash_map_class_init(ValaHashMapClass * klass,gpointer klass_data)2011 vala_hash_map_class_init (ValaHashMapClass * klass,
2012 gpointer klass_data)
2013 {
2014 vala_hash_map_parent_class = g_type_class_peek_parent (klass);
2015 ((ValaMapClass *) klass)->finalize = vala_hash_map_finalize;
2016 g_type_class_adjust_private_offset (klass, &ValaHashMap_private_offset);
2017 ((ValaMapClass *) klass)->get_keys = (ValaSet* (*) (ValaMap*)) vala_hash_map_real_get_keys;
2018 ((ValaMapClass *) klass)->get_values = (ValaCollection* (*) (ValaMap*)) vala_hash_map_real_get_values;
2019 ((ValaMapClass *) klass)->map_iterator = (ValaMapIterator* (*) (ValaMap*)) vala_hash_map_real_map_iterator;
2020 ((ValaMapClass *) klass)->contains = (gboolean (*) (ValaMap*, gconstpointer)) vala_hash_map_real_contains;
2021 ((ValaMapClass *) klass)->get = (gpointer (*) (ValaMap*, gconstpointer)) vala_hash_map_real_get;
2022 ((ValaMapClass *) klass)->set = (void (*) (ValaMap*, gconstpointer, gconstpointer)) vala_hash_map_real_set;
2023 ((ValaMapClass *) klass)->remove = (gboolean (*) (ValaMap*, gconstpointer)) vala_hash_map_real_remove;
2024 ((ValaMapClass *) klass)->clear = (void (*) (ValaMap*)) vala_hash_map_real_clear;
2025 VALA_MAP_CLASS (klass)->get_size = vala_hash_map_real_get_size;
2026 }
2027
2028 static void
vala_hash_map_instance_init(ValaHashMap * self,gpointer klass)2029 vala_hash_map_instance_init (ValaHashMap * self,
2030 gpointer klass)
2031 {
2032 self->priv = vala_hash_map_get_instance_private (self);
2033 self->priv->_stamp = 0;
2034 }
2035
2036 static void
vala_hash_map_finalize(ValaMap * obj)2037 vala_hash_map_finalize (ValaMap * obj)
2038 {
2039 ValaHashMap * self;
2040 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_HASH_MAP, ValaHashMap);
2041 vala_map_clear ((ValaMap*) self);
2042 self->priv->_nodes = (_vala_array_free (self->priv->_nodes, self->priv->_nodes_length1, (GDestroyNotify) vala_hash_map_node_free), NULL);
2043 VALA_MAP_CLASS (vala_hash_map_parent_class)->finalize (obj);
2044 }
2045
2046 /**
2047 * Hashtable implementation of the Map interface.
2048 */
2049 static GType
vala_hash_map_get_type_once(void)2050 vala_hash_map_get_type_once (void)
2051 {
2052 static const GTypeInfo g_define_type_info = { sizeof (ValaHashMapClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_hash_map_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaHashMap), 0, (GInstanceInitFunc) vala_hash_map_instance_init, NULL };
2053 GType vala_hash_map_type_id;
2054 vala_hash_map_type_id = g_type_register_static (VALA_TYPE_MAP, "ValaHashMap", &g_define_type_info, 0);
2055 ValaHashMap_private_offset = g_type_add_instance_private (vala_hash_map_type_id, sizeof (ValaHashMapPrivate));
2056 return vala_hash_map_type_id;
2057 }
2058
2059 GType
vala_hash_map_get_type(void)2060 vala_hash_map_get_type (void)
2061 {
2062 static volatile gsize vala_hash_map_type_id__volatile = 0;
2063 if (g_once_init_enter (&vala_hash_map_type_id__volatile)) {
2064 GType vala_hash_map_type_id;
2065 vala_hash_map_type_id = vala_hash_map_get_type_once ();
2066 g_once_init_leave (&vala_hash_map_type_id__volatile, vala_hash_map_type_id);
2067 }
2068 return vala_hash_map_type_id__volatile;
2069 }
2070
2071 static void
_vala_array_destroy(gpointer array,gint array_length,GDestroyNotify destroy_func)2072 _vala_array_destroy (gpointer array,
2073 gint array_length,
2074 GDestroyNotify destroy_func)
2075 {
2076 if ((array != NULL) && (destroy_func != NULL)) {
2077 gint i;
2078 for (i = 0; i < array_length; i = i + 1) {
2079 if (((gpointer*) array)[i] != NULL) {
2080 destroy_func (((gpointer*) array)[i]);
2081 }
2082 }
2083 }
2084 }
2085
2086 static void
_vala_array_free(gpointer array,gint array_length,GDestroyNotify destroy_func)2087 _vala_array_free (gpointer array,
2088 gint array_length,
2089 GDestroyNotify destroy_func)
2090 {
2091 _vala_array_destroy (array, array_length, destroy_func);
2092 g_free (array);
2093 }
2094
2095