Imported Upstream version 2.33.4 upstream/2.33.4
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 7 Sep 2020 06:38:27 +0000 (23:38 -0700)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 7 Sep 2020 06:38:27 +0000 (23:38 -0700)
20 files changed:
.gitignore
ChangeLog
NEWS
configure.ac
gio/src/gio_extra_objects.defs
glib/src/checksum.hg
glib/src/keyfile.ccg
glib/src/keyfile.hg
glib/src/threads.ccg
glib/src/threads.hg
glib/src/variant.ccg
glib/src/variant.hg
glib/src/varianttype.ccg
glib/src/varianttype.hg
tests/glibmm_variant/main.cc
tools/m4/class_boxedtype.m4
tools/m4/class_boxedtype_static.m4
tools/m4/class_gobject.m4
tools/m4/class_interface.m4
tools/m4/class_opaque_copyable.m4

index 28f463e..a14333c 100644 (file)
@@ -93,6 +93,8 @@ giommconfig.h
 /glib/glibmm-*.pc
 /glib/glibmm/balancedtree.cc
 /glib/glibmm/balancedtree.h
+/glib/glibmm/bytes.cc
+/glib/glibmm/bytes.h
 /glib/glibmm/checksum.cc
 /glib/glibmm/checksum.h
 /glib/glibmm/convert.cc
index 6e05a96..1a26f33 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,82 @@
+2.33.4:
+
+2012-08-01  Murray Cumming  <murrayc@murrayc.com>
+
+       gio_extra_objects: Mention GMenuItem.
+
+       * gio/src/gio_extra_objects.defs:
+       This helps the documentation generator.
+
+2012-07-28  Krzesimir Nowak  <qdlacz@gmail.com>
+
+       Add a test checking whether floating variants are always sunk.
+
+       * tests/glibmm_variant/main.cc: New test.
+       Bug #680407
+
+2012-07-28  Krzesimir Nowak  <qdlacz@gmail.com>
+
+       Implement custom cast constructor for VariantBase.
+
+       * glib/src/variant.hg:
+       * glib/src/variant.ccg: Use _CUSTOM_CTOR_CAST macro and implement
+       cast constructor.  This is needed, because we always want to sink
+       a GVariant.
+       Bug #680407
+
+2012-07-28  Krzesimir Nowak  <qdlacz@gmail.com>
+
+       Add _CUSTOM_CTOR_CAST macro for _CLASS_OPAQUE_COPYABLE.
+
+       * tools/m4/class_opaque_copyable.m4: New macro.
+       Bug #680407
+
+2012-07-26  Kjell Ahlstedt  <kjell.ahlstedt@bredband.net>
+
+       Glib::Threads:[Rec]Mutex: Add wrap() functions.
+
+       * glib/src/threads.[hg|ccg]: Add Mutex* wrap(GMutex*) and
+       RecMutex* wrap(GRecMutex*). Bug #483790.
+
+2012-07-22  Krzesimir Nowak  <qdlacz@gmail.com>
+
+       Properly wrap g_key_file_load_from_dirs().
+
+       * glib/src/keyfile.hg:
+       * glib/src/keyfile.ccg: The just deprecated wrapper was
+       incorrectly passing an array wrapper for full_path parameter when
+       it should pass a std::string&, because full_path is an output
+       parameter. Added handwritten wrapper passing proper parameter.
+
+2012-07-22  Krzesimir Nowak  <qdlacz@gmail.com>
+
+       Wrap g_variant_type_peek_string() by hand.
+
+       * glib/src/gvarianttype.hg:
+       * glib/src/gvarianttype.ccg: The wrapped function does not return
+       a C string (it is not NULL terminated), so std::string(str, size)
+       constructor needs to be used. I wonder how glibmm_variant test
+       passed through all distchecks so far...
+
+2012-07-16  Murray Cumming  <murrayc@murrayc.com>
+
+       Show get_type() in the API documentation.
+
+       * tools/m4/class_boxedtype.m4:
+       * tools/m4/class_boxedtype_static.m4:
+       * tools/m4/class_gobject.m4:
+       * tools/m4/class_interface.m4: Move the static get_type()
+       functions out of the ifdef so that doxygen can see them,
+       because they are sometimes needed, for instance when 
+       implementing a custom container.
+       Bug #670212 (Mark Vender).
+
+2012-07-10  Krzesimir Nowak  <qdlacz@gmail.com>
+
+       Glib::Checksum: Fix a typo.
+
+       * glib/src/checksum.hg: Should be *_SHOULD_*, not *_SHOUD_*.
+
 2.33.3:
 
 2012-07-10  Murray Cumming  <murrayc@murrayc.com>
