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

#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <string.h>
#include <cairo-gobject.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
#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 PDFPC_TYPE_DRAWING_COMMAND (pdfpc_drawing_command_get_type ())
typedef struct _pdfpcDrawingCommand pdfpcDrawingCommand;

#define PDFPC_TYPE_DRAWING_COMMAND_LIST (pdfpc_drawing_command_list_get_type ())
#define PDFPC_DRAWING_COMMAND_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_TYPE_DRAWING_COMMAND_LIST, pdfpcDrawingCommandList))
#define PDFPC_DRAWING_COMMAND_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_TYPE_DRAWING_COMMAND_LIST, pdfpcDrawingCommandListClass))
#define PDFPC_IS_DRAWING_COMMAND_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_TYPE_DRAWING_COMMAND_LIST))
#define PDFPC_IS_DRAWING_COMMAND_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_TYPE_DRAWING_COMMAND_LIST))
#define PDFPC_DRAWING_COMMAND_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_TYPE_DRAWING_COMMAND_LIST, pdfpcDrawingCommandListClass))

typedef struct _pdfpcDrawingCommandList pdfpcDrawingCommandList;
typedef struct _pdfpcDrawingCommandListClass pdfpcDrawingCommandListClass;
typedef struct _pdfpcDrawingCommandListPrivate pdfpcDrawingCommandListPrivate;
#define _pdfpc_drawing_command_free0(var) ((var == NULL) ? NULL : (var = (pdfpc_drawing_command_free (var), NULL)))
typedef struct _Block4Data Block4Data;
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
#define _pdfpc_drawing_command_list_unref0(var) ((var == NULL) ? NULL : (var = (pdfpc_drawing_command_list_unref (var), NULL)))
typedef struct _pdfpcParamSpecDrawingCommandList pdfpcParamSpecDrawingCommandList;

struct _pdfpcDrawingCommand {
	gboolean new_path;
	gboolean is_eraser;
	gdouble x1;
	gdouble y1;
	gdouble x2;
	gdouble y2;
	gdouble lwidth;
	gdouble red;
	gdouble green;
	gdouble blue;
	gdouble alpha;
};

struct _pdfpcDrawingCommandList {
	GTypeInstance parent_instance;
	volatile int ref_count;
	pdfpcDrawingCommandListPrivate * priv;
	GList* drawing_commands;
	GList* redo_commands;
};

struct _pdfpcDrawingCommandListClass {
	GTypeClass parent_class;
	void (*finalize) (pdfpcDrawingCommandList *self);
};

struct _Block4Data {
	int _ref_count_;
	pdfpcDrawingCommandList* self;
	cairo_t* cr;
	gint width;
	gint height;
};

struct _pdfpcParamSpecDrawingCommandList {
	GParamSpec parent_instance;
};

static gpointer pdfpc_drawing_command_list_parent_class = NULL;

VALA_EXTERN GType pdfpc_drawing_command_get_type (void) G_GNUC_CONST ;
VALA_EXTERN pdfpcDrawingCommand* pdfpc_drawing_command_dup (const pdfpcDrawingCommand* self);
VALA_EXTERN void pdfpc_drawing_command_free (pdfpcDrawingCommand* self);
VALA_EXTERN gpointer pdfpc_drawing_command_list_ref (gpointer instance);
VALA_EXTERN void pdfpc_drawing_command_list_unref (gpointer instance);
VALA_EXTERN GParamSpec* pdfpc_param_spec_drawing_command_list (const gchar* name,
                                                   const gchar* nick,
                                                   const gchar* blurb,
                                                   GType object_type,
                                                   GParamFlags flags);
VALA_EXTERN void pdfpc_value_set_drawing_command_list (GValue* value,
                                           gpointer v_object);
VALA_EXTERN void pdfpc_value_take_drawing_command_list (GValue* value,
                                            gpointer v_object);
