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

#include "xmpp-vala.h"
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gobject/gvaluecollector.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _XmppXepServiceDiscoveryParamSpecItem XmppXepServiceDiscoveryParamSpecItem;

struct _XmppXepServiceDiscoveryParamSpecItem {
	GParamSpec parent_instance;
};

static gpointer xmpp_xep_service_discovery_item_parent_class = NULL;

static void xmpp_xep_service_discovery_item_finalize (XmppXepServiceDiscoveryItem * obj);
static GType xmpp_xep_service_discovery_item_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gpointer
_xmpp_jid_ref0 (gpointer self)
{
	return self ? xmpp_jid_ref (self) : NULL;
}

XmppXepServiceDiscoveryItem*
xmpp_xep_service_discovery_item_construct (GType object_type,
                                           XmppJid* jid,
                                           const gchar* name,
                                           const gchar* node)
{
	XmppXepServiceDiscoveryItem* self = NULL;
	XmppJid* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (jid != NULL, NULL);
	self = (XmppXepServiceDiscoveryItem*) g_type_create_instance (object_type);
	_tmp0_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (self->jid);
	self->jid = _tmp0_;
	_tmp1_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp1_;
	_tmp2_ = g_strdup (node);
	_g_free0 (self->node);
	self->node = _tmp2_;
	return self;
}

XmppXepServiceDiscoveryItem*
xmpp_xep_service_discovery_item_new (XmppJid* jid,
                                     const gchar* name,
                                     const gchar* node)
{
	return xmpp_xep_service_discovery_item_construct (XMPP_XEP_SERVICE_DISCOVERY_TYPE_ITEM, jid, name, node);
}

static void
xmpp_xep_service_discovery_value_item_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
xmpp_xep_service_discovery_value_item_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		xmpp_xep_service_discovery_item_unref (value->data[0].v_pointer);
	}
}

static void
xmpp_xep_service_discovery_value_item_copy_value (const GValue* src_value,
                                                  GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = xmpp_xep_service_discovery_item_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
xmpp_xep_service_discovery_value_item_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
xmpp_xep_service_discovery_value_item_collect_value (GValue* value,
                                                     guint n_collect_values,
                                                     GTypeCValue* collect_values,
                                                     guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		XmppXepServiceDiscoveryItem * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = xmpp_xep_service_discovery_item_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
xmpp_xep_service_discovery_value_item_lcopy_value (const GValue* value,
                                                   guint n_collect_values,
                                                   GTypeCValue* collect_values,
                                                   guint collect_flags)
{
	XmppXepServiceDiscoveryItem ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = xmpp_xep_service_discovery_item_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
xmpp_xep_service_discovery_param_spec_item (const gchar* name,
                                            const gchar* nick,
                                            const gchar* blurb,
                                            GType object_type,
                                            GParamFlags flags)
{
	XmppXepServiceDiscoveryParamSpecItem* spec;
	g_return_val_if_fail (g_type_is_a (object_type, XMPP_XEP_SERVICE_DISCOVERY_TYPE_ITEM), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
xmpp_xep_service_discovery_value_get_item (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_SERVICE_DISCOVERY_TYPE_ITEM), NULL);
	return value->data[0].v_pointer;
}

void
xmpp_xep_service_discovery_value_set_item (GValue* value,
                                           gpointer v_object)
{
	XmppXepServiceDiscoveryItem * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_SERVICE_DISCOVERY_TYPE_ITEM));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_SERVICE_DISCOVERY_TYPE_ITEM));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		xmpp_xep_service_discovery_item_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_service_discovery_item_unref (old);
	}
}

void
xmpp_xep_service_discovery_value_take_item (GValue* value,
                                            gpointer v_object)
{
	XmppXepServiceDiscoveryItem * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_SERVICE_DISCOVERY_TYPE_ITEM));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_SERVICE_DISCOVERY_TYPE_ITEM));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_service_discovery_item_unref (old);
	}
}

static void
xmpp_xep_service_discovery_item_class_init (XmppXepServiceDiscoveryItemClass * klass,
                                            gpointer klass_data)
{
	xmpp_xep_service_discovery_item_parent_class = g_type_class_peek_parent (klass);
	((XmppXepServiceDiscoveryItemClass *) klass)->finalize = xmpp_xep_service_discovery_item_finalize;
}

static void
xmpp_xep_service_discovery_item_instance_init (XmppXepServiceDiscoveryItem * self,
                                               gpointer klass)
{
	self->ref_count = 1;
}

static void
xmpp_xep_service_discovery_item_finalize (XmppXepServiceDiscoveryItem * obj)
{
	XmppXepServiceDiscoveryItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_SERVICE_DISCOVERY_TYPE_ITEM, XmppXepServiceDiscoveryItem);
	g_signal_handlers_destroy (self);
	_xmpp_jid_unref0 (self->jid);
	_g_free0 (self->name);
	_g_free0 (self->node);
}

static GType
xmpp_xep_service_discovery_item_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_xep_service_discovery_value_item_init, xmpp_xep_service_discovery_value_item_free_value, xmpp_xep_service_discovery_value_item_copy_value, xmpp_xep_service_discovery_value_item_peek_pointer, "p", xmpp_xep_service_discovery_value_item_collect_value, "p", xmpp_xep_service_discovery_value_item_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepServiceDiscoveryItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_service_discovery_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepServiceDiscoveryItem), 0, (GInstanceInitFunc) xmpp_xep_service_discovery_item_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType xmpp_xep_service_discovery_item_type_id;
	xmpp_xep_service_discovery_item_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppXepServiceDiscoveryItem", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return xmpp_xep_service_discovery_item_type_id;
}

GType
xmpp_xep_service_discovery_item_get_type (void)
{
	static volatile gsize xmpp_xep_service_discovery_item_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_service_discovery_item_type_id__once)) {
		GType xmpp_xep_service_discovery_item_type_id;
		xmpp_xep_service_discovery_item_type_id = xmpp_xep_service_discovery_item_get_type_once ();
		g_once_init_leave (&xmpp_xep_service_discovery_item_type_id__once, xmpp_xep_service_discovery_item_type_id);
	}
	return xmpp_xep_service_discovery_item_type_id__once;
}

gpointer
xmpp_xep_service_discovery_item_ref (gpointer instance)
{
	XmppXepServiceDiscoveryItem * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
xmpp_xep_service_discovery_item_unref (gpointer instance)
{
	XmppXepServiceDiscoveryItem * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_XEP_SERVICE_DISCOVERY_ITEM_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