diff --git a/NEWS b/NEWS
index 114e93f..7a9d187 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,24 @@
+2.33.4 (unstable):
+
+Glib:
+* KeyFile: Correct the load_from_dirs() implementation.
+  (Krzesimir Nowak)
+* Variant: Make sure that we always sink the initial reference.
+  (Krzesimir Nowak) Bug #680407
+* VariantType: peek_string(): Correct this to handle 
+  the non-null-terminated result from g_variant_type_peek_string().
+* Threads::Mutex, RecMutex: Add wrap() functions.
+  (Kjell Ahlstedt) Bug #483790
+
+gmmproc:
+*  Add _CUSTOM_CTOR_CAST
+  (Krzesimir Nowak)
+
+Documentation:
+* Show the get_type() functions in the API documentation.
+  (Murray Cumming) Bug #670212 (Mark Vender).
+
+
 2.33.3 (unstable):
 
 Glib:
index 8db4415..b382812 100644 (file)
@@ -60,7 +60,7 @@ AS_IF([test "x$enable_static" = xyes],
   AC_DEFINE([GIOMM_STATIC_LIB],  [1], [Define if giomm is built as a static library])
 ])
 
-glibreq='2.0 >= 2.33.3'
+glibreq='2.0 >= 2.33.4'
 
 GLIBMM_MODULES="sigc++-2.0 >= 2.2.10 glib-$glibreq gobject-$glibreq gmodule-$glibreq"
 GIOMM_MODULES="$GLIBMM_MODULES gio-$glibreq"
index 0b2b5f4..afbedc7 100644 (file)
   (gtype-id "G_TYPE_FILE_INFO")
 )
 
