File: vala-dmap-db.c

package info (click to toggle)
libdmapsharing 3.9.13-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,340 kB
  • sloc: ansic: 17,285; sh: 4,782; xml: 556; makefile: 459
file content (321 lines) | stat: -rw-r--r-- 10,661 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/* vala-dmap-db.c generated by valac 0.56.9, the Vala compiler
 * generated from vala-dmap-db.vala, do not modify */

/*   FILE: vala-dmap-db.vala -- A DmapDb implementation in Vala
 * AUTHOR: W. Michael Petullo <mike@flyn.org>
 *   DATE: 21 December 2010 
 *
 * Copyright (c) 2010 W. Michael Petullo <new@flyn.org>
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <glib-object.h>
#include <libdmapsharing/dmap.h>
#include <gee.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_VALA_DMAP_DB (vala_dmap_db_get_type ())
#define VALA_DMAP_DB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_VALA_DMAP_DB, ValaDmapDb))
#define VALA_DMAP_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_VALA_DMAP_DB, ValaDmapDbClass))
#define IS_VALA_DMAP_DB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_VALA_DMAP_DB))
#define IS_VALA_DMAP_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_VALA_DMAP_DB))
#define VALA_DMAP_DB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_VALA_DMAP_DB, ValaDmapDbClass))

typedef struct _ValaDmapDb ValaDmapDb;
typedef struct _ValaDmapDbClass ValaDmapDbClass;
typedef struct _ValaDmapDbPrivate ValaDmapDbPrivate;
enum  {
	VALA_DMAP_DB_0_PROPERTY,
	VALA_DMAP_DB_NUM_PROPERTIES
};
static GParamSpec* vala_dmap_db_properties[VALA_DMAP_DB_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ValaDmapDb {
	GObject parent_instance;
	ValaDmapDbPrivate * priv;
};

struct _ValaDmapDbClass {
	GObjectClass parent_class;
};

struct _ValaDmapDbPrivate {
	GeeArrayList* db;
};

static gint ValaDmapDb_private_offset;
static gpointer vala_dmap_db_parent_class = NULL;
static DmapDbInterface * vala_dmap_db_dmap_db_parent_iface = NULL;

VALA_EXTERN GType vala_dmap_db_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ValaDmapDb, g_object_unref)
static guint vala_dmap_db_real_add (DmapDb* base,
                             DmapRecord* record,
                             GError** error);
static guint vala_dmap_db_real_add_path (DmapDb* base,
                                  const gchar* path,
                                  GError** error);
static guint vala_dmap_db_real_add_with_id (DmapDb* base,
                                     DmapRecord* record,
                                     guint id,
                                     GError** error);
static gint64 vala_dmap_db_real_count (DmapDb* base);
static void vala_dmap_db_real_foreach (DmapDb* base,
                                DmapIdRecordFunc func,
                                gpointer func_target);
static DmapRecord* vala_dmap_db_real_lookup_by_id (DmapDb* base,
                                            guint id);
static guint vala_dmap_db_real_lookup_id_by_location (DmapDb* base,
                                               const gchar* location);
VALA_EXTERN ValaDmapDb* vala_dmap_db_new (void);
VALA_EXTERN ValaDmapDb* vala_dmap_db_construct (GType object_type);
static void vala_dmap_db_finalize (GObject * obj);
static GType vala_dmap_db_get_type_once (void);

static inline gpointer
vala_dmap_db_get_instance_private (ValaDmapDb* self)
{
	return G_STRUCT_MEMBER_P (self, ValaDmapDb_private_offset);
}

static guint
vala_dmap_db_real_add (DmapDb* base,
                       DmapRecord* record,
                       GError** error)
{
	ValaDmapDb * self;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	guint result;
	self = (ValaDmapDb*) base;
	g_return_val_if_fail (record != NULL, 0U);
	_tmp0_ = self->priv->db;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, G_TYPE_CHECK_INSTANCE_CAST (record, dmap_record_get_type (), DmapRecord));
	_tmp1_ = self->priv->db;
	_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	result = (guint) _tmp3_;
	return result;
}

static guint
vala_dmap_db_real_add_path (DmapDb* base,
                            const gchar* path,
                            GError** error)
{
	ValaDmapDb * self;
	self = (ValaDmapDb*) base;
	g_return_val_if_fail (path != NULL, 0U);
	g_error ("vala-dmap-db.vala:35: add_path not implemented");
}

static guint
vala_dmap_db_real_add_with_id (DmapDb* base,
                               DmapRecord* record,
                               guint id,
                               GError** error)
{
	ValaDmapDb * self;
	self = (ValaDmapDb*) base;
	g_return_val_if_fail (record != NULL, 0U);
	g_error ("vala-dmap-db.vala:39: add_with_id not implemented");
}

static gint64
vala_dmap_db_real_count (DmapDb* base)
{
	ValaDmapDb * self;
	GeeArrayList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint64 result;
	self = (ValaDmapDb*) base;
	_tmp0_ = self->priv->db;
	_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = (gint64) _tmp2_;
	return result;
}

static void
vala_dmap_db_real_foreach (DmapDb* base,
                           DmapIdRecordFunc func,
                           gpointer func_target)
{
	ValaDmapDb * self;
	gint i = 0;
	self = (ValaDmapDb*) base;
	{
		gboolean _tmp0_ = FALSE;
		i = 0;
		_tmp0_ = TRUE;
		while (TRUE) {
			GeeArrayList* _tmp2_;
			gint _tmp3_;
			gint _tmp4_;
			GeeArrayList* _tmp5_;
			gpointer _tmp6_;
			if (!_tmp0_) {
				gint _tmp1_;
				_tmp1_ = i;
				i = _tmp1_ + 1;
			}
			_tmp0_ = FALSE;
			_tmp2_ = self->priv->db;
			_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
			_tmp4_ = _tmp3_;
			if (!(i < _tmp4_)) {
				break;
			}
			_tmp5_ = self->priv->db;
			_tmp6_ = gee_abstract_list_get ((GeeAbstractList*) _tmp5_, i);
			func ((guint) (i + 1), (DmapRecord*) _tmp6_, func_target);
		}
	}
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static DmapRecord*
vala_dmap_db_real_lookup_by_id (DmapDb* base,
                                guint id)
{
	ValaDmapDb * self;
	DmapRecord* record = NULL;
	GeeArrayList* _tmp0_;
	gpointer _tmp1_;
	DmapRecord* _tmp2_;
	DmapRecord* result;
	self = (ValaDmapDb*) base;
	_tmp0_ = self->priv->db;
	_tmp1_ = gee_abstract_list_get ((GeeAbstractList*) _tmp0_, ((gint) id) - 1);
	record = (DmapRecord*) _tmp1_;
	g_object_ref ((GObject*) record);
	_tmp2_ = _g_object_ref0 (record);
	result = _tmp2_;
	return result;
}

static guint
vala_dmap_db_real_lookup_id_by_location (DmapDb* base,
                                         const gchar* location)
{
	ValaDmapDb * self;
	self = (ValaDmapDb*) base;
	g_return_val_if_fail (location != NULL, 0U);
	g_error ("vala-dmap-db.vala:65: lookup_id_by_location not implemented");
}

ValaDmapDb*
vala_dmap_db_construct (GType object_type)
{
	ValaDmapDb * self = NULL;
	self = (ValaDmapDb*) g_object_new (object_type, NULL);
	return self;
}

ValaDmapDb*
vala_dmap_db_new (void)
{
	return vala_dmap_db_construct (TYPE_VALA_DMAP_DB);
}

static void
vala_dmap_db_class_init (ValaDmapDbClass * klass,
                         gpointer klass_data)
{
	vala_dmap_db_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ValaDmapDb_private_offset);
	G_OBJECT_CLASS (klass)->finalize = vala_dmap_db_finalize;
}

static void
vala_dmap_db_dmap_db_interface_init (DmapDbInterface * iface,
                                     gpointer iface_data)
{
	vala_dmap_db_dmap_db_parent_iface = g_type_interface_peek_parent (iface);
	iface->add = (guint (*) (DmapDb*, DmapRecord*, GError**)) vala_dmap_db_real_add;
	iface->add_path = (guint (*) (DmapDb*, const gchar*, GError**)) vala_dmap_db_real_add_path;
	iface->add_with_id = (guint (*) (DmapDb*, DmapRecord*, guint, GError**)) vala_dmap_db_real_add_with_id;
	iface->count = (gint64 (*) (DmapDb*)) vala_dmap_db_real_count;
	iface->foreach = (void (*) (DmapDb*, DmapIdRecordFunc, gpointer)) vala_dmap_db_real_foreach;
	iface->lookup_by_id = (DmapRecord* (*) (DmapDb*, guint)) vala_dmap_db_real_lookup_by_id;
	iface->lookup_id_by_location = (guint (*) (DmapDb*, const gchar*)) vala_dmap_db_real_lookup_id_by_location;
}

static void
vala_dmap_db_instance_init (ValaDmapDb * self,
                            gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = vala_dmap_db_get_instance_private (self);
	_tmp0_ = gee_array_list_new (dmap_record_get_type (), NULL, NULL, NULL, NULL, NULL);
	self->priv->db = _tmp0_;
}

static void
vala_dmap_db_finalize (GObject * obj)
{
	ValaDmapDb * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_VALA_DMAP_DB, ValaDmapDb);
	_g_object_unref0 (self->priv->db);
	G_OBJECT_CLASS (vala_dmap_db_parent_class)->finalize (obj);
}

static GType
vala_dmap_db_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValaDmapDbClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_dmap_db_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaDmapDb), 0, (GInstanceInitFunc) vala_dmap_db_instance_init, NULL };
	static const GInterfaceInfo dmap_db_info = { (GInterfaceInitFunc) vala_dmap_db_dmap_db_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType vala_dmap_db_type_id;
	vala_dmap_db_type_id = g_type_register_static (G_TYPE_OBJECT, "ValaDmapDb", &g_define_type_info, 0);
	g_type_add_interface_static (vala_dmap_db_type_id, dmap_db_get_type (), &dmap_db_info);
	ValaDmapDb_private_offset = g_type_add_instance_private (vala_dmap_db_type_id, sizeof (ValaDmapDbPrivate));
	return vala_dmap_db_type_id;
}

GType
vala_dmap_db_get_type (void)
{
	static volatile gsize vala_dmap_db_type_id__once = 0;
	if (g_once_init_enter (&vala_dmap_db_type_id__once)) {
		GType vala_dmap_db_type_id;
		vala_dmap_db_type_id = vala_dmap_db_get_type_once ();
		g_once_init_leave (&vala_dmap_db_type_id__once, vala_dmap_db_type_id);
	}
	return vala_dmap_db_type_id__once;
}