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

#include <glib-object.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
#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_DRAWINGS_STORAGE_TYPE_BASE (pdfpc_drawings_storage_base_get_type ())
#define PDFPC_DRAWINGS_STORAGE_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_DRAWINGS_STORAGE_TYPE_BASE, pdfpcDrawingsStorageBase))
#define PDFPC_DRAWINGS_STORAGE_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_DRAWINGS_STORAGE_TYPE_BASE, pdfpcDrawingsStorageBaseClass))
#define PDFPC_DRAWINGS_STORAGE_IS_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_DRAWINGS_STORAGE_TYPE_BASE))
#define PDFPC_DRAWINGS_STORAGE_IS_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_DRAWINGS_STORAGE_TYPE_BASE))
#define PDFPC_DRAWINGS_STORAGE_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_DRAWINGS_STORAGE_TYPE_BASE, pdfpcDrawingsStorageBaseClass))

typedef struct _pdfpcDrawingsStorageBase pdfpcDrawingsStorageBase;
typedef struct _pdfpcDrawingsStorageBaseClass pdfpcDrawingsStorageBaseClass;
typedef struct _pdfpcDrawingsStorageBasePrivate pdfpcDrawingsStorageBasePrivate;

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

#define PDFPC_METADATA_TYPE_PDF (pdfpc_metadata_pdf_get_type ())
#define PDFPC_METADATA_PDF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_METADATA_TYPE_PDF, pdfpcMetadataPdf))
#define PDFPC_METADATA_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_METADATA_TYPE_PDF, pdfpcMetadataPdfClass))
#define PDFPC_METADATA_IS_PDF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_METADATA_TYPE_PDF))
#define PDFPC_METADATA_IS_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_METADATA_TYPE_PDF))
#define PDFPC_METADATA_PDF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_METADATA_TYPE_PDF, pdfpcMetadataPdfClass))

typedef struct _pdfpcMetadataPdf pdfpcMetadataPdf;
typedef struct _pdfpcMetadataPdfClass pdfpcMetadataPdfClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _pdfpcDrawingsStorageParamSpecBase pdfpcDrawingsStorageParamSpecBase;

#define PDFPC_DRAWINGS_STORAGE_TYPE_MEMORY_UNCOMPRESSED (pdfpc_drawings_storage_memory_uncompressed_get_type ())
#define PDFPC_DRAWINGS_STORAGE_MEMORY_UNCOMPRESSED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PDFPC_DRAWINGS_STORAGE_TYPE_MEMORY_UNCOMPRESSED, pdfpcDrawingsStorageMemoryUncompressed))
#define PDFPC_DRAWINGS_STORAGE_MEMORY_UNCOMPRESSED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PDFPC_DRAWINGS_STORAGE_TYPE_MEMORY_UNCOMPRESSED, pdfpcDrawingsStorageMemoryUncompressedClass))
#define PDFPC_DRAWINGS_STORAGE_IS_MEMORY_UNCOMPRESSED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PDFPC_DRAWINGS_STORAGE_TYPE_MEMORY_UNCOMPRESSED))
#define PDFPC_DRAWINGS_STORAGE_IS_MEMORY_UNCOMPRESSED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PDFPC_DRAWINGS_STORAGE_TYPE_MEMORY_UNCOMPRESSED))
#define PDFPC_DRAWINGS_STORAGE_MEMORY_UNCOMPRESSED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PDFPC_DRAWINGS_STORAGE_TYPE_MEMORY_UNCOMPRESSED, pdfpcDrawingsStorageMemoryUncompressedClass))

typedef struct _pdfpcDrawingsStorageMemoryUncompressed pdfpcDrawingsStorageMemoryUncompressed;
typedef struct _pdfpcDrawingsStorageMemoryUncompressedClass pdfpcDrawingsStorageMemoryUncompressedClass;
typedef struct _pdfpcDrawingsStorageMemoryUncompressedPrivate pdfpcDrawingsStorageMemoryUncompressedPrivate;
#define _pdfpc_drawing_command_list_unref0(var) ((var == NULL) ? NULL : (var = (pdfpc_drawing_command_list_unref (var), NULL)))

