[glib/gvariant-varargs] add "internal" header for the benefit of tests



commit c5fa6114fb846a9ccd787ce927fd33db4cf97533
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Mar 8 10:03:18 2010 -0500

    add "internal" header for the benefit of tests

 docs/reference/glib/glib-sections.txt |    2 -
 glib/glib.symbols                     |    9 +++++-
 glib/gvariant-internal.h              |   46 +++++++++++++++++++++++++++++++++
 glib/gvariant.c                       |   27 ++++++++-----------
 glib/gvariant.h                       |   12 +--------
 glib/tests/gvariant.c                 |   23 +++-------------
 6 files changed, 69 insertions(+), 50 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 57b6b65..5ae7413 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -2799,8 +2799,6 @@ g_variant_classify
 GVariantClass
 
 <SUBSECTION>
-g_variant_format_string_scan
-g_variant_format_string_scan_type
 g_variant_get
 g_variant_get_va
 g_variant_new
diff --git a/glib/glib.symbols b/glib/glib.symbols
index e126b44..b49a05d 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -1779,8 +1779,6 @@ g_variant_builder_new
 g_variant_builder_unref
 g_variant_builder_ref
 
-g_variant_format_string_scan
-g_variant_format_string_scan_type
 g_variant_new_va
 g_variant_get_va
 g_variant_new
@@ -1793,6 +1791,13 @@ g_variant_iter_loop
 #endif
 #endif
 
+#if IN_HEADER(__G_VARIANT_INTERNAL_H__)
+#if IN_FILE(__G_VARIANT_C__)
+g_variant_format_string_scan_type
+g_variant_format_string_scan
+#endif
+#endif
+
 #if IN_HEADER(__G_WIN32_H__)
 #if IN_FILE(__G_WIN32_H__)
 #ifdef G_OS_WIN32
diff --git a/glib/gvariant-internal.h b/glib/gvariant-internal.h
new file mode 100644
index 0000000..824ce26
--- /dev/null
+++ b/glib/gvariant-internal.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2007, 2008 Ryan Lortie
+ * Copyright © 2009, 2010 Codethink Limited
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ryan Lortie <desrt desrt ca>
+ */
+
+
+/* The purpose of this header is to allow certain internal symbols of
+ * GVariant to be put under test cases.
+ */
+
+#ifndef __G_VARIANT_INTERNAL_H__
+#define __G_VARIANT_INTERNAL_H__
+
+#ifndef GLIB_COMPILATION
+#define GLIB_COMPILATION
+#endif
+
+#include <glib/gvarianttype.h>
+#include <glib/gtypes.h>
+
+gboolean                        g_variant_format_string_scan            (const gchar          *string,
+                                                                         const gchar          *limit,
+                                                                         const gchar         **endptr);
+
+GVariantType *                  g_variant_format_string_scan_type       (const gchar          *string,
+                                                                         const gchar          *limit,
+                                                                         const gchar         **endptr);
+
+#endif /* __G_VARIANT_INTERNAL_H__ */
diff --git a/glib/gvariant.c b/glib/gvariant.c
index 1f78786..adc9030 100644
--- a/glib/gvariant.c
+++ b/glib/gvariant.c
@@ -25,6 +25,7 @@
 #include "config.h"
 
 #include <glib/gvariant-serialiser.h>
+#include "gvariant-internal.h"
 #include <glib/gvariant-core.h>
 #include <glib/gtestutils.h>
 #include <glib/gstrfuncs.h>
@@ -2677,7 +2678,7 @@ g_variant_builder_end (GVariantBuilder *builder)
 }
 
 /* Format strings {{{1 */
