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

#include <glib-object.h>
#include <json-glib/json-glib.h>
#include <glib.h>
#include <stdlib.h>
#include <string.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 DC_TYPE_PARAMS (dc_params_get_type ())
#define DC_PARAMS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_PARAMS, DcParams))
#define DC_PARAMS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_PARAMS, DcParamsClass))
#define DC_IS_PARAMS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_PARAMS))
#define DC_IS_PARAMS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_PARAMS))
#define DC_PARAMS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_PARAMS, DcParamsClass))

typedef struct _DcParams DcParams;
typedef struct _DcParamsClass DcParamsClass;
typedef struct _DcParamsPrivate DcParamsPrivate;
enum  {
	DC_PARAMS_0_PROPERTY,
	DC_PARAMS_NUM_PROPERTIES
};
static GParamSpec* dc_params_properties[DC_PARAMS_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))

struct _DcParams {
	GObject parent_instance;
	DcParamsPrivate * priv;
};

struct _DcParamsClass {
	GObjectClass parent_class;
};

struct _DcParamsPrivate {
	JsonBuilder* b;
};

static gint DcParams_private_offset;
static gpointer dc_params_parent_class = NULL;

VALA_EXTERN GType dc_params_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcParams, g_object_unref)
static DcParams* dc_params_new (void);
static DcParams* dc_params_construct (GType object_type);
VALA_EXTERN DcParams* dc_params_begin (void);
VALA_EXTERN DcParams* dc_params_add_int (DcParams* self,
                             gint v);
VALA_EXTERN DcParams* dc_params_add_string (DcParams* self,
                                const gchar* v);
VALA_EXTERN DcParams* dc_params_add_bool (DcParams* self,
                              gboolean v);
VALA_EXTERN DcParams* dc_params_add_null (DcParams* self);
VALA_EXTERN DcParams* dc_params_add_int_array (DcParams* self,
                                   gint* values,
                                   gint values_length1);
VALA_EXTERN DcParams* dc_params_add_string_array (DcParams* self,
                                      gchar** values,
                                      gint values_length1);
VALA_EXTERN DcParams* dc_params_add_json_array (DcParams* self,
                                    JsonArray* arr);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static void _vala_JsonNode_free (JsonNode* self);
VALA_EXTERN DcParams* dc_params_begin_object (DcParams* self);
VALA_EXTERN DcParams* dc_params_end_object (DcParams* self);
VALA_EXTERN DcParams* dc_params_set_string_member (DcParams* self,
                                       const gchar* name,
                                       const gchar* value);
VALA_EXTERN DcParams* dc_params_set_int_member (DcParams* self,
                                    const gchar* name,
                                    gint value);
VALA_EXTERN DcParams* dc_params_set_opt_int_member (DcParams* self,
                                        const gchar* name,
                                        gint value);
VALA_EXTERN DcParams* dc_params_set_null_member (DcParams* self,
                                     const gchar* name);
VALA_EXTERN JsonNode* dc_params_build (DcParams* self);
static void dc_params_finalize (GObject * obj);
static GType dc_params_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dc_params_get_instance_private (DcParams* self)
{
	return G_STRUCT_MEMBER_P (self, DcParams_private_offset);
}

static DcParams*
dc_params_construct (GType object_type)
{
	DcParams * self = NULL;
	JsonBuilder* _tmp0_;
	JsonBuilder* _tmp1_;
	self = (DcParams*) g_object_new (object_type, NULL);
	_tmp0_ = json_builder_new ();
	_g_object_unref0 (self->priv->b);
	self->priv->b = _tmp0_;
	_tmp1_ = self->priv->b;
	json_builder_begin_array (_tmp1_);
	return self;
}

static DcParams*
dc_params_new (void)
{
	return dc_params_construct (DC_TYPE_PARAMS);
}

DcParams*
dc_params_begin (void)
{
	DcParams* _tmp0_;
	DcParams* result;
	_tmp0_ = dc_params_new ();
	result = _tmp0_;
	return result;
}

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

DcParams*
dc_params_add_int (DcParams* self,
                   gint v)
{
	JsonBuilder* _tmp0_;
	DcParams* _tmp1_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_add_int_value (_tmp0_, (gint64) v);
	_tmp1_ = _g_object_ref0 (self);
	result = _tmp1_;
	return result;
}

