mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
added g_value_set_static_string().
Thu Oct 26 00:30:27 2000 Tim Janik <timj@gtk.org> * gvaluetypes.[hc]: added g_value_set_static_string(). * gboxed.[hc]: const corrections. added g_value_set_static_boxed().
This commit is contained in:
parent
ee23c09e83
commit
900d0ed069
@ -1,3 +1,9 @@
|
||||
Thu Oct 26 00:30:27 2000 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gvaluetypes.[hc]: added g_value_set_static_string().
|
||||
|
||||
* gboxed.[hc]: const corrections. added g_value_set_static_boxed().
|
||||
|
||||
Wed Oct 25 20:27:02 2000 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtype.c (g_type_free_instance): for the moment, freeing object
|
||||
|
@ -85,7 +85,7 @@ boxed_proxy_value_init (GValue *value)
|
||||
static void
|
||||
boxed_proxy_value_free (GValue *value)
|
||||
{
|
||||
if (value->data[0].v_pointer)
|
||||
if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_STATIC_TAG))
|
||||
{
|
||||
BoxedNode key, *node;
|
||||
|
||||
@ -204,10 +204,11 @@ g_boxed_type_register_static (const gchar *name,
|
||||
}
|
||||
|
||||
GBoxed*
|
||||
g_boxed_copy (GType boxed_type,
|
||||
gpointer src_boxed)
|
||||
g_boxed_copy (GType boxed_type,
|
||||
gconstpointer src_boxed)
|
||||
{
|
||||
GTypeValueTable *value_table;
|
||||
gpointer dest_boxed;
|
||||
|
||||
g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
|
||||
g_return_val_if_fail (G_TYPE_IS_ABSTRACT (boxed_type) == FALSE, NULL);
|
||||
@ -224,7 +225,7 @@ g_boxed_copy (GType boxed_type,
|
||||
|
||||
key.type = boxed_type;
|
||||
node = g_bsearch_array_lookup (&boxed_bsa, &key);
|
||||
src_boxed = node->copy (src_boxed);
|
||||
dest_boxed = node->copy ((gpointer) src_boxed);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -236,7 +237,7 @@ g_boxed_copy (GType boxed_type,
|
||||
memset (&dest_value.data, 0, sizeof (dest_value.data));
|
||||
dest_value.g_type = boxed_type;
|
||||
src_value.g_type = boxed_type;
|
||||
src_value.data[0].v_pointer = src_boxed;
|
||||
src_value.data[0].v_pointer = (gpointer) src_boxed;
|
||||
value_table->value_copy (&src_value, &dest_value);
|
||||
if (dest_value.data[1].v_ulong ||
|
||||
dest_value.data[2].v_ulong ||
|
||||
@ -244,10 +245,10 @@ g_boxed_copy (GType boxed_type,
|
||||
g_warning ("the copy_value() implementation of type `%s' seems to make use of reserved GValue fields",
|
||||
g_type_name (boxed_type));
|
||||
|
||||
src_boxed = dest_value.data[0].v_pointer;
|
||||
dest_boxed = dest_value.data[0].v_pointer;
|
||||
}
|
||||
|
||||
return src_boxed;
|
||||
return dest_boxed;
|
||||
}
|
||||
|
||||
void
|
||||
@ -286,19 +287,33 @@ g_boxed_free (GType boxed_type,
|
||||
}
|
||||
|
||||
void
|
||||
g_value_set_boxed (GValue *value,
|
||||
gpointer boxed)
|
||||
g_value_set_boxed (GValue *value,
|
||||
gconstpointer boxed)
|
||||
{
|
||||
g_return_if_fail (G_IS_VALUE_BOXED (value));
|
||||
g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
|
||||
|
||||
if (value->data[0].v_pointer)
|
||||
if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_STATIC_TAG))
|
||||
g_boxed_free (G_VALUE_TYPE (value), value->data[0].v_pointer);
|
||||
value->data[0].v_pointer = boxed ? g_boxed_copy (G_VALUE_TYPE (value), boxed) : NULL;
|
||||
value->data[1].v_uint = 0;
|
||||
}
|
||||
|
||||
void
|
||||
g_value_set_static_boxed (GValue *value,
|
||||
gconstpointer boxed)
|
||||
{
|
||||
g_return_if_fail (G_IS_VALUE_BOXED (value));
|
||||
g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
|
||||
|
||||
if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_STATIC_TAG))
|
||||
g_boxed_free (G_VALUE_TYPE (value), value->data[0].v_pointer);
|
||||
value->data[0].v_pointer = (gpointer) boxed;
|
||||
value->data[1].v_uint = boxed ? G_VALUE_STATIC_TAG : 0;
|
||||
}
|
||||
|
||||
gpointer
|
||||
g_value_get_boxed (GValue *value)
|
||||
g_value_get_boxed (const GValue *value)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_VALUE_BOXED (value), NULL);
|
||||
g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
|
||||
|
@ -39,14 +39,16 @@ typedef void (*GBoxedFreeFunc) (gpointer boxed);
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
GBoxed* g_boxed_copy (GType boxed_type,
|
||||
gpointer src_boxed);
|
||||
void g_boxed_free (GType boxed_type,
|
||||
gpointer boxed);
|
||||
void g_value_set_boxed (GValue *value,
|
||||
gpointer boxed);
|
||||
gpointer g_value_get_boxed (GValue *value);
|
||||
gpointer g_value_dup_boxed (GValue *value);
|
||||
GBoxed* g_boxed_copy (GType boxed_type,
|
||||
gconstpointer src_boxed);
|
||||
void g_boxed_free (GType boxed_type,
|
||||
gpointer boxed);
|
||||
void g_value_set_boxed (GValue *value,
|
||||
gconstpointer boxed);
|
||||
void g_value_set_static_boxed (GValue *value,
|
||||
gconstpointer boxed);
|
||||
gpointer g_value_get_boxed (const GValue *value);
|
||||
gpointer g_value_dup_boxed (GValue *value);
|
||||
|
||||
|
||||
/* --- convenience --- */
|
||||
|
@ -79,6 +79,7 @@ gboolean g_value_types_exchangable (GType value_type1,
|
||||
void g_value_register_exchange_func (GType value_type1,
|
||||
GType value_type2,
|
||||
GValueExchange func);
|
||||
#define G_VALUE_STATIC_TAG (1 << 27)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -221,7 +221,8 @@ value_string_init (GValue *value)
|
||||
static void
|
||||
value_string_free_value (GValue *value)
|
||||
{
|
||||
g_free (value->data[0].v_pointer);
|
||||
if (!(value->data[1].v_uint & G_VALUE_STATIC_TAG))
|
||||
g_free (value->data[0].v_pointer);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -640,10 +641,25 @@ g_value_set_string (GValue *value,
|
||||
{
|
||||
g_return_if_fail (G_IS_VALUE_STRING (value));
|
||||
|
||||
g_free (value->data[0].v_pointer);
|
||||
if (value->data[1].v_uint & G_VALUE_STATIC_TAG)
|
||||
value->data[1].v_uint = 0;
|
||||
else
|
||||
g_free (value->data[0].v_pointer);
|
||||
value->data[0].v_pointer = g_strdup (v_string);
|
||||
}
|
||||
|
||||
void
|
||||
g_value_set_static_string (GValue *value,
|
||||
const gchar *v_string)
|
||||
{
|
||||
g_return_if_fail (G_IS_VALUE_STRING (value));
|
||||
|
||||
if (!(value->data[1].v_uint & G_VALUE_STATIC_TAG))
|
||||
g_free (value->data[0].v_pointer);
|
||||
value->data[1].v_uint = G_VALUE_STATIC_TAG;
|
||||
value->data[0].v_pointer = (gchar*) v_string;
|
||||
}
|
||||
|
||||
gchar*
|
||||
g_value_get_string (const GValue *value)
|
||||
{
|
||||
|
@ -45,40 +45,43 @@ extern "C" {
|
||||
|
||||
|
||||
/* --- prototypes --- */
|
||||
void g_value_set_char (GValue *value,
|
||||
gint8 v_char);
|
||||
gint8 g_value_get_char (const GValue *value);
|
||||
void g_value_set_uchar (GValue *value,
|
||||
guint8 v_uchar);
|
||||
guint8 g_value_get_uchar (const GValue *value);
|
||||
void g_value_set_boolean (GValue *value,
|
||||
gboolean v_boolean);
|
||||
gboolean g_value_get_boolean (const GValue *value);
|
||||
void g_value_set_int (GValue *value,
|
||||
gint v_int);
|
||||
gint g_value_get_int (const GValue *value);
|
||||
void g_value_set_uint (GValue *value,
|
||||
guint v_uint);
|
||||
guint g_value_get_uint (const GValue *value);
|
||||
void g_value_set_long (GValue *value,
|
||||
glong v_long);
|
||||
glong g_value_get_long (const GValue *value);
|
||||
void g_value_set_ulong (GValue *value,
|
||||
gulong v_ulong);
|
||||
gulong g_value_get_ulong (const GValue *value);
|
||||
void g_value_set_float (GValue *value,
|
||||
gfloat v_float);
|
||||
gfloat g_value_get_float (const GValue *value);
|
||||
void g_value_set_double (GValue *value,
|
||||
gdouble v_double);
|
||||
gdouble g_value_get_double (const GValue *value);
|
||||
void g_value_set_string (GValue *value,
|
||||
const gchar *v_string);
|
||||
gchar* g_value_get_string (const GValue *value);
|
||||
gchar* g_value_dup_string (const GValue *value);
|
||||
void g_value_set_pointer (GValue *value,
|
||||
gpointer v_pointer);
|
||||
gpointer g_value_get_pointer (GValue *value);
|
||||
void g_value_set_char (GValue *value,
|
||||
gint8 v_char);
|
||||
gint8 g_value_get_char (const GValue *value);
|
||||
void g_value_set_uchar (GValue *value,
|
||||
guint8 v_uchar);
|
||||
guint8 g_value_get_uchar (const GValue *value);
|
||||
void g_value_set_boolean (GValue *value,
|
||||
gboolean v_boolean);
|
||||
gboolean g_value_get_boolean (const GValue *value);
|
||||
void g_value_set_int (GValue *value,
|
||||
gint v_int);
|
||||
gint g_value_get_int (const GValue *value);
|
||||
void g_value_set_uint (GValue *value,
|
||||
guint v_uint);
|
||||
guint g_value_get_uint (const GValue *value);
|
||||
void g_value_set_long (GValue *value,
|
||||
glong v_long);
|
||||
glong g_value_get_long (const GValue *value);
|
||||
void g_value_set_ulong (GValue *value,
|
||||
gulong v_ulong);
|
||||
gulong g_value_get_ulong (const GValue *value);
|
||||
void g_value_set_float (GValue *value,
|
||||
gfloat v_float);
|
||||
gfloat g_value_get_float (const GValue *value);
|
||||
void g_value_set_double (GValue *value,
|
||||
gdouble v_double);
|
||||
gdouble g_value_get_double (const GValue *value);
|
||||
void g_value_set_string (GValue *value,
|
||||
const gchar *v_string);
|
||||
void g_value_set_static_string (GValue *value,
|
||||
const gchar *v_string);
|
||||
gchar* g_value_get_string (const GValue *value);
|
||||
gchar* g_value_dup_string (const GValue *value);
|
||||
void g_value_set_pointer (GValue *value,
|
||||
gpointer v_pointer);
|
||||
gpointer g_value_get_pointer (GValue *value);
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user