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

#define _GNU_SOURCE

#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <errno.h>
#include <gio/gunixfdlist.h>
#include <unistd.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 G4_TYPE_PORTAL (g4_portal_get_type ())
#define G4_PORTAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_PORTAL, G4Portal))
#define G4_PORTAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_PORTAL, G4PortalClass))
#define G4_IS_PORTAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_PORTAL))
#define G4_IS_PORTAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_PORTAL))
#define G4_PORTAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_PORTAL, G4PortalClass))

typedef struct _G4Portal G4Portal;
typedef struct _G4PortalClass G4PortalClass;
typedef struct _G4PortalPrivate G4PortalPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g4_portal_unref0(var) ((var == NULL) ? NULL : (var = (g4_portal_unref (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_variant_builder_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_builder_unref (var), NULL)))
typedef struct _G4PortalOpenDirectoryAsyncData G4PortalOpenDirectoryAsyncData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _G4PortalRequestBackgroundAsyncData G4PortalRequestBackgroundAsyncData;
typedef struct _G4PortalTrashFileAsyncData G4PortalTrashFileAsyncData;
typedef struct _G4PortalCallWithFileAsyncData G4PortalCallWithFileAsyncData;
typedef struct _G4ParamSpecPortal G4ParamSpecPortal;

struct _G4Portal {
	GTypeInstance parent_instance;
	volatile int ref_count;
	G4PortalPrivate * priv;
};

struct _G4PortalClass {
	GTypeClass parent_class;
	void (*finalize) (G4Portal *self);
};

struct _G4PortalPrivate {
	GDBusConnection* _bus;
	gchar* _parent;
};

struct _G4PortalOpenDirectoryAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	G4Portal* self;
	gchar* uri;
	gboolean result;
	GFile* file;
	GFile* _tmp0_;
	GVariantBuilder* options;
	GVariantBuilder* _tmp1_;
	GVariant* parameters;
	const gchar* _tmp2_;
	GVariant* _tmp3_;
	GVariant* ret;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GVariant* _tmp7_;
	GVariant* _tmp8_;
	GError* _inner_error0_;
};

struct _G4PortalRequestBackgroundAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	G4Portal* self;
	gchar* reason;
	GVariantBuilder* options;
	GVariantBuilder* _tmp0_;
	GVariantBuilder* _tmp1_;
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	GVariantBuilder* _tmp4_;
	GVariant* _tmp5_;
	GVariant* _tmp6_;
	GVariantBuilder* _tmp7_;
	GVariant* _tmp8_;
	GVariant* _tmp9_;
	GVariant* parameters;
	const gchar* _tmp10_;
	GVariantBuilder* _tmp11_;
	GVariant* _tmp12_;
	GDBusConnection* _tmp13_;
	GDBusConnection* _tmp14_;
	GDBusConnection* _tmp15_;
	GDBusConnection* _tmp16_;
	GDBusConnection* _tmp17_;
	GDBusConnection* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	GVariant* _tmp24_;
	GVariant* _tmp25_;
	GVariant* _tmp26_;
	GError* e;
	GError* _tmp27_;
	const gchar* _tmp28_;
	GError* _inner_error0_;
};

struct _G4PortalTrashFileAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	G4Portal* self;
	gchar* uri;
	gboolean result;
	GFile* file;
	GFile* _tmp0_;
	GVariant* parameters;
	GVariant* _tmp1_;
	GVariant* ret;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GVariant* _tmp5_;
	GVariant* _tmp6_;
	guint val;
	GVariant* _tmp7_;
	guint _tmp8_;
	GError* _inner_error0_;
};

struct _G4PortalCallWithFileAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	G4Portal* self;
	GFile* file;
	gint flags;
	gchar* interface_name;
	gchar* method_name;
	GVariant* parameters;
	GVariant* result;
	gint fd;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* path;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	GError* _tmp5_;
	GUnixFDList* fd_list;
	GUnixFDList* _tmp6_;
	GUnixFDList* _tmp7_;
	GDBusConnection* _tmp8_;
	GDBusConnection* _tmp9_;
	GDBusConnection* _tmp10_;
	GDBusConnection* _tmp11_;
	GDBusConnection* _tmp12_;
	GVariant* _tmp13_;
	GDBusConnection* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	GUnixFDList* _tmp17_;
	GVariant* _tmp18_;
	GVariant* _tmp19_;
	GError* e;
	GError* _tmp20_;
	GError* _tmp21_;
	GError* _inner_error0_;
};

