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

/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
/*
 *
 * Copyright (C) 2016  Daniel Espinosa <esodan@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library 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
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *      Daniel Espinosa <esodan@gmail.com>
 */

#include "gxml/gxml.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include "gxml.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

enum  {
	GXML_EVENT_0_PROPERTY,
	GXML_EVENT_ETYPE_PROPERTY,
	GXML_EVENT_EVENT_TARGET_PROPERTY,
	GXML_EVENT_CURRENT_TARGET_PROPERTY,
	GXML_EVENT_BUBBLES_PROPERTY,
	GXML_EVENT_CANCELABLE_PROPERTY,
	GXML_EVENT_IS_TRUSTED_PROPERTY,
	GXML_EVENT_TIME_STAMP_PROPERTY,
	GXML_EVENT_DEFAULT_PREVENTED_PROPERTY,
	GXML_EVENT_EVENT_PHASE_PROPERTY,
	GXML_EVENT_NUM_PROPERTIES
};
static GParamSpec* gxml_event_properties[GXML_EVENT_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	GXML_CUSTOM_EVENT_0_PROPERTY,
	GXML_CUSTOM_EVENT_DETAIL_PROPERTY,
	GXML_CUSTOM_EVENT_NUM_PROPERTIES
};
static GParamSpec* gxml_custom_event_properties[GXML_CUSTOM_EVENT_NUM_PROPERTIES];

static gpointer gxml_event_parent_class = NULL;
static GXmlDomEventIface * gxml_event_gxml_dom_event_parent_iface = NULL;
static gpointer gxml_custom_event_parent_class = NULL;

static void gxml_event_real_stop_propagation (GXmlDomEvent* base);
static void gxml_event_real_stop_immediate_propagation (GXmlDomEvent* base);
static void gxml_event_real_prevent_default (GXmlDomEvent* base);
static void gxml_event_real_init_event (GXmlDomEvent* base,
                                 const gchar* type,
                                 gboolean bubbles,
                                 gboolean cancelable);
static void gxml_event_finalize (GObject * obj);
static GType gxml_event_get_type_once (void);
static void _vala_gxml_event_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec);
static void gxml_custom_event_finalize (GObject * obj);
static GType gxml_custom_event_get_type_once (void);
static void _vala_gxml_custom_event_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static const gchar*
gxml_event_real_get_etype (GXmlDomEvent* base)
{
	const gchar* result;
	GXmlEvent* self;
	const gchar* _tmp0_;
	self = (GXmlEvent*) base;
	_tmp0_ = self->_etype;
	result = _tmp0_;
	return result;
}

static GXmlDomEventTarget*
gxml_event_real_get_event_target (GXmlDomEvent* base)
{
	GXmlDomEventTarget* result;
	GXmlEvent* self;
	GXmlDomEventTarget* _tmp0_;
	self = (GXmlEvent*) base;
	_tmp0_ = self->_event_target;
	result = _tmp0_;
	return result;
}

static GXmlDomEventTarget*
gxml_event_real_get_current_target (GXmlDomEvent* base)
{
	GXmlDomEventTarget* result;
	GXmlEvent* self;
	GXmlDomEventTarget* _tmp0_;
	self = (GXmlEvent*) base;
	_tmp0_ = self->_current_target;
	result = _tmp0_;
	return result;
}

static gboolean
gxml_event_real_get_bubbles (GXmlDomEvent* base)
{
	gboolean result;
	GXmlEvent* self;
	self = (GXmlEvent*) base;
	result = self->_bubbles;
	return result;
}

static gboolean
gxml_event_real_get_cancelable (GXmlDomEvent* base)
{
	gboolean result;
	GXmlEvent* self;
	self = (GXmlEvent*) base;
	result = self->_cancelable;
	return result;
}

static gboolean
gxml_event_real_get_is_trusted (GXmlDomEvent* base)
{
	gboolean result;
	GXmlEvent* self;
	self = (GXmlEvent*) base;
	result = self->_is_trusted;
	return result;
}

static GXmlDomTimeStamp*
gxml_event_real_get_time_stamp (GXmlDomEvent* base)
{
	GXmlDomTimeStamp* result;
	GXmlEvent* self;
	GXmlDomTimeStamp* _tmp0_;
	self = (GXmlEvent*) base;
	_tmp0_ = self->_time_stamp;
	result = _tmp0_;
	return result;
}