VALA_EXTERN gpointer pdfpc_value_get_drawing_command_list (const GValue* value);
VALA_EXTERN GType pdfpc_drawing_command_list_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDrawingCommandList, pdfpc_drawing_command_list_unref)
static void _pdfpc_drawing_command_free0_ (gpointer var);
static inline void _g_list_free__pdfpc_drawing_command_free0_ (GList* self);
VALA_EXTERN pdfpcDrawingCommandList* pdfpc_drawing_command_list_new (void);
VALA_EXTERN pdfpcDrawingCommandList* pdfpc_drawing_command_list_construct (GType object_type);
VALA_EXTERN void pdfpc_drawing_command_list_clear (pdfpcDrawingCommandList* self);
VALA_EXTERN void pdfpc_drawing_command_list_add_line (pdfpcDrawingCommandList* self,
                                          gboolean is_eraser,
                                          gdouble x1,
                                          gdouble y1,
                                          gdouble x2,
                                          gdouble y2,
                                          gdouble lwidth,
                                          gdouble red,
                                          gdouble green,
                                          gdouble blue,
                                          gdouble alpha);
VALA_EXTERN void pdfpc_drawing_command_list_paint_in_surface (pdfpcDrawingCommandList* self,
                                                  cairo_surface_t* surface);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void __lambda8_ (Block4Data* _data4_,
                 pdfpcDrawingCommand* dc);
static void ___lambda8__gfunc (gconstpointer data,
                        gpointer self);
VALA_EXTERN void pdfpc_drawing_command_list_undo (pdfpcDrawingCommandList* self);
VALA_EXTERN void pdfpc_drawing_command_list_redo (pdfpcDrawingCommandList* self);
static void pdfpc_drawing_command_list_finalize (pdfpcDrawingCommandList * obj);
static GType pdfpc_drawing_command_list_get_type_once (void);

pdfpcDrawingCommand*
pdfpc_drawing_command_dup (const pdfpcDrawingCommand* self)
{
	pdfpcDrawingCommand* dup;
	dup = g_new0 (pdfpcDrawingCommand, 1);
	memcpy (dup, self, sizeof (pdfpcDrawingCommand));
	return dup;
}

void
pdfpc_drawing_command_free (pdfpcDrawingCommand* self)
{
	g_free (self);
}

static GType
pdfpc_drawing_command_get_type_once (void)
{
	GType pdfpc_drawing_command_type_id;
	pdfpc_drawing_command_type_id = g_boxed_type_register_static ("pdfpcDrawingCommand", (GBoxedCopyFunc) pdfpc_drawing_command_dup, (GBoxedFreeFunc) pdfpc_drawing_command_free);
	return pdfpc_drawing_command_type_id;
}

GType
pdfpc_drawing_command_get_type (void)
{
	static volatile gsize pdfpc_drawing_command_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_drawing_command_type_id__once)) {
		GType pdfpc_drawing_command_type_id;
		pdfpc_drawing_command_type_id = pdfpc_drawing_command_get_type_once ();
		g_once_init_leave (&pdfpc_drawing_command_type_id__once, pdfpc_drawing_command_type_id);
	}
	return pdfpc_drawing_command_type_id__once;
}

static void
_pdfpc_drawing_command_free0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (pdfpc_drawing_command_free (var), NULL));
}

static inline void
_g_list_free__pdfpc_drawing_command_free0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _pdfpc_drawing_command_free0_);
}

pdfpcDrawingCommandList*
pdfpc_drawing_command_list_construct (GType object_type)
{
	pdfpcDrawingCommandList* self = NULL;
	self = (pdfpcDrawingCommandList*) g_type_create_instance (object_type);
	pdfpc_drawing_command_list_clear (self);
	return self;
}

pdfpcDrawingCommandList*
pdfpc_drawing_command_list_new (void)
{
	return pdfpc_drawing_command_list_construct (PDFPC_TYPE_DRAWING_COMMAND_LIST);
}

void
pdfpc_drawing_command_list_clear (pdfpcDrawingCommandList* self)
{
	g_return_if_fail (self != NULL);
	(self->drawing_commands == NULL) ? NULL : (self->drawing_commands = (_g_list_free__pdfpc_drawing_command_free0_ (self->drawing_commands), NULL));
	self->drawing_commands = NULL;
	(self->redo_commands == NULL) ? NULL : (self->redo_commands = (_g_list_free__pdfpc_drawing_command_free0_ (self->redo_commands), NULL));
	self->redo_commands = NULL;
}

static gpointer
_pdfpc_drawing_command_dup0 (gpointer self)
{
	return self ? pdfpc_drawing_command_dup (self) : NULL;
}