+(define-object MenuItem
+  (in-module "Gio")
+  (c-name "GMenuItem")
+  (gtype-id "G_TYPE_MENU_ITEM")
+)
+
 (define-object Proxy
   (in-module "Gio")
   (c-name "GProxy")
index e9f599f..fce9309 100644 (file)
@@ -22,7 +22,7 @@ _DEFS(glibmm,glib)
 #include <glib.h>
 #include <string>
 
-#ifndef DOXYGEN_SHOUD_SKIP_THIS
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
 extern "C" { typedef struct _GChecksum GChecksum; }
 #endif
 
index 27c6d3e..5a6c65e 100644 (file)
@@ -74,6 +74,33 @@ bool KeyFile::load_from_data_dirs(const std::string& file, std::string& full_pat
   return (result != 0);
 }
 
+bool KeyFile::load_from_dirs(const std::string& file, const Glib::ArrayHandle<std::string>& search_dirs, std::string& full_path, KeyFileFlags flags)
+{
+  GError* gerror = 0;
+  char* full_path_c = 0;
+
+  const gboolean result = g_key_file_load_from_dirs(
+      gobj(), file.c_str(), const_cast<const gchar**>(search_dirs.data()),
+      &full_path_c, static_cast<GKeyFileFlags>(unsigned(flags)),
+      &gerror);
+
+  if(gerror)
+  {
+    if (full_path_c)
+    {
+      g_free(full_path_c);
+    }
+    Glib::Error::throw_exception(gerror);
+  }
+
+  if(full_path_c)
+    full_path = Glib::ScopedPtr<char>(full_path_c).get();
+  else
+    full_path.erase();
+
+  return (result != 0);
+}
+
 Glib::ustring KeyFile::to_data()
 {
   GError* gerror = 0;
index ac3122b..415dd49 100644 (file)
@@ -135,8 +135,16 @@ public:
 
 #m4 _CONVERSION(`const Glib::ArrayHandle<std::string>&', `const gchar**', `const_cast<const gchar**>($3.data())')
 #m4 _CONVERSION(`Glib::ArrayHandle<std::string>&', `gchar**', `const_cast<gchar**>($3.data())')
+
+_DEPRECATE_IFDEF_START
+
   _WRAP_METHOD(bool load_from_dirs(const std::string& file, const Glib::ArrayHandle<std::string>& search_dirs, Glib::ArrayHandle<std::string>& full_path, KeyFileFlags flags = Glib::KEY_FILE_NONE), g_key_file_load_from_dirs, errthrow)
 
+_DEPRECATE_IFDEF_END
+
+  _WRAP_METHOD_DOCS_ONLY(g_key_file_load_from_dirs)
+  bool load_from_dirs(const std::string& file, const Glib::ArrayHandle<std::string>& search_dirs, std::string& full_path, KeyFileFlags flags = Glib::KEY_FILE_NONE);
+
   /** Looks for a KeyFile named @a file in the paths returned from
    * g_get_user_data_dir() and g_get_system_data_dirs() and loads them
    * into the keyfile object, placing the full path to the file in
index 7133a3d..611c3e0 100644 (file)
@@ -135,6 +135,11 @@ void Mutex::unlock()
   g_mutex_unlock(&gobject_);
 }
 
+Mutex* wrap(GMutex* gobject)
+{
+  return reinterpret_cast<Mutex*>(gobject);
+}
+
 /**** Glib::RecMutex *******************************************************/
 
 RecMutex::RecMutex()
@@ -162,6 +167,11 @@ void RecMutex::unlock()
   g_rec_mutex_unlock(&gobject_);
 }
 
+RecMutex* wrap(GRecMutex* gobject)
+{
+  return reinterpret_cast<RecMutex*>(gobject);
+}
+
 /**** Glib::RWLock ***************************************************/
 
 void RWLock::reader_lock()
index 7f36988..5b9323c 100644 (file)
@@ -222,7 +222,19 @@ private:
   Mutex::Lock& operator=(const Mutex::Lock&);
 };
 
-//TODO: Docuemenation
+/** A C++ wrapper for the C object.
+ * Do not use operator delete on the returned pointer. If the caller owns the
+ * GMutex object, the caller must destroy it in the same way as if this function
+ * had not been called.
+ *
+ * @param gobject The C instance.
+ * @result The GMutex* cast to a Glib::Threads::Mutex*.
+ *
+ * @relates Glib::Threads::Mutex
+ */
+Mutex* wrap(GMutex* gobject);
+
+//TODO: Documentation
 class RecMutex
 {
 public:
@@ -272,6 +284,17 @@ private:
   RecMutex::Lock& operator=(const RecMutex::Lock&);
 };
 
+/** A C++ wrapper for the C object.
+ * Do not use operator delete on the returned pointer. If the caller owns the
+ * GRecMutex object, the caller must destroy it in the same way as if this function
+ * had not been called.
+ *
+ * @param gobject The C instance.
+ * @result The GRecMutex* cast to a Glib::Threads::RecMutex*.
+ *
+ * @relates Glib::Threads::RecMutex
+ */
+RecMutex* wrap(GRecMutex* gobject);
 
 //TODO: Documentation
 class RWLock