static gboolean
gxml_event_real_get_default_prevented (GXmlDomEvent* base)
{
	gboolean result;
	GXmlEvent* self;
	self = (GXmlEvent*) base;
	result = self->_default_prevented;
	return result;
}

static GXmlDomEventPhase
gxml_event_real_get_event_phase (GXmlDomEvent* base)
{
	GXmlDomEventPhase result;
	GXmlEvent* self;
	self = (GXmlEvent*) base;
	result = self->_event_phase;
	return result;
}

static void
gxml_event_real_stop_propagation (GXmlDomEvent* base)
{
	GXmlEvent * self;
	self = (GXmlEvent*) base;
	self->_flags = self->_flags & GXML_DOM_EVENT_FLAGS_STOP_PROPAGATION_FLAG;
}

static void
gxml_event_real_stop_immediate_propagation (GXmlDomEvent* base)
{
	GXmlEvent * self;
	self = (GXmlEvent*) base;
	self->_flags = self->_flags & GXML_DOM_EVENT_FLAGS_STOP_IMMEDIATE_PROPAGATION_FLAG;
}

static void
gxml_event_real_prevent_default (GXmlDomEvent* base)
{
	GXmlEvent * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	self = (GXmlEvent*) base;
	_tmp0_ = gxml_dom_event_get_cancelable ((GXmlDomEvent*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		self->_flags = self->_flags & GXML_DOM_EVENT_FLAGS_CANCELED_FLAG;
	}
}

static void
gxml_event_real_init_event (GXmlDomEvent* base,
                            const gchar* type,
                            gboolean bubbles,
                            gboolean cancelable)
{
	GXmlEvent * self;
	gchar* _tmp0_;
	self = (GXmlEvent*) base;
	g_return_if_fail (type != NULL);
	_tmp0_ = g_strdup (type);
	_g_free0 (self->_etype);
	self->_etype = _tmp0_;
	self->_bubbles = bubbles;
	self->_cancelable = cancelable;
}

GXmlEvent*
gxml_event_construct (GType object_type)
{
	GXmlEvent * self = NULL;
	self = (GXmlEvent*) g_object_new (object_type, NULL);
	return self;
}

GXmlEvent*
gxml_event_new (void)
{
	return gxml_event_construct (GXML_TYPE_EVENT);
}

static void
gxml_event_class_init (GXmlEventClass * klass,
                       gpointer klass_data)
{
	gxml_event_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_event_get_property;
	G_OBJECT_CLASS (klass)->finalize = gxml_event_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_EVENT_ETYPE_PROPERTY, gxml_event_properties[GXML_EVENT_ETYPE_PROPERTY] = g_param_spec_string ("etype", "etype", "etype", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_EVENT_EVENT_TARGET_PROPERTY, gxml_event_properties[GXML_EVENT_EVENT_TARGET_PROPERTY] = g_param_spec_object ("event-target", "event-target", "event-target", GXML_TYPE_DOM_EVENT_TARGET, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_EVENT_CURRENT_TARGET_PROPERTY, gxml_event_properties[GXML_EVENT_CURRENT_TARGET_PROPERTY] = g_param_spec_object ("current-target", "current-target", "current-target", GXML_TYPE_DOM_EVENT_TARGET, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_EVENT_BUBBLES_PROPERTY, gxml_event_properties[GXML_EVENT_BUBBLES_PROPERTY] = g_param_spec_boolean ("bubbles", "bubbles", "bubbles", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_EVENT_CANCELABLE_PROPERTY, gxml_event_properties[GXML_EVENT_CANCELABLE_PROPERTY] = g_param_spec_boolean ("cancelable", "cancelable", "cancelable", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_EVENT_IS_TRUSTED_PROPERTY, gxml_event_properties[GXML_EVENT_IS_TRUSTED_PROPERTY] = g_param_spec_boolean ("is-trusted", "is-trusted", "is-trusted", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_EVENT_TIME_STAMP_PROPERTY, gxml_event_properties[GXML_EVENT_TIME_STAMP_PROPERTY] = g_param_spec_object ("time-stamp", "time-stamp", "time-stamp", GXML_TYPE_DOM_TIME_STAMP, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_EVENT_DEFAULT_PREVENTED_PROPERTY, gxml_event_properties[GXML_EVENT_DEFAULT_PREVENTED_PROPERTY] = g_param_spec_boolean ("default-prevented", "default-prevented", "default-prevented", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_EVENT_EVENT_PHASE_PROPERTY, gxml_event_properties[GXML_EVENT_EVENT_PHASE_PROPERTY] = g_param_spec_enum ("event-phase", "event-phase", "event-phase", GXML_DOM_EVENT_TYPE_PHASE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gxml_event_gxml_dom_event_interface_init (GXmlDomEventIface * iface,
                                          gpointer iface_data)
{
	gxml_event_gxml_dom_event_parent_iface = g_type_interface_peek_parent (iface);
	iface->stop_propagation = (void (*) (GXmlDomEvent*)) gxml_event_real_stop_propagation;
	iface->stop_immediate_propagation = (void (*) (GXmlDomEvent*)) gxml_event_real_stop_immediate_propagation;
	iface->prevent_default = (void (*) (GXmlDomEvent*)) gxml_event_real_prevent_default;
	iface->init_event = (void (*) (GXmlDomEvent*, const gchar*, gboolean, gboolean)) gxml_event_real_init_event;
	iface->get_etype = gxml_event_real_get_etype;
	iface->get_event_target = gxml_event_real_get_event_target;
	iface->get_current_target = gxml_event_real_get_current_target;
	iface->get_bubbles = gxml_event_real_get_bubbles;
	iface->get_cancelable = gxml_event_real_get_cancelable;
	iface->get_is_trusted = gxml_event_real_get_is_trusted;
	iface->get_time_stamp = gxml_event_real_get_time_stamp;
	iface->get_default_prevented = gxml_event_real_get_default_prevented;
	iface->get_event_phase = gxml_event_real_get_event_phase;
}

static void
gxml_event_instance_init (GXmlEvent * self,
                          gpointer klass)
{
	GXmlDomTimeStamp* _tmp0_;
	self->_is_trusted = FALSE;
	_tmp0_ = gxml_dom_time_stamp_new ();
	self->_time_stamp = _tmp0_;
}

static void
gxml_event_finalize (GObject * obj)
{
	GXmlEvent * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_EVENT, GXmlEvent);
	_g_free0 (self->_etype);
	_g_object_unref0 (self->_event_target);
	_g_object_unref0 (self->_current_target);
	_g_object_unref0 (self->_time_stamp);
	G_OBJECT_CLASS (gxml_event_parent_class)->finalize (obj);
}

/**
 * DOM4 An event handler, powered by libxml2 library.
 */
static GType
gxml_event_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlEventClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_event_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlEvent), 0, (GInstanceInitFunc) gxml_event_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_event_info = { (GInterfaceInitFunc) gxml_event_gxml_dom_event_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_event_type_id;
	gxml_event_type_id = g_type_register_static (G_TYPE_OBJECT, "GXmlEvent", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_event_type_id, GXML_TYPE_DOM_EVENT, &gxml_dom_event_info);
	return gxml_event_type_id;
}

GType
gxml_event_get_type (void)
{
	static volatile gsize gxml_event_type_id__once = 0;
	if (g_once_init_enter (&gxml_event_type_id__once)) {
		GType gxml_event_type_id;
		gxml_event_type_id = gxml_event_get_type_once ();
		g_once_init_leave (&gxml_event_type_id__once, gxml_event_type_id);
	}
	return gxml_event_type_id__once;
}

static void
_vala_gxml_event_get_property (GObject * object,
                               guint property_id,
                               GValue * value,
                               GParamSpec * pspec)
{
	GXmlEvent * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_EVENT, GXmlEvent);
	switch (property_id) {
		case GXML_EVENT_ETYPE_PROPERTY:
		g_value_set_string (value, gxml_dom_event_get_etype ((GXmlDomEvent*) self));
		break;
		case GXML_EVENT_EVENT_TARGET_PROPERTY:
		g_value_set_object (value, gxml_dom_event_get_event_target ((GXmlDomEvent*) self));
		break;
		case GXML_EVENT_CURRENT_TARGET_PROPERTY:
		g_value_set_object (value, gxml_dom_event_get_current_target ((GXmlDomEvent*) self));
		break;
		case GXML_EVENT_BUBBLES_PROPERTY:
		g_value_set_boolean (value, gxml_dom_event_get_bubbles ((GXmlDomEvent*) self));
		break;
		case GXML_EVENT_CANCELABLE_PROPERTY:
		g_value_set_boolean (value, gxml_dom_event_get_cancelable ((GXmlDomEvent*) self));
		break;
		case GXML_EVENT_IS_TRUSTED_PROPERTY:
		g_value_set_boolean (value, gxml_dom_event_get_is_trusted ((GXmlDomEvent*) self));
		break;
		case GXML_EVENT_TIME_STAMP_PROPERTY:
		g_value_set_object (value, gxml_dom_event_get_time_stamp ((GXmlDomEvent*) self));
		break;
		case GXML_EVENT_DEFAULT_PREVENTED_PROPERTY:
		g_value_set_boolean (value, gxml_dom_event_get_default_prevented ((GXmlDomEvent*) self));
		break;
		case GXML_EVENT_EVENT_PHASE_PROPERTY:
		g_value_set_enum (value, gxml_dom_event_get_event_phase ((GXmlDomEvent*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

void
gxml_custom_event_get_detail (GXmlCustomEvent* self,
                              GValue * result)
{
	GValue _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->_detail;
	*result = _tmp0_;
	return;
}

void
gxml_custom_event_init_custom_event (GXmlCustomEvent* self,
                                     const gchar* type,
                                     gboolean bubbles,
                                     gboolean cancelable,
                                     GValue* detail)
{
	gchar* _tmp0_;
	GValue _tmp1_;
	GValue _tmp2_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (type != NULL);
	_tmp0_ = g_strdup (type);
	_g_free0 (((GXmlEvent*) self)->_etype);
	((GXmlEvent*) self)->_etype = _tmp0_;
	((GXmlEvent*) self)->_bubbles = bubbles;
	((GXmlEvent*) self)->_cancelable = cancelable;
	_tmp1_ = *detail;
	if (G_IS_VALUE (&_tmp1_)) {
		g_value_init (&_tmp2_, G_VALUE_TYPE (&_tmp1_));
		g_value_copy (&_tmp1_, &_tmp2_);
	} else {
		_tmp2_ = _tmp1_;
	}
	G_IS_VALUE (&self->_detail) ? (g_value_unset (&self->_detail), NULL) : NULL;
	self->_detail = _tmp2_;
}

GXmlCustomEvent*
gxml_custom_event_construct (GType object_type)
{
	GXmlCustomEvent * self = NULL;
	self = (GXmlCustomEvent*) gxml_event_construct (object_type);
	return self;
}

GXmlCustomEvent*
gxml_custom_event_new (void)
{
	return gxml_custom_event_construct (GXML_TYPE_CUSTOM_EVENT);
}

static void
gxml_custom_event_class_init (GXmlCustomEventClass * klass,
                              gpointer klass_data)
{
	gxml_custom_event_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_custom_event_get_property;
	G_OBJECT_CLASS (klass)->finalize = gxml_custom_event_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_CUSTOM_EVENT_DETAIL_PROPERTY, gxml_custom_event_properties[GXML_CUSTOM_EVENT_DETAIL_PROPERTY] = g_param_spec_boxed ("detail", "detail", "detail", G_TYPE_VALUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gxml_custom_event_instance_init (GXmlCustomEvent * self,
                                 gpointer klass)
{
}

static void
gxml_custom_event_finalize (GObject * obj)
{
	GXmlCustomEvent * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_CUSTOM_EVENT, GXmlCustomEvent);
	G_IS_VALUE (&self->_detail) ? (g_value_unset (&self->_detail), NULL) : NULL;
	G_OBJECT_CLASS (gxml_custom_event_parent_class)->finalize (obj);
}

/**
 * Custom event handler, powered by libxml2 library.
 */
static GType
gxml_custom_event_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlCustomEventClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_custom_event_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlCustomEvent), 0, (GInstanceInitFunc) gxml_custom_event_instance_init, NULL };
	GType gxml_custom_event_type_id;
	gxml_custom_event_type_id = g_type_register_static (GXML_TYPE_EVENT, "GXmlCustomEvent", &g_define_type_info, 0);
	return gxml_custom_event_type_id;
}

GType
gxml_custom_event_get_type (void)
{
	static volatile gsize gxml_custom_event_type_id__once = 0;
	if (g_once_init_enter (&gxml_custom_event_type_id__once)) {
		GType gxml_custom_event_type_id;
		gxml_custom_event_type_id = gxml_custom_event_get_type_once ();
		g_once_init_leave (&gxml_custom_event_type_id__once, gxml_custom_event_type_id);
	}
	return gxml_custom_event_type_id__once;
}

static void
_vala_gxml_custom_event_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	GXmlCustomEvent * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_CUSTOM_EVENT, GXmlCustomEvent);
	switch (property_id) {
		case GXML_CUSTOM_EVENT_DETAIL_PROPERTY:
		{
			GValue boxed;
			gxml_custom_event_get_detail (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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;
}

