=?utf-8?q?=5Btotem-pl-parser=5D_introspection=3A_Skip_TotemPlParserMetada?= =?utf-8?q?ta_because_it=E2=80=99s_evil?=



commit b39cd3367627691ef4686ca4c0ad12b5b9e447fd
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Feb 5 14:05:03 2012 +0000

    introspection: Skip TotemPlParserMetadata because itâs evil
    
    TotemPlParserMetadata is a GHashTable wearing a fake moustache, originating
    from the days when GHashTable wasnât a proper boxed type. GIR knows about the
    peculiarities of GHashTable (for example, its key and value element types);
    but is fooled by the fake moustache and doesnât know what to make of
    TotemPlParserMetadata.
    
    This is bad. Nobody likes fake moustaches.
    
    This commit marks TotemPlParserMetadata as to be (skip)ped by GIR, and
    overrides the locations where it used to pretend to be GHashTables. Since
    the copy/free functions for the boxed TotemPlParserMetadata and boxed
    GHashTable are the same, this shouldnât cause problems for bindings when
    they try and unbox the GHashTables, since no boxed type identifier is carried
    along with the box.
    
    Closes: https://bugzilla.gnome.org/show_bug.cgi?id=669398

 plparse/totem-pl-parser.c |    7 +++++--
 plparse/totem-pl-parser.h |    2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index abc93a8..6663441 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -394,7 +394,7 @@ totem_pl_parser_class_init (TotemPlParserClass *klass)
 	 * TotemPlParser::entry-parsed:
 	 * @parser: the object which received the signal
 	 * @uri: the URI of the entry parsed
-	 * @metadata: (type TotemPlParser.ParserMetadata): a #GHashTable of metadata relating to the entry added
+	 * @metadata: (type GHashTable) (element-type utf8 utf8): a #GHashTable of metadata relating to the entry added
 	 *
 	 * The ::entry-parsed signal is emitted when a new entry is parsed.
 	 */
@@ -410,7 +410,7 @@ totem_pl_parser_class_init (TotemPlParserClass *klass)
 	 * TotemPlParser::playlist-started:
 	 * @parser: the object which received the signal
 	 * @uri: the URI of the new playlist started
-	 * @metadata: (type TotemPlParser.ParserMetadata): a #GHashTable of metadata relating to the playlist that
+	 * @metadata: (type GHashTable) (element-type utf8 utf8): a #GHashTable of metadata relating to the playlist that
 	 * started.
 	 *
 	 * The ::playlist-started signal is emitted when a playlist parsing has
@@ -2490,6 +2490,9 @@ totem_pl_parser_metadata_get_type (void)
 	static volatile gsize g_define_type_id__volatile = 0;
 	if (g_once_init_enter (&g_define_type_id__volatile))
 	{
+		/* NOTE: This is equivalent to the definition for GHashTable in gboxed.c, in that it uses the same copy/free functions.
+		 * This means that if we box a TotemPlParserMetadata inside a GValue, we can safely unbox it as a GHashTable (and vice-versa).
+		 * This means we can hide TotemPlParserMetadata from introspection, and just pretend it's actually been a GHashTable all along. */
 		GType g_define_type_id = g_boxed_type_register_static (
 		    g_intern_static_string ("TotemPlParserMetadata"),
 		    (GBoxedCopyFunc) g_hash_table_ref,
diff --git a/plparse/totem-pl-parser.h b/plparse/totem-pl-parser.h
index 3aa9945..c3ffd82 100644
--- a/plparse/totem-pl-parser.h
+++ b/plparse/totem-pl-parser.h
@@ -363,7 +363,7 @@ void totem_pl_parser_parse_with_base_async (TotemPlParser *parser,
 TotemPlParser *totem_pl_parser_new (void);
 
 /**
- * TotemPlParserMetadata:
+ * TotemPlParserMetadata: (skip)
  *
  * An alias for #GHashTable, used in the #TotemPlParser::entry-parsed and
  * #TotemPlParser::playlist-started signals due to #GHashTable not being a



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]