struct _pdfpcDrawingsStorageBase {
	GTypeInstance parent_instance;
	volatile int ref_count;
	pdfpcDrawingsStorageBasePrivate * priv;
	pdfpcMetadataPdf* metadata;
};

struct _pdfpcDrawingsStorageBaseClass {
	GTypeClass parent_class;
	void (*finalize) (pdfpcDrawingsStorageBase *self);
	void (*store) (pdfpcDrawingsStorageBase* self, guint index, pdfpcDrawingCommandList* drawing_commands);
	pdfpcDrawingCommandList* (*retrieve) (pdfpcDrawingsStorageBase* self, guint index);
	void (*clear) (pdfpcDrawingsStorageBase* self);
};

struct _pdfpcDrawingsStorageParamSpecBase {
	GParamSpec parent_instance;
};

struct _pdfpcDrawingsStorageMemoryUncompressed {
	pdfpcDrawingsStorageBase parent_instance;
	pdfpcDrawingsStorageMemoryUncompressedPrivate * priv;
	pdfpcDrawingCommandList** drawing_commands_storage;
	gint drawing_commands_storage_length1;
};

struct _pdfpcDrawingsStorageMemoryUncompressedClass {
	pdfpcDrawingsStorageBaseClass parent_class;
};

static gpointer pdfpc_drawings_storage_base_parent_class = NULL;
static gpointer pdfpc_drawings_storage_memory_uncompressed_parent_class = NULL;

VALA_EXTERN gpointer pdfpc_drawings_storage_base_ref (gpointer instance);
VALA_EXTERN void pdfpc_drawings_storage_base_unref (gpointer instance);
VALA_EXTERN GParamSpec* pdfpc_drawings_storage_param_spec_base (const gchar* name,
                                                    const gchar* nick,
                                                    const gchar* blurb,
                                                    GType object_type,
                                                    GParamFlags flags);
VALA_EXTERN void pdfpc_drawings_storage_value_set_base (GValue* value,
                                            gpointer v_object);
VALA_EXTERN void pdfpc_drawings_storage_value_take_base (GValue* value,
                                             gpointer v_object);
VALA_EXTERN gpointer pdfpc_drawings_storage_value_get_base (const GValue* value);
VALA_EXTERN GType pdfpc_drawings_storage_base_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDrawingsStorageBase, pdfpc_drawings_storage_base_unref)
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)
VALA_EXTERN GType pdfpc_metadata_pdf_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcMetadataPdf, g_object_unref)
VALA_EXTERN void pdfpc_drawings_storage_base_store (pdfpcDrawingsStorageBase* self,
                                        guint index,
                                        pdfpcDrawingCommandList* drawing_commands);
VALA_EXTERN pdfpcDrawingCommandList* pdfpc_drawings_storage_base_retrieve (pdfpcDrawingsStorageBase* self,
                                                               guint index);
VALA_EXTERN void pdfpc_drawings_storage_base_clear (pdfpcDrawingsStorageBase* self);
VALA_EXTERN pdfpcDrawingsStorageBase* pdfpc_drawings_storage_base_construct (GType object_type,
                                                                 pdfpcMetadataPdf* metadata);
static void pdfpc_drawings_storage_base_real_store (pdfpcDrawingsStorageBase* self,
                                             guint index,
                                             pdfpcDrawingCommandList* drawing_commands);
static pdfpcDrawingCommandList* pdfpc_drawings_storage_base_real_retrieve (pdfpcDrawingsStorageBase* self,
                                                                    guint index);
static void pdfpc_drawings_storage_base_real_clear (pdfpcDrawingsStorageBase* self);
static void pdfpc_drawings_storage_base_finalize (pdfpcDrawingsStorageBase * obj);
static GType pdfpc_drawings_storage_base_get_type_once (void);
VALA_EXTERN GType pdfpc_drawings_storage_memory_uncompressed_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (pdfpcDrawingsStorageMemoryUncompressed, pdfpc_drawings_storage_base_unref)
VALA_EXTERN pdfpcDrawingsStorageMemoryUncompressed* pdfpc_drawings_storage_memory_uncompressed_new (pdfpcMetadataPdf* metadata);
VALA_EXTERN pdfpcDrawingsStorageMemoryUncompressed* pdfpc_drawings_storage_memory_uncompressed_construct (GType object_type,
                                                                                              pdfpcMetadataPdf* metadata);
