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

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2023 elementary, Inc. <https://elementary.io>
 *
 * Authored by: Marvin Ahlgrimm
 */

#include "fuzzy-search.h"
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.h>

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

#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _ParamSpecSearchResult ParamSpecSearchResult;

struct _ParamSpecSearchResult {
	GParamSpec parent_instance;
};

static gpointer search_result_parent_class = NULL;
static GType search_result_type_id = 0;

static void search_result_finalize (SearchResult * obj);

SearchResult*
search_result_construct (GType object_type,
                         gboolean fo,
                         gint sc)
{
	SearchResult* self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	self = (SearchResult*) g_type_create_instance (object_type);
	_tmp0_ = g_strdup ("");
	_g_free0 (self->full_path);
	self->full_path = _tmp0_;
	_tmp1_ = g_strdup ("");
	_g_free0 (self->relative_path);
	self->relative_path = _tmp1_;
	_tmp2_ = g_strdup ("");
	_g_free0 (self->project);
	self->project = _tmp2_;
	self->found = fo;
	self->score = sc;
	return self;
}

SearchResult*
search_result_new (gboolean fo,
                   gint sc)
{
	return search_result_construct (TYPE_SEARCH_RESULT, fo, sc);
}

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

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

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

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

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

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

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

void
value_set_search_result (GValue* value,
                         gpointer v_object)
{
	SearchResult * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_SEARCH_RESULT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_SEARCH_RESULT));
		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;
		search_result_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		search_result_unref (old);
	}
}

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

static void
search_result_class_init (SearchResultClass * klass,
                          gpointer klass_data)
{
	search_result_parent_class = g_type_class_peek_parent (klass);
	((SearchResultClass *) klass)->finalize = search_result_finalize;
}

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

static void
search_result_finalize (SearchResult * obj)
{
	SearchResult * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SEARCH_RESULT, SearchResult);
	g_signal_handlers_destroy (self);
	_g_free0 (self->full_path);
	_g_free0 (self->relative_path);
	_g_free0 (self->project);
}

GType
search_result_get_type (void)
{
	return search_result_type_id;
}

GType
search_result_register_type (GTypeModule * module)
{
	static const GTypeValueTable g_define_type_value_table = { value_search_result_init, value_search_result_free_value, value_search_result_copy_value, value_search_result_peek_pointer, "p", value_search_result_collect_value, "p", value_search_result_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (SearchResultClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) search_result_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SearchResult), 0, (GInstanceInitFunc) search_result_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) };
	search_result_type_id = g_type_register_fundamental (g_type_fundamental_next (), "SearchResult", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_NONE);
	return search_result_type_id;
}

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

void
search_result_unref (gpointer instance)
{
	SearchResult * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		SEARCH_RESULT_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

