From: Tim Janik Date: Wed, 23 Nov 2005 12:37:01 +0000 (+0000) Subject: minor cleanups, implemented G_TYPE_HASH_TABLE. X-Git-Tag: GLIB_2_9_1~68 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02b62d08cc24556b6b86f36f05319621e576ba40;p=platform%2Fupstream%2Fglib.git minor cleanups, implemented G_TYPE_HASH_TABLE. Wed Nov 23 13:36:02 2005 Tim Janik * gboxed.[hc]: minor cleanups, implemented G_TYPE_HASH_TABLE. --- diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 4524a24..ab60715 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,7 @@ +Wed Nov 23 13:36:02 2005 Tim Janik + + * gboxed.[hc]: minor cleanups, implemented G_TYPE_HASH_TABLE. + 2005-11-17 Matthias Clasen * === Released 2.9.0 === diff --git a/gobject/gboxed.c b/gobject/gboxed.c index 61cda3f..cab8164 100644 --- a/gobject/gboxed.c +++ b/gobject/gboxed.c @@ -93,30 +93,6 @@ value_free (gpointer boxed) g_free (value); } -static gpointer -gdate_copy (gpointer boxed) -{ - const GDate *date = (const GDate*) boxed; - - return g_date_new_julian (g_date_get_julian (date)); -} - -static gpointer -gstring_copy (gpointer boxed) -{ - const GString *src_gstring = boxed; - - return g_string_new_len (src_gstring->str, src_gstring->len); -} - -static void -gstring_free (gpointer boxed) -{ - GString *gstring = boxed; - - g_string_free (gstring, TRUE); -} - void g_boxed_type_init (void) { @@ -180,6 +156,14 @@ g_value_array_get_type (void) return type_id; } +static gpointer +gdate_copy (gpointer boxed) +{ + const GDate *date = (const GDate*) boxed; + + return g_date_new_julian (g_date_get_julian (date)); +} + GType g_date_get_type (void) { @@ -204,18 +188,59 @@ g_strv_get_type (void) return type_id; } +static gpointer +gstring_copy (gpointer boxed) +{ + const GString *src_gstring = boxed; + + return g_string_new_len (src_gstring->str, src_gstring->len); +} + +static void +gstring_free (gpointer boxed) +{ + GString *gstring = boxed; + + g_string_free (gstring, TRUE); +} + GType g_gstring_get_type (void) { static GType type_id = 0; if (!type_id) - type_id = g_boxed_type_register_static (g_intern_static_string ("GString"), /* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */ + type_id = g_boxed_type_register_static (g_intern_static_string ("GString"), + /* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */ gstring_copy, gstring_free); return type_id; } +static gpointer +hash_table_copy (gpointer boxed) +{ + GHashTable *hash_table = boxed; + return g_hash_table_ref (hash_table); +} + +static void +hash_table_free (gpointer boxed) +{ + GHashTable *hash_table = boxed; + g_hash_table_unref (hash_table); +} + +GType +g_hash_table_get_type (void) +{ + static GType type_id = 0; + if (!type_id) + type_id = g_boxed_type_register_static (g_intern_static_string ("GHashTable"), + hash_table_copy, hash_table_free); + return type_id; +} + static void boxed_proxy_value_init (GValue *value) { diff --git a/gobject/gboxed.h b/gobject/gboxed.h index 58c245d..eadb12e 100644 --- a/gobject/gboxed.h +++ b/gobject/gboxed.h @@ -63,6 +63,7 @@ GType g_boxed_type_register_static (const gchar *name, #define G_TYPE_DATE (g_date_get_type ()) #define G_TYPE_STRV (g_strv_get_type ()) #define G_TYPE_GSTRING (g_gstring_get_type ()) +#define G_TYPE_HASH_TABLE (g_hash_table_get_type ()) void g_value_take_boxed (GValue *value,