[glib/gvariant] remove GVariant "matches" teminology



commit f5d9b2da72fb28b0b515b46a1c52ee2176d4e147
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jan 14 18:16:49 2010 -0500

    remove GVariant "matches" teminology
    
    replace with more simple terms

 docs/reference/glib/glib-sections.txt |    4 +-
 glib/glib.symbols                     |    4 +-
 glib/gvariant-parser.c                |    2 +-
 glib/gvariant-util.c                  |   44 +++++++++++++++-----------------
 glib/gvariant-valist.c                |    2 +-
 glib/gvariant.h                       |    2 +-
 glib/gvarianttype.c                   |   24 +++++++++---------
 glib/gvarianttype.h                   |    4 +-
 8 files changed, 42 insertions(+), 44 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index dea8fa2..12c41f5 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -2761,7 +2761,7 @@ g_variant_type_is_concrete
 <SUBSECTION>
 g_variant_type_hash
 g_variant_type_equal
-g_variant_type_matches
+g_variant_type_is_subtype_of
 
 <SUBSECTION>
 g_variant_type_new_maybe
@@ -2788,7 +2788,7 @@ g_variant_ref_sink
 g_variant_unref
 g_variant_get_type
 g_variant_get_type_class
-g_variant_matches
+g_variant_has_type
 g_variant_get_type_string
 g_variant_is_basic
 g_variant_is_container
diff --git a/glib/glib.symbols b/glib/glib.symbols
index 42932ad..ed4f9ed 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -1671,7 +1671,7 @@ g_variant_get_type_class
 g_variant_get_type_string
 g_variant_is_basic
 g_variant_is_container
-g_variant_matches
+g_variant_has_type
 g_variant_new_boolean
 g_variant_new_byte
 g_variant_new_uint16
@@ -1770,7 +1770,7 @@ g_variant_type_is_container
 g_variant_type_is_basic
 g_variant_type_hash
 g_variant_type_equal
-g_variant_type_matches
+g_variant_type_is_subtype_of
 g_variant_type_is_in_class
 g_variant_type_get_class
 g_variant_type_class_is_container
diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c
index 5927108..514dedc 100644
--- a/glib/gvariant-parser.c
+++ b/glib/gvariant-parser.c
@@ -1748,7 +1748,7 @@ positional_get_value (AST                *ast,
   GVariant *tmp;
 
   g_assert (positional->value != NULL);
-  g_assert (g_variant_matches (positional->value, type));
+  g_assert (g_variant_has_type (positional->value, type));
 
   /* XXX if _get is called more than once then
    * things get messed up with respect to floating refs.
diff --git a/glib/gvariant-util.c b/glib/gvariant-util.c
index 88e5428..941848f 100644
--- a/glib/gvariant-util.c
+++ b/glib/gvariant-util.c
@@ -205,23 +205,21 @@ g_variant_iter_should_free (GVariantIter *iter)
 }
 
 /**
- * g_variant_matches:
+ * g_variant_has_type:
  * @value: a #GVariant instance
  * @pattern: a #GVariantType
- * @returns: %TRUE if the type of @value matches @pattern
+ * @returns: %TRUE if the type of @value matches @type
  *
- * Checks if a value has a type matching the provided pattern.  This
- * call is equivalent to calling g_variant_get_type() then
- * g_variant_type_matches().
+ * Checks if a value has a type matching the provided type.
  **/
 gboolean
-g_variant_matches (GVariant           *value,
-                   const GVariantType *pattern)
+g_variant_has_type (GVariant           *value,
+                    const GVariantType *type)
 {
   g_return_val_if_fail (value != NULL, FALSE);
   g_return_val_if_fail (value != NULL, FALSE);
 
-  return g_variant_type_matches (g_variant_get_type (value), pattern);
+  return g_variant_type_is_subtype_of (g_variant_get_type (value), type);
 }
 
 /**
@@ -543,7 +541,7 @@ g_variant_get_boolean (GVariant *value)
   guint8 byte;
 
   g_return_val_if_fail (value != NULL, FALSE);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_BOOLEAN));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_BOOLEAN));
   g_variant_store (value, &byte);
 
   return byte;
@@ -565,7 +563,7 @@ g_variant_get_byte (GVariant *value)
   guint8 byte;
 
   g_return_val_if_fail (value != NULL, 0);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_BYTE));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_BYTE));
   g_variant_store (value, &byte);
 
   return byte;
@@ -587,7 +585,7 @@ g_variant_get_int16 (GVariant *value)
   gint16 int16;
 
   g_return_val_if_fail (value != NULL, 0);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_INT16));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_INT16));
   g_variant_store (value, &int16);
 
   return int16;
@@ -609,7 +607,7 @@ g_variant_get_uint16 (GVariant *value)
   guint16 uint16;
 
   g_return_val_if_fail (value != NULL, 0);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_UINT16));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_UINT16));
   g_variant_store (value, &uint16);
 
   return uint16;
@@ -631,7 +629,7 @@ g_variant_get_int32 (GVariant *value)
   gint32 int32;
 
   g_return_val_if_fail (value != NULL, 0);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_INT32));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_INT32));
   g_variant_store (value, &int32);
 
   return int32;
@@ -653,7 +651,7 @@ g_variant_get_handle (GVariant *value)
   gint32 int32;
 
   g_return_val_if_fail (value != NULL, 0);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_HANDLE));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_HANDLE));
   g_variant_store (value, &int32);
 
   return int32;
@@ -675,7 +673,7 @@ g_variant_get_uint32 (GVariant *value)
   guint32 uint32;
 
   g_return_val_if_fail (value != NULL, 0);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_UINT32));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_UINT32));
   g_variant_store (value, &uint32);
 
   return uint32;
@@ -697,7 +695,7 @@ g_variant_get_int64 (GVariant *value)
   gint64 int64;
 
   g_return_val_if_fail (value != NULL, 0);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_INT64));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_INT64));
   g_variant_store (value, &int64);
 
   return int64;
@@ -719,7 +717,7 @@ g_variant_get_uint64 (GVariant *value)
   guint64 uint64;
 
   g_return_val_if_fail (value != NULL, 0);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_UINT64));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_UINT64));
   g_variant_store (value, &uint64);
 
   return uint64;
@@ -741,7 +739,7 @@ g_variant_get_double (GVariant *value)
   gdouble floating;
 
   g_return_val_if_fail (value != NULL, 0);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_DOUBLE));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_DOUBLE));
   g_variant_store (value, &floating);
 
   return floating;
@@ -877,7 +875,7 @@ GVariant *
 g_variant_get_variant (GVariant *value)
 {
   g_return_val_if_fail (value != NULL, NULL);
-  g_assert (g_variant_matches (value, G_VARIANT_TYPE_VARIANT));
+  g_assert (g_variant_has_type (value, G_VARIANT_TYPE_VARIANT));
 
   return g_variant_get_child_value (value, 0);
 }
@@ -1515,7 +1513,7 @@ g_variant_builder_check_add (GVariantBuilder     *builder,
 
   /* type <= expected */
   if (builder->expected && type &&
-      !g_variant_type_matches (type, builder->expected))
+      !g_variant_type_is_subtype_of (type, builder->expected))
     {
       gchar *expected_str, *type_str;
 
@@ -1533,7 +1531,7 @@ g_variant_builder_check_add (GVariantBuilder     *builder,
   /* expected2 <= tclass && expected2 <= type */
   if (builder->expected2 &&
       ((!g_variant_type_is_in_class (builder->expected2, tclass)) ||
-       (type && !g_variant_type_matches (builder->expected2, type))))
+       (type && !g_variant_type_is_subtype_of (builder->expected2, type))))
     {
       g_set_error (error, G_VARIANT_BUILDER_ERROR,
                    G_VARIANT_BUILDER_ERROR_TYPE,
@@ -1912,7 +1910,7 @@ g_variant_get_strv (GVariant *value,
   gint i;
 
   g_return_val_if_fail (value != NULL, NULL);
-  g_return_val_if_fail (g_variant_matches (value, G_VARIANT_TYPE ("as")),
+  g_return_val_if_fail (g_variant_has_type (value, G_VARIANT_TYPE ("as")),
                         NULL);
 
   g_variant_flatten (value);
@@ -1960,7 +1958,7 @@ g_variant_dup_strv (GVariant *value,
   gint i;
 
   g_return_val_if_fail (value != NULL, NULL);
-  g_return_val_if_fail (g_variant_matches (value, G_VARIANT_TYPE ("as")),
+  g_return_val_if_fail (g_variant_has_type (value, G_VARIANT_TYPE ("as")),
                         NULL);
 
   g_variant_flatten (value);
diff --git a/glib/gvariant-valist.c b/glib/gvariant-valist.c
index c68a351..ec2a0e8 100644
--- a/glib/gvariant-valist.c
+++ b/glib/gvariant-valist.c
@@ -1379,7 +1379,7 @@ g_variant_get_va (GVariant     *value,
 
     type = g_variant_format_string_scan_type (format_string, NULL, endptr);
     g_return_if_fail (type != NULL);
-    g_return_if_fail (g_variant_matches (value, type));
+    g_return_if_fail (g_variant_has_type (value, type));
     g_variant_type_free (type);
   }
 
diff --git a/glib/gvariant.h b/glib/gvariant.h
index 92bce56..531451e 100644
--- a/glib/gvariant.h
+++ b/glib/gvariant.h
@@ -48,7 +48,7 @@ const GVariantType *            g_variant_get_type                      (GVarian
 const gchar *                   g_variant_get_type_string               (GVariant             *value);
 gboolean                        g_variant_is_basic                      (GVariant             *value);
 gboolean                        g_variant_is_container                  (GVariant             *value);
-gboolean                        g_variant_matches                       (GVariant             *value,
+gboolean                        g_variant_has_type                      (GVariant             *value,
                                                                          const GVariantType   *pattern);
 
 /* varargs construct/deconstruct */
diff --git a/glib/gvarianttype.c b/glib/gvarianttype.c
index 50f33f3..8a908b0 100644
--- a/glib/gvarianttype.c
+++ b/glib/gvarianttype.c
@@ -496,7 +496,7 @@ g_variant_type_equal (gconstpointer type1,
 }
 
 /**
- * g_variant_type_matches:
+ * g_variant_type_is_subtype_of:
  * @type: a #GVariantType
  * @pattern: a #GVariantType
  * @returns: %TRUE if @type matches @pattern
@@ -512,26 +512,26 @@ g_variant_type_equal (gconstpointer type1,
  * for which %G_VARIANT_TYPE_ANY is top.
  **/
 gboolean
-g_variant_type_matches (const GVariantType *type,
-                        const GVariantType *pattern)
+g_variant_type_is_subtype_of (const GVariantType *type,
+                              const GVariantType *supertype)
 {
-  const gchar *pattern_string;
-  const gchar *pattern_end;
+  const gchar *supertype_string;
+  const gchar *supertype_end;
   const gchar *type_string;
 
-  pattern_string = g_variant_type_peek_string (pattern);
+  supertype_string = g_variant_type_peek_string (supertype);
   type_string = g_variant_type_peek_string (type);
 
-  pattern_end = pattern_string + g_variant_type_get_string_length (pattern);
+  supertype_end = supertype_string + g_variant_type_get_string_length (supertype);
 
-  /* we know that type and pattern are both well-formed, so it's
+  /* we know that type and supertype are both well-formed, so it's
    * safe to treat this merely as a text processing problem.
    */
-  while (pattern_string < pattern_end)
+  while (supertype_string < supertype_end)
     {
-      char pattern_char = *pattern_string++;
+      char supertype_char = *supertype_string++;
 
-      if (pattern_char == *type_string)
+      if (supertype_char == *type_string)
         type_string++;
 
       else if (*type_string == ')')
@@ -541,7 +541,7 @@ g_variant_type_matches (const GVariantType *type,
         {
           const GVariantType *target_type = (GVariantType *) type_string;
 
-          if (!g_variant_type_is_in_class (target_type, pattern_char))
+          if (!g_variant_type_is_in_class (target_type, supertype_char))
             return FALSE;
 
           type_string += g_variant_type_get_string_length (target_type);
diff --git a/glib/gvarianttype.h b/glib/gvarianttype.h
index 80ed2f8..90d883b 100644
--- a/glib/gvarianttype.h
+++ b/glib/gvarianttype.h
@@ -300,8 +300,8 @@ gboolean                        g_variant_type_equal                    (gconstp
                                                                          gconstpointer        type2);
 
 /* matching */
-gboolean                        g_variant_type_matches                  (const GVariantType  *type,
-                                                                         const GVariantType  *pattern);
+gboolean                        g_variant_type_is_subtype_of            (const GVariantType  *type,
+                                                                         const GVariantType  *supertype);
 
 /* class functions */
 gboolean                        g_variant_type_is_in_class              (const GVariantType  *type,



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