hook gvariant vectors up to kdbus
[platform/upstream/glib.git] / gobject / gboxed.c
index e6f2274..ab41951 100644 (file)
  * 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.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
 
 #include <string.h>
 
+/* for GValueArray */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #include "gboxed.h"
+#include "gclosure.h"
 #include "gtype-private.h"
 #include "gvalue.h"
 #include "gvaluearray.h"
-#include "gclosure.h"
 #include "gvaluecollector.h"
 
 
@@ -74,10 +75,19 @@ value_free (GValue *value)
   g_free (value);
 }
 
+static GPollFD *
+pollfd_copy (GPollFD *src)
+{
+  GPollFD *dest = g_new0 (GPollFD, 1);
+  /* just a couple of integers */
+  memcpy (dest, src, sizeof (GPollFD));
+  return dest;
+}
+
 void
-g_boxed_type_init (void)
+_g_boxed_type_init (void)
 {
-  static const GTypeInfo info = {
+  const GTypeInfo info = {
     0,                          /* class_size */
     NULL,                       /* base_init */
     NULL,                       /* base_destroy */
@@ -127,20 +137,33 @@ G_DEFINE_BOXED_TYPE (GHashTable, g_hash_table, g_hash_table_ref, g_hash_table_un
 G_DEFINE_BOXED_TYPE (GArray, g_array, g_array_ref, g_array_unref)
 G_DEFINE_BOXED_TYPE (GPtrArray, g_ptr_array,g_ptr_array_ref, g_ptr_array_unref)
 G_DEFINE_BOXED_TYPE (GByteArray, g_byte_array, g_byte_array_ref, g_byte_array_unref)
+G_DEFINE_BOXED_TYPE (GBytes, g_bytes, g_bytes_ref, g_bytes_unref);
 
-#ifdef ENABLE_REGEX
 G_DEFINE_BOXED_TYPE (GRegex, g_regex, g_regex_ref, g_regex_unref)
-#else
-GType g_regex_get_type (void) { return G_TYPE_INVALID; }
-#endif /* ENABLE_REGEX */
+G_DEFINE_BOXED_TYPE (GMatchInfo, g_match_info, g_match_info_ref, g_match_info_unref)
 
 #define g_variant_type_get_type g_variant_type_get_gtype
 G_DEFINE_BOXED_TYPE (GVariantType, g_variant_type, g_variant_type_copy, g_variant_type_free)
 #undef g_variant_type_get_type
 
+G_DEFINE_BOXED_TYPE (GVariantBuilder, g_variant_builder, g_variant_builder_ref, g_variant_builder_unref)
+G_DEFINE_BOXED_TYPE (GVariantDict, g_variant_dict, g_variant_dict_ref, g_variant_dict_unref)
+
 G_DEFINE_BOXED_TYPE (GError, g_error, g_error_copy, g_error_free)
 
 G_DEFINE_BOXED_TYPE (GDateTime, g_date_time, g_date_time_ref, g_date_time_unref);
+G_DEFINE_BOXED_TYPE (GTimeZone, g_time_zone, g_time_zone_ref, g_time_zone_unref);
+G_DEFINE_BOXED_TYPE (GKeyFile, g_key_file, g_key_file_ref, g_key_file_unref)
+G_DEFINE_BOXED_TYPE (GMappedFile, g_mapped_file, g_mapped_file_ref, g_mapped_file_unref)
+
+G_DEFINE_BOXED_TYPE (GMainLoop, g_main_loop, g_main_loop_ref, g_main_loop_unref)
+G_DEFINE_BOXED_TYPE (GMainContext, g_main_context, g_main_context_ref, g_main_context_unref)
+G_DEFINE_BOXED_TYPE (GSource, g_source, g_source_ref, g_source_unref)
+G_DEFINE_BOXED_TYPE (GPollFD, g_pollfd, pollfd_copy, g_free)
+G_DEFINE_BOXED_TYPE (GMarkupParseContext, g_markup_parse_context, g_markup_parse_context_ref, g_markup_parse_context_unref)
+
+G_DEFINE_BOXED_TYPE (GThread, g_thread, g_thread_ref, g_thread_unref)
+G_DEFINE_BOXED_TYPE (GChecksum, g_checksum, g_checksum_copy, g_checksum_free)
 
 /* This one can't use G_DEFINE_BOXED_TYPE (GStrv, g_strv, g_strdupv, g_strfreev) */
 GType
@@ -233,7 +256,7 @@ boxed_proxy_lcopy_value (const GValue *value,
   gpointer *boxed_p = collect_values[0].v_pointer;
 
   if (!boxed_p)
-    return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
+    return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
 
   if (!value->data[0].v_pointer)
     *boxed_p = NULL;
@@ -293,7 +316,7 @@ g_boxed_type_register_static (const gchar   *name,
 
   type = g_type_register_static (G_TYPE_BOXED, name, &type_info, 0);
 
-  /* install proxy functions upon successfull registration */
+  /* install proxy functions upon successful registration */
   if (type)
     _g_type_boxed_init (type, boxed_copy, boxed_free);
 
@@ -307,7 +330,7 @@ g_boxed_type_register_static (const gchar   *name,
  * 
  * Provide a copy of a boxed structure @src_boxed which is of type @boxed_type.
  * 
- * Returns: The newly created copy of the boxed structure.
+ * Returns: (transfer full): The newly created copy of the boxed structure.
  */
 gpointer
 g_boxed_copy (GType         boxed_type,
@@ -336,7 +359,7 @@ g_boxed_copy (GType         boxed_type,
        * (data[0].v_pointer is the boxed struct, and
        * data[1].v_uint holds the G_VALUE_NOCOPY_CONTENTS flag,
        * rest zero).
-       * but then, we can expect that since we layed out the
+       * but then, we can expect that since we laid out the
        * g_boxed_*() API.
        * data[1].v_uint&G_VALUE_NOCOPY_CONTENTS shouldn't be set
        * after a copy.
@@ -352,7 +375,7 @@ g_boxed_copy (GType         boxed_type,
 
       /* double check and grouse if things went wrong */
       if (dest_value.data[1].v_ulong)
-       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));
 
       dest_boxed = dest_value.data[0].v_pointer;
@@ -402,7 +425,7 @@ g_boxed_free (GType    boxed_type,
  *
  * Get the contents of a %G_TYPE_BOXED derived #GValue.
  *
- * Returns: boxed contents of @value
+ * Returns: (transfer none): boxed contents of @value
  */
 gpointer
 g_value_get_boxed (const GValue *value)
@@ -414,7 +437,7 @@ g_value_get_boxed (const GValue *value)
 }
 
 /**
- * g_value_dup_boxed:
+ * g_value_dup_boxed: (skip)
  * @value: a valid #GValue of %G_TYPE_BOXED derived type
  *
  * Get the contents of a %G_TYPE_BOXED derived #GValue.  Upon getting,
@@ -459,7 +482,7 @@ value_set_boxed_internal (GValue       *value,
 /**
  * g_value_set_boxed:
  * @value: a valid #GValue of %G_TYPE_BOXED derived type
- * @v_boxed: boxed value to be set
+ * @v_boxed: (allow-none): boxed value to be set
  *
  * Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.
  */
@@ -476,7 +499,7 @@ g_value_set_boxed (GValue       *value,
 /**
  * g_value_set_static_boxed:
  * @value: a valid #GValue of %G_TYPE_BOXED derived type
- * @v_boxed: static boxed value to be set
+ * @v_boxed: (allow-none): static boxed value to be set
  *
  * Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.
  * The boxed value is assumed to be static, and is thus not duplicated
@@ -495,7 +518,7 @@ g_value_set_static_boxed (GValue       *value,
 /**
  * g_value_set_boxed_take_ownership:
  * @value: a valid #GValue of %G_TYPE_BOXED derived type
- * @v_boxed: duplicated unowned boxed value to be set
+ * @v_boxed: (allow-none): duplicated unowned boxed value to be set
  *
  * This is an internal function introduced mainly for C marshallers.
  *
@@ -511,7 +534,7 @@ g_value_set_boxed_take_ownership (GValue       *value,
 /**
  * g_value_take_boxed:
  * @value: a valid #GValue of %G_TYPE_BOXED derived type
- * @v_boxed: duplicated unowned boxed value to be set
+ * @v_boxed: (allow-none): duplicated unowned boxed value to be set
  *
  * Sets the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed
  * and takes over the ownership of the callers reference to @v_boxed;