[glibmm] Added missing files.



commit 7d7d42f0b16518c160380e7121ffb99bc43dbb11
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Mon Feb 21 19:35:24 2011 +0100

    Added missing files.

 ChangeLog                             |   12 ++--
 glib/glibmm/arrayhandle.cc            |   38 ++++++++++++++
 tests/Makefile.am                     |    4 +-
 tests/glibmm_bool_arrayhandle/main.cc |   89 +++++++++++++++++++++++++++++++++
 4 files changed, 135 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1780b2d..98575d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,12 +7,12 @@
 
 2011-02-21  Fabricio Godoy  <skarllot gmail com>
 
-  Extended build_filename() to accept up to nine parameters.
-  
-  * glib/glibmm/miscutils.[h|cc]: Added build_filename() method overloads that 
- take more parameters, for convenience.
-  * tests/Makefile.am
-  * tests/glibmm_buildfilename/main.cc: Added a new testcase.
+	Extended build_filename() to accept up to nine parameters.
+
+	* glib/glibmm/miscutils.[h|cc]: Added build_filename() method overloads that
+	take more parameters, for convenience.
+	* tests/Makefile.am
+	* tests/glibmm_buildfilename/main.cc: Added a new testcase.
 
 2.27.94:
 
diff --git a/glib/glibmm/arrayhandle.cc b/glib/glibmm/arrayhandle.cc
new file mode 100644
index 0000000..cc8e25a
--- /dev/null
+++ b/glib/glibmm/arrayhandle.cc
@@ -0,0 +1,38 @@
+/* Copyright (C) 2011 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.
+ */
+
+#include <glibmm/arrayhandle.h>
+
+namespace Glib
+{
+
+ArrayHandle<bool,Container_Helpers::TypeTraits<bool> >::~ArrayHandle()
+{
+  if(ownership_ != Glib::OWNERSHIP_NONE)
+  {
+    if(ownership_ != Glib::OWNERSHIP_SHALLOW)
+    {
+      // Deep ownership: release each container element.
+      const CType *const pend = parray_ + size_;
+      for(const CType* p = parray_; p != pend; ++p)
+        Tr::release_c_type(*p);
+    }
+    g_free(const_cast<CType*>(parray_));
+  }
+}
+
+} // namespace Glib
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9f922b2..b2015ff 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,7 +23,7 @@ check_PROGRAMS =				\
 	giomm_asyncresult_sourceobject/test	\
 	glibmm_btree/test			\
 	glibmm_date/test			\
-	glibmm_buildfilename/test	\
+	glibmm_buildfilename/test		\
 	glibmm_nodetree/test			\
 	glibmm_ustring_compose/test		\
 	glibmm_ustring_format/test		\
@@ -57,7 +57,7 @@ giomm_asyncresult_sourceobject_test_SOURCES  = giomm_asyncresult_sourceobject/ma
 giomm_asyncresult_sourceobject_test_LDADD    = $(giomm_ldadd)
 
 glibmm_btree_test_SOURCES            = glibmm_btree/main.cc
-glibmm_buildfilename_test_SOURCES   = glibmm_buildfilename/main.cc
+glibmm_buildfilename_test_SOURCES    = glibmm_buildfilename/main.cc
 glibmm_date_test_SOURCES             = glibmm_date/main.cc
 glibmm_nodetree_test_SOURCES         = glibmm_nodetree/main.cc
 glibmm_ustring_compose_test_SOURCES  = glibmm_ustring_compose/main.cc
diff --git a/tests/glibmm_bool_arrayhandle/main.cc b/tests/glibmm_bool_arrayhandle/main.cc
new file mode 100644
index 0000000..60c9356
--- /dev/null
+++ b/tests/glibmm_bool_arrayhandle/main.cc
@@ -0,0 +1,89 @@
+/* Copyright (C) 2011 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.
+ */
+#include <cstdlib>
+#include <ctime>
+
+#include <iostream>
+
+#include <glibmm.h>
+
+const unsigned int magic_limit (5);
+
+void
+setup_rand ()
+{
+  static bool setup (false);
+
+  if (!setup)
+  {
+    std::srand (std::time (0));
+    setup = true;
+  }
+}
+
+gboolean*
+c_get_bool_array ()
+{
+  gboolean* array (static_cast<gboolean*> (g_malloc ((magic_limit + 1) * sizeof (gboolean))));
+
+  setup_rand ();
+  for (unsigned int iter (0); iter < magic_limit; ++iter)
+  {
+    array[iter] = std::rand() % 2 ? TRUE : FALSE;
+  }
+  array[magic_limit] = FALSE;
+  return array;
+}
+
+void
+c_print_bool_array (gboolean* array)
+{
+  for (unsigned int iter (0); iter < magic_limit; ++iter)
+  {
+    std::cout << iter << ": " << (array[iter] ? "TRUE" : "FALSE") << "\n";
+  }
+}
+
+Glib::ArrayHandle<bool>
+cxx_get_bool_array ()
+{
+  return Glib::ArrayHandle<bool> (c_get_bool_array (), magic_limit, Glib::OWNERSHIP_SHALLOW);
+}
+
+void
+cxx_print_bool_array (const Glib::ArrayHandle<bool>& array)
+{
+  c_print_bool_array (const_cast<gboolean*> (array.data ()));
+}
+
+int main()
+{
+  Glib::init();
+
+  std::vector<bool> v (cxx_get_bool_array ());
+  std::list<bool> l (cxx_get_bool_array ());
+  std::deque<bool> d (cxx_get_bool_array ());
+
+  std::cout << "vector:\n";
+  cxx_print_bool_array (v);
+  std::cout << "list:\n";
+  cxx_print_bool_array (l);
+  std::cout << "deque:\n";
+  cxx_print_bool_array (d);
+
+  return 0;
+}



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