index c002c14..8dc5ad8 100644 (file)
 namespace Glib
 {
 
+VariantBase::VariantBase(GVariant* castitem, bool make_a_copy /* = false */)
+{
+  if (castitem)
+  {
+    if (g_variant_is_floating(castitem))
+    {
+      g_variant_ref_sink (castitem);
+    }
+    if (make_a_copy)
+    {
+      g_variant_ref (castitem);
+    }
+  }
+
+  gobject_ = castitem;
+}
+
 void VariantBase::get_normal_form(VariantBase& result) const
 {
   GVariant* const g_value =
index 87143bd..97f8e71 100644 (file)
@@ -82,6 +82,7 @@ namespace Glib
 class VariantBase
 {
   _CLASS_OPAQUE_COPYABLE(VariantBase, GVariant, NONE, g_variant_ref_sink, g_variant_unref)
+  _CUSTOM_CTOR_CAST()
   _IGNORE(g_variant_ref, g_variant_ref_sink, g_variant_unref,
     g_variant_get, g_variant_get_va)
 public:
index 62a46a7..c60031e 100644 (file)
@@ -101,4 +101,9 @@ const VariantType VARIANT_TYPE_BYTESTRING(G_VARIANT_TYPE_BYTESTRING);
 
 const VariantType VARIANT_TYPE_BYTESTRING_ARRAY(G_VARIANT_TYPE_STRING_ARRAY);
 
+std::string VariantType::get_string() const
+{
+  return std::string(g_variant_type_peek_string(gobj()), g_variant_type_get_string_length(gobj()));
+}
+
 }
index feb2fb9..8fc2c32 100644 (file)
@@ -120,7 +120,9 @@ public:
 
   //TODO: Use something instead of gsize?
   _WRAP_METHOD(gsize _get_string_length() const, g_variant_type_get_string_length)
-  _WRAP_METHOD(std::string get_string() const, g_variant_type_peek_string)
+  dnl wrapped by hand, because g_variant_type_peek_string does not return a C string.
+  _WRAP_METHOD_DOCS_ONLY(g_variant_type_peek_string)
+  std::string get_string() const;
   _IGNORE(g_variant_type_dup_string)
 
   _WRAP_METHOD(bool is_definite() const, g_variant_type_is_definite)
index f8de65d..49da1e2 100644 (file)
@@ -8,6 +8,7 @@
 std::stringstream debug;
 std::ostream& ostr = debug;
 
+static void test_variant_floating();
 static void test_dynamic_cast();
 
 int main(int, char**)
@@ -119,6 +120,7 @@ int main(int, char**)
       " in the variant are: " << value << '.' << std::endl;
   }
 
+  test_variant_floating();
   test_dynamic_cast();
 
   return EXIT_SUCCESS;
@@ -303,3 +305,74 @@ static void test_dynamic_cast()
   test_dynamic_cast_ustring_types();
   test_dynamic_cast_string_types();
 }
+
+static GLogLevelFlags
+get_log_flags()
+{
+  return static_cast<GLogLevelFlags>(static_cast<unsigned>(G_LOG_LEVEL_CRITICAL) | static_cast<unsigned>(G_LOG_LEVEL_WARNING));
+}
+
+struct WarnCatcher
+{
+  WarnCatcher(const std::string& domain)
+    : m_domain(domain)
+    , m_old_flags(g_log_set_fatal_mask(m_domain.c_str(), get_log_flags()))
+  {}
+
+  ~WarnCatcher()
+  {
+    g_log_set_fatal_mask(m_domain.c_str(), m_old_flags);
+  }
+
+  std::string m_domain;
+  GLogLevelFlags m_old_flags;
+};
+
+static void test_variant_floating()
+{
+  WarnCatcher warn_catcher("GLib");
+
+  {
+    GVariant* cv = g_variant_new("i", 42);
+    Glib::VariantBase cxxv = Glib::wrap(cv, false);
+
+    g_assert(!cxxv.is_floating());
+  }
+
+  {
+    GVariant* cv = g_variant_new("i", 42);
+    Glib::VariantBase cxxv = Glib::wrap(cv, true);
+
+    g_assert(!cxxv.is_floating());
+
+    g_variant_unref(cv);
+  }
+
+  {
+    GVariant* cv = g_variant_new("i", 42);
+
+    if (g_variant_is_floating(cv))
+    {
+      g_variant_ref_sink(cv);
+    }
+
+    Glib::VariantBase cxxv = Glib::wrap(cv, false);
+
+    g_assert(!cxxv.is_floating());
+  }
+
+  {
+    GVariant* cv = g_variant_new("i", 42);
+
+    if (g_variant_is_floating(cv))
+    {
+      g_variant_ref_sink(cv);
+    }
+
+    Glib::VariantBase cxxv = Glib::wrap(cv, true);
+
+    g_assert(!cxxv.is_floating());
+
+    g_variant_unref(cv);
+  }
+}
index fce5f65..1a9b731 100644 (file)
@@ -190,9 +190,11 @@ public:
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   typedef __CPPNAME__ CppObjectType;
   typedef __CNAME__ BaseObjectType;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