static void pdfpc_drawings_storage_memory_uncompressed_real_store (pdfpcDrawingsStorageBase* base,
                                                            guint index,
                                                            pdfpcDrawingCommandList* drawing_commands);
static pdfpcDrawingCommandList* pdfpc_drawings_storage_memory_uncompressed_real_retrieve (pdfpcDrawingsStorageBase* base,
                                                                                   guint index);
static void pdfpc_drawings_storage_memory_uncompressed_real_clear (pdfpcDrawingsStorageBase* base);
VALA_EXTERN guint pdfpc_metadata_pdf_get_slide_count (pdfpcMetadataPdf* self);
static void pdfpc_drawings_storage_memory_uncompressed_finalize (pdfpcDrawingsStorageBase * obj);
static GType pdfpc_drawings_storage_memory_uncompressed_get_type_once (void);
VALA_EXTERN pdfpcDrawingsStorageBase* pdfpc_drawings_storage_create (pdfpcMetadataPdf* metadata);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

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

pdfpcDrawingsStorageBase*
pdfpc_drawings_storage_base_construct (GType object_type,
                                       pdfpcMetadataPdf* metadata)
{
	pdfpcDrawingsStorageBase* self = NULL;
	pdfpcMetadataPdf* _tmp0_;
	g_return_val_if_fail (metadata != NULL, NULL);
	self = (pdfpcDrawingsStorageBase*) g_type_create_instance (object_type);
	_tmp0_ = _g_object_ref0 (metadata);
	_g_object_unref0 (self->metadata);
	self->metadata = _tmp0_;
	return self;
}

/**
         * Store an overlay drawing with the given index as an identifier.
         */