DcParams*
dc_params_add_string (DcParams* self,
                      const gchar* v)
{
	DcParams* _tmp2_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (v != NULL) {
		JsonBuilder* _tmp0_;
		_tmp0_ = self->priv->b;
		json_builder_add_string_value (_tmp0_, v);
	} else {
		JsonBuilder* _tmp1_;
		_tmp1_ = self->priv->b;
		json_builder_add_null_value (_tmp1_);
	}
	_tmp2_ = _g_object_ref0 (self);
	result = _tmp2_;
	return result;
}

DcParams*
dc_params_add_bool (DcParams* self,
                    gboolean v)
{
	JsonBuilder* _tmp0_;
	DcParams* _tmp1_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_add_boolean_value (_tmp0_, v);
	_tmp1_ = _g_object_ref0 (self);
	result = _tmp1_;
	return result;
}

DcParams*
dc_params_add_null (DcParams* self)
{
	JsonBuilder* _tmp0_;
	DcParams* _tmp1_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_add_null_value (_tmp0_);
	_tmp1_ = _g_object_ref0 (self);
	result = _tmp1_;
	return result;
}

DcParams*
dc_params_add_int_array (DcParams* self,
                         gint* values,
                         gint values_length1)
{
	JsonBuilder* _tmp0_;
	JsonBuilder* _tmp2_;
	DcParams* _tmp3_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_begin_array (_tmp0_);
	{
		gint* v_collection = NULL;
		gint v_collection_length1 = 0;
		gint _v_collection_size_ = 0;
		gint v_it = 0;
		v_collection = values;
		v_collection_length1 = values_length1;
		for (v_it = 0; v_it < v_collection_length1; v_it = v_it + 1) {
			gint v = 0;
			v = v_collection[v_it];
			{
				JsonBuilder* _tmp1_;
				_tmp1_ = self->priv->b;
				json_builder_add_int_value (_tmp1_, (gint64) v);
			}
		}
	}
	_tmp2_ = self->priv->b;
	json_builder_end_array (_tmp2_);
	_tmp3_ = _g_object_ref0 (self);
	result = _tmp3_;
	return result;
}

DcParams*
dc_params_add_string_array (DcParams* self,
                            gchar** values,
                            gint values_length1)
{
	JsonBuilder* _tmp0_;
	JsonBuilder* _tmp4_;
	DcParams* _tmp5_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_begin_array (_tmp0_);
	{
		gchar** v_collection = NULL;
		gint v_collection_length1 = 0;
		gint _v_collection_size_ = 0;
		gint v_it = 0;
		v_collection = values;
		v_collection_length1 = values_length1;
		for (v_it = 0; v_it < v_collection_length1; v_it = v_it + 1) {
			gchar* _tmp1_;
			gchar* v = NULL;
			_tmp1_ = g_strdup (v_collection[v_it]);
			v = _tmp1_;
			{
				JsonBuilder* _tmp2_;
				const gchar* _tmp3_;
				_tmp2_ = self->priv->b;
				_tmp3_ = v;
				json_builder_add_string_value (_tmp2_, _tmp3_);
				_g_free0 (v);
			}
		}
	}
	_tmp4_ = self->priv->b;
	json_builder_end_array (_tmp4_);
	_tmp5_ = _g_object_ref0 (self);
	result = _tmp5_;
	return result;
}

static JsonNode*
_vala_JsonNode_copy (JsonNode* self)
{
	return g_boxed_copy (json_node_get_type (), self);
}

static gpointer
__vala_JsonNode_copy0 (gpointer self)
{
	return self ? _vala_JsonNode_copy (self) : NULL;
}

static void
_vala_JsonNode_free (JsonNode* self)
{
	g_boxed_free (json_node_get_type (), self);
}

DcParams*
dc_params_add_json_array (DcParams* self,
                          JsonArray* arr)
{
	JsonNode* node = NULL;
	JsonNode* _tmp0_;
	JsonBuilder* _tmp1_;
	JsonNode* _tmp2_;
	DcParams* _tmp3_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (arr != NULL, NULL);
	_tmp0_ = json_node_new (JSON_NODE_ARRAY);
	node = _tmp0_;
	json_node_set_array (node, arr);
	_tmp1_ = self->priv->b;
	_tmp2_ = __vala_JsonNode_copy0 (node);
	json_builder_add_value (_tmp1_, _tmp2_);
	_tmp3_ = _g_object_ref0 (self);
	result = _tmp3_;
	__vala_JsonNode_free0 (node);
	return result;
}

DcParams*
dc_params_begin_object (DcParams* self)
{
	JsonBuilder* _tmp0_;
	DcParams* _tmp1_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_begin_object (_tmp0_);
	_tmp1_ = _g_object_ref0 (self);
	result = _tmp1_;
	return result;
}