struct _G4ParamSpecPortal {
	GParamSpec parent_instance;
};

static gint G4Portal_private_offset;
static gpointer g4_portal_parent_class = NULL;
static gchar* g4_portal_PORTAL_NAME;
static gchar* g4_portal_PORTAL_NAME = NULL;
static gchar* g4_portal_BUS_NAME;
static gchar* g4_portal_BUS_NAME = NULL;
static gchar* g4_portal_OBJECT_PATH;
static gchar* g4_portal_OBJECT_PATH = NULL;

VALA_EXTERN gpointer g4_portal_ref (gpointer instance);
VALA_EXTERN void g4_portal_unref (gpointer instance);
VALA_EXTERN GParamSpec* g4_param_spec_portal (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags);
VALA_EXTERN void g4_value_set_portal (GValue* value,
                          gpointer v_object);
VALA_EXTERN void g4_value_take_portal (GValue* value,
                           gpointer v_object);
VALA_EXTERN gpointer g4_value_get_portal (const GValue* value);
VALA_EXTERN GType g4_portal_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4Portal, g4_portal_unref)
VALA_EXTERN G4Portal* g4_portal_new (const gchar* parent);
VALA_EXTERN G4Portal* g4_portal_construct (GType object_type,
                               const gchar* parent);
static void g4_portal_open_directory_async_data_free (gpointer _data);
VALA_EXTERN void g4_portal_open_directory_async (G4Portal* self,
                                     const gchar* uri,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN gboolean g4_portal_open_directory_finish (G4Portal* self,
                                          GAsyncResult* _res_,
                                          GError** error);
static gboolean g4_portal_open_directory_async_co (G4PortalOpenDirectoryAsyncData* _data_);
static GVariantBuilder* g4_portal_make_options_builder (G4Portal* self);
static void g4_portal_call_with_file_async (G4Portal* self,
                                     GFile* file,
                                     gint flags,
                                     const gchar* interface_name,
                                     const gchar* method_name,
                                     GVariant* parameters,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static GVariant* g4_portal_call_with_file_finish (G4Portal* self,
                                           GAsyncResult* _res_,
                                           GError** error);
static void g4_portal_open_directory_async_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
static void g4_portal_request_background_async_data_free (gpointer _data);
VALA_EXTERN void g4_portal_request_background_async (G4Portal* self,
                                         const gchar* reason,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN void g4_portal_request_background_finish (G4Portal* self,
                                          GAsyncResult* _res_);
static gboolean g4_portal_request_background_async_co (G4PortalRequestBackgroundAsyncData* _data_);
static void g4_portal_request_background_async_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
static void g4_portal_trash_file_async_data_free (gpointer _data);
VALA_EXTERN void g4_portal_trash_file_async (G4Portal* self,
                                 const gchar* uri,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_);
VALA_EXTERN gboolean g4_portal_trash_file_finish (G4Portal* self,
                                      GAsyncResult* _res_,
                                      GError** error);
static gboolean g4_portal_trash_file_async_co (G4PortalTrashFileAsyncData* _data_);
static void g4_portal_trash_file_async_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_);
static void g4_portal_call_with_file_async_data_free (gpointer _data);
static gboolean g4_portal_call_with_file_async_co (G4PortalCallWithFileAsyncData* _data_);
static void g4_portal_call_with_file_async_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
static void g4_portal_finalize (G4Portal * obj);
static GType g4_portal_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
g4_portal_get_instance_private (G4Portal* self)
{
	return G_STRUCT_MEMBER_P (self, G4Portal_private_offset);
}

G4Portal*
g4_portal_construct (GType object_type,
                     const gchar* parent)
{
	G4Portal* self = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	self = (G4Portal*) g_type_create_instance (object_type);
	_tmp0_ = parent;
	if (_tmp0_ == NULL) {
		_tmp0_ = "";
	}
	_tmp1_ = g_strdup ((const gchar*) _tmp0_);
	_g_free0 (self->priv->_parent);
	self->priv->_parent = _tmp1_;
	return self;
}

G4Portal*
g4_portal_new (const gchar* parent)
{
	return g4_portal_construct (G4_TYPE_PORTAL, parent);
}

static void
g4_portal_open_directory_async_data_free (gpointer _data)
{
	G4PortalOpenDirectoryAsyncData* _data_;
	_data_ = _data;
	_g_free0 (_data_->uri);
	_g4_portal_unref0 (_data_->self);
	g_slice_free (G4PortalOpenDirectoryAsyncData, _data_);
}

static gpointer
_g4_portal_ref0 (gpointer self)
{
	return self ? g4_portal_ref (self) : NULL;
}

void
g4_portal_open_directory_async (G4Portal* self,
                                const gchar* uri,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	G4PortalOpenDirectoryAsyncData* _data_;
	G4Portal* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	_data_ = g_slice_new0 (G4PortalOpenDirectoryAsyncData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, g4_portal_open_directory_async_data_free);
	_tmp0_ = _g4_portal_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (uri);
	_g_free0 (_data_->uri);
	_data_->uri = _tmp1_;
	g4_portal_open_directory_async_co (_data_);
}

gboolean
g4_portal_open_directory_finish (G4Portal* self,
                                 GAsyncResult* _res_,
                                 GError** error)
{
	gboolean result;
	G4PortalOpenDirectoryAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
g4_portal_open_directory_async_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	G4PortalOpenDirectoryAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	g4_portal_open_directory_async_co (_data_);
}

static gboolean
g4_portal_open_directory_async_co (G4PortalOpenDirectoryAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_file_new_for_uri (_data_->uri);
	_data_->file = _data_->_tmp0_;
	_data_->_tmp1_ = g4_portal_make_options_builder (_data_->self);
	_data_->options = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->self->priv->_parent;
	_data_->_tmp3_ = g_variant_new ("(sha{sv})", _data_->_tmp2_, 0, _data_->options, NULL);
	g_variant_ref_sink (_data_->_tmp3_);
	_data_->parameters = _data_->_tmp3_;
	_data_->_tmp4_ = g4_portal_PORTAL_NAME;
	_data_->_tmp5_ = g_strconcat (_data_->_tmp4_, "OpenURI", NULL);
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_state_ = 1;
	g4_portal_call_with_file_async (_data_->self, _data_->file, O_CLOEXEC, _data_->_tmp6_, "OpenDirectory", _data_->parameters, g4_portal_open_directory_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp7_ = g4_portal_call_with_file_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp8_ = _data_->_tmp7_;
	_g_free0 (_data_->_tmp6_);
	_data_->ret = _data_->_tmp8_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_variant_unref0 (_data_->parameters);
		_g_variant_builder_unref0 (_data_->options);
		_g_object_unref0 (_data_->file);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->ret != NULL;
	_g_variant_unref0 (_data_->ret);
	_g_variant_unref0 (_data_->parameters);
	_g_variant_builder_unref0 (_data_->options);
	_g_object_unref0 (_data_->file);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
g4_portal_request_background_async_data_free (gpointer _data)
{
	G4PortalRequestBackgroundAsyncData* _data_;
	_data_ = _data;
	_g_free0 (_data_->reason);
	_g4_portal_unref0 (_data_->self);
	g_slice_free (G4PortalRequestBackgroundAsyncData, _data_);
}

void
g4_portal_request_background_async (G4Portal* self,
                                    const gchar* reason,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	G4PortalRequestBackgroundAsyncData* _data_;
	G4Portal* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (G4PortalRequestBackgroundAsyncData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, g4_portal_request_background_async_data_free);
	_tmp0_ = _g4_portal_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (reason);
	_g_free0 (_data_->reason);
	_data_->reason = _tmp1_;
	g4_portal_request_background_async_co (_data_);
}

void
g4_portal_request_background_finish (G4Portal* self,
                                     GAsyncResult* _res_)
{
	G4PortalRequestBackgroundAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

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

static void
g4_portal_request_background_async_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	G4PortalRequestBackgroundAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	g4_portal_request_background_async_co (_data_);
}

static gboolean
g4_portal_request_background_async_co (G4PortalRequestBackgroundAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = g4_portal_make_options_builder (_data_->self);
		_data_->options = _data_->_tmp0_;
		if (_data_->reason != NULL) {
			_data_->_tmp1_ = _data_->options;
			_data_->_tmp2_ = g_variant_new_string ((const gchar*) _data_->reason);
			g_variant_ref_sink (_data_->_tmp2_);
			_data_->_tmp3_ = _data_->_tmp2_;
			g_variant_builder_add (_data_->_tmp1_, "{sv}", "reason", _data_->_tmp3_, NULL);
			_g_variant_unref0 (_data_->_tmp3_);
		}
		_data_->_tmp4_ = _data_->options;
		_data_->_tmp5_ = g_variant_new_boolean (FALSE);
		g_variant_ref_sink (_data_->_tmp5_);
		_data_->_tmp6_ = _data_->_tmp5_;
		g_variant_builder_add (_data_->_tmp4_, "{sv}", "autostart", _data_->_tmp6_, NULL);
		_g_variant_unref0 (_data_->_tmp6_);
		_data_->_tmp7_ = _data_->options;
		_data_->_tmp8_ = g_variant_new_boolean (FALSE);
		g_variant_ref_sink (_data_->_tmp8_);
		_data_->_tmp9_ = _data_->_tmp8_;
		g_variant_builder_add (_data_->_tmp7_, "{sv}", "dbus-activatable", _data_->_tmp9_, NULL);
		_g_variant_unref0 (_data_->_tmp9_);
		_data_->_tmp10_ = _data_->self->priv->_parent;
		_data_->_tmp11_ = _data_->options;
		_data_->_tmp12_ = g_variant_new ("(sa{sv})", _data_->_tmp10_, _data_->_tmp11_, NULL);
		g_variant_ref_sink (_data_->_tmp12_);
		_data_->parameters = _data_->_tmp12_;
		_data_->_tmp14_ = _data_->self->priv->_bus;
		_data_->_tmp15_ = _g_object_ref0 (_data_->_tmp14_);
		_data_->_tmp13_ = _data_->_tmp15_;
		if (_data_->_tmp13_ == NULL) {
			_data_->_state_ = 1;
			g_bus_get (G_BUS_TYPE_SESSION, NULL, g4_portal_request_background_async_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp16_ = g_bus_get_finish (_data_->_res_, &_data_->_inner_error0_);
			_g_object_unref0 (_data_->_tmp13_);
			_data_->_tmp13_ = _data_->_tmp16_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->_tmp13_);
				_g_variant_unref0 (_data_->parameters);
				_g_variant_builder_unref0 (_data_->options);
				goto __catch0_g_error;
			}
		}
		_data_->_tmp17_ = _data_->_tmp13_;
		_data_->_tmp13_ = NULL;
		_g_object_unref0 (_data_->self->priv->_bus);
		_data_->self->priv->_bus = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp17_, g_dbus_connection_get_type (), GDBusConnection);
		_data_->_tmp18_ = _data_->self->priv->_bus;
		_data_->_tmp19_ = g4_portal_BUS_NAME;
		_data_->_tmp20_ = g4_portal_OBJECT_PATH;
		_data_->_tmp21_ = g4_portal_PORTAL_NAME;
		_data_->_tmp22_ = g_strconcat (_data_->_tmp21_, "Background", NULL);
		_data_->_tmp23_ = _data_->_tmp22_;
		_data_->_tmp24_ = _data_->parameters;
		_data_->_state_ = 2;
		g_dbus_connection_call (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp18_, g_dbus_connection_get_type (), GDBusConnection), _data_->_tmp19_, _data_->_tmp20_, _data_->_tmp23_, "RequestBackground", _data_->_tmp24_, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, g4_portal_request_background_async_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp25_ = g_dbus_connection_call_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp18_, g_dbus_connection_get_type (), GDBusConnection), _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp26_ = _data_->_tmp25_;
		_g_variant_unref0 (_data_->_tmp26_);
		_g_free0 (_data_->_tmp23_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->_tmp13_);
			_g_variant_unref0 (_data_->parameters);
			_g_variant_builder_unref0 (_data_->options);
			goto __catch0_g_error;
		}
		_g_object_unref0 (_data_->_tmp13_);
		_g_variant_unref0 (_data_->parameters);
		_g_variant_builder_unref0 (_data_->options);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp27_ = _data_->e;
		_data_->_tmp28_ = _data_->_tmp27_->message;
		g_print ("Bus.call error: %s\n", _data_->_tmp28_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
g4_portal_trash_file_async_data_free (gpointer _data)
{
	G4PortalTrashFileAsyncData* _data_;
	_data_ = _data;
	_g_free0 (_data_->uri);
	_g4_portal_unref0 (_data_->self);
	g_slice_free (G4PortalTrashFileAsyncData, _data_);
}

void
g4_portal_trash_file_async (G4Portal* self,
                            const gchar* uri,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_)
{
	G4PortalTrashFileAsyncData* _data_;
	G4Portal* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	_data_ = g_slice_new0 (G4PortalTrashFileAsyncData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, g4_portal_trash_file_async_data_free);
	_tmp0_ = _g4_portal_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (uri);
	_g_free0 (_data_->uri);
	_data_->uri = _tmp1_;
	g4_portal_trash_file_async_co (_data_);
}

gboolean
g4_portal_trash_file_finish (G4Portal* self,
                             GAsyncResult* _res_,
                             GError** error)
{
	gboolean result;
	G4PortalTrashFileAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
g4_portal_trash_file_async_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_)
{
	G4PortalTrashFileAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	g4_portal_trash_file_async_co (_data_);
}

static gboolean
g4_portal_trash_file_async_co (G4PortalTrashFileAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_file_new_for_uri (_data_->uri);
	_data_->file = _data_->_tmp0_;
	_data_->_tmp1_ = g_variant_new ("(h)", 0, NULL);
	g_variant_ref_sink (_data_->_tmp1_);
	_data_->parameters = _data_->_tmp1_;
	_data_->_tmp2_ = g4_portal_PORTAL_NAME;
	_data_->_tmp3_ = g_strconcat (_data_->_tmp2_, "Trash", NULL);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_state_ = 1;
	g4_portal_call_with_file_async (_data_->self, _data_->file, O_CLOEXEC | 010000000, _data_->_tmp4_, "TrashFile", _data_->parameters, g4_portal_trash_file_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp5_ = g4_portal_call_with_file_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp6_ = _data_->_tmp5_;
	_g_free0 (_data_->_tmp4_);
	_data_->ret = _data_->_tmp6_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_variant_unref0 (_data_->parameters);
		_g_object_unref0 (_data_->file);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->val = (guint) 0;
	_data_->_tmp7_ = _data_->ret;
	if (_data_->_tmp7_ != NULL) {
		_data_->_tmp8_ = 0U;
		g_variant_get ((GVariant*) _data_->_tmp7_, "(u)", &_data_->_tmp8_, NULL);
		_data_->val = _data_->_tmp8_;
	}
	_data_->result = _data_->val == ((guint) 1);
	_g_variant_unref0 (_data_->ret);
	_g_variant_unref0 (_data_->parameters);
	_g_object_unref0 (_data_->file);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
g4_portal_call_with_file_async_data_free (gpointer _data)
{
	G4PortalCallWithFileAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->file);
	_g_free0 (_data_->interface_name);
	_g_free0 (_data_->method_name);
	_g_variant_unref0 (_data_->parameters);
	_g_variant_unref0 (_data_->result);
	_g4_portal_unref0 (_data_->self);
	g_slice_free (G4PortalCallWithFileAsyncData, _data_);
}

static gpointer
_g_variant_ref0 (gpointer self)
{
	return self ? g_variant_ref (self) : NULL;
}

static void
g4_portal_call_with_file_async (G4Portal* self,
                                GFile* file,
                                gint flags,
                                const gchar* interface_name,
                                const gchar* method_name,
                                GVariant* parameters,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	G4PortalCallWithFileAsyncData* _data_;
	G4Portal* _tmp0_;
	GFile* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GVariant* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	g_return_if_fail (interface_name != NULL);
	g_return_if_fail (method_name != NULL);
	_data_ = g_slice_new0 (G4PortalCallWithFileAsyncData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, g4_portal_call_with_file_async_data_free);
	_tmp0_ = _g4_portal_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (file);
	_g_object_unref0 (_data_->file);
	_data_->file = _tmp1_;
	_data_->flags = flags;
	_tmp2_ = g_strdup (interface_name);
	_g_free0 (_data_->interface_name);
	_data_->interface_name = _tmp2_;
	_tmp3_ = g_strdup (method_name);
	_g_free0 (_data_->method_name);
	_data_->method_name = _tmp3_;
	_tmp4_ = _g_variant_ref0 (parameters);
	_g_variant_unref0 (_data_->parameters);
	_data_->parameters = _tmp4_;
	g4_portal_call_with_file_async_co (_data_);
}

static GVariant*
g4_portal_call_with_file_finish (G4Portal* self,
                                 GAsyncResult* _res_,
                                 GError** error)
{
	GVariant* result;
	G4PortalCallWithFileAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static GError*
vala_g_io_error_from_errno (gint err_no)
{
	const gchar* _tmp0_;
	GError* _tmp1_;
	GError* result;
	_tmp0_ = g_strerror (err_no);
	_tmp1_ = g_error_new (g_io_error_quark (), g_io_error_from_errno (err_no), "%s", _tmp0_);
	result = (GError*) _tmp1_;
	return result;
}

static void
g4_portal_call_with_file_async_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	G4PortalCallWithFileAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	g4_portal_call_with_file_async_co (_data_);
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

static gboolean
g4_portal_call_with_file_async_co (G4PortalCallWithFileAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->fd = -1;
	{
		_data_->_tmp1_ = g_file_get_path (_data_->file);
		_data_->_tmp0_ = _data_->_tmp1_;
		if (_data_->_tmp0_ == NULL) {
			_data_->_tmp2_ = g_file_get_parse_name (_data_->file);
			_g_free0 (_data_->_tmp0_);
			_data_->_tmp0_ = _data_->_tmp2_;
		}
		_data_->_tmp3_ = _data_->_tmp0_;
		_data_->_tmp0_ = NULL;
		_data_->path = (gchar*) _data_->_tmp3_;
		_data_->_tmp4_ = _data_->path;
		_data_->fd = open (_data_->_tmp4_, _data_->flags, (mode_t) 0);
		if (_data_->fd == -1) {
			_data_->_tmp5_ = vala_g_io_error_from_errno (errno);
			_data_->_inner_error0_ = _data_->_tmp5_;
			_g_free0 (_data_->path);
			_g_free0 (_data_->_tmp0_);
			goto __catch0_g_error;
		}
		_data_->_tmp6_ = g_unix_fd_list_new ();
		_data_->fd_list = _data_->_tmp6_;
		_data_->_tmp7_ = _data_->fd_list;
		g_unix_fd_list_append (_data_->_tmp7_, _data_->fd, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->fd_list);
			_g_free0 (_data_->path);
			_g_free0 (_data_->_tmp0_);
			goto __catch0_g_error;
		}
		_data_->_tmp9_ = _data_->self->priv->_bus;
		_data_->_tmp10_ = _g_object_ref0 (_data_->_tmp9_);
		_data_->_tmp8_ = _data_->_tmp10_;
		if (_data_->_tmp8_ == NULL) {
			_data_->_state_ = 1;
			g_bus_get (G_BUS_TYPE_SESSION, NULL, g4_portal_call_with_file_async_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp11_ = g_bus_get_finish (_data_->_res_, &_data_->_inner_error0_);
			_g_object_unref0 (_data_->_tmp8_);
			_data_->_tmp8_ = _data_->_tmp11_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->_tmp8_);
				_g_object_unref0 (_data_->fd_list);
				_g_free0 (_data_->path);
				_g_free0 (_data_->_tmp0_);
				goto __catch0_g_error;
			}
		}
		_data_->_tmp12_ = _data_->_tmp8_;
		_data_->_tmp8_ = NULL;
		_g_object_unref0 (_data_->self->priv->_bus);
		_data_->self->priv->_bus = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp12_, g_dbus_connection_get_type (), GDBusConnection);
		_data_->_tmp14_ = _data_->self->priv->_bus;
		_data_->_tmp15_ = g4_portal_BUS_NAME;
		_data_->_tmp16_ = g4_portal_OBJECT_PATH;
		_data_->_tmp17_ = _data_->fd_list;
		_data_->_state_ = 2;
		g_dbus_connection_call_with_unix_fd_list (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp14_, g_dbus_connection_get_type (), GDBusConnection), _data_->_tmp15_, _data_->_tmp16_, _data_->interface_name, _data_->method_name, _data_->parameters, NULL, G_DBUS_CALL_FLAGS_NONE, -1, _data_->_tmp17_, NULL, g4_portal_call_with_file_async_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp18_ = g_dbus_connection_call_with_unix_fd_list_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp14_, g_dbus_connection_get_type (), GDBusConnection), NULL, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp13_ = _data_->_tmp18_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->_tmp8_);
			_g_object_unref0 (_data_->fd_list);
			_g_free0 (_data_->path);
			_g_free0 (_data_->_tmp0_);
			goto __catch0_g_error;
		}
		_data_->_tmp19_ = _data_->_tmp13_;
		_data_->_tmp13_ = NULL;
		_data_->result = _data_->_tmp19_;
		_g_variant_unref0 (_data_->_tmp13_);
		_g_object_unref0 (_data_->_tmp8_);
		_g_object_unref0 (_data_->fd_list);
		_g_free0 (_data_->path);
		_g_free0 (_data_->_tmp0_);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		if (_data_->fd != -1) {
			close (_data_->fd);
		}
		_data_->_tmp20_ = _data_->e;
		_data_->_tmp21_ = _g_error_copy0 (_data_->_tmp20_);
		_data_->_inner_error0_ = _data_->_tmp21_;
		_g_error_free0 (_data_->e);
		goto __finally0;
	}
	__finally0:
	g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static GVariantBuilder*