static void
pdfpc_drawings_storage_base_real_store (pdfpcDrawingsStorageBase* self,
                                        guint index,
                                        pdfpcDrawingCommandList* drawing_commands)
{
	g_critical ("Type `%s' does not implement abstract method `pdfpc_drawings_storage_base_store'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
pdfpc_drawings_storage_base_store (pdfpcDrawingsStorageBase* self,
                                   guint index,
                                   pdfpcDrawingCommandList* drawing_commands)
{
	pdfpcDrawingsStorageBaseClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = PDFPC_DRAWINGS_STORAGE_BASE_GET_CLASS (self);
	if (_klass_->store) {
		_klass_->store (self, index, drawing_commands);
	}
}

/**
         * Retrieve an overlay drawing from storage, or null if none was made.
         *
         * The returned reference can be modified without modifying the storage.
         */
static pdfpcDrawingCommandList*
pdfpc_drawings_storage_base_real_retrieve (pdfpcDrawingsStorageBase* self,
                                           guint index)
{
	g_critical ("Type `%s' does not implement abstract method `pdfpc_drawings_storage_base_retrieve'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

pdfpcDrawingCommandList*
pdfpc_drawings_storage_base_retrieve (pdfpcDrawingsStorageBase* self,
                                      guint index)
{
	pdfpcDrawingsStorageBaseClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = PDFPC_DRAWINGS_STORAGE_BASE_GET_CLASS (self);
	if (_klass_->retrieve) {
		return _klass_->retrieve (self, index);
	}
	return NULL;
}

/**
         * Clear the storage
         */
static void
pdfpc_drawings_storage_base_real_clear (pdfpcDrawingsStorageBase* self)
{
	g_critical ("Type `%s' does not implement abstract method `pdfpc_drawings_storage_base_clear'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
pdfpc_drawings_storage_base_clear (pdfpcDrawingsStorageBase* self)
{
	pdfpcDrawingsStorageBaseClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = PDFPC_DRAWINGS_STORAGE_BASE_GET_CLASS (self);
	if (_klass_->clear) {
		_klass_->clear (self);
	}
}

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

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

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

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

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

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

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

void
pdfpc_drawings_storage_value_set_base (GValue* value,
                                       gpointer v_object)
{
	pdfpcDrawingsStorageBase * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PDFPC_DRAWINGS_STORAGE_TYPE_BASE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PDFPC_DRAWINGS_STORAGE_TYPE_BASE));
		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_drawings_storage_base_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		pdfpc_drawings_storage_base_unref (old);
	}
}

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

static void
pdfpc_drawings_storage_base_class_init (pdfpcDrawingsStorageBaseClass * klass,
                                        gpointer klass_data)
{
	pdfpc_drawings_storage_base_parent_class = g_type_class_peek_parent (klass);
	((pdfpcDrawingsStorageBaseClass *) klass)->finalize = pdfpc_drawings_storage_base_finalize;
	((pdfpcDrawingsStorageBaseClass *) klass)->store = (void (*) (pdfpcDrawingsStorageBase*, guint, pdfpcDrawingCommandList*)) pdfpc_drawings_storage_base_real_store;
	((pdfpcDrawingsStorageBaseClass *) klass)->retrieve = (pdfpcDrawingCommandList* (*) (pdfpcDrawingsStorageBase*, guint)) pdfpc_drawings_storage_base_real_retrieve;
	((pdfpcDrawingsStorageBaseClass *) klass)->clear = (void (*) (pdfpcDrawingsStorageBase*)) pdfpc_drawings_storage_base_real_clear;
}

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

static void
pdfpc_drawings_storage_base_finalize (pdfpcDrawingsStorageBase * obj)
{
	pdfpcDrawingsStorageBase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_DRAWINGS_STORAGE_TYPE_BASE, pdfpcDrawingsStorageBase);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->metadata);
}

/**
     * Storage of overlay drawings.
     *
     * This is very similar to caching of slide renderings, except we're likely
     * to want to place the overlays in a user-navigible directory and resize
     * them.
     */
static GType
pdfpc_drawings_storage_base_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { pdfpc_drawings_storage_value_base_init, pdfpc_drawings_storage_value_base_free_value, pdfpc_drawings_storage_value_base_copy_value, pdfpc_drawings_storage_value_base_peek_pointer, "p", pdfpc_drawings_storage_value_base_collect_value, "p", pdfpc_drawings_storage_value_base_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcDrawingsStorageBaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_drawings_storage_base_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcDrawingsStorageBase), 0, (GInstanceInitFunc) pdfpc_drawings_storage_base_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_drawings_storage_base_type_id;
	pdfpc_drawings_storage_base_type_id = g_type_register_fundamental (g_type_fundamental_next (), "pdfpcDrawingsStorageBase", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
	return pdfpc_drawings_storage_base_type_id;
}

GType
pdfpc_drawings_storage_base_get_type (void)
{
	static volatile gsize pdfpc_drawings_storage_base_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_drawings_storage_base_type_id__once)) {
		GType pdfpc_drawings_storage_base_type_id;
		pdfpc_drawings_storage_base_type_id = pdfpc_drawings_storage_base_get_type_once ();
		g_once_init_leave (&pdfpc_drawings_storage_base_type_id__once, pdfpc_drawings_storage_base_type_id);
	}
	return pdfpc_drawings_storage_base_type_id__once;
}

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

