/* WeakRef.c generated by valac 0.26.2, the Vala compiler
 * generated from WeakRef.vala, do not modify */

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2013 Timm Bäder
 *
 *  corebird 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 3 of the License, or
 *  (at your option) any later version.
 *
 *  corebird 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 corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>


#define TYPE_WEAK_REF (weak_ref_get_type ())
#define WEAK_REF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WEAK_REF, WeakRef))
#define WEAK_REF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WEAK_REF, WeakRefClass))
#define IS_WEAK_REF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WEAK_REF))
#define IS_WEAK_REF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WEAK_REF))
#define WEAK_REF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WEAK_REF, WeakRefClass))

typedef struct _WeakRef WeakRef;
typedef struct _WeakRefClass WeakRefClass;
typedef struct _WeakRefPrivate WeakRefPrivate;

struct _WeakRef {
	GObject parent_instance;
	WeakRefPrivate * priv;
};

struct _WeakRefClass {
	GObjectClass parent_class;
};

struct _WeakRefPrivate {
	GType g_type;
	GBoxedCopyFunc g_dup_func;
	GDestroyNotify g_destroy_func;
	GWeakRef wr;
};


static gpointer weak_ref_parent_class = NULL;

GType weak_ref_get_type (void) G_GNUC_CONST;
#define WEAK_REF_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_WEAK_REF, WeakRefPrivate))
enum  {
	WEAK_REF_DUMMY_PROPERTY,
	WEAK_REF_G_TYPE,
	WEAK_REF_G_DUP_FUNC,
	WEAK_REF_G_DESTROY_FUNC
};
WeakRef* weak_ref_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer obj);
WeakRef* weak_ref_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer obj);
gpointer weak_ref_get (WeakRef* self);
static void weak_ref_finalize (GObject* obj);
static void _vala_weak_ref_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_weak_ref_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


WeakRef* weak_ref_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer obj) {
	WeakRef * self = NULL;
	gconstpointer _tmp0_ = NULL;
	self = (WeakRef*) g_object_new (object_type, NULL);
	self->priv->g_type = g_type;
	self->priv->g_dup_func = g_dup_func;
	self->priv->g_destroy_func = g_destroy_func;
	_tmp0_ = obj;
	g_weak_ref_clear (&self->priv->wr);
	g_weak_ref_init (&self->priv->wr, G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, G_TYPE_OBJECT, GObject));
	return self;
}


WeakRef* weak_ref_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, gconstpointer obj) {
	return weak_ref_construct (TYPE_WEAK_REF, g_type, g_dup_func, g_destroy_func, obj);
}


gpointer weak_ref_get (WeakRef* self) {
	gpointer result = NULL;
	GObject* _tmp0_ = NULL;
	g_return_val_if_fail (IS_WEAK_REF (self), NULL);
	_tmp0_ = g_weak_ref_get (&self->priv->wr);
	result = _tmp0_;
	return result;
}


static void weak_ref_class_init (WeakRefClass * klass) {
	weak_ref_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (WeakRefPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_weak_ref_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_weak_ref_set_property;
	G_OBJECT_CLASS (klass)->finalize = weak_ref_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WEAK_REF_G_TYPE, g_param_spec_gtype ("g-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WEAK_REF_G_DUP_FUNC, g_param_spec_pointer ("g-dup-func", "dup func", "dup func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), WEAK_REF_G_DESTROY_FUNC, g_param_spec_pointer ("g-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}


static void weak_ref_instance_init (WeakRef * self) {
	self->priv = WEAK_REF_GET_PRIVATE (self);
}


static void weak_ref_finalize (GObject* obj) {
	WeakRef * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_WEAK_REF, WeakRef);
	g_weak_ref_clear (&self->priv->wr);
	G_OBJECT_CLASS (weak_ref_parent_class)->finalize (obj);
}


GType weak_ref_get_type (void) {
	static volatile gsize weak_ref_type_id__volatile = 0;
	if (g_once_init_enter (&weak_ref_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (WeakRefClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) weak_ref_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WeakRef), 0, (GInstanceInitFunc) weak_ref_instance_init, NULL };
		GType weak_ref_type_id;
		weak_ref_type_id = g_type_register_static (G_TYPE_OBJECT, "WeakRef", &g_define_type_info, 0);
		g_once_init_leave (&weak_ref_type_id__volatile, weak_ref_type_id);
	}
	return weak_ref_type_id__volatile;
}


static void _vala_weak_ref_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	WeakRef * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_WEAK_REF, WeakRef);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_weak_ref_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	WeakRef * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_WEAK_REF, WeakRef);
	switch (property_id) {
		case WEAK_REF_G_TYPE:
		self->priv->g_type = g_value_get_gtype (value);
		break;
		case WEAK_REF_G_DUP_FUNC:
		self->priv->g_dup_func = g_value_get_pointer (value);
		break;
		case WEAK_REF_G_DESTROY_FUNC:
		self->priv->g_destroy_func = g_value_get_pointer (value);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