DcParams*
dc_params_end_object (DcParams* self)
{
	JsonBuilder* _tmp0_;
	DcParams* _tmp1_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_end_object (_tmp0_);
	_tmp1_ = _g_object_ref0 (self);
	result = _tmp1_;
	return result;
}

DcParams*
dc_params_set_string_member (DcParams* self,
                             const gchar* name,
                             const gchar* value)
{
	JsonBuilder* _tmp0_;
	DcParams* _tmp3_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_set_member_name (_tmp0_, name);
	if (value != NULL) {
		JsonBuilder* _tmp1_;
		_tmp1_ = self->priv->b;
		json_builder_add_string_value (_tmp1_, value);
	} else {
		JsonBuilder* _tmp2_;
		_tmp2_ = self->priv->b;
		json_builder_add_null_value (_tmp2_);
	}
	_tmp3_ = _g_object_ref0 (self);
	result = _tmp3_;
	return result;
}

DcParams*
dc_params_set_int_member (DcParams* self,
                          const gchar* name,
                          gint value)
{
	JsonBuilder* _tmp0_;
	JsonBuilder* _tmp1_;
	DcParams* _tmp2_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_set_member_name (_tmp0_, name);
	_tmp1_ = self->priv->b;
	json_builder_add_int_value (_tmp1_, (gint64) value);
	_tmp2_ = _g_object_ref0 (self);
	result = _tmp2_;
	return result;
}

/** Adds an integer member, or null when the value is not positive. */
DcParams*
dc_params_set_opt_int_member (DcParams* self,
                              const gchar* name,
                              gint value)
{
	JsonBuilder* _tmp0_;
	DcParams* _tmp3_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_set_member_name (_tmp0_, name);
	if (value > 0) {
		JsonBuilder* _tmp1_;
		_tmp1_ = self->priv->b;
		json_builder_add_int_value (_tmp1_, (gint64) value);
	} else {
		JsonBuilder* _tmp2_;
		_tmp2_ = self->priv->b;
		json_builder_add_null_value (_tmp2_);
	}
	_tmp3_ = _g_object_ref0 (self);
	result = _tmp3_;
	return result;
}

DcParams*
dc_params_set_null_member (DcParams* self,
                           const gchar* name)
{
	JsonBuilder* _tmp0_;
	JsonBuilder* _tmp1_;
	DcParams* _tmp2_;
	DcParams* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_set_member_name (_tmp0_, name);
	_tmp1_ = self->priv->b;
	json_builder_add_null_value (_tmp1_);
	_tmp2_ = _g_object_ref0 (self);
	result = _tmp2_;
	return result;
}

JsonNode*
dc_params_build (DcParams* self)
{
	JsonBuilder* _tmp0_;
	JsonBuilder* _tmp1_;
	JsonNode* _tmp2_;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->b;
	json_builder_end_array (_tmp0_);
	_tmp1_ = self->priv->b;
	_tmp2_ = json_builder_get_root (_tmp1_);
	result = _tmp2_;
	return result;
}

static void
dc_params_class_init (DcParamsClass * klass,
                      gpointer klass_data)
{
	dc_params_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcParams_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_params_finalize;
}

static void
dc_params_instance_init (DcParams * self,
                         gpointer klass)
{
	self->priv = dc_params_get_instance_private (self);
}

static void
dc_params_finalize (GObject * obj)
{
	DcParams * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_PARAMS, DcParams);
	_g_object_unref0 (self->priv->b);
	G_OBJECT_CLASS (dc_params_parent_class)->finalize (obj);
}

/**
     * Fluent builder for JSON-RPC params arrays.
     */
static GType
dc_params_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcParamsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_params_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcParams), 0, (GInstanceInitFunc) dc_params_instance_init, NULL };
	GType dc_params_type_id;
	dc_params_type_id = g_type_register_static (G_TYPE_OBJECT, "DcParams", &g_define_type_info, 0);
	DcParams_private_offset = g_type_add_instance_private (dc_params_type_id, sizeof (DcParamsPrivate));
	return dc_params_type_id;
}

GType
dc_params_get_type (void)
{
	static volatile gsize dc_params_type_id__once = 0;
	if (g_once_init_enter (&dc_params_type_id__once)) {
		GType dc_params_type_id;
		dc_params_type_id = dc_params_get_type_once ();
		g_once_init_leave (&dc_params_type_id__once, dc_params_type_id);
	}
	return dc_params_type_id__once;
}

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