g4_portal_make_options_builder (G4Portal* self)
{
	gchar* token = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GVariantBuilder* options = NULL;
	const GVariantType* _tmp4_;
	GVariantBuilder* _tmp5_;
	GVariant* _tmp6_;
	GVariant* _tmp7_;
	GVariantBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup_printf ("%u", g_random_int ());
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strconcat ("portal", _tmp1_, NULL);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	token = _tmp3_;
	_tmp4_ = G_VARIANT_TYPE_VARDICT;
	_tmp5_ = g_variant_builder_new (_tmp4_);
	options = _tmp5_;
	_tmp6_ = g_variant_new_string (token);
	g_variant_ref_sink (_tmp6_);
	_tmp7_ = _tmp6_;
	g_variant_builder_add (options, "{sv}", "handle_token", _tmp7_, NULL);
	_g_variant_unref0 (_tmp7_);
	result = options;
	_g_free0 (token);
	return result;
}

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

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

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

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

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

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

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

void
g4_value_set_portal (GValue* value,
                     gpointer v_object)
{
	G4Portal * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, G4_TYPE_PORTAL));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, G4_TYPE_PORTAL));
		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;
		g4_portal_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		g4_portal_unref (old);
	}
}

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

static void
g4_portal_class_init (G4PortalClass * klass,
                      gpointer klass_data)
{
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	g4_portal_parent_class = g_type_class_peek_parent (klass);
	((G4PortalClass *) klass)->finalize = g4_portal_finalize;
	g_type_class_adjust_private_offset (klass, &G4Portal_private_offset);
	_tmp0_ = g_strdup ("org.freedesktop.portal.");
	g4_portal_PORTAL_NAME = _tmp0_;
	_tmp1_ = g4_portal_PORTAL_NAME;
	_tmp2_ = g_strconcat (_tmp1_, "Desktop", NULL);
	g4_portal_BUS_NAME = _tmp2_;
	_tmp3_ = g_strdup ("/org/freedesktop/portal/desktop");
	g4_portal_OBJECT_PATH = _tmp3_;
}