-/**
+/*< private >
  * g_variant_format_string_scan:
  * @string: a string that may be prefixed with a format string
  * @limit: a pointer to the end of @string, or %NULL
@@ -2700,7 +2701,7 @@ g_variant_builder_end (GVariantBuilder *builder)
  * Format Strings</link>.
  *
  * Since: 2.24
- **/
+ */
 gboolean
 g_variant_format_string_scan (const gchar  *string,
                               const gchar  *limit,
@@ -2788,7 +2789,7 @@ g_variant_format_string_scan (const gchar  *string,
   return TRUE;
 }
 
-/**
+/*< private >
  * g_variant_format_string_scan_type:
  * @string: a string that may be prefixed with a format string
  * @limit: a pointer to the end of @string
@@ -2806,7 +2807,7 @@ g_variant_format_string_scan (const gchar  *string,
  * g_variant_format_string_scan().
  *
  * Since: 2.24
- **/
+ */
 GVariantType *
 g_variant_format_string_scan_type (const gchar  *string,
                                    const gchar  *limit,
@@ -3503,7 +3504,7 @@ g_variant_new (const gchar *format_string,
                         NULL);
 
   va_start (ap, format_string);
-  value = g_variant_new_va (NULL, format_string, NULL, &ap);
+  value = g_variant_new_va (format_string, NULL, &ap);
   va_end (ap);
 
   return value;
@@ -3511,7 +3512,6 @@ g_variant_new (const gchar *format_string,
 
 /**
  * g_variant_new_va:
- * @must_be_null: %NULL (for future expansion)
  * @format_string: a string that is prefixed with a format string
  * @endptr: location to store the end pointer, or %NULL
  * @app: a pointer to a #va_list
@@ -3553,8 +3553,7 @@ g_variant_new (const gchar *format_string,
  * Since: 2.24
  **/
 GVariant *
-g_variant_new_va (gpointer      must_be_null,
-                  const gchar  *format_string,
+g_variant_new_va (const gchar  *format_string,
                   const gchar **endptr,
                   va_list      *app)
 {
@@ -3562,7 +3561,6 @@ g_variant_new_va (gpointer      must_be_null,
 
   g_return_val_if_fail (valid_format_string (format_string, !endptr, NULL),
                         NULL);
-  g_return_val_if_fail (must_be_null == NULL, NULL);
   g_return_val_if_fail (app != NULL, NULL);
 
   value = g_variant_valist_new (&format_string, app);
@@ -3607,14 +3605,13 @@ g_variant_get (GVariant    *value,
     g_variant_get_data (value);
 
   va_start (ap, format_string);
-  g_variant_get_va (value, NULL, format_string, NULL, &ap);
+  g_variant_get_va (value, format_string, NULL, &ap);
   va_end (ap);
 }
 
 /**
  * g_variant_get_va:
  * @value: a #GVariant
- * @must_be_null: %NULL (for future expansion)
  * @format_string: a string that is prefixed with a format string
  * @endptr: location to store the end pointer, or %NULL
  * @app: a pointer to a #va_list
@@ -3643,13 +3640,11 @@ g_variant_get (GVariant    *value,
  **/
 void
 g_variant_get_va (GVariant     *value,
-                  gpointer      must_be_null,
                   const gchar  *format_string,
                   const gchar **endptr,
                   va_list      *app)
 {
   g_return_if_fail (valid_format_string (format_string, !endptr, value));
-  g_return_if_fail (must_be_null == NULL);
   g_return_if_fail (value != NULL);
   g_return_if_fail (app != NULL);
 
@@ -3710,7 +3705,7 @@ g_variant_builder_add (GVariantBuilder *builder,
   va_list ap;
 
   va_start (ap, format_string);
-  variant = g_variant_new_va (NULL, format_string, NULL, &ap);
+  variant = g_variant_new_va (format_string, NULL, &ap);
   va_end (ap);
 
   g_variant_builder_add_value (builder, variant);
@@ -3719,7 +3714,7 @@ g_variant_builder_add (GVariantBuilder *builder,
 /**
  * g_variant_get_child:
  * @value: a container #GVariant
- * @index: the index of the child to deconstruct
+ * @index_: the index of the child to deconstruct
  * @format_string: a #GVariant format string
  * @...: arguments, as per @format_string
  *
@@ -3743,7 +3738,7 @@ g_variant_get_child (GVariant    *value,
   g_return_if_fail (valid_format_string (format_string, TRUE, child));
 
   va_start (ap, format_string);
-  g_variant_get_va (child, NULL, format_string, NULL, &ap);
+  g_variant_get_va (child, format_string, NULL, &ap);
   va_end (ap);
 
   g_variant_unref (child);
diff --git a/glib/gvariant.h b/glib/gvariant.h
index be8dd12..a073b2b 100644
--- a/glib/gvariant.h
+++ b/glib/gvariant.h
@@ -182,25 +182,15 @@ void                            g_variant_builder_add                   (GVarian
                                                                          const gchar          *format_string,
                                                                          ...);
 
-gboolean                        g_variant_format_string_scan            (const gchar          *string,
-                                                                         const gchar          *limit,
-                                                                         const gchar         **endptr);
-
-GVariantType *                  g_variant_format_string_scan_type       (const gchar          *string,
-                                                                         const gchar          *limit,
-                                                                         const gchar         **endptr);
-
 GVariant *                      g_variant_new                           (const gchar          *format_string,
                                                                          ...);
 void                            g_variant_get                           (GVariant             *value,
                                                                          const gchar          *format_string,
                                                                          ...);
-GVariant *                      g_variant_new_va                        (gpointer              must_be_null,
-                                                                         const gchar          *format_string,
+GVariant *                      g_variant_new_va                        (const gchar          *format_string,
                                                                          const gchar         **endptr,
                                                                          va_list              *app);
 void                            g_variant_get_va                        (GVariant             *value,
-                                                                         gpointer              must_be_null,
                                                                          const gchar          *format_string,
                                                                          const gchar         **endptr,
                                                                          va_list              *app);
diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c
index d6b9541..be2f0f4 100644
--- a/glib/tests/gvariant.c
+++ b/glib/tests/gvariant.c
@@ -11,6 +11,7 @@
  * Author: Ryan Lortie <desrt desrt ca>
  */
 
+#include <glib/gvariant-internal.h>
 #include <string.h>
 #include <stdlib.h>
 #include <glib.h>
@@ -2756,7 +2757,7 @@ test_invalid_varargs (void)
     {
       const gchar *end;
 
-      g_variant_new_va (NULL, "z", &end, NULL);
+      g_variant_new_va ("z", &end, NULL);
       abort ();
     }
 
@@ -2765,22 +2766,6 @@ test_invalid_varargs (void)
       g_variant_get (g_variant_new ("y", 'a'), "q");
       abort ();
     }
-
-  if (do_failed_test ("*must_be_null*"))
-    {
-      int q;
-
-      g_variant_new_va (&q, "u", NULL, NULL);
-      abort ();
-    }
-
-  if (do_failed_test ("*must_be_null*"))
-    {
-      int q;
-
-      g_variant_get_va (g_variant_new ("u", 1), &q, "u", NULL, NULL);
-      abort ();
-    }
 }
 
 static void
@@ -3276,7 +3261,7 @@ hash_get (GVariant    *value,
   hash = g_str_has_suffix (format, "#");
 
   va_start (ap, format);
-  g_variant_get_va (value, NULL, format, hash ? &endptr : NULL, &ap);
+  g_variant_get_va (value, format, hash ? &endptr : NULL, &ap);
   va_end (ap);
 
   if (hash)
@@ -3295,7 +3280,7 @@ hash_new (const gchar *format,
   hash = g_str_has_suffix (format, "#");
 
   va_start (ap, format);
-  value = g_variant_new_va (NULL, format, hash ? &endptr : NULL, &ap);
+  value = g_variant_new_va (format, hash ? &endptr : NULL, &ap);
   va_end (ap);
 
   if (hash)



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