From: DongHun Kwak Date: Mon, 7 Sep 2020 06:38:27 +0000 (-0700) Subject: Imported Upstream version 2.33.4 X-Git-Tag: upstream/2.33.4^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9fba7c16a6b3739cf623f6d30d4cb531198c2b0;p=platform%2Fupstream%2Fglibmm.git Imported Upstream version 2.33.4 --- diff --git a/.gitignore b/.gitignore index 28f463e..a14333c 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/ChangeLog b/ChangeLog index 6e05a96..1a26f33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,82 @@ +2.33.4: + +2012-08-01 Murray Cumming + + gio_extra_objects: Mention GMenuItem. + + * gio/src/gio_extra_objects.defs: + This helps the documentation generator. + +2012-07-28 Krzesimir Nowak + + Add a test checking whether floating variants are always sunk. + + * tests/glibmm_variant/main.cc: New test. + Bug #680407 + +2012-07-28 Krzesimir Nowak + + 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 + + Add _CUSTOM_CTOR_CAST macro for _CLASS_OPAQUE_COPYABLE. + + * tools/m4/class_opaque_copyable.m4: New macro. + Bug #680407 + +2012-07-26 Kjell Ahlstedt + + 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 + + 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 + + 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 + + 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 + + Glib::Checksum: Fix a typo. + + * glib/src/checksum.hg: Should be *_SHOULD_*, not *_SHOUD_*. + 2.33.3: 2012-07-10 Murray Cumming diff --git a/NEWS b/NEWS index 114e93f..7a9d187 100644 --- 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: diff --git a/configure.ac b/configure.ac index 8db4415..b382812 100644 --- a/configure.ac +++ b/configure.ac @@ -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" diff --git a/gio/src/gio_extra_objects.defs b/gio/src/gio_extra_objects.defs index 0b2b5f4..afbedc7 100644 --- a/gio/src/gio_extra_objects.defs +++ b/gio/src/gio_extra_objects.defs @@ -133,6 +133,12 @@ (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") diff --git a/glib/src/checksum.hg b/glib/src/checksum.hg index e9f599f..fce9309 100644 --- a/glib/src/checksum.hg +++ b/glib/src/checksum.hg @@ -22,7 +22,7 @@ _DEFS(glibmm,glib) #include #include -#ifndef DOXYGEN_SHOUD_SKIP_THIS +#ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { typedef struct _GChecksum GChecksum; } #endif diff --git a/glib/src/keyfile.ccg b/glib/src/keyfile.ccg index 27c6d3e..5a6c65e 100644 --- a/glib/src/keyfile.ccg +++ b/glib/src/keyfile.ccg @@ -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& 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(search_dirs.data()), + &full_path_c, static_cast(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(full_path_c).get(); + else + full_path.erase(); + + return (result != 0); +} + Glib::ustring KeyFile::to_data() { GError* gerror = 0; diff --git a/glib/src/keyfile.hg b/glib/src/keyfile.hg index ac3122b..415dd49 100644 --- a/glib/src/keyfile.hg +++ b/glib/src/keyfile.hg @@ -135,8 +135,16 @@ public: #m4 _CONVERSION(`const Glib::ArrayHandle&', `const gchar**', `const_cast($3.data())') #m4 _CONVERSION(`Glib::ArrayHandle&', `gchar**', `const_cast($3.data())') + +_DEPRECATE_IFDEF_START + _WRAP_METHOD(bool load_from_dirs(const std::string& file, const Glib::ArrayHandle& search_dirs, Glib::ArrayHandle& 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& 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 diff --git a/glib/src/threads.ccg b/glib/src/threads.ccg index 7133a3d..611c3e0 100644 --- a/glib/src/threads.ccg +++ b/glib/src/threads.ccg @@ -135,6 +135,11 @@ void Mutex::unlock() g_mutex_unlock(&gobject_); } +Mutex* wrap(GMutex* gobject) +{ + return reinterpret_cast(gobject); +} + /**** Glib::RecMutex *******************************************************/ RecMutex::RecMutex() @@ -162,6 +167,11 @@ void RecMutex::unlock() g_rec_mutex_unlock(&gobject_); } +RecMutex* wrap(GRecMutex* gobject) +{ + return reinterpret_cast(gobject); +} + /**** Glib::RWLock ***************************************************/ void RWLock::reader_lock() diff --git a/glib/src/threads.hg b/glib/src/threads.hg index 7f36988..5b9323c 100644 --- a/glib/src/threads.hg +++ b/glib/src/threads.hg @@ -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 diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg index c002c14..8dc5ad8 100644 --- a/glib/src/variant.ccg +++ b/glib/src/variant.ccg @@ -23,6 +23,23 @@ 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 = diff --git a/glib/src/variant.hg b/glib/src/variant.hg index 87143bd..97f8e71 100644 --- a/glib/src/variant.hg +++ b/glib/src/variant.hg @@ -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: diff --git a/glib/src/varianttype.ccg b/glib/src/varianttype.ccg index 62a46a7..c60031e 100644 --- a/glib/src/varianttype.ccg +++ b/glib/src/varianttype.ccg @@ -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())); +} + } diff --git a/glib/src/varianttype.hg b/glib/src/varianttype.hg index feb2fb9..8fc2c32 100644 --- a/glib/src/varianttype.hg +++ b/glib/src/varianttype.hg @@ -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) diff --git a/tests/glibmm_variant/main.cc b/tests/glibmm_variant/main.cc index f8de65d..49da1e2 100644 --- a/tests/glibmm_variant/main.cc +++ b/tests/glibmm_variant/main.cc @@ -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(static_cast(G_LOG_LEVEL_CRITICAL) | static_cast(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); + } +} diff --git a/tools/m4/class_boxedtype.m4 b/tools/m4/class_boxedtype.m4 index fce5f65..1a9b731 100644 --- a/tools/m4/class_boxedtype.m4 +++ b/tools/m4/class_boxedtype.m4 @@ -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 diff --git a/tools/m4/class_boxedtype_static.m4 b/tools/m4/class_boxedtype_static.m4 index b242150..ecda942 100644 --- a/tools/m4/class_boxedtype_static.m4 +++ b/tools/m4/class_boxedtype_static.m4 @@ -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__`'(); diff --git a/tools/m4/class_gobject.m4 b/tools/m4/class_gobject.m4 index f56fd7a..b73069e 100644 --- a/tools/m4/class_gobject.m4 +++ b/tools/m4/class_gobject.m4 @@ -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; ',`') diff --git a/tools/m4/class_interface.m4 b/tools/m4/class_interface.m4 index e47925c..99d1d75 100644 --- a/tools/m4/class_interface.m4 +++ b/tools/m4/class_interface.m4 @@ -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 diff --git a/tools/m4/class_opaque_copyable.m4 b/tools/m4/class_opaque_copyable.m4 index 9223e88..81be7b5 100644 --- a/tools/m4/class_opaque_copyable.m4 +++ b/tools/m4/class_opaque_copyable.m4 @@ -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