void
pdfpc_drawings_storage_base_unref (gpointer instance)
{
	pdfpcDrawingsStorageBase * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		PDFPC_DRAWINGS_STORAGE_BASE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

/**
         * Initialize the storage
         */
pdfpcDrawingsStorageMemoryUncompressed*
pdfpc_drawings_storage_memory_uncompressed_construct (GType object_type,
                                                      pdfpcMetadataPdf* metadata)
{
	pdfpcDrawingsStorageMemoryUncompressed* self = NULL;
	g_return_val_if_fail (metadata != NULL, NULL);
	self = (pdfpcDrawingsStorageMemoryUncompressed*) pdfpc_drawings_storage_base_construct (object_type, metadata);
	pdfpc_drawings_storage_base_clear ((pdfpcDrawingsStorageBase*) self);
	return self;
}

pdfpcDrawingsStorageMemoryUncompressed*
pdfpc_drawings_storage_memory_uncompressed_new (pdfpcMetadataPdf* metadata)
{
	return pdfpc_drawings_storage_memory_uncompressed_construct (PDFPC_DRAWINGS_STORAGE_TYPE_MEMORY_UNCOMPRESSED, metadata);
}

static gpointer
_pdfpc_drawing_command_list_ref0 (gpointer self)
{
	return self ? pdfpc_drawing_command_list_ref (self) : NULL;
}

static void
pdfpc_drawings_storage_memory_uncompressed_real_store (pdfpcDrawingsStorageBase* base,
                                                       guint index,
                                                       pdfpcDrawingCommandList* drawing_commands)
{
	pdfpcDrawingsStorageMemoryUncompressed * self;
	pdfpcDrawingCommandList** _tmp0_;
	gint _tmp0__length1;
	pdfpcDrawingCommandList* _tmp1_;
	self = (pdfpcDrawingsStorageMemoryUncompressed*) base;
	g_return_if_fail (drawing_commands != NULL);
	_tmp0_ = self->drawing_commands_storage;
	_tmp0__length1 = self->drawing_commands_storage_length1;
	_tmp1_ = _pdfpc_drawing_command_list_ref0 (drawing_commands);
	_pdfpc_drawing_command_list_unref0 (_tmp0_[index]);
	_tmp0_[index] = _tmp1_;
}

static pdfpcDrawingCommandList*
pdfpc_drawings_storage_memory_uncompressed_real_retrieve (pdfpcDrawingsStorageBase* base,
                                                          guint index)
{
	pdfpcDrawingsStorageMemoryUncompressed * self;
	pdfpcDrawingCommandList* _result_ = NULL;
	pdfpcDrawingCommandList** _tmp0_;
	gint _tmp0__length1;
	pdfpcDrawingCommandList* _tmp1_;
	pdfpcDrawingCommandList* _tmp2_;
	pdfpcDrawingCommandList** _tmp3_;
	gint _tmp3__length1;
	pdfpcDrawingCommandList* result;
	self = (pdfpcDrawingsStorageMemoryUncompressed*) base;
	_tmp0_ = self->drawing_commands_storage;
	_tmp0__length1 = self->drawing_commands_storage_length1;
	_tmp1_ = _tmp0_[index];
	_tmp2_ = _pdfpc_drawing_command_list_ref0 (_tmp1_);
	_result_ = _tmp2_;
	_tmp3_ = self->drawing_commands_storage;
	_tmp3__length1 = self->drawing_commands_storage_length1;
	_pdfpc_drawing_command_list_unref0 (_tmp3_[index]);
	_tmp3_[index] = NULL;
	result = _result_;
	return result;
}

static void
pdfpc_drawings_storage_memory_uncompressed_real_clear (pdfpcDrawingsStorageBase* base)
{
	pdfpcDrawingsStorageMemoryUncompressed * self;
	pdfpcMetadataPdf* _tmp0_;
	pdfpcDrawingCommandList** _tmp1_;
	self = (pdfpcDrawingsStorageMemoryUncompressed*) base;
	_tmp0_ = ((pdfpcDrawingsStorageBase*) self)->metadata;
	_tmp1_ = g_new0 (pdfpcDrawingCommandList*, pdfpc_metadata_pdf_get_slide_count (_tmp0_) + 1);
	self->drawing_commands_storage = (_vala_array_free (self->drawing_commands_storage, self->drawing_commands_storage_length1, (GDestroyNotify) pdfpc_drawing_command_list_unref), NULL);
	self->drawing_commands_storage = _tmp1_;
	self->drawing_commands_storage_length1 = pdfpc_metadata_pdf_get_slide_count (_tmp0_);
}

static void
pdfpc_drawings_storage_memory_uncompressed_class_init (pdfpcDrawingsStorageMemoryUncompressedClass * klass,
                                                       gpointer klass_data)
{
	pdfpc_drawings_storage_memory_uncompressed_parent_class = g_type_class_peek_parent (klass);
	((pdfpcDrawingsStorageBaseClass *) klass)->finalize = pdfpc_drawings_storage_memory_uncompressed_finalize;
	((pdfpcDrawingsStorageBaseClass *) klass)->store = (void (*) (pdfpcDrawingsStorageBase*, guint, pdfpcDrawingCommandList*)) pdfpc_drawings_storage_memory_uncompressed_real_store;
	((pdfpcDrawingsStorageBaseClass *) klass)->retrieve = (pdfpcDrawingCommandList* (*) (pdfpcDrawingsStorageBase*, guint)) pdfpc_drawings_storage_memory_uncompressed_real_retrieve;
	((pdfpcDrawingsStorageBaseClass *) klass)->clear = (void (*) (pdfpcDrawingsStorageBase*)) pdfpc_drawings_storage_memory_uncompressed_real_clear;
}

static void
pdfpc_drawings_storage_memory_uncompressed_instance_init (pdfpcDrawingsStorageMemoryUncompressed * self,
                                                          gpointer klass)
{
	self->drawing_commands_storage = NULL;
	self->drawing_commands_storage_length1 = 0;
}

static void
pdfpc_drawings_storage_memory_uncompressed_finalize (pdfpcDrawingsStorageBase * obj)
{
	pdfpcDrawingsStorageMemoryUncompressed * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PDFPC_DRAWINGS_STORAGE_TYPE_MEMORY_UNCOMPRESSED, pdfpcDrawingsStorageMemoryUncompressed);
	self->drawing_commands_storage = (_vala_array_free (self->drawing_commands_storage, self->drawing_commands_storage_length1, (GDestroyNotify) pdfpc_drawing_command_list_unref), NULL);
	PDFPC_DRAWINGS_STORAGE_BASE_CLASS (pdfpc_drawings_storage_memory_uncompressed_parent_class)->finalize (obj);
}

