[glibmm] glibmm: Add ByteArray.



commit a142e6316be8ce65ad5635ac01f881615b75f66f
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Mon Feb 25 19:45:49 2013 -0500

    glibmm: Add ByteArray.
    
        * glib/src/bytearray.{ccg,hg}:
        * glib/src/filelist.am: Add the new sources for the ByteArray class
        that wraps GByteArray and include the sources in the build.  Some of
        the GTls* API uses GByteArray so it is necessary to wrap it.
        * glib/src/glib_extra_objects.defs: Include an object definition for
        GByteArray to avoid a gmmproc documentation warning.
        * tools/m4/convert_glib.m4: Add a GByteArray conversion so the sources
        can be processed properly.

 ChangeLog                        |   13 +++++++
 glib/src/bytearray.ccg           |   46 +++++++++++++++++++++++++
 glib/src/bytearray.hg            |   70 ++++++++++++++++++++++++++++++++++++++
 glib/src/filelist.am             |    1 +
 glib/src/glib_extra_objects.defs |    5 +++
 tools/m4/convert_glib.m4         |    3 ++
 6 files changed, 138 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7608fa7..2dae60b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2013-02-25  José Alburquerque  <jaalburquerque gmail com>
+
+       glibmm: Add ByteArray.
+
+       * glib/src/bytearray.{ccg,hg}:
+       * glib/src/filelist.am: Add the new sources for the ByteArray class
+       that wraps GByteArray and include the sources in the build.  Some of
+       the GTls* API uses GByteArray so it is necessary to wrap it.
+       * glib/src/glib_extra_objects.defs: Include an object definition for
+       GByteArray to avoid a gmmproc documentation warning.
+       * tools/m4/convert_glib.m4: Add a GByteArray conversion so the sources
+       can be processed properly.
+
 2013-02-25  Pavel Vasin  <rat4vier gmail com>
 
        AppInfo::get_all(): Fix ownerships
