mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-12 23:53:46 +02: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>
|
Wed Oct 25 20:27:02 2000 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtype.c (g_type_free_instance): for the moment, freeing object
|
* gtype.c (g_type_free_instance): for the moment, freeing object
|
||||||
|
@ -85,7 +85,7 @@ boxed_proxy_value_init (GValue *value)
|
|||||||
static void
|
static void
|
||||||
boxed_proxy_value_free (GValue *value)
|
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;
|
BoxedNode key, *node;
|
||||||
|
|
||||||
@ -205,9 +205,10 @@ g_boxed_type_register_static (const gchar *name,
|
|||||||
|
|
||||||
GBoxed*
|
GBoxed*
|
||||||
g_boxed_copy (GType boxed_type,
|
g_boxed_copy (GType boxed_type,
|
||||||
gpointer src_boxed)
|
gconstpointer src_boxed)
|
||||||
{
|
{
|
||||||
GTypeValueTable *value_table;
|
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_BOXED (boxed_type), NULL);
|
||||||
g_return_val_if_fail (G_TYPE_IS_ABSTRACT (boxed_type) == FALSE, 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;
|
key.type = boxed_type;
|
||||||
node = g_bsearch_array_lookup (&boxed_bsa, &key);
|
node = g_bsearch_array_lookup (&boxed_bsa, &key);
|
||||||
src_boxed = node->copy (src_boxed);
|
dest_boxed = node->copy ((gpointer) src_boxed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -236,7 +237,7 @@ g_boxed_copy (GType boxed_type,
|
|||||||
memset (&dest_value.data, 0, sizeof (dest_value.data));
|
memset (&dest_value.data, 0, sizeof (dest_value.data));
|
||||||
dest_value.g_type = boxed_type;
|
dest_value.g_type = boxed_type;
|
||||||
src_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);
|
value_table->value_copy (&src_value, &dest_value);
|
||||||
if (dest_value.data[1].v_ulong ||
|
if (dest_value.data[1].v_ulong ||
|
||||||
dest_value.data[2].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_warning ("the copy_value() implementation of type `%s' seems to make use of reserved GValue fields",
|
||||||
g_type_name (boxed_type));
|
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
|
void
|
||||||
@ -287,18 +288,32 @@ g_boxed_free (GType boxed_type,
|
|||||||
|
|
||||||
void
|
void
|
||||||
g_value_set_boxed (GValue *value,
|
g_value_set_boxed (GValue *value,
|
||||||
gpointer boxed)
|
gconstpointer boxed)
|
||||||
{
|
{
|
||||||
g_return_if_fail (G_IS_VALUE_BOXED (value));
|
g_return_if_fail (G_IS_VALUE_BOXED (value));
|
||||||
g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (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);
|
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[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
|
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_IS_VALUE_BOXED (value), NULL);
|
||||||
g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
|
g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
|
||||||
|
@ -40,12 +40,14 @@ typedef void (*GBoxedFreeFunc) (gpointer boxed);
|
|||||||
|
|
||||||
/* --- prototypes --- */
|
/* --- prototypes --- */
|
||||||
GBoxed* g_boxed_copy (GType boxed_type,
|
GBoxed* g_boxed_copy (GType boxed_type,
|
||||||
gpointer src_boxed);
|
gconstpointer src_boxed);
|
||||||
void g_boxed_free (GType boxed_type,
|
void g_boxed_free (GType boxed_type,
|
||||||
gpointer boxed);
|
gpointer boxed);
|
||||||
void g_value_set_boxed (GValue *value,
|
void g_value_set_boxed (GValue *value,
|
||||||
gpointer boxed);
|
gconstpointer boxed);
|
||||||
gpointer g_value_get_boxed (GValue *value);
|
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);
|
gpointer g_value_dup_boxed (GValue *value);
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ gboolean g_value_types_exchangable (GType value_type1,
|
|||||||
void g_value_register_exchange_func (GType value_type1,
|
void g_value_register_exchange_func (GType value_type1,
|
||||||
GType value_type2,
|
GType value_type2,
|
||||||
GValueExchange func);
|
GValueExchange func);
|
||||||
|
#define G_VALUE_STATIC_TAG (1 << 27)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -221,6 +221,7 @@ value_string_init (GValue *value)
|
|||||||
static void
|
static void
|
||||||
value_string_free_value (GValue *value)
|
value_string_free_value (GValue *value)
|
||||||
{
|
{
|
||||||
|
if (!(value->data[1].v_uint & G_VALUE_STATIC_TAG))
|
||||||
g_free (value->data[0].v_pointer);
|
g_free (value->data[0].v_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,10 +641,25 @@ g_value_set_string (GValue *value,
|
|||||||
{
|
{
|
||||||
g_return_if_fail (G_IS_VALUE_STRING (value));
|
g_return_if_fail (G_IS_VALUE_STRING (value));
|
||||||
|
|
||||||
|
if (value->data[1].v_uint & G_VALUE_STATIC_TAG)
|
||||||
|
value->data[1].v_uint = 0;
|
||||||
|
else
|
||||||
g_free (value->data[0].v_pointer);
|
g_free (value->data[0].v_pointer);
|
||||||
value->data[0].v_pointer = g_strdup (v_string);
|
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*
|
gchar*
|
||||||
g_value_get_string (const GValue *value)
|
g_value_get_string (const GValue *value)
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,8 @@ void g_value_set_double (GValue *value,
|
|||||||
gdouble g_value_get_double (const GValue *value);
|
gdouble g_value_get_double (const GValue *value);
|
||||||
void g_value_set_string (GValue *value,
|
void g_value_set_string (GValue *value,
|
||||||
const gchar *v_string);
|
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_get_string (const GValue *value);
|
||||||
gchar* g_value_dup_string (const GValue *value);
|
gchar* g_value_dup_string (const GValue *value);
|
||||||
void g_value_set_pointer (GValue *value,
|
void g_value_set_pointer (GValue *value,
|
||||||
@ -83,6 +85,7 @@ gpointer g_value_get_pointer (GValue *value);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user