static GType
pdfpc_drawings_storage_memory_uncompressed_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (pdfpcDrawingsStorageMemoryUncompressedClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pdfpc_drawings_storage_memory_uncompressed_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (pdfpcDrawingsStorageMemoryUncompressed), 0, (GInstanceInitFunc) pdfpc_drawings_storage_memory_uncompressed_instance_init, NULL };
	GType pdfpc_drawings_storage_memory_uncompressed_type_id;
	pdfpc_drawings_storage_memory_uncompressed_type_id = g_type_register_static (PDFPC_DRAWINGS_STORAGE_TYPE_BASE, "pdfpcDrawingsStorageMemoryUncompressed", &g_define_type_info, 0);
	return pdfpc_drawings_storage_memory_uncompressed_type_id;
}

GType
pdfpc_drawings_storage_memory_uncompressed_get_type (void)
{
	static volatile gsize pdfpc_drawings_storage_memory_uncompressed_type_id__once = 0;
	if (g_once_init_enter (&pdfpc_drawings_storage_memory_uncompressed_type_id__once)) {
		GType pdfpc_drawings_storage_memory_uncompressed_type_id;
		pdfpc_drawings_storage_memory_uncompressed_type_id = pdfpc_drawings_storage_memory_uncompressed_get_type_once ();
		g_once_init_leave (&pdfpc_drawings_storage_memory_uncompressed_type_id__once, pdfpc_drawings_storage_memory_uncompressed_type_id);
	}
	return pdfpc_drawings_storage_memory_uncompressed_type_id__once;
}

pdfpcDrawingsStorageBase*
pdfpc_drawings_storage_create (pdfpcMetadataPdf* metadata)
{
	pdfpcDrawingsStorageMemoryUncompressed* _tmp0_;
	pdfpcDrawingsStorageBase* result;
	g_return_val_if_fail (metadata != NULL, NULL);
	_tmp0_ = pdfpc_drawings_storage_memory_uncompressed_new (metadata);
	result = (pdfpcDrawingsStorageBase*) _tmp0_;
	return result;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