void
pdfpc_drawing_command_list_add_line (pdfpcDrawingCommandList* self,
                                     gboolean is_eraser,
                                     gdouble x1,
                                     gdouble y1,
                                     gdouble x2,
                                     gdouble y2,
                                     gdouble lwidth,
                                     gdouble red,
                                     gdouble green,
                                     gdouble blue,
                                     gdouble alpha)
{
	gboolean new_path = FALSE;
	gdouble epsilon = 0.0;
	GList* _tmp0_;
	pdfpcDrawingCommand dc = {0};
	pdfpcDrawingCommand _tmp10_;
	pdfpcDrawingCommand* _tmp11_;
	g_return_if_fail (self != NULL);
	(self->redo_commands == NULL) ? NULL : (self->redo_commands = (_g_list_free__pdfpc_drawing_command_free0_ (self->redo_commands), NULL));
	self->redo_commands = NULL;
	new_path = TRUE;
	epsilon = 1e-4;
	_tmp0_ = self->drawing_commands;
	if (_tmp0_ != NULL) {
		pdfpcDrawingCommand* last = NULL;
		GList* _tmp1_;
		GList* _tmp2_;
		gconstpointer _tmp3_;
		pdfpcDrawingCommand* _tmp4_;
		gboolean _tmp5_ = FALSE;
		gboolean _tmp6_ = FALSE;
		pdfpcDrawingCommand* _tmp7_;
		_tmp1_ = self->drawing_commands;
		_tmp2_ = g_list_last (_tmp1_);
		_tmp3_ = _tmp2_->data;
		_tmp4_ = _pdfpc_drawing_command_dup0 ((pdfpcDrawingCommand*) _tmp3_);
		last = _tmp4_;
		_tmp7_ = last;
		if (is_eraser == (*_tmp7_).is_eraser) {
			pdfpcDrawingCommand* _tmp8_;
			_tmp8_ = last;
			_tmp6_ = fabs ((*_tmp8_).x2 - x1) < epsilon;
		} else {
			_tmp6_ = FALSE;
		}
		if (_tmp6_) {
			pdfpcDrawingCommand* _tmp9_;
			_tmp9_ = last;
			_tmp5_ = fabs ((*_tmp9_).y2 - y1) < epsilon;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			new_path = FALSE;
		}
		_pdfpc_drawing_command_free0 (last);
	}
	memset (&dc, 0, sizeof (pdfpcDrawingCommand));
	dc.new_path = new_path;
	dc.is_eraser = is_eraser;
	dc.x1 = x1;
	dc.y1 = y1;
	dc.x2 = x2;
	dc.y2 = y2;
	dc.lwidth = lwidth;
	dc.red = red;
	dc.green = green;
	dc.blue = blue;
	dc.alpha = alpha;
	_tmp10_ = dc;
	_tmp11_ = _pdfpc_drawing_command_dup0 (&_tmp10_);
	self->drawing_commands = g_list_append (self->drawing_commands, _tmp11_);
}

static Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		pdfpcDrawingCommandList* self;
		self = _data4_->self;
		_cairo_destroy0 (_data4_->cr);
		_pdfpc_drawing_command_list_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}

static void
__lambda8_ (Block4Data* _data4_,
            pdfpcDrawingCommand* dc)
{
	pdfpcDrawingCommandList* self;
	self = _data4_->self;
	if ((*dc).is_eraser) {
		cairo_set_operator (_data4_->cr, CAIRO_OPERATOR_CLEAR);
	} else {
		cairo_set_operator (_data4_->cr, CAIRO_OPERATOR_OVER);
	}
	cairo_set_line_width (_data4_->cr, (*dc).lwidth * _data4_->width);
	cairo_set_source_rgba (_data4_->cr, (*dc).red, (*dc).green, (*dc).blue, (*dc).alpha);
	cairo_move_to (_data4_->cr, (*dc).x1 * _data4_->width, (*dc).y1 * _data4_->height);
	cairo_line_to (_data4_->cr, (*dc).x2 * _data4_->width, (*dc).y2 * _data4_->height);
	cairo_stroke (_data4_->cr);
}

static void
___lambda8__gfunc (gconstpointer data,
                   gpointer self)
{
	__lambda8_ (self, (pdfpcDrawingCommand*) data);
}

