#include "gvaluetypes.h"
#include "gvaluecollector.h"
+#include "gobjectalias.h"
#include <string.h>
#include <stdlib.h> /* qsort() */
static void
value_copy_int64 (const GValue *src_value,
- GValue *dest_value)
+ GValue *dest_value)
{
dest_value->data[0].v_int64 = src_value->data[0].v_int64;
}
static gchar*
value_collect_int64 (GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
value->data[0].v_int64 = collect_values[0].v_int64;
static gchar*
value_lcopy_int64 (const GValue *value,
- guint n_collect_values,
- GTypeCValue *collect_values,
- guint collect_flags)
+ guint n_collect_values,
+ GTypeCValue *collect_values,
+ guint collect_flags)
{
gint64 *int64_p = collect_values[0].v_pointer;
/* --- type initialization --- */
void
-g_value_types_init (void) /* sync with gtype.c */
+g_value_types_init (void)
{
GTypeInfo info = {
0, /* class_size */
value_lcopy_char, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_CHAR, "gchar", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_CHAR, g_intern_static_string ("gchar"), &info, &finfo, 0);
g_assert (type == G_TYPE_CHAR);
- type = g_type_register_fundamental (G_TYPE_UCHAR, "guchar", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_UCHAR, g_intern_static_string ("guchar"), &info, &finfo, 0);
g_assert (type == G_TYPE_UCHAR);
}
value_lcopy_boolean, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_BOOLEAN, "gboolean", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_BOOLEAN, g_intern_static_string ("gboolean"), &info, &finfo, 0);
g_assert (type == G_TYPE_BOOLEAN);
}
value_lcopy_int, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_INT, "gint", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_INT, g_intern_static_string ("gint"), &info, &finfo, 0);
g_assert (type == G_TYPE_INT);
- type = g_type_register_fundamental (G_TYPE_UINT, "guint", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_UINT, g_intern_static_string ("guint"), &info, &finfo, 0);
g_assert (type == G_TYPE_UINT);
}
value_lcopy_long, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_LONG, "glong", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_LONG, g_intern_static_string ("glong"), &info, &finfo, 0);
g_assert (type == G_TYPE_LONG);
- type = g_type_register_fundamental (G_TYPE_ULONG, "gulong", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_ULONG, g_intern_static_string ("gulong"), &info, &finfo, 0);
g_assert (type == G_TYPE_ULONG);
}
"q", /* collect_format */
value_collect_int64, /* collect_value */
"p", /* lcopy_format */
- value_lcopy_int64, /* lcopy_value */
+ value_lcopy_int64, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_INT64, "gint64", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_INT64, g_intern_static_string ("gint64"), &info, &finfo, 0);
g_assert (type == G_TYPE_INT64);
- type = g_type_register_fundamental (G_TYPE_UINT64, "guint64", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_UINT64, g_intern_static_string ("guint64"), &info, &finfo, 0);
g_assert (type == G_TYPE_UINT64);
}
value_lcopy_float, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_FLOAT, "gfloat", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_FLOAT, g_intern_static_string ("gfloat"), &info, &finfo, 0);
g_assert (type == G_TYPE_FLOAT);
}
value_lcopy_double, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_DOUBLE, "gdouble", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_DOUBLE, g_intern_static_string ("gdouble"), &info, &finfo, 0);
g_assert (type == G_TYPE_DOUBLE);
}
value_lcopy_string, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_STRING, "gchararray", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_STRING, g_intern_static_string ("gchararray"), &info, &finfo, 0);
g_assert (type == G_TYPE_STRING);
}
value_lcopy_pointer, /* lcopy_value */
};
info.value_table = &value_table;
- type = g_type_register_fundamental (G_TYPE_POINTER, "gpointer", &info, &finfo, 0);
+ type = g_type_register_fundamental (G_TYPE_POINTER, g_intern_static_string ("gpointer"), &info, &finfo, 0);
g_assert (type == G_TYPE_POINTER);
}
}
void
g_value_set_int64 (GValue *value,
- gint64 v_int64)
+ gint64 v_int64)
{
g_return_if_fail (G_VALUE_HOLDS_INT64 (value));
void
g_value_set_uint64 (GValue *value,
- guint64 v_uint64)
+ guint64 v_uint64)
{
g_return_if_fail (G_VALUE_HOLDS_UINT64 (value));
g_value_set_string (GValue *value,
const gchar *v_string)
{
+ gchar *new_val;
+
g_return_if_fail (G_VALUE_HOLDS_STRING (value));
-
+
+ new_val = g_strdup (v_string);
+
if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
value->data[1].v_uint = 0;
else
g_free (value->data[0].v_pointer);
- value->data[0].v_pointer = g_strdup (v_string);
+
+ value->data[0].v_pointer = new_val;
}
void
g_value_set_string_take_ownership (GValue *value,
gchar *v_string)
{
+ g_value_take_string (value, v_string);
+}
+
+void
+g_value_take_string (GValue *value,
+ gchar *v_string)
+{
g_return_if_fail (G_VALUE_HOLDS_STRING (value));
if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
return contents;
}
+
+GType
+g_pointer_type_register_static (const gchar *name)
+{
+ static const GTypeInfo type_info = {
+ 0, /* class_size */
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ NULL, /* class_init */
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ 0, /* instance_size */
+ 0, /* n_preallocs */
+ NULL, /* instance_init */
+ NULL /* value_table */
+ };
+ GType type;
+
+ g_return_val_if_fail (name != NULL, 0);
+ g_return_val_if_fail (g_type_from_name (name) == 0, 0);
+
+ type = g_type_register_static (G_TYPE_POINTER, name, &type_info, 0);
+
+ return type;
+}
+
+#define __G_VALUETYPES_C__
+#include "gobjectaliasdef.c"