+  /** Get the GType for this class, for use with the underlying GObject type system.
+   */
   static GType get_type() G_GNUC_CONST;
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
 ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',`dnl
 ',`dnl else
index b242150..ecda942 100644 (file)
@@ -141,9 +141,11 @@ public:
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   typedef __CPPNAME__ CppObjectType;
   typedef __CNAME__ BaseObjectType;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
+  /** Get the GType for this class, for use with the underlying GObject type system.
+   */
   static GType get_type() G_GNUC_CONST;
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
 ifdef(`__BOOL_CUSTOM_DEFAULT_CTOR__',,`dnl else
   __CPPNAME__`'();
index f56fd7a..b73069e 100644 (file)
@@ -247,9 +247,11 @@ public:
 _IMPORT(SECTION_DTOR_DOCUMENTATION)
   virtual ~__CPPNAME__`'();
 
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
+  /** Get the GType for this class, for use with the underlying GObject type system.
+   */
   static GType get_type()      G_GNUC_CONST;
 
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
 ifdef(`__BOOL_DYNAMIC_GTYPE_REGISTRATION__',`
   static GType get_type(GTypeModule* module)      G_GNUC_CONST;
 ',`')
index e47925c..99d1d75 100644 (file)
@@ -259,8 +259,11 @@ _IMPORT(SECTION_DTOR_DOCUMENTATION)
 
   static void add_interface(GType gtype_implementer);
 
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
+  /** Get the GType for this class, for use with the underlying GObject type system.
+   */
   static GType get_type()      G_GNUC_CONST;
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
   static GType get_base_type() G_GNUC_CONST;
 #endif
 
index 9223e88..81be7b5 100644 (file)
@@ -21,6 +21,13 @@ define(`__BOOL_CUSTOM_DEFAULT_CTOR__',`$1')
 _POP()
 ')
 
+define(`_CUSTOM_CTOR_CAST',`dnl
+_PUSH()
+dnl Define this macro to be tested for later.
+define(`__BOOL_CUSTOM_CTOR_CAST__',`$1')
+_POP()
+')
+
 _POP()
 _SECTION(SECTION_CLASS2)
 ') dnl End of _CLASS_OPAQUE_COPYABLE.
@@ -91,6 +98,7 @@ __CPPNAME__::__CPPNAME__`'(const __CPPNAME__& src)
   gobject_ ((src.gobject_) ? __OPAQUE_FUNC_COPY`'(src.gobject_) : 0)
 {}
 
+ifdef(`__BOOL_CUSTOM_CTOR_CAST__',,`dnl else
 __CPPNAME__::__CPPNAME__`'(__CNAME__* castitem, bool make_a_copy /* = false */)
 {
   if(!make_a_copy)
@@ -108,6 +116,7 @@ __CPPNAME__::__CPPNAME__`'(__CNAME__* castitem, bool make_a_copy /* = false */)
       gobject_ = 0;
   }
 }
+')
 
 ifelse(__OPAQUE_FUNC_COPY,NONE,`dnl
 ',`dnl else