void
pdfpc_drawing_command_list_paint_in_surface (pdfpcDrawingCommandList* self,
                                             cairo_surface_t* surface)
{
	Block4Data* _data4_;
	cairo_t* _tmp0_;
	GList* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (surface != NULL);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->self = pdfpc_drawing_command_list_ref (self);
	_tmp0_ = cairo_create (surface);
	_data4_->cr = _tmp0_;
	cairo_set_operator (_data4_->cr, CAIRO_OPERATOR_CLEAR);
	cairo_paint (_data4_->cr);
	cairo_set_operator (_data4_->cr, CAIRO_OPERATOR_OVER);
	cairo_set_source_rgba (_data4_->cr, (gdouble) 1, (gdouble) 0, (gdouble) 0, (gdouble) 1);
	cairo_set_line_width (_data4_->cr, (gdouble) 5);
	cairo_set_line_cap (_data4_->cr, CAIRO_LINE_CAP_ROUND);
	cairo_set_line_join (_data4_->cr, CAIRO_LINE_JOIN_ROUND);
	_data4_->width = cairo_image_surface_get_width (surface);
	_data4_->height = cairo_image_surface_get_height (surface);
	_tmp1_ = self->drawing_commands;
	g_list_foreach (_tmp1_, ___lambda8__gfunc, _data4_);
	block4_data_unref (_data4_);
	_data4_ = NULL;
}

void
pdfpc_drawing_command_list_undo (pdfpcDrawingCommandList* self)
{
	g_return_if_fail (self != NULL);
	while (TRUE) {
		GList* _tmp0_;
		GList* el = NULL;
		GList* _tmp1_;
		GList* _tmp2_;
		pdfpcDrawingCommand dc = {0};
		GList* _tmp3_;
		gconstpointer _tmp4_;
		GList* _tmp5_;
		pdfpcDrawingCommand _tmp6_;
		pdfpcDrawingCommand* _tmp7_;
		pdfpcDrawingCommand _tmp8_;
		_tmp0_ = self->drawing_commands;
		if (!(_tmp0_ != NULL)) {
			break;
		}
		_tmp1_ = self->drawing_commands;
		_tmp2_ = g_list_last (_tmp1_);
		el = _tmp2_;
		_tmp3_ = el;
		_tmp4_ = _tmp3_->data;
		dc = *((pdfpcDrawingCommand*) _tmp4_);
		_tmp5_ = el;
		self->drawing_commands = g_list_remove_link (self->drawing_commands, _tmp5_);
		_tmp6_ = dc;
		_tmp7_ = _pdfpc_drawing_command_dup0 (&_tmp6_);
		self->redo_commands = g_list_append (self->redo_commands, _tmp7_);
		_tmp8_ = dc;
		if (_tmp8_.new_path) {
			break;
		}
	}
}

void
pdfpc_drawing_command_list_redo (pdfpcDrawingCommandList* self)
{
	gboolean first = FALSE;
	g_return_if_fail (self != NULL);
	first = TRUE;
	while (TRUE) {
		GList* _tmp0_;
		GList* el = NULL;
		GList* _tmp1_;
		GList* _tmp2_;
		pdfpcDrawingCommand dc = {0};
		GList* _tmp3_;
		gconstpointer _tmp4_;
		gboolean _tmp5_ = FALSE;
		GList* _tmp7_;
		pdfpcDrawingCommand _tmp8_;
		pdfpcDrawingCommand* _tmp9_;
		_tmp0_ = self->redo_commands;
		if (!(_tmp0_ != NULL)) {
			break;
		}
		_tmp1_ = self->redo_commands;
		_tmp2_ = g_list_last (_tmp1_);
		el = _tmp2_;
		_tmp3_ = el;
		_tmp4_ = _tmp3_->data;
		dc = *((pdfpcDrawingCommand*) _tmp4_);
		if (!first) {
			pdfpcDrawingCommand _tmp6_;
			_tmp6_ = dc;
			_tmp5_ = _tmp6_.new_path;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			break;
		}
		first = FALSE;
		_tmp7_ = el;
		self->redo_commands = g_list_remove_link (self->redo_commands, _tmp7_);
		_tmp8_ = dc;
		_tmp9_ = _pdfpc_drawing_command_dup0 (&_tmp8_);
		self->drawing_commands = g_list_append (self->drawing_commands, _tmp9_);
	}
}

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

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

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

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