static void
g4_portal_instance_init (G4Portal * self,
                         gpointer klass)
{
	self->priv = g4_portal_get_instance_private (self);
	self->priv->_bus = NULL;
	self->ref_count = 1;
}

static void
g4_portal_finalize (G4Portal * obj)
{
	G4Portal * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, G4_TYPE_PORTAL, G4Portal);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->_bus);
	_g_free0 (self->priv->_parent);
}

static GType
g4_portal_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { g4_value_portal_init, g4_value_portal_free_value, g4_value_portal_copy_value, g4_value_portal_peek_pointer, "p", g4_value_portal_collect_value, "p", g4_value_portal_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (G4PortalClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) g4_portal_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (G4Portal), 0, (GInstanceInitFunc) g4_portal_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 g4_portal_type_id;
	g4_portal_type_id = g_type_register_fundamental (g_type_fundamental_next (), "G4Portal", &g_define_type_info, &g_define_type_fundamental_info, 0);
	G4Portal_private_offset = g_type_add_instance_private (g4_portal_type_id, sizeof (G4PortalPrivate));
	return g4_portal_type_id;
}

GType
g4_portal_get_type (void)
{
	static volatile gsize g4_portal_type_id__once = 0;
	if (g_once_init_enter (&g4_portal_type_id__once)) {
		GType g4_portal_type_id;
		g4_portal_type_id = g4_portal_get_type_once ();
		g_once_init_leave (&g4_portal_type_id__once, g4_portal_type_id);
	}
	return g4_portal_type_id__once;
}

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

void
g4_portal_unref (gpointer instance)
{
	G4Portal * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		G4_PORTAL_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;
}