diff --git a/glib/src/bytearray.ccg b/glib/src/bytearray.ccg
new file mode 100644
index 0000000..71a0d5f
--- /dev/null
+++ b/glib/src/bytearray.ccg
@@ -0,0 +1,46 @@
+/* Copyright (C) 2013 The glibmm Development Team
+ *
+ * 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.1 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+namespace
+{
+
+extern "C"
+{
+
+int ByteArray_Compare_Data_Func(gconstpointer a, gconstpointer b,
+  gpointer user_data)
+{
+  Glib::ByteArray::SlotCompare* slot =
+    static_cast<Glib::ByteArray::SlotCompare*>(user_data);
+
+  return (*slot)(static_cast<const guint8*>(a), static_cast<const guint8*>(b));
+}
+
+}
+
+}
+
+namespace Glib
+{
+
+Glib::RefPtr<Glib::ByteArray> ByteArray::create()
+{
+  GByteArray* array = g_byte_array_new();
+  return Glib::wrap(array);
+}
+
+} // namespace Glib
diff --git a/glib/src/bytearray.hg b/glib/src/bytearray.hg
new file mode 100644
index 0000000..8cd6555
--- /dev/null
+++ b/glib/src/bytearray.hg
@@ -0,0 +1,70 @@
+/* Copyright (C) 2013 The glibmm Development Team
+ *
+ * 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.1 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+_DEFS(glibmm,glib)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+typedef struct _GByteArray GByteArray;
+#endif
+
+namespace Glib
+{
+
+/** ByteArray - Arrays of bytes.
+ * ByteArray is a mutable array of bytes, to provide arrays of bytes which grow
+ * automatically as elements are added.
+ *
+ * To create a new ByteArray use create(). To add elements to a ByteArray, use
+ * append(), and prepend().
+ *
+ * To set the size of a ByteArray, use set_size().
+ *
+ * @newin{2,36}
+ */
+class ByteArray
+{
+  _CLASS_OPAQUE_REFCOUNTED(ByteArray, GByteArray, NONE, g_byte_array_ref, g_byte_array_unref)
+  _IGNORE(g_byte_array_ref, g_byte_array_unref)
+public:
+  /** A Slot type to compare two elements in the array.  The slot should return
+   * -1 if the first value is less than the second, 0 if they are equal and 1
+   * if the first value is greater than the second.
+   *
+   * Slot Prototype:
+   *
+   * <code>
+   * int compare(const guint8* first, const guint8* second);
+   * </code>
+   */
+  typedef sigc::slot<int, const guint8*, const guint8*> SlotCompare;
+
+  _WRAP_METHOD_DOCS_ONLY(g_byte_array_new)
+  static Glib::RefPtr<Glib::ByteArray> create();
+
+  _WRAP_METHOD(Glib::RefPtr<ByteArray> append(const guint8* data, guint len), g_byte_array_append)
+  _WRAP_METHOD(Glib::RefPtr<ByteArray> prepend(const guint8* data, guint len), g_byte_array_prepend)
+  _WRAP_METHOD(Glib::RefPtr<ByteArray> remove_index(guint index_), g_byte_array_remove_index)
+  _WRAP_METHOD(Glib::RefPtr<ByteArray> remove_index_fast(guint index_), g_byte_array_remove_index_fast)
+  _WRAP_METHOD(Glib::RefPtr<ByteArray> remove_range(guint index_, guint length), g_byte_array_remove_range)
+
+  _WRAP_METHOD(void sort(const SlotCompare& slot), g_byte_array_sort_with_data, slot_name slot, 
slot_callback ByteArray_Compare_Data_Func, no_slot_copy)
+  _IGNORE(g_byte_array_sort)
+
+  _WRAP_METHOD(Glib::RefPtr<ByteArray> set_size(guint length), g_byte_array_set_size)
+};
+
+} // namespace Glib
diff --git a/glib/src/filelist.am b/glib/src/filelist.am
index 64b8b60..0c5ef5d 100644
--- a/glib/src/filelist.am
+++ b/glib/src/filelist.am
@@ -18,6 +18,7 @@ glibmm_files_defs =           \
 glibmm_files_hg =              \
        balancedtree.hg         \
        bytes.hg                \
+       bytearray.hg            \
        checksum.hg             \
        convert.hg              \
        date.hg                 \
diff --git a/glib/src/glib_extra_objects.defs b/glib/src/glib_extra_objects.defs
index d173edc..1774ec4 100644
--- a/glib/src/glib_extra_objects.defs
+++ b/glib/src/glib_extra_objects.defs
@@ -6,6 +6,11 @@
 ; that are mentioned in documentation text.
 ; (DocsParser.pm:substitute_function(), which uses GtkDefs.pm:lookup_object().)
 
+(define-object ByteArray
+  (in-module "GLib")
+  (c-name "GByteArray")
+)
+
 (define-object Checksum
   (in-module "GLib")
   (c-name "GChecksum")
diff --git a/tools/m4/convert_glib.m4 b/tools/m4/convert_glib.m4
index 5e36245..810d781 100644
--- a/tools/m4/convert_glib.m4
+++ b/tools/m4/convert_glib.m4
@@ -127,6 +127,9 @@ _CONVERSION(`GBytes*',`Glib::RefPtr<Glib::Bytes>',`Glib::wrap($3)')
 _CONVERSION(`GBytes*',`Glib::RefPtr<const Glib::Bytes>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<const Glib::Bytes>&',`GBytes*',__CONVERT_CONST_REFPTR_TO_P_SUN(Glib::Bytes)))
 
+dnl ByteArray
+_CONVERSION(`GByteArray*',`Glib::RefPtr<ByteArray>',`Glib::wrap($3)')
+
 dnl Regex
 _CONVERSION(`GRegex*',`Glib::RefPtr<Regex>',`Glib::wrap($3)')
 _CONVERSION(`GRegex*',`Glib::RefPtr<const Regex>',`Glib::wrap($3)')


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