static gchar*
pdfpc_value_drawing_command_list_collect_value (GValue* value,
                                                guint n_collect_values,
                                                GTypeCValue* collect_values,
                                                guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		pdfpcDrawingCommandList * 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 = pdfpc_drawing_command_list_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
pdfpc_value_drawing_command_list_lcopy_value (const GValue* value,
                                              guint n_collect_values,
                                              GTypeCValue* collect_values,
                                              guint collect_flags)
{
	pdfpcDrawingCommandList ** 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 = pdfpc_drawing_command_list_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
pdfpc_param_spec_drawing_command_list (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags)
{
	pdfpcParamSpecDrawingCommandList* spec;
	g_return_val_if_fail (g_type_is_a (object_type, PDFPC_TYPE_DRAWING_COMMAND_LIST), 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
pdfpc_value_get_drawing_command_list (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PDFPC_TYPE_DRAWING_COMMAND_LIST), NULL);
	return value->data[0].v_pointer;
}

void
pdfpc_value_set_drawing_command_list (GValue* value,
                                      gpointer v_object)
{
	pdfpcDrawingCommandList * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PDFPC_TYPE_DRAWING_COMMAND_LIST));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PDFPC_TYPE_DRAWING_COMMAND_LIST));
		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;
		pdfpc_drawing_command_list_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		pdfpc_drawing_command_list_unref (old);
	}
}

void
pdfpc_value_take_drawing_command_list (GValue* value,
                                       gpointer v_object)
{
	pdfpcDrawingCommandList * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PDFPC_TYPE_DRAWING_COMMAND_LIST));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PDFPC_TYPE_DRAWING_COMMAND_LIST));
		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) {
		pdfpc_drawing_command_list_unref (old);
	}
}

static void
pdfpc_drawing_command_list_class_init (pdfpcDrawingCommandListClass * klass,
                                       gpointer klass_data)
{
	pdfpc_drawing_command_list_parent_class = g_type_class_peek_parent (klass);
	((pdfpcDrawingCommandListClass *) klass)->finalize = pdfpc_drawing_command_list_finalize;
}

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

static void
pdfpc_drawing_command_list_finalize (pdfpcDrawingCommandList * obj)
{
	pdfpcDrawingCommandList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_TYPE_DRAWING_COMMAND_LIST, pdfpcDrawingCommandList);
	g_signal_handlers_destroy (self);
	(self->drawing_commands == NULL) ? NULL : (self->drawing_commands = (_g_list_free__pdfpc_drawing_command_free0_ (self->drawing_commands), NULL));
	(self->redo_commands == NULL) ? NULL : (self->redo_commands = (_g_list_free__pdfpc_drawing_command_free0_ (self->redo_commands), NULL));
}

static GType
pdfpc_drawing_command_list_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { pdfpc_value_drawing_command_list_init, pdfpc_value_drawing_command_list_free_value, pdfpc_value_drawing_command_list_copy_value, pdfpc_value_drawing_command_list_peek_pointer, "p", pdfpc_value_drawing_command_list_collect_value, "p", pdfpc_value_drawing_command_list_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcDrawingCommandListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_drawing_command_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcDrawingCommandList), 0, (GInstanceInitFunc) pdfpc_drawing_command_list_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 pdfpc_drawing_command_list_type_id;
	pdfpc_drawing_command_list_type_id = g_type_register_fundamental (g_type_fundamental_next (), "pdfpcDrawingCommandList", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return pdfpc_drawing_command_list_type_id;
}

GType
pdfpc_drawing_command_list_get_type (void)
{
	static volatile gsize pdfpc_drawing_command_list_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_drawing_command_list_type_id__once)) {
		GType pdfpc_drawing_command_list_type_id;
		pdfpc_drawing_command_list_type_id = pdfpc_drawing_command_list_get_type_once ();
		g_once_init_leave (&pdfpc_drawing_command_list_type_id__once, pdfpc_drawing_command_list_type_id);
	}
	return pdfpc_drawing_command_list_type_id__once;
}

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

void
pdfpc_drawing_command_list_unref (gpointer instance)
{
	pdfpcDrawingCommandList * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		PDFPC_DRAWING_COMMAND_LIST_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

