From: DongHun Kwak Date: Mon, 7 Sep 2020 07:17:39 +0000 (-0700) Subject: Imported Upstream version 2.51.1 X-Git-Tag: upstream/2.51.1^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e801a0c8ef526429fc0cea174b3cf5566f216491;p=platform%2Fupstream%2Fglibmm.git Imported Upstream version 2.51.1 --- diff --git a/MSVC_Net2013/glibmm-install.props b/MSVC_Net2013/glibmm-install.props index f28a0c8..2848409 100644 --- a/MSVC_Net2013/glibmm-install.props +++ b/MSVC_Net2013/glibmm-install.props @@ -11,9 +11,7 @@ mkdir $(CopyDir) mkdir $(CopyDir)\bin copy $(BinDir)\glibmm-vc$(VSVer)0-$(ApiMajorVersion)_$(ApiMinorVersion).dll $(CopyDir)\bin -copy $(BinDir)\glibmm-vc$(VSVer)0-$(ApiMajorVersion)_$(ApiMinorVersion).pdb $(CopyDir)\bin copy $(BinDir)\giomm-vc$(VSVer)0-$(ApiMajorVersion)_$(ApiMinorVersion).dll $(CopyDir)\bin -copy $(BinDir)\giomm-vc$(VSVer)0-$(ApiMajorVersion)_$(ApiMinorVersion).pdb $(CopyDir)\bin mkdir $(CopyDir)\lib\glibmm-$(ApiMajorVersion).$(ApiMinorVersion)\include mkdir $(CopyDir)\lib\giomm-$(ApiMajorVersion).$(ApiMinorVersion)\include diff --git a/NEWS b/NEWS index b0fd906..fa3d1d0 100644 --- a/NEWS +++ b/NEWS @@ -1,35 +1,36 @@ -2.50.1 (stable): +2.51.1: -Glib -* Dispatcher: Don't cast a HANDLE to an int on Windows. - (Kjell Ahlstedt) Bug 772074 +This is the first release of the glibmm-2.52 API/ABI. +It installs in parallel with the gtkmm-2.4 API/ABI, of which +the most recent version is glibmm 2.50. We know that is a bit +confusing. We are taking the opportunity to do this glibmm ABI +break while GTK+ (and therefore gtkmm) is also doing an ABI +break. But we cannot call this glibmm-3.0 because there is no +glib 3.0. + +Build: +* Require C++14. + (Murray Cumming) +* Use libsigc++-3.0 instead of libsigc++-2.0. + https://www.murrayc.com/permalink/2016/03/07/libsigc-3-0-very-variadic/ + (Murray Cumming) +* Remove lots of deprecated API. + (Kjell Ahlstedt) Gio: -* Action: Include variant.h in the header. - (Daniel Boles) Bug #777953 -* Application::get_default(): Correct the refcounting. - (Daniel Boles) Bug #779936 -* SettingsSchemaSource: Correct the refcounting. +* BufferedInputStream, InputStream, OutputStream: Add vfuncs, + allowing implementation in C++. + (Krzysztof Kosiński, Kjell Ahlstedt) Bug #572471 +* SettingsSchemaSource::get_default(): Correct the reference count. (Marcin Kolny) Bug #774593 +* Settings: Fix type of 'key' parameter of writable-change-event signal + (Marcin Kolny) Bug #773977 -Gio::DBus -* Proxy: Fix memory leak in get_cached_property_names(). - (Kjell Ahlstedt) Bug #775210 - -Documentation: -* Glib::Variant: Improve documentation of "maybe" types. - (Daniel Boles) Bug #778219 - Gio::ActionMap: Clarify doc of ActivateWithParameterSlot. - (Daniel Boles) - -Build: -* C++11: Variant: Replace throw(std::bad_cast) with noexcept(false). - See https://bugzilla.redhat.com/show_bug.cgi?id=1438766 -* Visual Studio: Install the .pdb files. - (Chun-wei Fan) +Glib: +* ustring: Add cbegin() and cend(). -2.50.0 (stable): +2.50.0: No changes since 2.49.7. diff --git a/configure.ac b/configure.ac index 02352bd..03d994a 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ ## You should have received a copy of the GNU Lesser General Public License ## along with this library. If not, see . -AC_INIT([glibmm], [2.50.1], +AC_INIT([glibmm], [2.51.1], [http://bugzilla.gnome.org/enter_bug.cgi?product=glibmm], [glibmm], [http://www.gtkmm.org/]) AC_PREREQ([2.59]) @@ -31,8 +31,8 @@ AM_MAINTAINER_MODE AC_ARG_VAR([ACLOCAL_FLAGS], [aclocal flags, e.g. -I ]) MM_PREREQ([0.9.10]) -MM_INIT_MODULE([glibmm-2.4]) -MM_INIT_MODULE([giomm-2.4]) +MM_INIT_MODULE([glibmm-2.52]) +MM_INIT_MODULE([giomm-2.52]) # Copy the mm-common .pl scripts into docs/, # and use them from there, @@ -43,7 +43,7 @@ MM_CONFIG_DOCTOOL_DIR([docs]) AC_SUBST([LIBGLIBMM_SO_VERSION], [4:0:3]) AC_PROG_CXX -MM_AX_CXX_COMPILE_STDCXX([11], [noext],[mandatory]) +MM_AX_CXX_COMPILE_STDCXX([14], [noext],[mandatory]) AC_DISABLE_STATIC LT_INIT([win32-dll]) @@ -64,7 +64,7 @@ AS_IF([test "x$enable_static" = xyes], glibreq='2.0 >= 2.50.0' -GLIBMM_MODULES="sigc++-2.0 >= 2.9.1 glib-$glibreq gobject-$glibreq gmodule-$glibreq" +GLIBMM_MODULES="sigc++-3.0 >= 2.99.5 glib-$glibreq gobject-$glibreq gmodule-$glibreq" GIOMM_MODULES="$GLIBMM_MODULES gio-$glibreq" test "x$glibmm_host_windows" = xyes || GIOMM_MODULES="$GIOMM_MODULES gio-unix-$glibreq" @@ -114,10 +114,16 @@ MM_ARG_WITH_TAGFILE_DOC([libsigc++-2.0.tag], [sigc++-2.0]) # Check whether --enable-debug-refcounting was given. GLIBMM_ARG_ENABLE_DEBUG_REFCOUNTING +glibmm_warnings_fatal='-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long' # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([GLIBMM_WXXFLAGS], [-Wall], - [-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long], + [$glibmm_warnings_fatal], + [G SIGCXX]) + +MM_ARG_ENABLE_WARNINGS([GLIBMM_INTERFACE_TEST_WXXFLAGS], + [-Wall], + [$glibmm_warnings_fatal -Wno-unused-function], [G SIGCXX]) # Offer the ability to omit some API from the library, diff --git a/docs/Makefile_web.am_fragment b/docs/Makefile_web.am_fragment index 9ac3ad8..e3bdb00 100644 --- a/docs/Makefile_web.am_fragment +++ b/docs/Makefile_web.am_fragment @@ -1,8 +1,8 @@ web_host = gtkmm.org -web_path_gtkmm = /home/murrayc/gtkmm.org/docs/glibmm-2.4/ -#web_path_gtkmm = /home/groups/g/gt/gtkmm/htdocs/docs/glibmm-2.4/ +web_path_gtkmm = /home/murrayc/gtkmm.org/docs/glibmm-2.52/ +#web_path_gtkmm = /home/groups/g/gt/gtkmm/htdocs/docs/glibmm-2.52/ web_path_docs = $(web_path_gtkmm)docs/ rsync_args = -vz --rsh ssh -gtkmm_docdir = $(datadir)/doc/glibmm-2.4/docs +gtkmm_docdir = $(datadir)/doc/glibmm-2.52/docs diff --git a/examples/Makefile.am b/examples/Makefile.am index 0de871a..885552d 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -32,11 +32,7 @@ check_PROGRAMS = \ options/example \ properties/example \ regex/example \ - settings/settings \ - thread/dispatcher \ - thread/dispatcher2 \ - thread/thread \ - thread/threadpool + settings/settings glibmm_includes = -I$(top_builddir)/glib $(if $(srcdir:.=),-I$(top_srcdir)/glib) giomm_includes = -I$(top_builddir)/gio $(if $(srcdir:.=),-I$(top_srcdir)/gio) diff --git a/examples/thread/thread.cc b/examples/thread/thread.cc deleted file mode 100644 index 7af2735..0000000 --- a/examples/thread/thread.cc +++ /dev/null @@ -1,126 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#if defined(_MSC_VER) && (_MSC_VER < 1900) -/* For using noexcept on Visual Studio 2013 */ -#include -#endif -#include -#include -#include - -namespace -{ - -class MessageQueue -{ -public: - MessageQueue(); - ~MessageQueue(); - - void producer(); - void consumer(); - -private: - std::mutex mutex_; - std::condition_variable cond_push_; - std::condition_variable cond_pop_; - std::queue queue_; -}; - -MessageQueue::MessageQueue() -{ -} - -MessageQueue::~MessageQueue() -{ -} - -void -MessageQueue::producer() -{ - Glib::Rand rand(1234); - - for (auto i = 0; i < 200; ++i) - { - { - std::unique_lock lock(mutex_); - - cond_pop_.wait(lock, [this]() -> bool { return queue_.size() < 64; }); - - queue_.push(i); - std::cout << '*'; - std::cout.flush(); - - // We unlock before notifying, because that is what the documentation suggests: - // http://en.cppreference.com/w/cpp/thread/condition_variable - lock.unlock(); - cond_push_.notify_one(); - } - - if (rand.get_bool()) - continue; - - Glib::usleep(rand.get_int_range(0, 100000)); - } -} - -void -MessageQueue::consumer() -{ - Glib::Rand rand(4567); - - for (;;) - { - { - std::unique_lock lock(mutex_); - - cond_push_.wait(lock, [this]() -> bool { return !queue_.empty(); }); - - const int i = queue_.front(); - queue_.pop(); - std::cout << "\x08 \x08"; - std::cout.flush(); - - // We unlock before notifying, because that is what the documentation suggests: - // http://en.cppreference.com/w/cpp/thread/condition_variable - lock.unlock(); - cond_pop_.notify_one(); - - if (i >= 199) - break; - } - - if (rand.get_bool()) - continue; - - Glib::usleep(rand.get_int_range(10000, 200000)); - } -} -} - -int -main(int, char**) -{ - Glib::init(); - - MessageQueue queue; - - // TODO: Use std::make_unique() when we use C++14: - const auto producer = - std::unique_ptr(new std::thread(&MessageQueue::producer, &queue)); - - const auto consumer = - std::unique_ptr(new std::thread(&MessageQueue::consumer, &queue)); - - producer->join(); - consumer->join(); - - std::cout << std::endl; - - return 0; -} diff --git a/examples/thread/threadpool.cc b/examples/thread/threadpool.cc deleted file mode 100644 index 885962b..0000000 --- a/examples/thread/threadpool.cc +++ /dev/null @@ -1,68 +0,0 @@ - -#include -#include -#include - -// TODO: Remove this example sometime. Glib::ThreadPool is deprecated. -// TODO: Maybe use std::async() instead? -#undef GLIBMM_DISABLE_DEPRECATED - -#include - -#ifdef GLIBMM_DISABLE_DEPRECATED -int -main(int, char**) -{ - // If glibmm is configured with --disable-deprecated-api, - // GLIBMM_DISABLE_DEPRECATED is defined in glibmmconfig.h. - std::cout << "Glib::ThreadPool not available because deprecated API has been disabled." - << std::endl; - return 77; // Tell automake's test harness to skip this test. -} - -#else - -#include -#include -#include - -namespace -{ - -std::mutex mutex; - -void -print_char(char c) -{ - Glib::Rand rand; - - for (auto i = 0; i < 100; ++i) - { - { - std::lock_guard lock(mutex); - std::cout << c; - std::cout.flush(); - } - Glib::usleep(rand.get_int_range(10000, 100000)); - } -} - -} // anonymous namespace - -int -main(int, char**) -{ - Glib::ThreadPool pool(10); - - for (auto c = 'a'; c <= 'z'; ++c) - { - pool.push(sigc::bind(sigc::ptr_fun(&print_char), c)); - } - - pool.shutdown(); - - std::cout << std::endl; - - return 0; -} -#endif // GLIBMM_DISABLE_DEPRECATED diff --git a/gio/giomm/socketsource.cc b/gio/giomm/socketsource.cc index af1e974..4284261 100644 --- a/gio/giomm/socketsource.cc +++ b/gio/giomm/socketsource.cc @@ -31,7 +31,7 @@ giomm_generic_socket_callback(sigc::slot_base* slot, GIOCondition condition) try { // Recreate the specific slot from the generic slot node. - return (*static_cast*>(slot))((Glib::IOCondition)condition); + return (*static_cast*>(slot))((Glib::IOCondition)condition); } catch (...) { @@ -66,7 +66,7 @@ inline SignalSocket::SignalSocket(GMainContext* context) : context_(context) } sigc::connection -SignalSocket::connect(const sigc::slot& slot, +SignalSocket::connect(const sigc::slot& slot, const Glib::RefPtr& socket, Glib::IOCondition condition, const Glib::RefPtr& cancellable, int priority) { diff --git a/gio/giomm/socketsource.h b/gio/giomm/socketsource.h index c1345c6..feadfb0 100644 --- a/gio/giomm/socketsource.h +++ b/gio/giomm/socketsource.h @@ -69,7 +69,7 @@ public: * @param priority The priority of the new event source. * @return A connection handle, which can be used to disconnect the handler. */ - sigc::connection connect(const sigc::slot& slot, + sigc::connection connect(const sigc::slot& slot, const Glib::RefPtr& socket, Glib::IOCondition condition, const Glib::RefPtr& cancellable = Glib::RefPtr(), int priority = Glib::PRIORITY_DEFAULT); diff --git a/gio/src/action.ccg b/gio/src/action.ccg index c5a1735..9dbb598 100644 --- a/gio/src/action.ccg +++ b/gio/src/action.ccg @@ -17,6 +17,8 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include +#include #include namespace Gio diff --git a/gio/src/action.hg b/gio/src/action.hg index f05d226..ffff582 100644 --- a/gio/src/action.hg +++ b/gio/src/action.hg @@ -18,7 +18,6 @@ _CONFIGINCLUDE(giommconfig.h) #include -#include #include #include @@ -30,6 +29,13 @@ _PINCLUDE(gio/gio.h) typedef struct _GActionInterface GActionInterface; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ +namespace Glib +{ + +class VariantBase; + +} + namespace Gio { @@ -128,8 +134,6 @@ public: _WRAP_METHOD(void change_state_variant(const Glib::VariantBase& value), g_action_change_state) - _WRAP_METHOD(void change_state(const Glib::VariantBase& value), g_action_change_state, deprecated "Use the templated method instead, passing a normal C++ type.") - /** Queries the current state of the action. * * If the action is not stateful then a null Variant will be returned. If the @@ -166,8 +170,6 @@ public: _WRAP_METHOD(void activate_variant(const Glib::VariantBase& parameter), g_action_activate) - _WRAP_METHOD(void activate(const Glib::VariantBase& parameter), g_action_activate, deprecated "Use the templated method instead, passing a normal C++ type.") - _WRAP_METHOD(static bool name_is_valid(const Glib::ustring& action_name), g_action_name_is_valid ) /** Parses a detailed action name into its separate name and target components. diff --git a/gio/src/actiongroup.hg b/gio/src/actiongroup.hg index d8f9c10..5877e20 100644 --- a/gio/src/actiongroup.hg +++ b/gio/src/actiongroup.hg @@ -104,9 +104,6 @@ public: _WRAP_METHOD(Glib::VariantContainerBase get_action_state_hint_variant(const Glib::ustring& action_name) const, g_action_group_get_action_state_hint) - - _WRAP_METHOD(Glib::VariantBase get_action_state(const Glib::ustring& action_name) const, g_action_group_get_action_state, deprecated "Use the get_action_state() method that takes an output parameter instead.") - //TODO: How do we check for a nullptr Variant? /** Queries the current state of the named action within the action group. * diff --git a/gio/src/actionmap.hg b/gio/src/actionmap.hg index 6e59a62..e3bcdf0 100644 --- a/gio/src/actionmap.hg +++ b/gio/src/actionmap.hg @@ -53,14 +53,13 @@ public: _WRAP_METHOD(Glib::RefPtr lookup_action(const Glib::ustring& action_name), g_action_map_lookup_action, refreturn) _WRAP_METHOD(Glib::RefPtr lookup_action(const Glib::ustring& action_name) const, g_action_map_lookup_action, constversion, refreturn) - /** A Slot to be called when an action has been activated, - * passing a parameter of a specified type. + /** A Slot to be called when an action has been activated. * See add_action_with_parameter(). * * For instance, * void on_slot_activated(const Glib::VariantBase& parameter); */ - using ActivateWithParameterSlot = sigc::slot; + using ActivateWithParameterSlot = sigc::slot; //This is an equivalent for g_action_map_add_action_entries(). /** A convenience method for creating a SimpleAction instance @@ -84,12 +83,12 @@ public: /** A Slot to be called when an action has been activated, * without passing a parameter to the slot. - * See add_action() and add_action_bool(). + * See add_action(). * * For instance, * void on_slot_activated(); */ - using ActivateSlot = sigc::slot; + using ActivateSlot = sigc::slot; /** A convenience method for creating a SimpleAction instance * and adding it to the ActionMap. @@ -135,9 +134,9 @@ public: * See add_action_radio_string(). * * For instance, - * void on_slot_activated(const Glib::ustring& parameter); + * void on_slot_activated(const Glib::VariantBase& parameter); */ - using ActivateWithStringParameterSlot = sigc::slot; + using ActivateWithStringParameterSlot = sigc::slot; //TODO: Docs: Add hints about how to specify the various possible states in the GtkBuilder XML. /** A convenience method for creating a string-based radio SimpleAction instance @@ -161,13 +160,13 @@ public: Glib::RefPtr add_action_radio_integer(const Glib::ustring& name, gint32 state); /** A Slot to be called when an action has been activated. - * See add_action_radio_integer(). + * See add_action_radio_int(). * * For instance, - * void on_slot_activated(int parameter); + * void on_slot_activated(const Glib::VariantBase& parameter); */ - using ActivateWithIntParameterSlot = sigc::slot; - + using ActivateWithIntParameterSlot = sigc::slot; + //TODO: Docs: Add hints about how to specify the various possible states in the GtkBuilder XML. /** A convenience method for creating an integer-based radio SimpleAction instance * and adding it to the ActionMap. diff --git a/gio/src/appinfo.hg b/gio/src/appinfo.hg index 255dce6..238cc07 100644 --- a/gio/src/appinfo.hg +++ b/gio/src/appinfo.hg @@ -157,10 +157,6 @@ public: _WRAP_METHOD(bool supports_files() const, g_app_info_supports_files) #m4 _CONVERSION(`const Glib::ListHandle&',`GList*',`$3.data()') - _WRAP_METHOD(bool launch_uris(const Glib::ListHandle& uris, - GAppLaunchContext* launch_context), - g_app_info_launch_uris, - errthrow, deprecated "Use the method that takes an AppLaunchContext") //TODO: I think we use Glib::ustring elsewhere for URIs: _WRAP_METHOD(bool launch_uris(const Glib::ListHandle& uris, diff --git a/gio/src/application.ccg b/gio/src/application.ccg index 7b53edf..785d050 100644 --- a/gio/src/application.ccg +++ b/gio/src/application.ccg @@ -57,7 +57,7 @@ static void Application_signal_open_callback( GApplication* self, GFile** files, gint n_files, const gchar* hint, void* data) { - using SlotType = sigc::slot; + using SlotType = sigc::slot; Gio::Application::type_vec_files vec_files(n_files); for (int i = 0; i < n_files; ++i) @@ -92,7 +92,7 @@ Application_signal_open_notify_callback( GApplication* self, GFile** files, gint n_files, const gchar* hint, void* data) { using namespace Gio; - using SlotType = sigc::slot; + using SlotType = sigc::slot; Application::type_vec_files vec_files(n_files); for (int i = 0; i < n_files; i++) @@ -352,10 +352,10 @@ Application_Class::open_callback(GApplication* self, GFile** files, gint n_files (*base->open)(self, files, n_files, hint); } -Glib::SignalProxy +Glib::SignalProxy Application::signal_open() { - return Glib::SignalProxy( + return Glib::SignalProxy( this, &Application_signal_open_info); } diff --git a/gio/src/application.hg b/gio/src/application.hg index f9432ed..ea752fe 100644 --- a/gio/src/application.hg +++ b/gio/src/application.hg @@ -164,8 +164,7 @@ public: */ void unset_resource_base_path(); - _WRAP_METHOD(void set_action_group(const Glib::RefPtr& action_group), g_application_set_action_group, - deprecated "Use the Gio::ActionMap interface instead.") + _IGNORE(g_application_set_action_group) //Note: We would like to add a group, not just some entries, //so we can do pre and post parsing. See https://bugzilla.gnome.org/show_bug.cgi?id=727602 @@ -345,7 +344,7 @@ public: /// Unsets any existing default application. static void unset_default(); - _WRAP_METHOD(static Glib::RefPtr get_default(), g_application_get_default, refreturn) + _WRAP_METHOD(static Glib::RefPtr get_default(), g_application_get_default) _WRAP_METHOD(void mark_busy(), g_application_mark_busy) _WRAP_METHOD(void unmark_busy(), g_application_unmark_busy) @@ -359,7 +358,7 @@ public: // _WRAP_METHOD(void bind_busy_property(const Glib::RefPtr& object, const Glib::ustring& property), g_application_bind_busy_property) // _WRAP_METHOD(void unbind_busy_property(const Glib::RefPtr& object, const Glib::ustring& property), g_application_unbind_busy_property) - _WRAP_PROPERTY("action-group", Glib::RefPtr, deprecated "Use the Gio::ActionMap interface instead.") + _IGNORE_PROPERTY("action-group") _WRAP_PROPERTY("application-id", Glib::ustring) _WRAP_PROPERTY("flags", ApplicationFlags) _WRAP_PROPERTY("inactivity-timeout", guint) @@ -380,7 +379,7 @@ public: //We wrap the open signal without _WRAP_SIGNAL(), because we need to change its parameters. //See bug https://bugzilla.gnome.org/show_bug.cgi?id=637457 - Glib::SignalProxy< void, const type_vec_files&, const Glib::ustring& > signal_open(); + Glib::SignalProxy signal_open(); _IGNORE_SIGNAL(open) #m4 _CONVERSION(`GApplicationCommandLine*', `const Glib::RefPtr&',`Glib::wrap($3, true)') diff --git a/gio/src/asyncresult.hg b/gio/src/asyncresult.hg index 7d9567c..31b6a15 100644 --- a/gio/src/asyncresult.hg +++ b/gio/src/asyncresult.hg @@ -42,7 +42,7 @@ class AsyncResult; * * @newin{2,16} */ -using SlotAsyncReady = sigc::slot&>; +using SlotAsyncReady = sigc::slot&)>; /** Provides a base class for implementing asynchronous function results. * Asynchronous operations are broken up into two separate operations which are chained together by a SlotAsyncReady. @@ -106,13 +106,7 @@ class AsyncResult : public Glib::Interface public: _IGNORE(g_async_result_get_user_data) - - //Note that this returns a reference, unlike most GTK+ get_*() functions, - //so we don't need to use refreturn. - _WRAP_METHOD(Glib::RefPtr get_source_object(), - g_async_result_get_source_object, deprecated "Use get_source_object_base()") - _WRAP_METHOD(Glib::RefPtr get_source_object() const, - g_async_result_get_source_object, constversion, deprecated "Use get_source_object_base()") + _IGNORE(g_async_result_get_source_object) //Note that this returns a reference, unlike most GTK+ get_*() functions, //so we don't need to use refreturn. diff --git a/gio/src/bufferedinputstream.hg b/gio/src/bufferedinputstream.hg index 9661d1e..3894f95 100644 --- a/gio/src/bufferedinputstream.hg +++ b/gio/src/bufferedinputstream.hg @@ -107,9 +107,8 @@ public: _WRAP_PROPERTY("buffer-size", guint) protected: - //TODO: When we can break ABI, add vfunc. See https://bugzilla.gnome.org/show_bug.cgi?id=572471 #m4 _CONVERSION(`GCancellable*', `const Glib::RefPtr&', `Glib::wrap($3, true)') - //_WRAP_VFUNC(gssize fill(gssize count, const Glib::RefPtr& cancellable), fill, errthrow, err_return_value -1) + _WRAP_VFUNC(gssize fill(gssize count, const Glib::RefPtr& cancellable), fill, errthrow, err_return_value -1) }; } // namespace Gio diff --git a/gio/src/cancellable.hg b/gio/src/cancellable.hg index fc8bff8..a1cc68a 100644 --- a/gio/src/cancellable.hg +++ b/gio/src/cancellable.hg @@ -37,7 +37,7 @@ protected: _CTOR_DEFAULT public: - using SlotCancelledCallback = sigc::slot; + using SlotCancelledCallback = sigc::slot; _WRAP_CREATE() diff --git a/gio/src/dbusconnection.hg b/gio/src/dbusconnection.hg index 6b0e558..96b65c8 100644 --- a/gio/src/dbusconnection.hg +++ b/gio/src/dbusconnection.hg @@ -173,9 +173,9 @@ public: * Glib::ustring& signal_name, const Glib::VariantContainerBase& parameters);. * @endcode */ - using SlotSignal = sigc::slot&, + using SlotSignal = sigc::slot&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, - const Glib::ustring&, const Glib::VariantContainerBase&>; + const Glib::ustring&, const Glib::VariantContainerBase&)>; /** Signature for slot used in add_filter(). * For example, @@ -191,9 +191,9 @@ public: * drop a message can simply return 0. And filter function may * modify a message by copying it and return the copy. */ - using SlotMessageFilter = sigc::slot, + using SlotMessageFilter = sigc::slot( const Glib::RefPtr&, - const Glib::RefPtr&, bool>; + const Glib::RefPtr&, bool)>; /** Asynchronously connects to the message bus specified by @a bus_type. * diff --git a/gio/src/dbusinterfacevtable.hg b/gio/src/dbusinterfacevtable.hg index caf181a..c4081e7 100644 --- a/gio/src/dbusinterfacevtable.hg +++ b/gio/src/dbusinterfacevtable.hg @@ -63,14 +63,14 @@ public: * @endcode */ using SlotInterfaceMethodCall = sigc::slot< - void, + void( const Glib::RefPtr&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, const Glib::VariantContainerBase&, - const Glib::RefPtr& + const Glib::RefPtr&) >; /** The type for a slot which handles getting a property for a D-Bus @@ -85,13 +85,13 @@ public: * @throw Glib::Error. */ using SlotInterfaceGetProperty = sigc::slot< - void, + void( Glib::VariantBase&, const Glib::RefPtr&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, - const Glib::ustring& + const Glib::ustring&) >; /** The type for a slot which handles setting a property for a D-Bus @@ -106,13 +106,13 @@ public: * @throw Glib::Error. */ using SlotInterfaceSetProperty = sigc::slot< - bool, + bool( const Glib::RefPtr&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, - const Glib::VariantBase& + const Glib::VariantBase&) >; /** Constructs a new InterfaceVTable using the specified slots. diff --git a/gio/src/dbusownname.hg b/gio/src/dbusownname.hg index 8690d10..5944f43 100644 --- a/gio/src/dbusownname.hg +++ b/gio/src/dbusownname.hg @@ -35,21 +35,21 @@ _WRAP_ENUM(BusNameOwnerFlags, GBusNameOwnerFlags, s#^DBUS_##) * @newin{2,28} * @ingroup DBus */ -using SlotBusAcquired = sigc::slot&, Glib::ustring>; +using SlotBusAcquired = sigc::slot&, Glib::ustring)>; /** For example, * void on_name_acquired(const Glib::RefPtr& connection, * const Glib::ustring& name); * @ingroup DBus */ -using SlotNameAcquired = sigc::slot&, Glib::ustring>; +using SlotNameAcquired = sigc::slot&, Glib::ustring)>; /** For example, * void on_name_lost(const Glib::RefPtr& connection, * const Glib::ustring& name); * @ingroup DBus */ -using SlotNameLost = sigc::slot&, Glib::ustring>; +using SlotNameLost = sigc::slot&, Glib::ustring)>; //TODO: See https://bugzilla.gnome.org/show_bug.cgi?id=646427 about the apparent uselessness of SlotNameAcquired. //TODO: Add example from C API in class docs. diff --git a/gio/src/dbusproxy.hg b/gio/src/dbusproxy.hg index a6e7419..2e3729f 100644 --- a/gio/src/dbusproxy.hg +++ b/gio/src/dbusproxy.hg @@ -1,3 +1,5 @@ +// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*- + /* Copyright (C) 2010 The giomm Development Team * * This library is free software; you can redistribute it and/or @@ -253,7 +255,7 @@ public: _WRAP_METHOD(void set_cached_property(const Glib::ustring& property_name, const Glib::VariantBase& value), g_dbus_proxy_set_cached_property) -#m4 _CONVERSION(`gchar**', `Glib::StringArrayHandle', `Glib::StringArrayHandle($3, Glib::OWNERSHIP_DEEP)') +#m4 _CONVERSION(`gchar**', `Glib::StringArrayHandle', `Glib::StringArrayHandle($3)') _WRAP_METHOD(Glib::StringArrayHandle get_cached_property_names() const, g_dbus_proxy_get_cached_property_names) _WRAP_METHOD(void set_interface_info(const Glib::RefPtr& info), g_dbus_proxy_set_interface_info) diff --git a/gio/src/dbussubtreevtable.hg b/gio/src/dbussubtreevtable.hg index ead80ee..3c2d6d8 100644 --- a/gio/src/dbussubtreevtable.hg +++ b/gio/src/dbussubtreevtable.hg @@ -67,10 +67,10 @@ public: * @endcode */ using SlotSubtreeEnumerate = sigc::slot< - std::vector, + std::vector( const Glib::RefPtr&, const Glib::ustring&, - const Glib::ustring& + const Glib::ustring&) >; /** The type for a slot which handles introspecting a child node. @@ -94,11 +94,11 @@ public: * @endcode */ using SlotSubtreeIntrospect = sigc::slot< - std::vector< Glib::RefPtr >, + std::vector< Glib::RefPtr >( const Glib::RefPtr&, const Glib::ustring&, const Glib::ustring&, - const Glib::ustring& + const Glib::ustring&) >; /** The type for a slot which handles dispatching a remote call on a child @@ -116,12 +116,12 @@ public: * @endcode */ using SlotSubtreeDispatch = sigc::slot< - const InterfaceVTable*, + const InterfaceVTable*( const Glib::RefPtr&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, - const Glib::ustring& + const Glib::ustring&) >; /** Constructs a new SubtreeVTable using specified slots. diff --git a/gio/src/dbuswatchname.hg b/gio/src/dbuswatchname.hg index dd697ce..63cdab4 100644 --- a/gio/src/dbuswatchname.hg +++ b/gio/src/dbuswatchname.hg @@ -34,14 +34,14 @@ _WRAP_ENUM(BusNameWatcherFlags, GBusNameWatcherFlags, s#^DBUS_##, NO_GTYPE) * const Glib::ustring& name, const Glib::ustring& name_owner); * @ingroup DBus */ -using SlotNameAppeared = sigc::slot&, Glib::ustring, const Glib::ustring&>; +using SlotNameAppeared = sigc::slot&, Glib::ustring, const Glib::ustring&)>; /** For example, * void on_name_vanished(const Glib::RefPtr& connection, * const Glib::ustring& name); * @ingroup DBus */ -using SlotNameVanished = sigc::slot&, Glib::ustring>; +using SlotNameVanished = sigc::slot&, Glib::ustring)>; //TODO: Add example from C API in class docs? /** Starts watching @a name on the bus specified by @a bus_type and calls diff --git a/gio/src/desktopappinfo.hg b/gio/src/desktopappinfo.hg index 9c08401..ba65428 100644 --- a/gio/src/desktopappinfo.hg +++ b/gio/src/desktopappinfo.hg @@ -55,8 +55,8 @@ public: _WRAP_METHOD(std::string get_filename() const, g_desktop_app_info_get_filename) _WRAP_METHOD(bool is_hidden() const, g_desktop_app_info_get_is_hidden) - _WRAP_METHOD(static void set_desktop_env(const std::string& desktop_env), g_desktop_app_info_set_desktop_env, - deprecated "Do not use this API. Since 2.42 the value of the `XDG_CURRENT_DESKTOP` environment variable will be used.") + + _IGNORE(g_desktop_app_info_set_desktop_env) #m4 _CONVERSION(`const char* const*', `std::vector', `Glib::ArrayHandler::array_to_vector($3, Glib::OWNERSHIP_NONE)') _WRAP_METHOD(std::vector get_keywords() const, g_desktop_app_info_get_keywords) diff --git a/gio/src/file.hg b/gio/src/file.hg index 25c182f..cbe8bac 100644 --- a/gio/src/file.hg +++ b/gio/src/file.hg @@ -1118,7 +1118,7 @@ public: /** A signal handler would be, for instance: * void on_file_progress(goffset current_num_bytes, goffset total_num_bytes); */ - using SlotFileProgress = sigc::slot; + using SlotFileProgress = sigc::slot; /** Copies the file source to the location specified by destination. Can not handle recursive copies of directories. * If the flag FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten. @@ -1803,7 +1803,7 @@ public: * * @newin{2,38} */ - using SlotFileMeasureProgress = sigc::slot; + using SlotFileMeasureProgress = sigc::slot; //We do not use the {callback} syntax with _WRAP_METHOD here, because it expects to use user_data rather than progress_data. //We ignore the gboolean result, because we throw an exception if it is false. @@ -2097,7 +2097,7 @@ public: /** A signal handler would be, for instance: * bool on_read_more(const char* file_contents, goffset file_size); */ - using SlotReadMore = sigc::slot; + using SlotReadMore = sigc::slot; //Note that slot_read_more can be nullptr but that would not be a useful method overload, because the documentation says that it would //then be equivalent to load_contents_async. diff --git a/gio/src/gio_signals.defs b/gio/src/gio_signals.defs index 7af937c..31a2683 100644 --- a/gio/src/gio_signals.defs +++ b/gio/src/gio_signals.defs @@ -1049,7 +1049,7 @@ (return-type "gboolean") (when "last") (parameters - '("guint" "p0") + '("GQuark" "p0") ) ) @@ -1752,7 +1752,7 @@ (return-type "gboolean") (when "last") (parameters - '("guint" "p0") + '("GQuark" "p0") ) ) diff --git a/gio/src/gio_signals.defs.patch b/gio/src/gio_signals.defs.patch index a7b07ba..06a331f 100644 --- a/gio/src/gio_signals.defs.patch +++ b/gio/src/gio_signals.defs.patch @@ -36,6 +36,24 @@ ) ) +@@ -1049,6 +1049,6 @@ + (return-type "gboolean") + (when "last") + (parameters +- '("guint" "p0") ++ '("GQuark" "p0") + ) + ) + +@@ -1752,6 +1752,6 @@ + (return-type "gboolean") + (when "last") + (parameters +- '("guint" "p0") ++ '("GQuark" "p0") + ) + ) + @@ -1824,8 +1824,8 @@ (return-type "void") (when "last") diff --git a/gio/src/inputstream.hg b/gio/src/inputstream.hg index b98da27..315ed86 100644 --- a/gio/src/inputstream.hg +++ b/gio/src/inputstream.hg @@ -390,11 +390,10 @@ protected: _WRAP_METHOD(bool set_pending(), g_input_stream_set_pending, errthrow, newin "2,50") _WRAP_METHOD(void clear_pending(), g_input_stream_clear_pending, newin "2,50") - //TODO: When we can break ABI, add vfuncs. See https://bugzilla.gnome.org/show_bug.cgi?id=572471 #m4 _CONVERSION(`GCancellable*', `const Glib::RefPtr&', `Glib::wrap($3, true)') - //_WRAP_VFUNC(gssize read(void* buffer, gsize count, const Glib::RefPtr& cancellable), read_fn, errthrow, err_return_value -1) - //_WRAP_VFUNC(gssize skip(gsize count, const Glib::RefPtr& cancellable), skip, errthrow, err_return_value -1) - //_WRAP_VFUNC(bool close(const Glib::RefPtr& cancellable), close_fn, errthrow) + _WRAP_VFUNC(gssize read(void* buffer, gsize count, const Glib::RefPtr& cancellable), read_fn, errthrow, err_return_value -1) + _WRAP_VFUNC(gssize skip(gsize count, const Glib::RefPtr& cancellable), skip, errthrow, err_return_value -1) + _WRAP_VFUNC(bool close(const Glib::RefPtr& cancellable), close_fn, errthrow) }; } // namespace Gio diff --git a/gio/src/liststore.hg b/gio/src/liststore.hg index 840d739..2b3af6c 100644 --- a/gio/src/liststore.hg +++ b/gio/src/liststore.hg @@ -63,7 +63,7 @@ public: * * @newin{2,50} */ - using SlotCompare = sigc::slot&, const Glib::RefPtr&>; + using SlotCompare = sigc::slot&, const Glib::RefPtr&)>; _WRAP_METHOD(guint insert_sorted(const Glib::RefPtr& item, const SlotCompare& slot{compare_func}), g_list_store_insert_sorted, @@ -175,7 +175,7 @@ public: * * @newin{2,50} */ - using SlotCompare = sigc::slot&, const Glib::RefPtr&>; + using SlotCompare = sigc::slot&, const Glib::RefPtr&)>; /** Inserts @a item at a position to be determined by the @a slot. * diff --git a/gio/src/memoryinputstream.ccg b/gio/src/memoryinputstream.ccg index e896528..9c5068c 100644 --- a/gio/src/memoryinputstream.ccg +++ b/gio/src/memoryinputstream.ccg @@ -62,29 +62,6 @@ destroy_data_callback(void* user_data) namespace Gio { -_DEPRECATE_IFDEF_START -void -MemoryInputStream::add_data(const std::string& data) -{ - char* data_copy = g_strdup(data.c_str()); - g_memory_input_stream_add_data(gobj(), data_copy, -1, g_free); -} - -void -MemoryInputStream::add_data(const void* data, gssize len) -{ - char* data_copy = nullptr; - - // copy the data so that the caller doesn't need to keep the data alive - if (len < 0) - data_copy = g_strdup(static_cast(data)); - else - data_copy = static_cast(g_memdup(data, len)); - - g_memory_input_stream_add_data(gobj(), data_copy, len, g_free); -} -_DEPRECATE_IFDEF_END - void MemoryInputStream::add_data(const void* data, gssize len, const SlotDestroyData& destroy_slot) { diff --git a/gio/src/memoryinputstream.hg b/gio/src/memoryinputstream.hg index 0fc03f4..156ab09 100644 --- a/gio/src/memoryinputstream.hg +++ b/gio/src/memoryinputstream.hg @@ -46,27 +46,6 @@ protected: public: _WRAP_CREATE() -_DEPRECATE_IFDEF_START - /** Appends to data that can be read from the input stream. - * - * @param data Input data. - * - * @deprecated Use add_data() with SlotDestroyData or GDestroyNotify instead. - */ - void add_data(const std::string& data); - - /** Appends to data that can be read from the input stream. - * - * Note that the data will be copied internally and freed when no longer needed. - * - * @param data Input data. - * @param len Length of the data, may be -1 if data is a null-terminated string. - * - * @deprecated Use add_data() with SlotDestroyData or GDestroyNotify instead. - */ - void add_data(const void* data, gssize len); -_DEPRECATE_IFDEF_END - _WRAP_METHOD(void add_data(const void* data, gssize len, GDestroyNotify destroy), g_memory_input_stream_add_data) /** For example, @@ -76,7 +55,7 @@ _DEPRECATE_IFDEF_END * * @newin{2,40} */ - using SlotDestroyData = sigc::slot; + using SlotDestroyData = sigc::slot; /** Appends to data that can be read from the input stream. * diff --git a/gio/src/menuitem.ccg b/gio/src/menuitem.ccg index 6912c05..2f6dc38 100644 --- a/gio/src/menuitem.ccg +++ b/gio/src/menuitem.ccg @@ -43,14 +43,6 @@ MenuItem::MenuItem(const Glib::RefPtr& submenu) : _CONSTRUCT() set_submenu(submenu); } -_DEPRECATE_IFDEF_START -void -MenuItem::set_action_and_target(const Glib::ustring& action) -{ - g_menu_item_set_action_and_target_value(gobj(), action.c_str(), nullptr); -} -_DEPRECATE_IFDEF_END - void MenuItem::set_action(const Glib::ustring& action) { diff --git a/gio/src/menuitem.hg b/gio/src/menuitem.hg index 5590393..3830880 100644 --- a/gio/src/menuitem.hg +++ b/gio/src/menuitem.hg @@ -102,7 +102,6 @@ GMenuItem * g_menu_item_new_section (const Glib::ustring& label, //void set_attribute(const Glib::ustring& attribute, const T_Value& value) const; _WRAP_METHOD(void set_attribute_value(const Glib::ustring& attribute, const Glib::VariantBase& value), g_menu_item_set_attribute_value) - _WRAP_METHOD(void set_attribute(const Glib::ustring& attribute, const Glib::VariantBase& value), g_menu_item_set_attribute_value, deprecated "Use set_attribute() instead.") _IGNORE(g_menu_item_set_attribute) //These are documented as transfer-full, so we don't need to use refreturn. @@ -120,19 +119,11 @@ GMenuItem * g_menu_item_new_section (const Glib::ustring& label, //void get_attribute(const Glib::ustring& attribute, T_Value& value) const; //_WRAP_METHOD(Glib::VariantBase get_attribute_value(const Glib::ustring& attribute, const Glib::VariantType& expected_type{?}) const, g_menu_item_get_attribute_value) - _WRAP_METHOD(Glib::VariantBase get_attribute(const Glib::ustring& attribute, const Glib::VariantType& expected_type{?}) const, g_menu_item_get_attribute_value, deprecated "Use get_attribute_value() instead.") _WRAP_METHOD(Glib::VariantBase get_attribute_value(const Glib::ustring& attribute, const Glib::VariantType& expected_type{?}) const, g_menu_item_get_attribute_value) // Ignore varargs function. _IGNORE(g_menu_item_get_attribute) -_DEPRECATE_IFDEF_START - /** Unsets the target for the specified @a action. - * @deprecated Use set_action() or unset_target() instead. - */ - void set_action_and_target(const Glib::ustring& action); -_DEPRECATE_IFDEF_END - /** Sets the action for the menu item. * See set_action_and_target(). * diff --git a/gio/src/notification.hg b/gio/src/notification.hg index df9a7ee..de15fcf 100644 --- a/gio/src/notification.hg +++ b/gio/src/notification.hg @@ -71,7 +71,7 @@ public: _WRAP_METHOD(void set_title(const Glib::ustring& title), g_notification_set_title) _WRAP_METHOD(void set_body(const Glib::ustring& body), g_notification_set_body) _WRAP_METHOD(void set_icon(const Glib::RefPtr& icon), g_notification_set_icon) - _WRAP_METHOD(void set_urgent(bool urgent = true), g_notification_set_urgent, deprecated "Use set_priority() instead.") + _IGNORE(g_notification_set_urgent) _WRAP_METHOD(void set_priority(NotificationPriority priority = NOTIFICATION_PRIORITY_NORMAL), g_notification_set_priority, newin "2,44") _WRAP_METHOD(void add_button(const Glib::ustring& label, const Glib::ustring& detailed_action), g_notification_add_button) diff --git a/gio/src/outputstream.hg b/gio/src/outputstream.hg index d1e3f41..8b0c938 100644 --- a/gio/src/outputstream.hg +++ b/gio/src/outputstream.hg @@ -503,13 +503,12 @@ protected: _WRAP_METHOD(bool set_pending(), g_output_stream_set_pending, errthrow, newin "2,50") _WRAP_METHOD(void clear_pending(), g_output_stream_clear_pending, newin "2,50") - //TODO: When we can break ABI, add vfuncs. See https://bugzilla.gnome.org/show_bug.cgi?id=572471 #m4 _CONVERSION(`GCancellable*', `const Glib::RefPtr&', `Glib::wrap($3, true)') #m4 _CONVERSION(`GInputStream*', `const Glib::RefPtr&', `Glib::wrap($3, true)') - //_WRAP_VFUNC(gssize write(const void* buffer, gsize count, const Glib::RefPtr& cancellable), write_fn, errthrow, err_return_value -1) - //_WRAP_VFUNC(gssize splice(const Glib::RefPtr& source, const Glib::RefPtr& cancellable{.}, OutputStreamSpliceFlags flags{.}), splice, errthrow, err_return_value -1) - //_WRAP_VFUNC(bool flush(const Glib::RefPtr& cancellable), flush, errthrow) - //_WRAP_VFUNC(bool close(const Glib::RefPtr& cancellable), close_fn, errthrow) + _WRAP_VFUNC(gssize write(const void* buffer, gsize count, const Glib::RefPtr& cancellable), write_fn, errthrow, err_return_value -1) + _WRAP_VFUNC(gssize splice(const Glib::RefPtr& source, const Glib::RefPtr& cancellable{.}, OutputStreamSpliceFlags flags{.}), splice, errthrow, err_return_value -1) + _WRAP_VFUNC(bool flush(const Glib::RefPtr& cancellable), flush, errthrow) + _WRAP_VFUNC(bool close(const Glib::RefPtr& cancellable), close_fn, errthrow) }; } // namespace Gio diff --git a/gio/src/settings.ccg b/gio/src/settings.ccg index 3ec8691..b5f33ef 100644 --- a/gio/src/settings.ccg +++ b/gio/src/settings.ccg @@ -66,14 +66,4 @@ Settings::bind_writable( bind_writable(key, property_proxy.get_object(), property_proxy.get_name(), inverted); } -_DEPRECATE_IFDEF_START -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -std::vector -Settings::list_schemas() -{ - return Glib::ArrayHandler::array_to_vector( - g_settings_list_schemas(), Glib::OWNERSHIP_NONE); -} -G_GNUC_END_IGNORE_DEPRECATIONS -_DEPRECATE_IFDEF_END } diff --git a/gio/src/settings.hg b/gio/src/settings.hg index 49c1905..b886b2b 100644 --- a/gio/src/settings.hg +++ b/gio/src/settings.hg @@ -136,7 +136,7 @@ public: _WRAP_METHOD(gint64 get_int64(const Glib::ustring& key) const, g_settings_get_int64) _WRAP_METHOD(void set_int64(const Glib::ustring& key, gint64 value), g_settings_set_int64) _WRAP_METHOD(guint get_uint(const Glib::ustring& key) const, g_settings_get_uint) - _WRAP_METHOD(void set_uiint(const Glib::ustring& key, guint value), g_settings_set_uint, deprecated "Use set_uint() instead.") + _IGNORE(g_settings_set_uint) _WRAP_METHOD(void set_uint(const Glib::ustring& key, guint value), g_settings_set_uint) _WRAP_METHOD(guint64 get_uint64(const Glib::ustring& key) const, g_settings_get_uint64) _WRAP_METHOD(void set_uint64(const Glib::ustring& key, guint64 value), g_settings_set_uint64) @@ -171,22 +171,13 @@ public: _WRAP_METHOD(void reset(const Glib::ustring& key), g_settings_reset) -_DEPRECATE_IFDEF_START -//We must hand-code this because gmmproc is confused by the static keyword with the vector. -//#m4 _CONVERSION(`const gchar*const*',`std::vector',`Glib::ArrayHandler::array_to_vector($3, Glib::OWNERSHIP_NONE)') - _WRAP_METHOD_DOCS_ONLY(g_settings_list_schemas) - static std::vector list_schemas(); - _IGNORE(g_settings_list_schemas) -_DEPRECATE_IFDEF_END - #m4 _CONVERSION(`gchar**',`std::vector',`Glib::ArrayHandler::array_to_vector($3, Glib::OWNERSHIP_DEEP)') _WRAP_METHOD(std::vector list_children() const, g_settings_list_children) - _WRAP_METHOD(std::vector list_keys() const, g_settings_list_keys, deprecated "Use SettingsSchema::list_kes().") + _IGNORE(g_settings_list_keys) _IGNORE(g_settings_get_range, g_settings_list_relocatable_schemas) // deprecated - _WRAP_METHOD(bool range_check(const Glib::ustring& key, const Glib::VariantBase& value) const, g_settings_range_check, - deprecated "Use g_settings_schema_key_range_check() instead.") + _IGNORE(g_settings_range_check) //TODO: Wrap GSettingsSchema #m4 _CONVERSION(`Glib::ObjectBase*',`gpointer',(gpointer)$3->gobj()) @@ -204,7 +195,7 @@ _DEPRECATE_IFDEF_END _WRAP_PROPERTY("delay-apply", bool) _WRAP_PROPERTY("has-unapplied", bool) _WRAP_PROPERTY("path", std::string) - _WRAP_PROPERTY("schema", Glib::ustring, deprecated "Use the 'schema-id' property instead. In a future version, this property may instead refer to a SettingsSchema.") + _IGNORE_PROPERTY("schema") _WRAP_PROPERTY("schema-id", Glib::ustring) //TODO: _WRAP_PROPERTY("settings-schema", Glib::RefPtr) @@ -215,7 +206,7 @@ _DEPRECATE_IFDEF_END #m4 _CONVERSION(`const char*',`const Glib::ustring&',__GCHARP_TO_USTRING) _WRAP_SIGNAL(void changed(const Glib::ustring& key), "changed", detail_name key, two_signal_methods) - _WRAP_SIGNAL(bool writable_change_event(guint key), "writable-change-event") + _WRAP_SIGNAL(bool writable_change_event(GQuark key), "writable-change-event") _WRAP_SIGNAL(void writable_changed(const Glib::ustring& key), writable_changed) }; diff --git a/gio/src/simpleaction.hg b/gio/src/simpleaction.hg index 1c57541..d1e6f23 100644 --- a/gio/src/simpleaction.hg +++ b/gio/src/simpleaction.hg @@ -53,7 +53,9 @@ protected: */ explicit SimpleAction(const Glib::ustring& name); - /** Creates a new stateful action. + /** Creates a new new stateful action. + * + * The created action is stateless. * * @a state is the initial state of the action. All future state values * must have the same VariantType as the initial state. diff --git a/gio/src/simpleactiongroup.hg b/gio/src/simpleactiongroup.hg index 0c3fc8c..36dd91b 100644 --- a/gio/src/simpleactiongroup.hg +++ b/gio/src/simpleactiongroup.hg @@ -49,11 +49,7 @@ public: _WRAP_METHOD_DOCS_ONLY(g_simple_action_group_new) _WRAP_CREATE() - _WRAP_METHOD(Glib::RefPtr lookup(const Glib::ustring& action_name), g_simple_action_group_lookup, refreturn, deprecated "Use ActionMap::lookup_action() instead") - _WRAP_METHOD(Glib::RefPtr lookup(const Glib::ustring& action_name) const, g_simple_action_group_lookup, refreturn, constversion, deprecated "Use ActionMap::lookup_action() instead") - - _WRAP_METHOD(void insert(const Glib::RefPtr& action), g_simple_action_group_insert, deprecated "Use ActionMap::add_action() instead") - _WRAP_METHOD(void remove(const Glib::ustring& action_name), g_simple_action_group_remove, deprecated "Use ActionMap::remove_action() instead") + _IGNORE(g_simple_action_group_lookup, g_simple_action_group_insert, g_simple_action_group_remove) _IGNORE(g_simple_action_group_add_entries) // deprecated }; diff --git a/gio/src/tlsconnection.hg b/gio/src/tlsconnection.hg index 80852f1..319c052 100644 --- a/gio/src/tlsconnection.hg +++ b/gio/src/tlsconnection.hg @@ -64,10 +64,7 @@ public: _WRAP_METHOD(void set_rehandshake_mode(TlsRehandshakeMode mode), g_tls_connection_set_rehandshake_mode) _WRAP_METHOD(TlsRehandshakeMode get_rehandshake_mode() const, g_tls_connection_get_rehandshake_mode) - _WRAP_METHOD(void set_use_system_certdb(bool use_system_certdb = true), g_tls_connection_set_use_system_certdb, - deprecated "Use set_database() instead.") - _WRAP_METHOD(bool get_use_system_certdb() const, g_tls_connection_get_use_system_certdb, - deprecated "Use get_database() instead.") + _IGNORE(g_tls_connection_set_use_system_certdb, g_tls_connection_get_use_system_certdb) _WRAP_METHOD(Glib::RefPtr get_database(), g_tls_connection_get_database) _WRAP_METHOD(Glib::RefPtr get_database() const, g_tls_connection_get_database, constversion) @@ -94,7 +91,7 @@ public: _WRAP_PROPERTY("peer-certificate-errors", TlsCertificateFlags) _WRAP_PROPERTY("rehandshake-mode", TlsRehandshakeMode) _WRAP_PROPERTY("require-close-notify", bool) - _WRAP_PROPERTY("use-system-certdb", bool, deprecated "Use property_database() instead.") + _IGNORE_PROPERTY("use-system-certdb") #m4 _CONVERSION(`GTlsCertificate*',`const Glib::RefPtr&',`Glib::wrap($3, true)') _WRAP_SIGNAL(bool accept_certificate(const Glib::RefPtr& peer_cert, TlsCertificateFlags errors), "accept_certificate") diff --git a/gio/src/unixsocketaddress.hg b/gio/src/unixsocketaddress.hg index e3e4170..cea8669 100644 --- a/gio/src/unixsocketaddress.hg +++ b/gio/src/unixsocketaddress.hg @@ -82,7 +82,7 @@ public: _WRAP_METHOD(static bool abstract_names_supported(), g_unix_socket_address_abstract_names_supported) - _WRAP_PROPERTY("abstract", bool, deprecated "Use property_address_type() instead, which distinguishes between zero-padded and non-zero-padded abstract addresses.") + _IGNORE_PROPERTY("abstract") _WRAP_PROPERTY("address-type", UnixSocketAddressType) _WRAP_PROPERTY("path", std::string) _WRAP_PROPERTY("path-as-array", Glib::RefPtr) diff --git a/gio/src/volumemonitor.hg b/gio/src/volumemonitor.hg index df32646..f12976f 100644 --- a/gio/src/volumemonitor.hg +++ b/gio/src/volumemonitor.hg @@ -55,8 +55,7 @@ public: _WRAP_METHOD(Glib::RefPtr get_volume_for_uuid(const std::string& uuid), g_volume_monitor_get_volume_for_uuid, refreturn) _WRAP_METHOD(Glib::RefPtr get_mount_for_uuid(const std::string& uuid), g_volume_monitor_get_mount_for_uuid, refreturn) - _WRAP_METHOD(static Glib::RefPtr adopt_orphan_mount(const Glib::RefPtr& mount), g_volume_monitor_adopt_orphan_mount, - deprecated "Instead of using this function, create shadow mounts with the URI of the mount you intend to adopt.") + _IGNORE(g_volume_monitor_adopt_orphan_mount) #m4 _CONVERSION(`GVolume*',`const Glib::RefPtr&',`Glib::wrap($3, true)') _WRAP_SIGNAL(void volume_added(const Glib::RefPtr& volume), volume_added) diff --git a/glib/glibmm.h b/glib/glibmm.h index 80b27b5..153d65e 100644 --- a/glib/glibmm.h +++ b/glib/glibmm.h @@ -65,12 +65,12 @@ * * If your source file is @c program.cc, you can compile it with: * @code - * g++ program.cc -o program `pkg-config --cflags --libs glibmm-2.4 giomm-2.4` + * g++ program.cc -o program `pkg-config --cflags --libs glibmm-2.52 giomm-2.52` * @endcode * * Alternatively, if using autoconf, use the following in @c configure.ac: * @code - * PKG_CHECK_MODULES([GLIBMM], [glibmm-2.4 giomm-2.4]) + * PKG_CHECK_MODULES([GLIBMM], [glibmm-2.52 giomm-2.52]) * @endcode * Then use the generated @c GLIBMM_CFLAGS and @c GLIBMM_LIBS variables in the * project Makefile.am files. For example: @@ -84,12 +84,6 @@ //#include //This must be included by the application, after system headers such as //. -// Include this first because we need it to be the first thing to include , -// so we can do an undef trick to still use deprecated API in the header: -#include - -#include - #include #include #include @@ -140,14 +134,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include diff --git a/glib/glibmm.pc.in b/glib/glibmm.pc.in index b08f62d..25e6c16 100644 --- a/glib/glibmm.pc.in +++ b/glib/glibmm.pc.in @@ -16,6 +16,6 @@ Name: glibmm Description: C++ wrapper for GLib Version: @PACKAGE_VERSION@ URL: http://www.gtkmm.org/ -Requires: gobject-2.0 sigc++-2.0 +Requires: gobject-2.0 sigc++-3.0 Libs: -L${libdir} -lglibmm-@GLIBMM_API_VERSION@ Cflags: -I${includedir}/@GLIBMM_MODULE_NAME@ -I${libdir}/@GLIBMM_MODULE_NAME@/include diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc index d9067a3..3c8a65d 100644 --- a/glib/glibmm/dispatcher.cc +++ b/glib/glibmm/dispatcher.cc @@ -15,10 +15,6 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef GLIBMM_CAN_USE_THREAD_LOCAL -#include -#endif - #include #include #include @@ -147,11 +143,7 @@ protected: explicit DispatchNotifier(const Glib::RefPtr& context); private: -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL static thread_local DispatchNotifier* thread_specific_instance_; -#else - static Glib::Threads::Private thread_specific_instance_; -#endif std::set deleted_dispatchers_; @@ -175,11 +167,7 @@ private: // static -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL thread_local DispatchNotifier* DispatchNotifier::thread_specific_instance_ = nullptr; -#else -Glib::Threads::Private DispatchNotifier::thread_specific_instance_; -#endif DispatchNotifier::DispatchNotifier(const Glib::RefPtr& context) : deleted_dispatchers_(), @@ -198,11 +186,11 @@ DispatchNotifier::DispatchNotifier(const Glib::RefPtr& context) try { - // PollFD::fd_t is the type of GPollFD::fd. - // In Windows, it has the same size as HANDLE, but it's not guaranteed to be the same type. - // In Unix, a file descriptor is an int. - const auto fd = (PollFD::fd_t)fd_receiver_; - +#ifdef G_OS_WIN32 + const int fd = GPOINTER_TO_INT(fd_receiver_); +#else + const int fd = fd_receiver_; +#endif // The following code is equivalent to // context_->signal_io().connect( // sigc::mem_fun(*this, &DispatchNotifier::pipe_io_handler), fd, Glib::IO_IN); @@ -282,20 +270,12 @@ DispatchNotifier* DispatchNotifier::reference_instance( const Glib::RefPtr& context, const Dispatcher* dispatcher) { -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL DispatchNotifier* instance = thread_specific_instance_; -#else - DispatchNotifier* instance = thread_specific_instance_.get(); -#endif if (!instance) { instance = new DispatchNotifier(context); -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL thread_specific_instance_ = instance; -#else - thread_specific_instance_.replace(instance); -#endif } else { @@ -323,11 +303,7 @@ DispatchNotifier::reference_instance( void DispatchNotifier::unreference_instance(DispatchNotifier* notifier, const Dispatcher* dispatcher) { -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL DispatchNotifier* const instance = thread_specific_instance_; -#else - DispatchNotifier* const instance = thread_specific_instance_.get(); -#endif // Yes, the notifier argument is only used to check for sanity. g_return_if_fail(instance == notifier); @@ -344,12 +320,8 @@ DispatchNotifier::unreference_instance(DispatchNotifier* notifier, const Dispatc { g_return_if_fail(instance->ref_count_ == 0); // could be < 0 if messed up -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL delete thread_specific_instance_; thread_specific_instance_ = nullptr; -#else - thread_specific_instance_.replace(nullptr); -#endif } } @@ -527,13 +499,13 @@ Dispatcher::operator()() } sigc::connection -Dispatcher::connect(const sigc::slot& slot) +Dispatcher::connect(const sigc::slot& slot) { return signal_.connect(slot); } sigc::connection -Dispatcher::connect(sigc::slot&& slot) +Dispatcher::connect(sigc::slot&& slot) { return signal_.connect(std::move(slot)); } diff --git a/glib/glibmm/dispatcher.h b/glib/glibmm/dispatcher.h index e3b0d18..2109560 100644 --- a/glib/glibmm/dispatcher.h +++ b/glib/glibmm/dispatcher.h @@ -30,7 +30,7 @@ class DispatchNotifier; /** Signal class for inter-thread communication. * @ingroup Threads - * Glib::Dispatcher works similar to sigc::signal. But unlike normal + * Glib::Dispatcher works similar to sigc::signal. But unlike normal * signals, the notification happens asynchronously through a pipe. This is * a simple and efficient way of communicating between threads, and especially * useful in a thread model with a single GUI thread. @@ -88,13 +88,13 @@ public: void emit(); void operator()(); - sigc::connection connect(const sigc::slot& slot); + sigc::connection connect(const sigc::slot& slot); /** @newin{2,48} */ - sigc::connection connect(sigc::slot&& slot); + sigc::connection connect(sigc::slot&& slot); private: - sigc::signal signal_; + sigc::signal signal_; DispatchNotifier* notifier_; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/glib/glibmm/exceptionhandler.cc b/glib/glibmm/exceptionhandler.cc index 95032a3..e80e009 100644 --- a/glib/glibmm/exceptionhandler.cc +++ b/glib/glibmm/exceptionhandler.cc @@ -19,9 +19,6 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef GLIBMM_CAN_USE_THREAD_LOCAL -#include -#endif #include #include #include @@ -36,11 +33,7 @@ using HandlerList = std::list>; // Each thread has its own list of exception handlers // to avoid thread synchronization problems. -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL static thread_local HandlerList* thread_specific_handler_list = nullptr; -#else -static Glib::Threads::Private thread_specific_handler_list; -#endif static void glibmm_exception_warning(const GError* error) @@ -90,22 +83,14 @@ namespace Glib { sigc::connection -add_exception_handler(const sigc::slot& slot) +add_exception_handler(const sigc::slot& slot) { -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL HandlerList* handler_list = thread_specific_handler_list; -#else - HandlerList* handler_list = thread_specific_handler_list.get(); -#endif if (!handler_list) { handler_list = new HandlerList(); -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL thread_specific_handler_list = handler_list; -#else - thread_specific_handler_list.set(handler_list); -#endif } handler_list->emplace_back(slot); @@ -130,11 +115,7 @@ exception_handlers_invoke() noexcept // handled. If there are no more handlers in the list and the exception // is still unhandled, call glibmm_unexpected_exception(). -#ifdef GLIBMM_CAN_USE_THREAD_LOCAL if (HandlerList* const handler_list = thread_specific_handler_list) -#else - if(HandlerList *const handler_list = thread_specific_handler_list.get()) -#endif { HandlerList::iterator pslot = handler_list->begin(); diff --git a/glib/glibmm/exceptionhandler.h b/glib/glibmm/exceptionhandler.h index 89c169b..acfd6f5 100644 --- a/glib/glibmm/exceptionhandler.h +++ b/glib/glibmm/exceptionhandler.h @@ -29,7 +29,7 @@ namespace Glib /** Specify a slot to be called when an exception is thrown by a signal handler. */ -sigc::connection add_exception_handler(const sigc::slot& slot); +sigc::connection add_exception_handler(const sigc::slot& slot); #ifndef DOXYGEN_SHOULD_SKIP_THIS // internal diff --git a/glib/glibmm/filelist.am b/glib/glibmm/filelist.am index dc6615f..afeb2b4 100644 --- a/glib/glibmm/filelist.am +++ b/glib/glibmm/filelist.am @@ -30,7 +30,6 @@ glibmm_files_extra_cc = \ signalproxy_connectionnode.cc \ streamiochannel.cc \ stringutils.cc \ - threadpool.cc \ timer.cc \ timeval.cc \ ustring.cc \ @@ -74,7 +73,6 @@ glibmm_files_extra_h = \ slisthandle.h \ streamiochannel.h \ stringutils.h \ - threadpool.h \ timer.h \ timeval.h \ ustring.h \ diff --git a/glib/glibmm/main.cc b/glib/glibmm/main.cc index 93ba40e..27464d3 100644 --- a/glib/glibmm/main.cc +++ b/glib/glibmm/main.cc @@ -17,13 +17,6 @@ #include // May define GLIBMM_DISABLE_DEPRECATED -#ifndef GLIBMM_DISABLE_DEPRECATED -// Include glibmm/thread.h first because we need it to be first to include , -// so we can do an undef trick to still use deprecated API in the header: -#include -#include -#endif // GLIBMM_DISABLE_DEPRECATED - #include #include #include @@ -33,7 +26,6 @@ namespace { -#ifdef GLIBMM_DISABLE_DEPRECATED void time64_to_time_val(gint64 time64, Glib::TimeVal& time_val) { @@ -43,7 +35,6 @@ time64_to_time_val(gint64 time64, Glib::TimeVal& time_val) static_cast(time64 - static_cast(seconds) * G_GINT64_CONSTANT(1000000)); time_val = Glib::TimeVal(seconds, microseconds); } -#endif // GLIBMM_DISABLE_DEPRECATED // TODO: At the next ABI break, replace ExtraSourceData by new data members in Source. // Then the mutex is not necessary, but to keep the code thread-safe, use the @@ -64,13 +55,13 @@ std::map extra_source_data; // Accesses to extra_source_data must be thread-safe. std::mutex extra_source_data_mutex; -class SourceConnectionNode +class SourceConnectionNode : public sigc::notifiable { public: explicit inline SourceConnectionNode(const sigc::slot_base& slot); - static void* notify(void* data); - static void destroy_notify_callback(void* data); + static void notify(sigc::notifiable* data); + static void destroy_notify_callback(sigc::notifiable* data); inline void install(GSource* source); inline sigc::slot_base* get_slot(); @@ -86,8 +77,8 @@ inline SourceConnectionNode::SourceConnectionNode(const sigc::slot_base& slot) slot_.set_parent(this, &SourceConnectionNode::notify); } -void* -SourceConnectionNode::notify(void* data) +void +SourceConnectionNode::notify(sigc::notifiable* data) { SourceConnectionNode* const self = static_cast(data); @@ -102,13 +93,11 @@ SourceConnectionNode::notify(void* data) // Destroying the object triggers execution of destroy_notify_handler(), // either immediately or later, so we leave that to do the deletion. } - - return nullptr; } // static void -SourceConnectionNode::destroy_notify_callback(void* data) +SourceConnectionNode::destroy_notify_callback(sigc::notifiable* data) { SourceConnectionNode* const self = static_cast(data); @@ -232,7 +221,7 @@ glibmm_source_callback(void* data) try { // Recreate the specific slot from the generic slot node. - return (*static_cast*>(conn_data->get_slot()))(); + return (*static_cast*>(conn_data->get_slot()))(); } catch (...) { @@ -253,7 +242,7 @@ glibmm_source_callback_once(void* data) try { // Recreate the specific slot from the generic slot node. - (*static_cast*>(conn_data->get_slot()))(); + (*static_cast*>(conn_data->get_slot()))(); } catch (...) { @@ -262,6 +251,13 @@ glibmm_source_callback_once(void* data) return 0; // Destroy the event source after one call } +static void +glibmm_source_destroy_notify_callback(void* data) +{ + SourceConnectionNode* const conn_data = static_cast(data); + SourceConnectionNode::destroy_notify_callback(conn_data); +} + static gboolean glibmm_iosource_callback(GIOChannel*, GIOCondition condition, void* data) { @@ -271,7 +267,7 @@ glibmm_iosource_callback(GIOChannel*, GIOCondition condition, void* data) try { // Recreate the specific slot from the generic slot node. - return (*static_cast*>(callback_data->node->get_slot()))( + return (*static_cast*>(callback_data->node->get_slot()))( (Glib::IOCondition)condition); } catch (...) @@ -293,7 +289,7 @@ glibmm_child_watch_callback(GPid pid, gint child_status, void* data) try { // Recreate the specific slot from the generic slot node. - (*static_cast*>(conn_data->get_slot()))(pid, child_status); + (*static_cast*>(conn_data->get_slot()))(pid, child_status); } catch (...) { @@ -304,7 +300,7 @@ glibmm_child_watch_callback(GPid pid, gint child_status, void* data) static void glibmm_signal_connect_once( - const sigc::slot& slot, int priority, GSource* source, GMainContext* context) + const sigc::slot& slot, int priority, GSource* source, GMainContext* context) { SourceConnectionNode* const conn_node = new SourceConnectionNode(slot); @@ -312,7 +308,7 @@ glibmm_signal_connect_once( g_source_set_priority(source, priority); g_source_set_callback(source, &glibmm_source_callback_once, conn_node, - &SourceConnectionNode::destroy_notify_callback); + &glibmm_source_destroy_notify_callback); conn_node->install(source); g_source_attach(source, context); @@ -327,7 +323,7 @@ glibmm_main_context_invoke_callback(void* data) try { // Recreate the specific slot from the generic slot node. - return (*static_cast*>(slot))(); + return (*static_cast*>(slot))(); } catch (...) { @@ -357,14 +353,14 @@ PollFD::PollFD() gobject_.revents = 0; } -PollFD::PollFD(PollFD::fd_t fd) +PollFD::PollFD(int fd) { gobject_.fd = fd; gobject_.events = 0; gobject_.revents = 0; } -PollFD::PollFD(PollFD::fd_t fd, IOCondition events) +PollFD::PollFD(int fd, IOCondition events) { gobject_.fd = fd; gobject_.events = events; @@ -379,7 +375,7 @@ inline SignalTimeout::SignalTimeout(GMainContext* context) : context_(context) /* Note that this is our equivalent of g_timeout_add(). */ sigc::connection -SignalTimeout::connect(const sigc::slot& slot, unsigned int interval, int priority) +SignalTimeout::connect(const sigc::slot& slot, unsigned int interval, int priority) { SourceConnectionNode* const conn_node = new SourceConnectionNode(slot); const sigc::connection connection(*conn_node->get_slot()); @@ -390,7 +386,8 @@ SignalTimeout::connect(const sigc::slot& slot, unsigned int interval, int g_source_set_priority(source, priority); g_source_set_callback( - source, &glibmm_source_callback, conn_node, &SourceConnectionNode::destroy_notify_callback); + source, &glibmm_source_callback, conn_node, + &glibmm_source_destroy_notify_callback); conn_node->install(source); g_source_attach(source, context_); @@ -400,7 +397,7 @@ SignalTimeout::connect(const sigc::slot& slot, unsigned int interval, int } void -SignalTimeout::connect_once(const sigc::slot& slot, unsigned int interval, int priority) +SignalTimeout::connect_once(const sigc::slot& slot, unsigned int interval, int priority) { GSource* const source = g_timeout_source_new(interval); glibmm_signal_connect_once(slot, priority, source, context_); @@ -408,7 +405,7 @@ SignalTimeout::connect_once(const sigc::slot& slot, unsigned int interval, /* Note that this is our equivalent of g_timeout_add_seconds(). */ sigc::connection -SignalTimeout::connect_seconds(const sigc::slot& slot, unsigned int interval, int priority) +SignalTimeout::connect_seconds(const sigc::slot& slot, unsigned int interval, int priority) { SourceConnectionNode* const conn_node = new SourceConnectionNode(slot); const sigc::connection connection(*conn_node->get_slot()); @@ -419,7 +416,8 @@ SignalTimeout::connect_seconds(const sigc::slot& slot, unsigned int interv g_source_set_priority(source, priority); g_source_set_callback( - source, &glibmm_source_callback, conn_node, &SourceConnectionNode::destroy_notify_callback); + source, &glibmm_source_callback, conn_node, + &glibmm_source_destroy_notify_callback); conn_node->install(source); g_source_attach(source, context_); @@ -430,7 +428,7 @@ SignalTimeout::connect_seconds(const sigc::slot& slot, unsigned int interv void SignalTimeout::connect_seconds_once( - const sigc::slot& slot, unsigned int interval, int priority) + const sigc::slot& slot, unsigned int interval, int priority) { GSource* const source = g_timeout_source_new_seconds(interval); glibmm_signal_connect_once(slot, priority, source, context_); @@ -449,7 +447,7 @@ inline SignalIdle::SignalIdle(GMainContext* context) : context_(context) } sigc::connection -SignalIdle::connect(const sigc::slot& slot, int priority) +SignalIdle::connect(const sigc::slot& slot, int priority) { SourceConnectionNode* const conn_node = new SourceConnectionNode(slot); const sigc::connection connection(*conn_node->get_slot()); @@ -460,7 +458,8 @@ SignalIdle::connect(const sigc::slot& slot, int priority) g_source_set_priority(source, priority); g_source_set_callback( - source, &glibmm_source_callback, conn_node, &SourceConnectionNode::destroy_notify_callback); + source, &glibmm_source_callback, conn_node, + &glibmm_source_destroy_notify_callback); conn_node->install(source); g_source_attach(source, context_); @@ -470,7 +469,7 @@ SignalIdle::connect(const sigc::slot& slot, int priority) } void -SignalIdle::connect_once(const sigc::slot& slot, int priority) +SignalIdle::connect_once(const sigc::slot& slot, int priority) { GSource* const source = g_idle_source_new(); glibmm_signal_connect_once(slot, priority, source, context_); @@ -490,7 +489,7 @@ inline SignalIO::SignalIO(GMainContext* context) : context_(context) sigc::connection SignalIO::connect( - const sigc::slot& slot, PollFD::fd_t fd, IOCondition condition, int priority) + const sigc::slot& slot, int fd, IOCondition condition, int priority) { const auto source = IOSource::create(fd, condition); @@ -505,7 +504,7 @@ SignalIO::connect( } sigc::connection -SignalIO::connect(const sigc::slot& slot, const Glib::RefPtr& channel, +SignalIO::connect(const sigc::slot& slot, const Glib::RefPtr& channel, IOCondition condition, int priority) { const auto source = IOSource::create(channel, condition); @@ -533,7 +532,7 @@ inline SignalChildWatch::SignalChildWatch(GMainContext* context) : context_(cont } sigc::connection -SignalChildWatch::connect(const sigc::slot& slot, GPid pid, int priority) +SignalChildWatch::connect(const sigc::slot& slot, GPid pid, int priority) { SourceConnectionNode* const conn_node = new SourceConnectionNode(slot); const sigc::connection connection(*conn_node->get_slot()); @@ -543,8 +542,9 @@ SignalChildWatch::connect(const sigc::slot& slot, GPid pid, int if (priority != G_PRIORITY_DEFAULT) g_source_set_priority(source, priority); - g_source_set_callback(source, (GSourceFunc)&glibmm_child_watch_callback, conn_node, - &SourceConnectionNode::destroy_notify_callback); + g_source_set_callback(source, (GSourceFunc)&glibmm_child_watch_callback, + conn_node, + &glibmm_source_destroy_notify_callback); conn_node->install(source); g_source_attach(source, context_); @@ -599,20 +599,6 @@ MainContext::acquire() return g_main_context_acquire(gobj()); } -#ifndef GLIBMM_DISABLE_DEPRECATED -bool -MainContext::wait(Glib::Cond& cond, Glib::Mutex& mutex) -{ - return g_main_context_wait(gobj(), cond.gobj(), mutex.gobj()); -} - -bool -MainContext::wait(Glib::Threads::Cond& cond, Glib::Threads::Mutex& mutex) -{ - return g_main_context_wait(gobj(), cond.gobj(), mutex.gobj()); -} -#endif // GLIBMM_DISABLE_DEPRECATED - void MainContext::release() { @@ -691,10 +677,10 @@ MainContext::remove_poll(PollFD& fd) } void -MainContext::invoke(const sigc::slot& slot, int priority) +MainContext::invoke(const sigc::slot& slot, int priority) { // Make a copy of slot on the heap. - sigc::slot_base* const slot_copy = new sigc::slot(slot); + sigc::slot_base* const slot_copy = new sigc::slot(slot); g_main_context_invoke_full(gobj(), priority, glibmm_main_context_invoke_callback, slot_copy, glibmm_main_context_invoke_destroy_notify_callback); @@ -1019,16 +1005,6 @@ Source::remove_poll(Glib::PollFD& poll_fd) g_source_remove_poll(gobject_, poll_fd.gobj()); } -#ifndef GLIBMM_DISABLE_DEPRECATED -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -void -Source::get_current_time(Glib::TimeVal& current_time) -{ - g_source_get_current_time(gobject_, ¤t_time); -} -G_GNUC_END_IGNORE_DEPRECATIONS -#endif // GLIBMM_DISABLE_DEPRECATED - gint64 Source::get_time() const { @@ -1126,7 +1102,8 @@ Source::attach_signal_source(const sigc::slot_base& slot, int priority, GSource* g_source_set_priority(source, priority); g_source_set_callback( - source, callback_func, conn_node, &SourceConnectionNode::destroy_notify_callback); + source, callback_func, conn_node, + &glibmm_source_destroy_notify_callback); conn_node->install(source); g_source_attach(source, context); @@ -1161,7 +1138,7 @@ TimeoutSource::create(unsigned int interval) } sigc::connection -TimeoutSource::connect(const sigc::slot& slot) +TimeoutSource::connect(const sigc::slot& slot) { return connect_generic(slot); } @@ -1180,11 +1157,7 @@ bool TimeoutSource::prepare(int& timeout) { Glib::TimeVal current_time; -#ifndef GLIBMM_DISABLE_DEPRECATED - get_current_time(current_time); -#else time64_to_time_val(get_time(), current_time); -#endif // GLIBMM_DISABLE_DEPRECATED Glib::TimeVal remaining = expiration_; remaining.subtract(current_time); @@ -1221,11 +1194,7 @@ bool TimeoutSource::check() { Glib::TimeVal current_time; -#ifndef GLIBMM_DISABLE_DEPRECATED - get_current_time(current_time); -#else time64_to_time_val(get_time(), current_time); -#endif // GLIBMM_DISABLE_DEPRECATED return (expiration_ <= current_time); } @@ -1233,15 +1202,11 @@ TimeoutSource::check() bool TimeoutSource::dispatch(sigc::slot_base* slot) { - const bool again = (*static_cast*>(slot))(); + const bool again = (*static_cast*>(slot))(); if (again) { -#ifndef GLIBMM_DISABLE_DEPRECATED - get_current_time(expiration_); -#else time64_to_time_val(get_time(), expiration_); -#endif // GLIBMM_DISABLE_DEPRECATED expiration_.add_milliseconds(std::min(G_MAXLONG, interval_)); } @@ -1258,7 +1223,7 @@ IdleSource::create() } sigc::connection -IdleSource::connect(const sigc::slot& slot) +IdleSource::connect(const sigc::slot& slot) { return connect_generic(slot); } @@ -1288,14 +1253,14 @@ IdleSource::check() bool IdleSource::dispatch(sigc::slot_base* slot) { - return (*static_cast*>(slot))(); + return (*static_cast*>(slot))(); } /**** Glib::IOSource *******************************************************/ // static Glib::RefPtr -IOSource::create(PollFD::fd_t fd, IOCondition condition) +IOSource::create(int fd, IOCondition condition) { return Glib::RefPtr(new IOSource(fd, condition)); } @@ -1307,12 +1272,12 @@ IOSource::create(const Glib::RefPtr& channel, IOCondition condition) } sigc::connection -IOSource::connect(const sigc::slot& slot) +IOSource::connect(const sigc::slot& slot) { return connect_generic(slot); } -IOSource::IOSource(PollFD::fd_t fd, IOCondition condition) : poll_fd_(fd, condition) +IOSource::IOSource(int fd, IOCondition condition) : poll_fd_(fd, condition) { add_poll(poll_fd_); } @@ -1347,7 +1312,7 @@ IOSource::check() bool IOSource::dispatch(sigc::slot_base* slot) { - return (*static_cast*>(slot))(poll_fd_.get_revents()); + return (*static_cast*>(slot))(poll_fd_.get_revents()); } } // namespace Glib diff --git a/glib/glibmm/main.h b/glib/glibmm/main.h index c6dc839..2671876 100644 --- a/glib/glibmm/main.h +++ b/glib/glibmm/main.h @@ -30,17 +30,6 @@ namespace Glib { -#ifndef GLIBMM_DISABLE_DEPRECATED -class Cond; -class Mutex; - -namespace Threads -{ -class Cond; -class Mutex; -} -#endif // GLIBMM_DISABLE_DEPRECATED - /** @defgroup MainLoop The Main Event Loop * Manages all available sources of events. * @{ @@ -49,14 +38,12 @@ class Mutex; class PollFD { public: - using fd_t = decltype(GPollFD::fd); - PollFD(); - explicit PollFD(fd_t fd); - PollFD(fd_t fd, IOCondition events); + explicit PollFD(int fd); + PollFD(int fd, IOCondition events); - void set_fd(fd_t fd) { gobject_.fd = fd; } - fd_t get_fd() const { return gobject_.fd; } + void set_fd(int fd) { gobject_.fd = fd; } + int get_fd() const { return gobject_.fd; } void set_events(IOCondition events) { gobject_.events = events; } IOCondition get_events() const { return static_cast(gobject_.events); } @@ -71,16 +58,6 @@ private: GPollFD gobject_; }; -// Concerning SignalTimeout::connect_once(), SignalTimeout::connect_seconds_once() -// and SignalIdle::connect_once(): -// See https://bugzilla.gnome.org/show_bug.cgi?id=396963 and -// http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue. -// It's recommended to replace sigc::slot& by std::function& in -// Threads::Thread::create() and ThreadPool::push() at the next ABI break. -// Such a replacement would be a mixed blessing in SignalTimeout and SignalIdle. -// In a single-threaded program auto-disconnection of trackable slots is safe -// and can be useful. - class SignalTimeout { public: @@ -124,7 +101,7 @@ public: * @return A connection handle, which can be used to disconnect the handler. */ sigc::connection connect( - const sigc::slot& slot, unsigned int interval, int priority = PRIORITY_DEFAULT); + const sigc::slot& slot, unsigned int interval, int priority = PRIORITY_DEFAULT); /** Connects a timeout handler that runs only once. * This method takes a function pointer to a function with a void return @@ -146,7 +123,7 @@ public: * @param priority The priority of the new event source. */ void connect_once( - const sigc::slot& slot, unsigned int interval, int priority = PRIORITY_DEFAULT); + const sigc::slot& slot, unsigned int interval, int priority = PRIORITY_DEFAULT); /** Connects a timeout handler with whole second granularity. * @@ -184,7 +161,7 @@ public: * @newin{2,14} */ sigc::connection connect_seconds( - const sigc::slot& slot, unsigned int interval, int priority = PRIORITY_DEFAULT); + const sigc::slot& slot, unsigned int interval, int priority = PRIORITY_DEFAULT); /** Connects a timeout handler that runs only once with whole second * granularity. @@ -208,7 +185,7 @@ public: * @param priority The priority of the new event source. */ void connect_seconds_once( - const sigc::slot& slot, unsigned int interval, int priority = PRIORITY_DEFAULT); + const sigc::slot& slot, unsigned int interval, int priority = PRIORITY_DEFAULT); private: GMainContext* context_; @@ -246,7 +223,7 @@ public: * @param priority The priority of the new event source. * @return A connection handle, which can be used to disconnect the handler. */ - sigc::connection connect(const sigc::slot& slot, int priority = PRIORITY_DEFAULT_IDLE); + sigc::connection connect(const sigc::slot& slot, int priority = PRIORITY_DEFAULT_IDLE); /** Connects an idle handler that runs only once. * This method takes a function pointer to a function with a void return @@ -266,7 +243,7 @@ public: * @endcode * @param priority The priority of the new event source. */ - void connect_once(const sigc::slot& slot, int priority = PRIORITY_DEFAULT_IDLE); + void connect_once(const sigc::slot& slot, int priority = PRIORITY_DEFAULT_IDLE); private: GMainContext* context_; @@ -307,7 +284,7 @@ public: * @param priority The priority of the new event source. * @return A connection handle, which can be used to disconnect the handler. */ - sigc::connection connect(const sigc::slot& slot, PollFD::fd_t fd, IOCondition condition, + sigc::connection connect(const sigc::slot& slot, int fd, IOCondition condition, int priority = PRIORITY_DEFAULT); /** Connects an I/O handler that watches an I/O channel. @@ -336,7 +313,7 @@ public: * @param priority The priority of the new event source. * @return A connection handle, which can be used to disconnect the handler. */ - sigc::connection connect(const sigc::slot& slot, + sigc::connection connect(const sigc::slot& slot, const Glib::RefPtr& channel, IOCondition condition, int priority = PRIORITY_DEFAULT); private: @@ -368,7 +345,7 @@ public: * @return A connection handle, which can be used to disconnect the handler. */ sigc::connection connect( - const sigc::slot& slot, GPid pid, int priority = PRIORITY_DEFAULT); + const sigc::slot& slot, GPid pid, int priority = PRIORITY_DEFAULT); private: GMainContext* context_; @@ -455,36 +432,6 @@ public: */ bool acquire(); -#ifndef GLIBMM_DISABLE_DEPRECATED - /** Tries to become the owner of the specified context, as with acquire(). But if another thread - * is the owner, - * atomically drop mutex and wait on cond until that owner releases ownership or until cond is - * signaled, then try - * again (once) to become the owner. - * @param cond A condition variable. - * @param mutex A mutex, currently held. - * @return true if the operation succeeded, and this thread is now the owner of context. - * - * @deprecated Use wait(Glib::Threads::Cond& cond, Glib::Threads::Mutex& mutex) instead. - */ - bool wait(Glib::Cond& cond, Glib::Mutex& mutex); - - // Deprecated mostly because it uses deprecated Glib::Threads:: for parameters. - /** Tries to become the owner of the specified context, as with acquire(). But if another thread - * is the owner, - * atomically drop mutex and wait on cond until that owner releases ownership or until cond is - * signaled, then try - * again (once) to become the owner. - * @param cond A condition variable. - * @param mutex A mutex, currently held. - * @return true if the operation succeeded, and this thread is now the owner of context. - * - * @deprecated Please use the underlying g_main_context_wait() function if you really need this - * functionality. - */ - bool wait(Glib::Threads::Cond& cond, Glib::Threads::Mutex& mutex); -#endif // GLIBMM_DISABLE_DEPRECATED - /** Releases ownership of a context previously acquired by this thread with acquire(). If the * context was acquired * multiple times, the only release ownership when release() is called as many times as it was @@ -585,7 +532,7 @@ public: * * @newin{2,38} */ - void invoke(const sigc::slot& slot, int priority = PRIORITY_DEFAULT); + void invoke(const sigc::slot& slot, int priority = PRIORITY_DEFAULT); /** Timeout signal, attached to this MainContext. * @return A signal proxy; you want to use SignalTimeout::connect(). @@ -850,7 +797,7 @@ public: using CppObjectType = Glib::TimeoutSource; static Glib::RefPtr create(unsigned int interval); - sigc::connection connect(const sigc::slot& slot); + sigc::connection connect(const sigc::slot& slot); protected: explicit TimeoutSource(unsigned int interval); @@ -873,7 +820,7 @@ public: using CppObjectType = Glib::IdleSource; static Glib::RefPtr create(); - sigc::connection connect(const sigc::slot& slot); + sigc::connection connect(const sigc::slot& slot); protected: IdleSource(); @@ -889,13 +836,13 @@ class IOSource : public Glib::Source public: using CppObjectType = Glib::IOSource; - static Glib::RefPtr create(PollFD::fd_t fd, IOCondition condition); + static Glib::RefPtr create(int fd, IOCondition condition); static Glib::RefPtr create( const Glib::RefPtr& channel, IOCondition condition); - sigc::connection connect(const sigc::slot& slot); + sigc::connection connect(const sigc::slot& slot); protected: - IOSource(PollFD::fd_t fd, IOCondition condition); + IOSource(int fd, IOCondition condition); IOSource(const Glib::RefPtr& channel, IOCondition condition); /** Wrap an existing GSource object and install the given callback function. diff --git a/glib/glibmm/objectbase.cc b/glib/glibmm/objectbase.cc index c524a16..d2a252d 100644 --- a/glib/glibmm/objectbase.cc +++ b/glib/glibmm/objectbase.cc @@ -353,20 +353,20 @@ ObjectBase::get_property_value(const Glib::ustring& property_name, Glib::ValueBa void ObjectBase::connect_property_changed( - const Glib::ustring& property_name, const sigc::slot& slot) + const Glib::ustring& property_name, const sigc::slot& slot) { connect_property_changed_with_return(property_name, slot); } void -ObjectBase::connect_property_changed(const Glib::ustring& property_name, sigc::slot&& slot) +ObjectBase::connect_property_changed(const Glib::ustring& property_name, sigc::slot&& slot) { connect_property_changed_with_return(property_name, std::move(slot)); } sigc::connection ObjectBase::connect_property_changed_with_return( - const Glib::ustring& property_name, const sigc::slot& slot) + const Glib::ustring& property_name, const sigc::slot& slot) { // Create a proxy to hold our connection info // This will be deleted by destroy_notify_handler. @@ -379,7 +379,7 @@ ObjectBase::connect_property_changed_with_return( sigc::connection ObjectBase::connect_property_changed_with_return( - const Glib::ustring& property_name, sigc::slot&& slot) + const Glib::ustring& property_name, sigc::slot&& slot) { // Create a proxy to hold our connection info // This will be deleted by destroy_notify_handler. diff --git a/glib/glibmm/objectbase.h b/glib/glibmm/objectbase.h index cf6a4a0..6cbc767 100644 --- a/glib/glibmm/objectbase.h +++ b/glib/glibmm/objectbase.h @@ -126,13 +126,13 @@ public: * * See also connect_property_changed_with_return(). */ - void connect_property_changed(const Glib::ustring& property_name, const sigc::slot& slot); + void connect_property_changed(const Glib::ustring& property_name, const sigc::slot& slot); /** You can use the signal_changed() signal of the property proxy instead. * * @newin{2,48} */ - void connect_property_changed(const Glib::ustring& property_name, sigc::slot&& slot); + void connect_property_changed(const Glib::ustring& property_name, sigc::slot&& slot); /** You can use the signal_changed() signal of the property proxy instead. * @@ -140,14 +140,14 @@ public: * and we could not break the ABI by changing that function. */ sigc::connection connect_property_changed_with_return( - const Glib::ustring& property_name, const sigc::slot& slot); + const Glib::ustring& property_name, const sigc::slot& slot); /** You can use the signal_changed() signal of the property proxy instead. * * @newin{2,48} */ sigc::connection connect_property_changed_with_return( - const Glib::ustring& property_name, sigc::slot&& slot); + const Glib::ustring& property_name, sigc::slot&& slot); /** Increases the freeze count on object. If the freeze count is non-zero, the * emission of "notify" signals on object is stopped. The signals are queued diff --git a/glib/glibmm/propertyproxy_base.cc b/glib/glibmm/propertyproxy_base.cc index 5b7a400..66ebf70 100644 --- a/glib/glibmm/propertyproxy_base.cc +++ b/glib/glibmm/propertyproxy_base.cc @@ -58,7 +58,7 @@ void PropertyProxyConnectionNode::callback(GObject*, GParamSpec* pspec, gpointer if (pspec && data) { if (sigc::slot_base* const slot = SignalProxyBase::data_to_slot(data)) - (*static_cast*>(slot))(); + (*static_cast*>(slot))(); } } diff --git a/glib/glibmm/propertyproxy_base.h b/glib/glibmm/propertyproxy_base.h index fdfb237..c5e6a53 100644 --- a/glib/glibmm/propertyproxy_base.h +++ b/glib/glibmm/propertyproxy_base.h @@ -39,7 +39,7 @@ public: SignalProxyProperty(Glib::ObjectBase* obj, const gchar* property_name); ~SignalProxyProperty() noexcept; - using SlotType = sigc::slot; + using SlotType = sigc::slot; sigc::connection connect(const SlotType& slot); /** @newin{2,48} */ diff --git a/glib/glibmm/signalproxy.cc b/glib/glibmm/signalproxy.cc index a7e5d9c..e7815df 100644 --- a/glib/glibmm/signalproxy.cc +++ b/glib/glibmm/signalproxy.cc @@ -101,7 +101,7 @@ SignalProxyNormal::slot0_void_callback(GObject* self, void* data) try { if (sigc::slot_base* const slot = data_to_slot(data)) - (*static_cast*>(slot))(); + (*static_cast*>(slot))(); } catch (...) { diff --git a/glib/glibmm/signalproxy.h b/glib/glibmm/signalproxy.h index 458e6b1..8aae39d 100644 --- a/glib/glibmm/signalproxy.h +++ b/glib/glibmm/signalproxy.h @@ -150,11 +150,18 @@ private: * to connect signal handlers to signals. */ template -class SignalProxy : public SignalProxyNormal +class SignalProxy; + +/** Proxy for signals with any number of arguments. + * Use the connect() or connect_notify() method, with sigc::mem_fun() or sigc::ptr_fun() + * to connect signal handlers to signals. + */ +template +class SignalProxy : public SignalProxyNormal { public: - using SlotType = sigc::slot; - using VoidSlotType = sigc::slot; + using SlotType = sigc::slot; + using VoidSlotType = sigc::slot; SignalProxy(ObjectBase* obj, const SignalProxyInfo* info) : SignalProxyNormal(obj, info) {} @@ -220,25 +227,6 @@ public: } }; -/* Templates below has been added to avoid API break, and should not be - * used in a newly created code. SignalProxy class should be used instead - * of SignalProxy# class. - */ -template -using SignalProxy0 = SignalProxy; -template -using SignalProxy1 = SignalProxy; -template -using SignalProxy2 = SignalProxy; -template -using SignalProxy3 = SignalProxy; -template -using SignalProxy4 = SignalProxy; -template -using SignalProxy5 = SignalProxy; -template -using SignalProxy6 = SignalProxy; - // TODO: When we can break ABI, consider renaming // SignalProxyDetailed => SignalProxyDetailedBase // SignalProxyDetailedAnyType => SignalProxyDetailed @@ -300,11 +288,14 @@ private: * to connect signal handlers to signals. */ template -class SignalProxyDetailedAnyType : public SignalProxyDetailed +class SignalProxyDetailedAnyType; + +template +class SignalProxyDetailedAnyType : public SignalProxyDetailed { public: - using SlotType = sigc::slot; - using VoidSlotType = sigc::slot; + using SlotType = sigc::slot; + using VoidSlotType = sigc::slot; SignalProxyDetailedAnyType( ObjectBase* obj, const SignalProxyInfo* info, const Glib::ustring& detail_name) diff --git a/glib/glibmm/signalproxy_connectionnode.cc b/glib/glibmm/signalproxy_connectionnode.cc index d4d0855..8603e76 100644 --- a/glib/glibmm/signalproxy_connectionnode.cc +++ b/glib/glibmm/signalproxy_connectionnode.cc @@ -41,8 +41,8 @@ SignalProxyConnectionNode::SignalProxyConnectionNode(sigc::slot_base&& slot, GOb // notify is a message coming up from the slot to be passed back to Gtk+ // disconnect is a message coming up from the Gtk+ to be passed down to SigC++ // static -void* -SignalProxyConnectionNode::notify(void* data) +void +SignalProxyConnectionNode::notify(sigc::notifiable* data) { // notification from libsigc++. SignalProxyConnectionNode* conn = static_cast(data); @@ -73,8 +73,6 @@ SignalProxyConnectionNode::notify(void* data) g_signal_handler_disconnect(o, connection_id); } } - - return nullptr; // apparently unused in libsigc++ } // static diff --git a/glib/glibmm/signalproxy_connectionnode.h b/glib/glibmm/signalproxy_connectionnode.h index 88e98ee..3099269 100644 --- a/glib/glibmm/signalproxy_connectionnode.h +++ b/glib/glibmm/signalproxy_connectionnode.h @@ -37,7 +37,7 @@ namespace Glib * It lives between the layer of Gtk+ and libsigc++. * It is very much an internal class. */ -class SignalProxyConnectionNode +class SignalProxyConnectionNode : public sigc::notifiable { public: /** @param slot The signal handler for the glib signal. @@ -56,7 +56,7 @@ public: * This callback is registered in the slot. * @param data The SignalProxyConnectionNode object (@p this). */ - static void* notify(void* data); + static void notify(sigc::notifiable* data); /** Callback that is executed when the glib closure is destroyed. * @param data The SignalProxyConnectionNode object (@p this). diff --git a/glib/glibmm/threadpool.cc b/glib/glibmm/threadpool.cc deleted file mode 100644 index 75a6a7b..0000000 --- a/glib/glibmm/threadpool.cc +++ /dev/null @@ -1,255 +0,0 @@ -/* Copyright (C) 2002 The gtkmm 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 -#ifndef GLIBMM_DISABLE_DEPRECATED - -#include -#include -#include -#include -#include - -namespace Glib -{ - -// internal -class ThreadPool::SlotList -{ -public: - SlotList(); - ~SlotList() noexcept; - - // noncopyable - SlotList(const ThreadPool::SlotList&) = delete; - ThreadPool::SlotList& operator=(const ThreadPool::SlotList&) = delete; - - sigc::slot* push(const sigc::slot& slot); - sigc::slot pop(sigc::slot* slot_ptr); - - void lock_and_unlock(); - -private: - Glib::Threads::Mutex mutex_; - std::list> list_; -}; - -ThreadPool::SlotList::SlotList() -{ -} - -ThreadPool::SlotList::~SlotList() noexcept -{ -} - -sigc::slot* -ThreadPool::SlotList::push(const sigc::slot& slot) -{ - Threads::Mutex::Lock lock(mutex_); - - list_.emplace_back(slot); - return &list_.back(); -} - -sigc::slot -ThreadPool::SlotList::pop(sigc::slot* slot_ptr) -{ - sigc::slot slot; - - { - Threads::Mutex::Lock lock(mutex_); - - std::list>::iterator pslot = list_.begin(); - while (pslot != list_.end() && slot_ptr != &*pslot) - ++pslot; - - if (pslot != list_.end()) - { - slot = *pslot; - list_.erase(pslot); - } - } - - return slot; -} - -void -ThreadPool::SlotList::lock_and_unlock() -{ - mutex_.lock(); - mutex_.unlock(); -} - -} // namespace Glib - -namespace -{ - -static void -call_thread_entry_slot(void* data, void* user_data) -{ - try - { - Glib::ThreadPool::SlotList* const slot_list = - static_cast(user_data); - - sigc::slot slot(slot_list->pop(static_cast*>(data))); - - slot(); - } - catch (Glib::Threads::Thread::Exit&) - { - // Just exit from the thread. The Thread::Exit exception - // is our sane C++ replacement of g_thread_exit(). - } - catch (...) - { - Glib::exception_handlers_invoke(); - } -} - -} // anonymous namespace - -namespace Glib -{ - -ThreadPool::ThreadPool(int max_threads, bool exclusive) -: gobject_(nullptr), slot_list_(new SlotList()) -{ - GError* error = nullptr; - - gobject_ = g_thread_pool_new(&call_thread_entry_slot, slot_list_, max_threads, exclusive, &error); - - if (error) - { - delete slot_list_; - slot_list_ = nullptr; - Glib::Error::throw_exception(error); - } -} - -ThreadPool::~ThreadPool() noexcept -{ - if (gobject_) - g_thread_pool_free(gobject_, 1, 1); - - if (slot_list_) - { - slot_list_->lock_and_unlock(); - delete slot_list_; - } -} - -void -ThreadPool::push(const sigc::slot& slot) -{ - sigc::slot* const slot_ptr = slot_list_->push(slot); - - GError* error = nullptr; - g_thread_pool_push(gobject_, slot_ptr, &error); - - if (error) - { - slot_list_->pop(slot_ptr); - Glib::Error::throw_exception(error); - } -} - -void -ThreadPool::set_max_threads(int max_threads) -{ - GError* error = nullptr; - g_thread_pool_set_max_threads(gobject_, max_threads, &error); - - if (error) - Glib::Error::throw_exception(error); -} - -int -ThreadPool::get_max_threads() const -{ - return g_thread_pool_get_max_threads(gobject_); -} - -unsigned int -ThreadPool::get_num_threads() const -{ - return g_thread_pool_get_num_threads(gobject_); -} - -unsigned int -ThreadPool::unprocessed() const -{ - return g_thread_pool_unprocessed(gobject_); -} - -bool -ThreadPool::get_exclusive() const -{ - g_return_val_if_fail(gobject_ != nullptr, false); - - return gobject_->exclusive; -} - -void -ThreadPool::shutdown(bool immediately) -{ - if (gobject_) - { - g_thread_pool_free(gobject_, immediately, 1); - gobject_ = nullptr; - } - - if (slot_list_) - { - slot_list_->lock_and_unlock(); - delete slot_list_; - slot_list_ = nullptr; - } -} - -// static -void -ThreadPool::set_max_unused_threads(int max_threads) -{ - g_thread_pool_set_max_unused_threads(max_threads); -} - -// static -int -ThreadPool::get_max_unused_threads() -{ - return g_thread_pool_get_max_unused_threads(); -} - -// static -unsigned int -ThreadPool::get_num_unused_threads() -{ - return g_thread_pool_get_num_unused_threads(); -} - -// static -void -ThreadPool::stop_unused_threads() -{ - g_thread_pool_stop_unused_threads(); -} - -} // namespace Glib - -#endif // GLIBMM_DISABLE_DEPRECATED diff --git a/glib/glibmm/threadpool.h b/glib/glibmm/threadpool.h deleted file mode 100644 index f75f34d..0000000 --- a/glib/glibmm/threadpool.h +++ /dev/null @@ -1,200 +0,0 @@ -#ifndef _GLIBMM_THREADPOOL_H -#define _GLIBMM_THREADPOOL_H - -/* Copyright (C) 2002 The gtkmm 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 - -#ifndef GLIBMM_DISABLE_DEPRECATED - -#include - -extern "C" { -using GThreadPool = struct _GThreadPool; -} - -namespace Glib -{ - -/** @defgroup ThreadPools Thread Pools - * Pools of threads to execute work concurrently. - * - * @deprecated This is deprecated in favor of the standard C++ concurrency API in C++11 and C++14. - * - * @{ - */ - -// TODO: Is std::async() an appropriate replacement to mention for this deprecated API? - -/** A pool of threads to execute work concurrently. - * - * @deprecated This is deprecated in favor of the standard C++ concurrency API in C++11 and C++14. - */ -class ThreadPool -{ -public: - /** Constructs a new thread pool. - * Whenever you call ThreadPool::push(), either a new thread is created or an - * unused one is reused. At most @a max_threads threads are running - * concurrently for this thread pool. @a max_threads = -1 allows - * unlimited threads to be created for this thread pool. - * - * The parameter @a exclusive determines, whether the thread pool owns all - * threads exclusive or whether the threads are shared globally. If @a - * exclusive is true, @a max_threads threads are started immediately - * and they will run exclusively for this thread pool until it is destroyed - * by ~ThreadPool(). If @a exclusive is false, threads are created - * when needed and shared between all non-exclusive thread pools. This - * implies that @a max_threads may not be -1 for exclusive thread pools. - * - * @param max_threads The maximal number of threads to execute concurrently - * in the new thread pool, -1 means no limit. - * @param exclusive Should this thread pool be exclusive? - * @throw Glib::ThreadError An error can only occur when @a exclusive is - * set to true and not all @a max_threads threads could be created. - */ - explicit ThreadPool(int max_threads = -1, bool exclusive = false); - virtual ~ThreadPool() noexcept; - - // See http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue. - // TODO: At the next ABI break, consider changing const sigc::slot& slot - // to const std::function& func, if it can be assumed that all supported - // compilers understand the C++11 template class std::function<>. - /** Inserts @a slot into the list of tasks to be executed by the pool. - * When the number of currently running threads is lower than the maximal - * allowed number of threads, a new thread is started (or reused). Otherwise - * @a slot stays in the queue until a thread in this pool finishes its - * previous task and processes @a slot. - * - * Because sigc::trackable is not thread-safe, if the slot represents a - * non-static class method and is created by sigc::mem_fun(), the class concerned - * should not derive from sigc::trackable. You can use, say, boost::bind() or, - * in C++11, std::bind() or a C++11 lambda expression instead of sigc::mem_fun(). - * - * @param slot A new task for the thread pool. - * @throw Glib::ThreadError An error can only occur when a new thread - * couldn't be created. In that case @a slot is simply appended to the - * queue of work to do. - */ - void push(const sigc::slot& slot); - - /** Sets the maximal allowed number of threads for the pool. - * A value of -1 means that the maximal number of threads is unlimited. - * Setting @a max_threads to 0 means stopping all work for pool. It is - * effectively frozen until @a max_threads is set to a non-zero value again. - * - * A thread is never terminated while it is still running. Instead the - * maximal number of threads only has effect for the allocation of new - * threads in ThreadPool::push(). A new thread is allocated whenever the - * number of currently running threads in the pool is smaller than the - * maximal number. - * - * @param max_threads A new maximal number of threads for the pool. - * @throw Glib::ThreadError An error can only occur when a new thread - * couldn't be created. - */ - void set_max_threads(int max_threads); - - /** Returns the maximal number of threads for the pool. - * @return The maximal number of threads. - */ - int get_max_threads() const; - - /** Returns the number of threads currently running in the pool. - * @return The number of threads currently running. - */ - unsigned int get_num_threads() const; - - /** Returns the number of tasks still unprocessed in the pool. - * @return The number of unprocessed tasks. - */ - unsigned int unprocessed() const; - - /** Returns whether all threads are exclusive to this pool. - * @return Whether all threads are exclusive to this pool. - */ - bool get_exclusive() const; - - /** Frees all resources allocated for the pool. - * If @a immediately is true, no new task is processed. Otherwise the - * pool is not freed before the last task is processed. Note however, that no - * thread of this pool is interrupted while processing a task. Instead at least - * all still running threads can finish their tasks before the pool is freed. - * - * This method does not return before all tasks to be processed (dependent on - * @a immediately, whether all or only the currently running) are ready. - * After calling shutdown() the pool must not be used anymore. - * - * @param immediately Should the pool shut down immediately? - */ - void shutdown(bool immediately = false); - - /** Sets the maximal number of unused threads to @a max_threads. - * If @a max_threads is -1, no limit is imposed on the number of unused threads. - * @param max_threads Maximal number of unused threads. - */ - static void set_max_unused_threads(int max_threads); - - /** Returns the maximal allowed number of unused threads. - * @return The maximal number of unused threads. - */ - static int get_max_unused_threads(); - - /** Returns the number of currently unused threads. - * @return The number of currently unused threads. - */ - static unsigned int get_num_unused_threads(); - - /** Stops all currently unused threads. - * This does not change the maximal number of unused threads. This function can - * be used to regularly stop all unused threads e.g. from Glib::signal_timeout(). - */ - static void stop_unused_threads(); - - GThreadPool* gobj() { return gobject_; } - const GThreadPool* gobj() const { return gobject_; } - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - class SlotList; -#endif - -private: - GThreadPool* gobject_; - SlotList* slot_list_; - - ThreadPool(const ThreadPool&); - ThreadPool& operator=(const ThreadPool&); -}; - -/** @} group ThreadPools */ - -/***************************************************************************/ -/* inline implementation */ -/***************************************************************************/ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -/**** Glib::Private ********************************************************/ - -#endif /* DOXYGEN_SHOULD_SKIP_THIS */ - -} // namespace Glib - -#endif // GLIBMM_DISABLE_DEPRECATED - -#endif /* _GLIBMM_THREADPOOL_H */ diff --git a/glib/glibmm/ustring.cc b/glib/glibmm/ustring.cc index 15ab009..eae9802 100644 --- a/glib/glibmm/ustring.cc +++ b/glib/glibmm/ustring.cc @@ -841,6 +841,18 @@ ustring::rend() const return const_reverse_iterator(const_iterator(string_.begin())); } +ustring::const_iterator +ustring::cbegin() const +{ + return const_iterator(string_.begin()); +} + +ustring::const_iterator +ustring::cend() const +{ + return const_iterator(string_.end()); +} + /**** Glib::ustring::find() ************************************************/ ustring::size_type diff --git a/glib/glibmm/ustring.h b/glib/glibmm/ustring.h index 8e8a546..fe45c1a 100644 --- a/glib/glibmm/ustring.h +++ b/glib/glibmm/ustring.h @@ -469,6 +469,16 @@ public: const_reverse_iterator rbegin() const; const_reverse_iterator rend() const; + /** + * @newin{2,52} + */ + const_iterator cbegin() const; + + /** + * @newin{2,52} + */ + const_iterator cend() const; + //! @} //! @name Find sub-strings. //! @{ diff --git a/glib/src/balancedtree.hg b/glib/src/balancedtree.hg index 4707320..5444046 100644 --- a/glib/src/balancedtree.hg +++ b/glib/src/balancedtree.hg @@ -57,8 +57,8 @@ class BalancedTree { _CLASS_GENERIC(BalancedTree, GTree) public: - using TraverseFunc = sigc::slot; - using CompareFunc = sigc::slot; + using TraverseFunc = sigc::slot; + using CompareFunc = sigc::slot; protected: BalancedTree() : @@ -235,8 +235,8 @@ public: */ V* search(const CompareFunc &search_func, const K& key) { - sigc::slot real_slot = sigc::ptr_fun(on_compare_key); - sigc::slot bound_slot = sigc::bind(real_slot, search_func, key); + sigc::slot real_slot = sigc::ptr_fun(on_compare_key); + sigc::slot bound_slot = sigc::bind(real_slot, search_func, key); gpointer value = g_tree_search(gobj(), c_callback_search, reinterpret_cast(&bound_slot)); return reinterpret_cast(value); @@ -278,7 +278,7 @@ private: /// Wrapper for invoking GCompareFunc. static gint c_callback_search(gconstpointer a, gconstpointer b) { - const sigc::slot* slot = reinterpret_cast *>(b); + const auto slot = reinterpret_cast *>(b); return (*slot)(*reinterpret_cast(a)); } diff --git a/glib/src/binding.hg b/glib/src/binding.hg index b30cba1..730baad 100644 --- a/glib/src/binding.hg +++ b/glib/src/binding.hg @@ -106,7 +106,7 @@ public: * * @return true if the transformation was successful, and false otherwise. */ - using SlotTransform = sigc::slot; + using SlotTransform = sigc::slot; /** Creates a binding between @a source_property and @a target_property, * allowing you to set the transformation functions to be used by the binding. @@ -183,7 +183,7 @@ public: * stored in a Glib::Value object. * @tparam T_functor_to Type of functor that translates from the source to the target. * Must be convertible to
- * sigc::slot. + * sigc::slot. * * @see bind_property_value() * @@ -196,7 +196,7 @@ public: BindingFlags flags, const T_functor_to& transform_to) { - sigc::slot slot_transform_to = transform_to; + sigc::slot slot_transform_to = transform_to; return bind_property_value(source_property, target_property, flags, slot_transform_to.empty() ? SlotTransform() : TransformProp(slot_transform_to)); @@ -219,7 +219,7 @@ public: * stored in a Glib::Value object. * @tparam T_functor_to Type of functor that translates from the source to the target. * Must be convertible to
- * sigc::slot. + * sigc::slot. * * @see bind_property_value() * @@ -232,7 +232,7 @@ public: BindingFlags flags, const T_functor_to& transform_to) { - sigc::slot slot_transform_to = transform_to; + sigc::slot slot_transform_to = transform_to; return bind_property_value(source_property, target_property, flags, slot_transform_to.empty() ? SlotTransform() : TransformProp(slot_transform_to)); @@ -255,7 +255,7 @@ public: * stored in a Glib::Value object. * @tparam T_functor_to Type of functor that translates from the source to the target. * Must be convertible to
- * sigc::slot. + * sigc::slot. * * @see bind_property_value() * @@ -268,7 +268,7 @@ public: BindingFlags flags, const T_functor_to& transform_to) { - sigc::slot slot_transform_to = transform_to; + sigc::slot slot_transform_to = transform_to; return bind_property_value(source_property, target_property, flags, slot_transform_to.empty() ? SlotTransform() : TransformProp(slot_transform_to)); @@ -291,7 +291,7 @@ public: * stored in a Glib::Value object. * @tparam T_functor_to Type of functor that translates from the source to the target. * Must be convertible to
- * sigc::slot. + * sigc::slot. * * @see bind_property_value() * @@ -304,7 +304,7 @@ public: BindingFlags flags, const T_functor_to& transform_to) { - sigc::slot slot_transform_to = transform_to; + sigc::slot slot_transform_to = transform_to; return bind_property_value(source_property, target_property, flags, slot_transform_to.empty() ? SlotTransform() : TransformProp(slot_transform_to)); @@ -329,10 +329,10 @@ public: * stored in a Glib::Value object. * @tparam T_functor_to Type of functor that translates from the source to the target. * Must be convertible to
- * sigc::slot. + * sigc::slot. * @tparam T_functor_from Type of functor that translates from the target to the source. * Must be convertible to
- * sigc::slot. + * sigc::slot. * * @see bind_property_value() * @@ -346,8 +346,8 @@ public: const T_functor_to& transform_to, const T_functor_from& transform_from) { - sigc::slot slot_transform_to = transform_to; - sigc::slot slot_transform_from = transform_from; + sigc::slot slot_transform_to = transform_to; + sigc::slot slot_transform_from = transform_from; return bind_property_value(source_property, target_property, flags, slot_transform_to.empty() ? SlotTransform() : TransformProp(slot_transform_to), @@ -391,11 +391,10 @@ private: // The functor TransformProp can be implicitly converted to a SlotTransform // and used in a call to bind_property_value(). template - class TransformProp : public sigc::functor_base + class TransformProp { public: - using result_type = bool; - using SlotTypedTransform = sigc::slot; + using SlotTypedTransform = sigc::slot; TransformProp(const SlotTypedTransform& slot) : typed_transform(slot) {} diff --git a/glib/src/bytearray.hg b/glib/src/bytearray.hg index 3005197..1e657b5 100644 --- a/glib/src/bytearray.hg +++ b/glib/src/bytearray.hg @@ -58,7 +58,7 @@ public: * int compare(const guint8* first, const guint8* second); * */ - using SlotCompare = sigc::slot; + using SlotCompare = sigc::slot; _WRAP_METHOD(static Glib::RefPtr create(), g_byte_array_new) diff --git a/glib/src/date.ccg b/glib/src/date.ccg index 4f15dda..ad23886 100644 --- a/glib/src/date.ccg +++ b/glib/src/date.ccg @@ -76,24 +76,6 @@ Date::set_parse(const Glib::ustring& str) g_date_set_parse(&gobject_, str.c_str()); } -_DEPRECATE_IFDEF_START - -// Avoid a build problem in the case that std::time_t is equivalent to gint32 (GTime is also gint32) -// That would make the set_time() method overload impossible. -#ifdef GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 -void -Date::set_time(GTime time) -{ - // This method, and the C function g_date_set_time() that it wraps, are deprecated. - //(::time_t is used here instead of std::time_t, since the C function is declared - // with ::time_t. It's not important. The C++ standard requires that ::time_t - // and std::time_t shall be identical when both are defined.) - g_date_set_time_t(&gobject_, static_cast(time)); -} -#endif // GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 - -_DEPRECATE_IFDEF_END - void Date::set_time(std::time_t timet) { diff --git a/glib/src/date.hg b/glib/src/date.hg index 228272a..e5c0ca6 100644 --- a/glib/src/date.hg +++ b/glib/src/date.hg @@ -109,24 +109,6 @@ public: */ void set_parse (const Glib::ustring& str); - - _DEPRECATE_IFDEF_START - - //Avoid a build problem in the case that std::time_t is equivalent to gint32 (GTime is also gint32) - //That would make the set_time() method overload impossible. - #ifdef GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 - /** Sets the value of a date from a GTime value. - * - * @param time GTime value to set. - * - * @deprecated Please use set_time(std::time_t) or set_time(const GTimeVal&). - */ - void set_time(GTime time); - #endif //GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 - - _DEPRECATE_IFDEF_END - - /** Sets the value of a date from a std::time_t value. * * @param timet std::time_t value to set diff --git a/glib/src/filelist.am b/glib/src/filelist.am index 6b52c61..78bb944 100644 --- a/glib/src/filelist.am +++ b/glib/src/filelist.am @@ -36,12 +36,9 @@ glibmm_files_any_hg = \ regex.hg \ shell.hg \ spawn.hg \ - thread.hg \ - threads.hg \ timezone.hg \ unicode.hg \ uriutils.hg \ - valuearray.hg \ variant.hg \ variantdict.hg \ variantiter.hg \ diff --git a/glib/src/keyfile.hg b/glib/src/keyfile.hg index c43ccb0..41c2de2 100644 --- a/glib/src/keyfile.hg +++ b/glib/src/keyfile.hg @@ -142,8 +142,7 @@ public: #m4 _CONVERSION(`const Glib::ArrayHandle&', `const gchar**', `const_cast($3.data())') #m4 _CONVERSION(`Glib::ArrayHandle&', `gchar**', `const_cast($3.data())') - _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, deprecated "Use the load_from_dirs() method that takes a std::string& full_path.") + _IGNORE(g_key_file_load_from_dirs) _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); diff --git a/glib/src/miscutils.ccg b/glib/src/miscutils.ccg index a6754c3..4d2f331 100644 --- a/glib/src/miscutils.ccg +++ b/glib/src/miscutils.ccg @@ -117,14 +117,6 @@ get_current_dir() return convert_return_gchar_ptr_to_stdstring(g_get_current_dir()); } -#ifndef GLIBMM_DISABLE_DEPRECATED -std::string -get_user_special_dir(GUserDirectory directory) -{ - return convert_const_gchar_ptr_to_stdstring(g_get_user_special_dir(directory)); -} -#endif // GLIBMM_DISABLE_DEPRECATED - std::string get_user_special_dir(UserDirectory directory) { diff --git a/glib/src/miscutils.hg b/glib/src/miscutils.hg index f4833f5..63040c0 100644 --- a/glib/src/miscutils.hg +++ b/glib/src/miscutils.hg @@ -165,28 +165,6 @@ std::string get_tmp_dir(); */ std::string get_current_dir(); -#ifndef GLIBMM_DISABLE_DEPRECATED -/** Returns the full path of a special directory using its logical id. - * - * On Unix this is done using the XDG special user directories. - * For compatibility with existing practise, G_USER_DIRECTORY_DESKTOP - * falls back to `$HOME/Desktop` when XDG special user directories have - * not been set up. - * - * Depending on the platform, the user might be able to change the path - * of the special directory without requiring the session to restart; GLib - * will not reflect any change once the special directories are loaded. - * - * @param directory The logical id of special directory. - * @return The path to the specified special directory, or an empty string - * if the logical id was not found. - * - * @newin{2,14} - * @deprecated Use get_user_special_dir(Glib::UserDirectory directory) instead. - */ -std::string get_user_special_dir(GUserDirectory directory); -#endif // GLIBMM_DISABLE_DEPRECATED - /** Returns the full path of a special directory using its logical id. * * On Unix this is done using the XDG special user directories. diff --git a/glib/src/nodetree.hg b/glib/src/nodetree.hg index 75b63c0..bcec2dd 100644 --- a/glib/src/nodetree.hg +++ b/glib/src/nodetree.hg @@ -69,8 +69,8 @@ class NodeTree { _CLASS_GENERIC(NodeTree, GNode) public: - using TraverseFunc = sigc::slot&>; - using ForeachFunc = sigc::slot&>; + using TraverseFunc = sigc::slot&)>; + using ForeachFunc = sigc::slot&)>; private: static NodeTree* wrap(GNode* node) @@ -337,10 +337,10 @@ public: */ NodeTree* find_child(const T& the_data, TraverseFlags flags = TRAVERSE_ALL) { - sigc::slot real_slot = sigc::ptr_fun(on_compare_child); + sigc::slot real_slot = sigc::ptr_fun(on_compare_child); GNode* child = nullptr; - using type_foreach_gnode_slot = sigc::slot; + using type_foreach_gnode_slot = sigc::slot; type_foreach_gnode_slot bound_slot = sigc::bind(real_slot, the_data, &child); g_node_children_foreach(gobj(), (GTraverseFlags)flags, c_callback_foreach_compare_child, reinterpret_cast(&bound_slot)); @@ -371,10 +371,10 @@ public: NodeTree* find(const T& the_data, TraverseType order = TRAVERSE_IN_ORDER, TraverseFlags flags = TRAVERSE_ALL) { //We use a sigc::slot for the C callback, so we can bind some extra data. - sigc::slot real_slot = sigc::ptr_fun(on_compare_node); + sigc::slot real_slot = sigc::ptr_fun(on_compare_node); GNode* child = nullptr; - using type_traverse_gnode_slot = sigc::slot; + using type_traverse_gnode_slot = sigc::slot; type_traverse_gnode_slot bound_slot = sigc::bind(real_slot, the_data, &child); g_node_traverse(const_cast(gobj()), (GTraverseType)order, (GTraverseFlags)flags, -1, c_callback_traverse_compare_node, reinterpret_cast(&bound_slot)); @@ -732,7 +732,7 @@ private: } } - /// Wrapper for invoking a sigc::slot (Internal use). + /// Wrapper for invoking a sigc::slot (Internal use). static void c_callback_foreach_compare_child(GNode* node, gpointer data) { const ForeachFunc* slot = reinterpret_cast(data); @@ -750,7 +750,7 @@ private: return FALSE; } - /// Wrapper for invoking a sigc::slot (Internal use). + /// Wrapper for invoking a sigc::slot (Internal use). static gboolean c_callback_traverse_compare_node(GNode* node, gpointer data) { const TraverseFunc* slot = reinterpret_cast(data); diff --git a/glib/src/optioncontext.hg b/glib/src/optioncontext.hg index 04fe81d..0f86e6e 100644 --- a/glib/src/optioncontext.hg +++ b/glib/src/optioncontext.hg @@ -200,7 +200,7 @@ public: * This function is used to translate user-visible strings, for --help output. * The function takes an untranslated string and returns a translated string */ - using SlotTranslate = sigc::slot; + using SlotTranslate = sigc::slot; /** * Sets the function which is used to translate user-visible diff --git a/glib/src/optiongroup.hg b/glib/src/optiongroup.hg index e89f27c..6db4e9e 100644 --- a/glib/src/optiongroup.hg +++ b/glib/src/optiongroup.hg @@ -49,17 +49,17 @@ class OptionGroup public: /** For example Glib::ustring on_translate(const Glib::ustring& original);. */ - using SlotTranslate = sigc::slot; + using SlotTranslate = sigc::slot; /** For example bool on_option_arg_string(const Glib::ustring& option_name, * const Glib::ustring& value, bool has_value);. */ - using SlotOptionArgString = sigc::slot; + using SlotOptionArgString = sigc::slot; /** For example bool on_option_arg_filename(const Glib::ustring& option_name, * const std::string& value, bool has_value);. */ - using SlotOptionArgFilename = sigc::slot; + using SlotOptionArgFilename = sigc::slot; OptionGroup(const Glib::ustring& name, const Glib::ustring& description, const Glib::ustring& help_description = Glib::ustring()); diff --git a/glib/src/spawn.hg b/glib/src/spawn.hg index 0949048..bd34ad5 100644 --- a/glib/src/spawn.hg +++ b/glib/src/spawn.hg @@ -42,7 +42,7 @@ _WRAP_GERROR(SpawnError, GSpawnError, G_SPAWN_ERROR, NO_GTYPE, s#^2BIG$#TOOBIG#) /** For instance,
* void on_child_setup(); */ -using SlotSpawnChildSetup = sigc::slot; +using SlotSpawnChildSetup = sigc::slot; /** Executes a child program asynchronously (your program will not * block waiting for the child to exit). The child program is diff --git a/glib/src/thread.ccg b/glib/src/thread.ccg deleted file mode 100644 index 3d6d795..0000000 --- a/glib/src/thread.ccg +++ /dev/null @@ -1,427 +0,0 @@ -/* Copyright (C) 2002 The gtkmm 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 -#include - -namespace -{ - -extern "C" { - -static void* -call_thread_entry_slot(void* data) -{ - const auto slot = reinterpret_cast(data); - - try - { - // Recreate the specific slot, and drop the reference obtained by create(). - (*static_cast*>(slot))(); - } - catch (Glib::Thread::Exit&) - { - // Just exit from the thread. The Thread::Exit exception - // is our sane C++ replacement of g_thread_exit(). - } - catch (...) - { - Glib::exception_handlers_invoke(); - } - - delete slot; - return nullptr; -} - -} // extern "C" - -} // anonymous namespace - -namespace Glib -{ - -// This was always meant as an internal method. It is no longer called, -// and no longer needs to be called. We are keeping it just to avoid -// breaking ABI, though hopefully nobody is using it anyway. -// TODO: Remove this when we can break ABI. -void -thread_init_impl() -{ - // Make sure the exception map is initialized before creating any thread. - Glib::Error::register_init(); -} - -/**** Glib::Thread *********************************************************/ - -// static -Thread* -Thread::create(const sigc::slot& slot, bool /* joinable */) -{ - // Make a copy of slot on the heap - const auto slot_copy = new sigc::slot(slot); - - GError* error = nullptr; - - const auto thread = g_thread_try_new(nullptr, &call_thread_entry_slot, slot_copy, &error); - - if (error) - { - delete slot_copy; - // Glib::Error::throw_exception() will probably wrap G_THREAD_ERROR in a - // Glib::Threads::ThreadError instance, but we want a Glib::ThreadError. - if (error->domain == G_THREAD_ERROR) - throw Glib::ThreadError(error); - else - Glib::Error::throw_exception(error); - } - - return reinterpret_cast(thread); -} - -// static -Thread* -Thread::create(const sigc::slot& slot, unsigned long stack_size, bool joinable, bool bound, - ThreadPriority priority) -{ - // Make a copy of slot on the heap - const auto slot_copy = new sigc::slot(slot); - - GError* error = nullptr; - - const auto thread = g_thread_create_full(&call_thread_entry_slot, slot_copy, stack_size, joinable, - bound, (GThreadPriority)priority, &error); - - if (error) - { - delete slot_copy; - // Glib::Error::throw_exception() will probably wrap G_THREAD_ERROR in a - // Glib::Threads::ThreadError instance, but we want a Glib::ThreadError. - if (error->domain == G_THREAD_ERROR) - throw Glib::ThreadError(error); - else - Glib::Error::throw_exception(error); - } - - return reinterpret_cast(thread); -} - -// static -Thread* -Thread::self() -{ - return reinterpret_cast(g_thread_self()); -} - -void -Thread::join() -{ - g_thread_join(&gobject_); -} - -bool -Thread::joinable() const -{ - return true; // An appropriate result now that this is deprecated because all threads are now - // joinable. -} - -void -Thread::set_priority(ThreadPriority priority) -{ - g_thread_set_priority(&gobject_, (GThreadPriority)priority); -} - -ThreadPriority -Thread::get_priority() const -{ - return THREAD_PRIORITY_NORMAL; // An appropriate result now that this is deprecated because the - // priority concept has been removed. -} - -void -thread_init(GThreadFunctions* /* vtable */) -{ - // g_thread_init() is deprecated and now does nothing, - // so we do not even call it. That avoids a need to link to gthread-2.0, - // which contains the empty g_thread_init() implementation. - // g_thread_init(vtable); - - Glib::thread_init_impl(); -} - -bool -thread_supported() -{ - // MSVC++ needs the != 0 to avoid an int -> bool cast warning. - return (g_thread_supported() != 0); -} - -// static -void -Thread::yield() -{ - g_thread_yield(); -} - -Thread* -wrap(GThread* gobject) -{ - return reinterpret_cast(gobject); -} - -/**** Glib::StaticMutex ****************************************************/ - -void -StaticMutex::lock() -{ - g_static_mutex_lock(&gobject_); -} - -bool -StaticMutex::trylock() -{ - return g_static_mutex_trylock(&gobject_); -} - -void -StaticMutex::unlock() -{ - g_static_mutex_unlock(&gobject_); -} - -StaticMutex::operator Mutex&() -{ - // If GStaticMutex is implemented as struct (e.g. on Linux), its first struct - // member (runtime_mutex) is a GMutex pointer. If the gthread implementation - // is native (i.e. the vtable pointer passed to g_thread_init() was 0), then - // the runtime_mutex pointer is unused, and the rest of the GStaticMutex - // struct resembles the mutex data. - // - // On Win32, GStaticMutex is just a typedef to struct _GMutex*. Either way, - // the first sizeof(GMutex*) bytes of GStaticMutex always resemble a GMutex - // pointer. The gthread implementation relies on that, and we'll also do so. - - GMutex*& runtime_mutex = reinterpret_cast(gobject_); - - // Fortunately, it cannot hurt if we set this to the GMutex pointer returned - // by g_static_mutex_get_mutex(). Either we just overwrite it with the same - // value, or it was unused anyway. Doing that allows casting the pointer - // location to a Glib::Mutex reference (its only data member is a GMutex*). - - runtime_mutex = g_static_mutex_get_mutex(&gobject_); - - return reinterpret_cast(runtime_mutex); -} - -/**** Glib::Mutex **********************************************************/ - -Mutex::Mutex() -: gobject_(g_mutex_new()) // TODO: Use a statically-allocated GMutext instead, with g_mutex_init(). -{ -} - -Mutex::~Mutex() -{ - g_mutex_free(gobject_); -} - -void -Mutex::lock() -{ - g_mutex_lock(gobject_); -} - -bool -Mutex::trylock() -{ - return g_mutex_trylock(gobject_); -} - -void -Mutex::unlock() -{ - g_mutex_unlock(gobject_); -} - -/**** Glib::StaticRecMutex *************************************************/ - -void -StaticRecMutex::lock() -{ - g_static_rec_mutex_lock(&gobject_); -} - -bool -StaticRecMutex::trylock() -{ - return g_static_rec_mutex_trylock(&gobject_); -} - -void -StaticRecMutex::unlock() -{ - g_static_rec_mutex_unlock(&gobject_); -} - -void -StaticRecMutex::lock_full(unsigned int depth) -{ - g_static_rec_mutex_lock_full(&gobject_, depth); -} - -unsigned int -StaticRecMutex::unlock_full() -{ - return g_static_rec_mutex_unlock_full(&gobject_); -} - -StaticRecMutex::operator RecMutex&() -{ - return static_cast(*this); -} - -/**** Glib::RecMutex *******************************************************/ - -RecMutex::RecMutex() -{ - g_static_rec_mutex_init(&gobject_); -} - -RecMutex::~RecMutex() -{ - g_static_rec_mutex_free(&gobject_); -} - -/**** Glib::StaticRWLock ***************************************************/ - -void -StaticRWLock::reader_lock() -{ - g_static_rw_lock_reader_lock(&gobject_); -} - -bool -StaticRWLock::reader_trylock() -{ - return g_static_rw_lock_reader_trylock(&gobject_); -} - -void -StaticRWLock::reader_unlock() -{ - g_static_rw_lock_reader_unlock(&gobject_); -} - -void -StaticRWLock::writer_lock() -{ - g_static_rw_lock_writer_lock(&gobject_); -} - -bool -StaticRWLock::writer_trylock() -{ - return g_static_rw_lock_writer_trylock(&gobject_); -} - -void -StaticRWLock::writer_unlock() -{ - g_static_rw_lock_writer_unlock(&gobject_); -} - -StaticRWLock::operator RWLock&() -{ - return static_cast(*this); -} - -/**** Glib::RWLock *********************************************************/ - -RWLock::RWLock() -{ - g_static_rw_lock_init(&gobject_); - - // GLib doesn't have GRWLock, only GStaticRWLock. Force initialization - // of the mutex and the condition variables now, to mimic the behaviour - // of a (hypothetical) GRWLock. - - if (g_static_mutex_get_mutex(&gobject_.mutex)) - { - gobject_.read_cond = g_cond_new(); - gobject_.write_cond = g_cond_new(); - } -} - -RWLock::~RWLock() -{ - g_static_rw_lock_free(&gobject_); -} - -/**** Glib::Cond ***********************************************************/ - -Cond::Cond() : gobject_(g_cond_new()) -{ -} - -Cond::~Cond() -{ - g_cond_free(gobject_); -} - -void -Cond::signal() -{ - g_cond_signal(gobject_); -} - -void -Cond::broadcast() -{ - g_cond_broadcast(gobject_); -} - -void -Cond::wait(Mutex& mutex) -{ - g_cond_wait(gobject_, mutex.gobj()); -} - -bool -Cond::timed_wait(Mutex& mutex, const Glib::TimeVal& abs_time) -{ - return g_cond_timed_wait(gobject_, mutex.gobj(), const_cast(&abs_time)); -} - -void* -StaticPrivate_get_helper(GStaticPrivate* private_key) -{ - return g_static_private_get(private_key); -} - -void -StaticPrivate_set_helper(GStaticPrivate* private_key, gpointer data, GDestroyNotify notify) -{ - return g_static_private_set(private_key, data, notify); -} - -GPrivate* -GPrivate_new_helper(GDestroyNotify notify) -{ - return g_private_new(notify); -} - -} // namespace Glib diff --git a/glib/src/thread.hg b/glib/src/thread.hg deleted file mode 100644 index 57b940f..0000000 --- a/glib/src/thread.hg +++ /dev/null @@ -1,1085 +0,0 @@ -/* Copyright (C) 2002 The gtkmm 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) -_CONFIGINCLUDE(glibmmconfig.h) - -_IS_DEPRECATED // This whole file is deprecated. - -#m4 _PUSH(SECTION_CC_PRE_INCLUDES) -//Stop the compiler warnings about using the deprecated API; -#define GLIB_DISABLE_DEPRECATION_WARNINGS 1 -#m4 _POP() - -// We use GThreadFunctions in the (deprecated) API, so we must temporarily undef G_DISABLE_DEPRECATED. -// Temporarily undef G_DISABLE_DEPRECATED, redefining it later if appropriate. -#if defined(G_DISABLE_DEPRECATED) && !defined(GLIBMM_G_DISABLE_DEPRECATED_UNDEFED) -//Stop the deprecation ifdef guards around the API declarations: -#undef G_DISABLE_DEPRECATED -#define GLIBMM_G_DISABLE_DEPRECATED_UNDEFED 1 -#endif - -#include - -// Redefine G_DISABLE_DEPRECATED if it was defined before we temporarily undefed it: -#if defined(GLIBMM_G_DISABLE_DEPRECATED_UNDEFED) -#define G_DISABLE_DEPRECATED 1 -#undef GLIBMM_G_DISABLE_DEPRECATED_UNDEFED -#endif - - -#include -#include -#include - -#include - -/* Shadow THREAD_PRIORITY_NORMAL macro (from winbase.h). - */ -#if defined(THREAD_PRIORITY_NORMAL) && !defined(GLIBMM_MACRO_SHADOW_THREAD_PRIORITY_NORMAL) -enum { GLIBMM_MACRO_DEFINITION_THREAD_PRIORITY_NORMAL = THREAD_PRIORITY_NORMAL }; -#undef THREAD_PRIORITY_NORMAL -enum { THREAD_PRIORITY_NORMAL = GLIBMM_MACRO_DEFINITION_THREAD_PRIORITY_NORMAL }; -#define THREAD_PRIORITY_NORMAL THREAD_PRIORITY_NORMAL -#define GLIBMM_MACRO_SHADOW_THREAD_PRIORITY_NORMAL 1 -#endif - - -/** Initializer macro for Glib::StaticRecMutex. - * @relates Glib::StaticRecMutex - * @hideinitializer - * - * @deprecated Glib::StaticRecMutex is deprecated in favour of Glib::Threads::RecMutex, which can be used statically. - */ -#define GLIBMM_STATIC_REC_MUTEX_INIT { G_STATIC_REC_MUTEX_INIT } - -/** Initializer macro for Glib::StaticRWLock. - * @relates Glib::StaticRWLock - * @hideinitializer - * - * @deprecated Glib::StaticRWLock is deprecated in favour of Glib::Threads::RWLock, which can be used statically. - */ -#define GLIBMM_STATIC_RW_LOCK_INIT { G_STATIC_RW_LOCK_INIT } - -/** Initializer macro for Glib::StaticPrivate. - * @relates Glib::StaticPrivate - * @hideinitializer - * - * @deprecated Glib::StaticPrivate is deprecated in favour of Glib::Threads::Private, which can be used statically. - */ -#define GLIBMM_STATIC_PRIVATE_INIT { G_STATIC_PRIVATE_INIT } - -namespace Glib -{ - -/** @deprecated Thread priorities no longer have any effect. - */ -_WRAP_ENUM(ThreadPriority, GThreadPriority, NO_GTYPE) - -/*! @var ThreadPriority THREAD_PRIORITY_LOW - * A priority lower than normal. - */ -/*! @var ThreadPriority THREAD_PRIORITY_NORMAL - * The default priority. - */ -/*! @var ThreadPriority THREAD_PRIORITY_HIGH - * A priority higher than normal. - */ -/*! @var ThreadPriority THREAD_PRIORITY_URGENT - * The highest priority. - */ - -/** Initializes the GLib thread system. - * @deprecated Calling thread_init() is no longer necessary and no longer has any effect. - */ -void thread_init(GThreadFunctions* vtable = nullptr); - -/** Returns whether the thread system is initialized. - * @return @c true, if the thread system is initialized. - * @deprecated This is no longer useful, because the thread system is always initialized. - */ -bool thread_supported(); - -/** - * @deprecated Use Glib::Threads::NotLock instead. - */ -enum NotLock { NOT_LOCK }; - -/** - * @deprecated Use Glib::Threads::TryLock instead. - */ -enum TryLock { TRY_LOCK }; - -class Mutex; -class RecMutex; -class RWLock; - -struct StaticRecMutex; -struct StaticRWLock; - - -/** Exception class for thread-related errors. - * @deprecated Use Glib::Threads::ThreadError instead. - */ -_WRAP_GERROR(ThreadError, GThreadError, G_THREAD_ERROR, NO_GTYPE) - - -/** Represents a running thread. - * An instance of this class can only be obtained with create(), self(), - * or wrap(GThread*). It's not possible to delete a Thread object. If the - * thread is @em not joinable, its resources will be freed automatically - * when it exits. Otherwise, if the thread @em is joinable, you must call - * join() to avoid a memory leak. - * - * @note g_thread_exit() is not wrapped, because that function exits a thread - * without any cleanup. That's especially dangerous in C++ code, since the - * destructors of automatic objects won't be invoked. Instead, you can throw - * a Thread::Exit exception, which will be caught by the internal thread - * entry function. - * - * @note You might have noticed that the thread entry slot doesn't have the - * usual void* return value. If you want to return any data from your thread - * you can pass an additional output argument to the thread's entry slot. - * - * @deprecated Use Glib::Threads::Thread instead. - */ -class Thread -{ -public: - - Thread(const Thread&) = delete; - Thread& operator=(const Thread&) = delete; - - class Exit; - - //See http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue. - /** Creates a new thread with the priority THREAD_PRIORITY_NORMAL. - * If @a joinable is @c true, you can wait for this thread's termination by - * calling join(). Otherwise the thread will just disappear, when ready. - * - * The new thread executes the function or method @a slot points to. You can - * pass additional arguments using sigc::bind(). If the thread was created - * successfully, it is returned, otherwise a ThreadError exception is thrown. - * - * Because sigc::trackable is not thread safe, if the slot represents a - * non-static class method (that is, it is created by sigc::mem_fun()), the - * class concerned should not derive from sigc::trackable. - * - * @param slot A slot to execute in the new thread. - * @param joinable This parameter is now ignored because Threads are now always joinable. - * @return The new Thread* on success. - * @throw Glib::ThreadError - */ - static Thread* create(const sigc::slot& slot, bool joinable = true); - - /** Returns the Thread* corresponding to the calling thread. - * @return The current thread. - */ - static Thread* self(); - - /** Waits until the thread finishes. - * Waits until the thread finishes, i.e. the slot, as given to create(), - * returns or g_thread_exit() is called by the thread. (Calling - * g_thread_exit() in a C++ program should be avoided.) All resources of - * the thread including the Glib::Thread object are released. The thread - * must have been created with joinable = true. - */ - void join(); - - //See http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue. - /** Creates a new thread with the priority @a priority. The stack gets the - * size @a stack_size or the default value for the current platform, if - * @a stack_size is 0. - * - * If @a joinable is @c true, you can wait for this thread's termination by - * calling join(). Otherwise the thread will just disappear, when ready. - * If @a bound is @c true, this thread will be scheduled in the system scope, - * otherwise the implementation is free to do scheduling in the process - * scope. The first variant is more expensive resource-wise, but generally - * faster. On some systems (e.g. Linux) all threads are bound. - * - * The new thread executes the function or method @a slot points to. You can - * pass additional arguments using sigc::bind(). If the thread was created - * successfully, it is returned. - * - * Because sigc::trackable is not thread safe, if the slot represents a - * non-static class method (that is, it is created by sigc::mem_fun()), the - * class concerned should not derive from sigc::trackable. - * - * @note It is not guaranteed, that threads with different priorities really - * behave accordingly. On some systems (e.g. Linux) only root can increase - * priorities. On other systems (e.g. Solaris) there doesn't seem to be - * different scheduling for different priorities. All in all try to avoid - * being dependent on priorities. Use Glib::THREAD_PRIORITY_NORMAL - * here as a default. - * - * @note Only use the extended - * create(const sigc::slot&, unsigned long, bool, bool, ThreadPriority) - * function, when you really can't use the simple - * create(const sigc::slot&, bool) - * instead. The latter overload does not take @a stack_size, @a bound and - * @a priority as arguments, as they should only be used for cases, where - * it is inevitable. - * - * @param slot A slot to execute in the new thread. - * @param stack_size A stack size for the new thread, or 0. - * @param joinable Should this thread be joinable? - * @param bound Should this thread be bound to a system thread? - * @param priority A priority for the thread. - * @return The new Thread* on success. - * @throw Glib::ThreadError - * - * @deprecated Use the simpler create() method instead, because all Threads - * are now joinable, and bounds and priority parameters now have no effect. - */ - static Thread* create(const sigc::slot& slot, unsigned long stack_size, - bool joinable, bool bound, ThreadPriority priority); - - /** Returns whether the thread is joinable. - * @return Whether the thread is joinable. - * - * @deprecated All threads are now joinable. - */ - bool joinable() const; - - /** Changes the priority of the thread to @a priority. - * @note It is not guaranteed, that threads with different priorities really - * behave accordingly. On some systems (e.g. Linux) only @c root can - * increase priorities. On other systems (e.g. Solaris) there doesn't seem - * to be different scheduling for different priorities. All in all try to - * avoid being dependent on priorities. - * @param priority A new priority for the thread. - * - * @deprecated Thread priorities no longer have any effect. - */ - void set_priority(ThreadPriority priority); - - /** Returns the priority of the thread. - * @return The thread's priority. - * - * @deprecated Thread priorities no longer have any effect. - */ - ThreadPriority get_priority() const; - - /** Gives way to other threads waiting to be scheduled. - * This function is often used as a method to make busy wait less evil. But - * in most cases, you will encounter, there are better methods to do that. - * So in general you shouldn't use this function. - */ - static void yield(); - - GThread* gobj() { return &gobject_; } - const GThread* gobj() const { return &gobject_; } - -private: - GThread gobject_; - - // Glib::Thread can neither be constructed nor deleted. - Thread(); - void operator delete(void*, std::size_t); -}; - -/** %Exception class used to exit from a thread. - * @code - * throw Glib::Thread::Exit(); - * @endcode - * Write this if you want to exit from a thread created by Thread::create(). - * Of course you must make sure not to catch Thread::Exit by accident, i.e. - * when using catch(...) somewhere in your code. - * - * @deprecated Use Glib::Threads::Thread::Exit instead. - */ -class Thread::Exit -{}; - - -//TODO: Make sure that Glib::wrap() uses Glib::Threads::wrap() instead. - -/** @relates Glib::Thread - * - * @deprecated Use Glib::Threads::wrap(GThread*) instead. - */ -Thread* wrap(GThread* gobject); - -struct StaticMutex; - -/** Like Glib::Mutex, but can be defined at compile time. - * Use @c GLIBMM_STATIC_MUTEX_INIT to initialize a StaticMutex: - * @code - * Glib::StaticMutex mutex = GLIBMM_STATIC_MUTEX_INIT; - * @endcode - * - * A StaticMutex can be used without calling Glib::thread_init(), it will - * silently do nothing then. That will also work when using the implicit - * conversion to Mutex&, thus you can safely use Mutex::Lock with a - * StaticMutex. - * - * @deprecated Use Glib::Threads::Mutex instead, which can be used statically. - */ -struct StaticMutex -{ - void lock(); - bool trylock(); - void unlock(); - - operator Mutex&(); - - GStaticMutex* gobj() { return &gobject_; } - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Must be public to allow initialization at compile time. - GStaticMutex gobject_; -#endif -}; - -/** Initializer macro for Glib::StaticMutex. - * @relates Glib::StaticMutex - * @hideinitializer - * - * @deprecated Glib::StaticMutex is deprecated in favour of Glib::Threads::Mutex, which can be used statically. - */ -#define GLIBMM_STATIC_MUTEX_INIT { G_STATIC_MUTEX_INIT } - -/** Represents a mutex (mutual exclusion). - * It can be used to protect data against shared access. Try to use - * Mutex::Lock instead of calling lock() and unlock() directly -- - * it will make your life much easier. - * - * @note Glib::Mutex is not recursive, i.e. a thread will deadlock, if it - * already has locked the mutex while calling lock(). Use Glib::RecMutex - * instead, if you need recursive mutexes. - * - * @deprecated Use Glib::Threads::Mutex instead. - */ -class Mutex -{ -public: - class Lock; - - Mutex(); - - Mutex(const Mutex&) = delete; - Mutex& operator=(const Mutex&) = delete; - - ~Mutex(); - - /** Locks the mutex. - * If mutex is already locked by another thread, the current thread will - * block until mutex is unlocked by the other thread. - * @see Mutex::Lock - */ - void lock(); - - /** Tries to lock the mutex. - * If the mutex is already locked by another thread, it immediately returns - * @c false. Otherwise it locks the mutex and returns @c true. - * @return Whether the mutex could be locked. - * @see Mutex::Lock - */ - bool trylock(); - - /** Unlocks the mutex. - * If another thread is blocked in a lock() call for this mutex, it will be - * woken and can lock the mutex itself. - * @see Mutex::Lock - */ - void unlock(); - - GMutex* gobj() { return gobject_; } - -private: - GMutex* gobject_; -}; - -/** Utility class for exception-safe mutex locking. - * @par Usage example: - * @code - * { - * Glib::Mutex::Lock lock (mutex); // calls mutex.lock() - * do_something(); - * } // the destructor calls mutex.unlock() - * @endcode - * As you can see, the compiler takes care of the unlocking. This is not - * only exception safe but also much less error-prone. You could even - * return while still holding the lock and it will be released - * properly. - * - * @deprecated Use Glib::Threads::Mutex::Lock instead. - */ -class Mutex::Lock -{ -public: - explicit inline Lock(Mutex& mutex); - inline Lock(Mutex& mutex, NotLock); - inline Lock(Mutex& mutex, TryLock); - inline ~Lock(); - - inline void acquire(); - inline bool try_acquire(); - inline void release(); - inline bool locked() const; - -private: - Mutex& mutex_; - bool locked_; - - -}; - - -/** Like Glib::RecMutex, but can be defined at compile time. - * Use @c GLIBMM_STATIC_REC_MUTEX_INIT to initialize a StaticRecMutex: - * @code - * Glib::StaticRecMutex mutex = GLIBMM_STATIC_REC_MUTEX_INIT; - * @endcode - * A StaticRecMutex can be used without calling Glib::thread_init(), it will - * silently do nothing then. That will also work when using the implicit - * conversion to RecMutex&, thus you can safely use RecMutex::Lock with a - * StaticRecMutex. - * - * @deprecated Use Glib::Threads::RecMutex instead, which can be used statically. - */ -struct StaticRecMutex -{ - void lock(); - bool trylock(); - void unlock(); - - void lock_full(unsigned int depth); - unsigned int unlock_full(); - - operator RecMutex&(); - - GStaticRecMutex* gobj() { return &gobject_; } - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Must be public to allow initialization at compile time. - GStaticRecMutex gobject_; -#endif -}; - -/** - * - * @deprecated Use Glib::Threads::RecMutex instead. - */ -class RecMutex : public StaticRecMutex -{ -public: - class Lock; - - RecMutex(); - ~RecMutex(); - -private: - // noncopyable - RecMutex(const RecMutex&); - RecMutex& operator=(const RecMutex&); -}; - -/** Utility class for exception-safe locking of recursive mutexes. - * - * @deprecated Use Glib::Threads::RecMutex instead. - */ -class RecMutex::Lock -{ -public: - explicit inline Lock(RecMutex& mutex); - inline Lock(RecMutex& mutex, NotLock); - inline Lock(RecMutex& mutex, TryLock); - - Lock(const RecMutex::Lock&) = delete; - RecMutex::Lock& operator=(const RecMutex::Lock&) = delete; - - inline ~Lock(); - - inline void acquire(); - inline bool try_acquire(); - inline void release(); - inline bool locked() const; - -private: - RecMutex& mutex_; - bool locked_; -}; - - -/** Like Glib::RWLock, but can be defined at compile time. - * Use @c GLIBMM_STATIC_RW_LOCK_INIT to initialize a StaticRWLock: - * @code - * Glib::StaticRWLock rw_lock = GLIBMM_STATIC_RW_LOCK_INIT; - * @endcode - * A StaticRWLock can be used without calling Glib::thread_init(), it will - * silently do nothing then. That will also work when using the implicit - * conversion to RWLock&, thus you can safely use RWLock::ReaderLock and - * RWLock::WriterLock with a StaticRWLock. - * - * @deprecated Use Glib::Threads::RWLock instead, which can be used statically. - */ -struct StaticRWLock -{ - void reader_lock(); - bool reader_trylock(); - void reader_unlock(); - - void writer_lock(); - bool writer_trylock(); - void writer_unlock(); - - operator RWLock&(); - - GStaticRWLock* gobj() { return &gobject_; } - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Must be public to allow initialization at compile time. - GStaticRWLock gobject_; -#endif -}; - -/** - * - * @deprecated Use Glib::Threads::RWLock instead. - */ -class RWLock : public StaticRWLock -{ -public: - class ReaderLock; - class WriterLock; - - RWLock(); - - RWLock(const RWLock&) = delete; - RWLock& operator=(const RWLock&) = delete; - - ~RWLock(); -}; - -/** Utility class for exception-safe locking of read/write locks. - * - * @deprecated Use Glib::Threads::RWLock::ReaderLock instead. - */ -class RWLock::ReaderLock -{ -public: - explicit inline ReaderLock(RWLock& rwlock); - inline ReaderLock(RWLock& rwlock, NotLock); - inline ReaderLock(RWLock& rwlock, TryLock); - - ReaderLock(const RWLock::ReaderLock&) = delete; - RWLock::ReaderLock& operator=(const RWLock::ReaderLock&) = delete; - - inline ~ReaderLock(); - - inline void acquire(); - inline bool try_acquire(); - inline void release(); - inline bool locked() const; - -private: - RWLock& rwlock_; - bool locked_; -}; - -/** Utility class for exception-safe locking of read/write locks. - * - * @deprecated Use Glib::Threads::RWLock::WriterLock instead. - */ -class RWLock::WriterLock -{ -public: - explicit inline WriterLock(RWLock& rwlock); - inline WriterLock(RWLock& rwlock, NotLock); - inline WriterLock(RWLock& rwlock, TryLock); - - WriterLock(const RWLock::WriterLock&) = delete; - RWLock::WriterLock& operator=(const RWLock::WriterLock&) = delete; - - inline ~WriterLock(); - - inline void acquire(); - inline bool try_acquire(); - inline void release(); - inline bool locked() const; - -private: - RWLock& rwlock_; - bool locked_; -}; - -/** An opaque data structure to represent a condition. - * A @a Cond is an object that threads can block on, if they find a certain - * condition to be false. If other threads change the state of this condition - * they can signal the @a Cond, such that the waiting thread is woken up. - * @par Usage example: - * @code - * Glib::Cond data_cond; - * Glib::Mutex data_mutex; - * void* current_data = nullptr; - * - * void push_data(void* data) - * { - * Glib::Mutex::Lock lock (data_mutex); - * - * current_data = data; - * data_cond.signal(); - * } - * - * void* pop_data() - * { - * Glib::Mutex::Lock lock (data_mutex); - * - * while (!current_data) - * data_cond.wait(data_mutex); - * - * void *const data = current_data; - * current_data = nullptr; - * - * return data; - * } - * @endcode - * - * @deprecated Use Glib::Threads::Cond instead. - */ -class Cond -{ -public: - Cond(); - - Cond(const Cond&) = delete; - Cond& operator=(const Cond&) = delete; - - ~Cond(); - - /** If threads are waiting for this @a Cond, exactly one of them is woken up. - * It is good practice to hold the same lock as the waiting thread, while calling - * this method, though not required. - * - */ - void signal(); - - /** If threads are waiting for this @a Cond, all of them are woken up. - * It is good practice to hold the same lock as the waiting thread, while calling - * this method, though not required. - */ - void broadcast(); - - /** Waits until this thread is woken up on this @a Cond. - * The mutex is unlocked before falling asleep and locked again before resuming. - * - * @param mutex a @a Mutex that is currently locked. - * - * @note It is important to use the @a wait() and @a timed_wait() methods - * only inside a loop, which checks for the condition to be true as it is not - * guaranteed that the waiting thread will find it fulfilled, even if the signaling - * thread left the condition in that state. This is because another thread can have - * altered the condition, before the waiting thread got the chance to be woken up, - * even if the condition itself is protected by a @a Mutex. - */ - void wait(Mutex& mutex); - - /** Waits until this thread is woken up on this @a Cond, but not longer than until the time, that is specified by @a abs_time. - * The mutex is unlocked before falling asleep and locked again before resuming. - * - * @param mutex a @a Mutex that is currently locked. - * @param abs_time a max time to wait. - * - * @note It is important to use the @a wait() and @a timed_wait() methods - * only inside a loop, which checks for the condition to be true as it is not - * guaranteed that the waiting thread will find it fulfilled, even if the signaling - * thread left the condition in that state. This is because another thread can have - * altered the condition, before the waiting thread got the chance to be woken up, - * even if the condition itself is protected by a @a Mutex. - */ - bool timed_wait(Mutex& mutex, const Glib::TimeVal& abs_time); - - GCond* gobj() { return gobject_; } - -private: - GCond* gobject_; -}; - - -/** Thread-local data pointer. - * - * @deprecated Use Glib::Threads::Private instead, which can be used statically. - */ -template -struct StaticPrivate -{ - using DestroyNotifyFunc = void (*) (void*); - - static void delete_ptr(void* data); - - inline T* get(); - inline void set(T* data, DestroyNotifyFunc notify_func = &StaticPrivate::delete_ptr); - - GStaticPrivate* gobj() { return &gobject_; } - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Must be public to allow initialization at compile time. - GStaticPrivate gobject_; -#endif -}; - -/** Thread-local data pointer. - * - * @deprecated Use Glib::Threads::Private instead. - */ -template -class Private -{ -public: - - Private(const Private&) = delete; - Private& operator=(const Private&) = delete; - - using DestructorFunc = void (*) (void*); - - static void delete_ptr(void* data); - - explicit inline Private(DestructorFunc destructor_func = &Private::delete_ptr); - inline T* get(); - inline void set(T* data); - - GPrivate* gobj() { return gobject_; } - -private: - GPrivate* gobject_; -}; - -/** @} group Threads */ - -/*! A glibmm thread example. - * @example thread/thread.cc - */ - - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -/***************************************************************************/ -/* inline implementation */ -/***************************************************************************/ - -// internal -/** @deprecated This was always for internal glibmm use and is now unecessary even inside glibmm. - */ -void thread_init_impl(); - -/**** Glib::Mutex::Lock ****************************************************/ - -inline -Mutex::Lock::Lock(Mutex& mutex) -: - mutex_ (mutex), - locked_ (true) -{ - mutex_.lock(); -} - -inline -Mutex::Lock::Lock(Mutex& mutex, NotLock) -: - mutex_ (mutex), - locked_ (false) -{} - -inline -Mutex::Lock::Lock(Mutex& mutex, TryLock) -: - mutex_ (mutex), - locked_ (mutex.trylock()) -{} - -inline -Mutex::Lock::~Lock() -{ - if(locked_) - mutex_.unlock(); -} - -inline -void Mutex::Lock::acquire() -{ - mutex_.lock(); - locked_ = true; -} - -inline -bool Mutex::Lock::try_acquire() -{ - locked_ = mutex_.trylock(); - return locked_; -} - -inline -void Mutex::Lock::release() -{ - mutex_.unlock(); - locked_ = false; -} - -inline -bool Mutex::Lock::locked() const -{ - return locked_; -} - - -/**** Glib::RecMutex::Lock *************************************************/ - -inline -RecMutex::Lock::Lock(RecMutex& mutex) -: - mutex_ (mutex), - locked_ (true) -{ - mutex_.lock(); -} - -inline -RecMutex::Lock::Lock(RecMutex& mutex, NotLock) -: - mutex_ (mutex), - locked_ (false) -{} - -inline -RecMutex::Lock::Lock(RecMutex& mutex, TryLock) -: - mutex_ (mutex), - locked_ (mutex.trylock()) -{} - -inline -RecMutex::Lock::~Lock() -{ - if(locked_) - mutex_.unlock(); -} - -inline -void RecMutex::Lock::acquire() -{ - mutex_.lock(); - locked_ = true; -} - -inline -bool RecMutex::Lock::try_acquire() -{ - locked_ = mutex_.trylock(); - return locked_; -} - -inline -void RecMutex::Lock::release() -{ - mutex_.unlock(); - locked_ = false; -} - -inline -bool RecMutex::Lock::locked() const -{ - return locked_; -} - - -/**** Glib::RWLock::ReaderLock *********************************************/ - -inline -RWLock::ReaderLock::ReaderLock(RWLock& rwlock) -: - rwlock_ (rwlock), - locked_ (true) -{ - rwlock_.reader_lock(); -} - -inline -RWLock::ReaderLock::ReaderLock(RWLock& rwlock, NotLock) -: - rwlock_ (rwlock), - locked_ (false) -{} - -inline -RWLock::ReaderLock::ReaderLock(RWLock& rwlock, TryLock) -: - rwlock_ (rwlock), - locked_ (rwlock.reader_trylock()) -{} - -inline -RWLock::ReaderLock::~ReaderLock() -{ - if(locked_) - rwlock_.reader_unlock(); -} - -inline -void RWLock::ReaderLock::acquire() -{ - rwlock_.reader_lock(); - locked_ = true; -} - -inline -bool RWLock::ReaderLock::try_acquire() -{ - locked_ = rwlock_.reader_trylock(); - return locked_; -} - -inline -void RWLock::ReaderLock::release() -{ - rwlock_.reader_unlock(); - locked_ = false; -} - -inline -bool RWLock::ReaderLock::locked() const -{ - return locked_; -} - - -/**** Glib::RWLock::WriterLock *********************************************/ - -inline -RWLock::WriterLock::WriterLock(RWLock& rwlock) -: - rwlock_ (rwlock), - locked_ (true) -{ - rwlock_.writer_lock(); -} - -inline -RWLock::WriterLock::WriterLock(RWLock& rwlock, NotLock) -: - rwlock_ (rwlock), - locked_ (false) -{} - -inline -RWLock::WriterLock::WriterLock(RWLock& rwlock, TryLock) -: - rwlock_ (rwlock), - locked_ (rwlock.writer_trylock()) -{} - -inline -RWLock::WriterLock::~WriterLock() -{ - if(locked_) - rwlock_.writer_unlock(); -} - -inline -void RWLock::WriterLock::acquire() -{ - rwlock_.writer_lock(); - locked_ = true; -} - -inline -bool RWLock::WriterLock::try_acquire() -{ - locked_ = rwlock_.writer_trylock(); - return locked_; -} - -inline -void RWLock::WriterLock::release() -{ - rwlock_.writer_unlock(); - locked_ = false; -} - -inline -bool RWLock::WriterLock::locked() const -{ - return locked_; -} - - -/**** Glib::StaticPrivate **************************************************/ - -// static -template -void StaticPrivate::delete_ptr(void* data) -{ - delete static_cast(data); -} - -/** This is only for use by glibmm itself. - */ -void* StaticPrivate_get_helper(GStaticPrivate *private_key); - -template inline -T* StaticPrivate::get() -{ - return static_cast(StaticPrivate_get_helper(&gobject_)); -} - -/** This is only for use by glibmm itself. - */ -void StaticPrivate_set_helper(GStaticPrivate *private_key, gpointer data, GDestroyNotify notify); - -template inline -void StaticPrivate::set(T* data, typename StaticPrivate::DestroyNotifyFunc notify_func) -{ - StaticPrivate_set_helper(&gobject_, data, notify_func); -} - - -/**** Glib::Private ********************************************************/ - -// static -template -void Private::delete_ptr(void* data) -{ - delete static_cast(data); -} - -/** This is only for use by glibmm itself. - */ -GPrivate* GPrivate_new_helper(GDestroyNotify notify); - -template inline -Private::Private(typename Private::DestructorFunc destructor_func) -: - gobject_ (GPrivate_new_helper(destructor_func)) -{} - -template inline -T* Private::get() -{ - return static_cast(g_private_get(gobject_)); -} - -template inline -void Private::set(T* data) -{ - g_private_set(gobject_, data); -} - -#endif /* DOXYGEN_SHOULD_SKIP_THIS */ - -} // namespace Glib - diff --git a/glib/src/threads.ccg b/glib/src/threads.ccg deleted file mode 100644 index 274b5a1..0000000 --- a/glib/src/threads.ccg +++ /dev/null @@ -1,302 +0,0 @@ -/* Copyright (C) 2002 The gtkmm 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 -#include - -/* Why reinterpret_cast(gobject) is needed: - * - * A Thread instance is in fact always a GThread instance. - * Unfortunately, GThread cannot be a member of Thread, - * because it is an opaque struct. Also, the C interface does not provide - * any hooks to install a destroy notification handler, thus we cannot - * wrap it dynamically either. - * - * The cast works because Thread does not have any member data, and - * it is impossible to derive from it. This is ensured by not implementing - * the (private) default constructor. - * This trick is used also in classes declared as _CLASS_OPAQUE_REFCOUNTED. - */ - -namespace -{ - -extern "C" { - -static void* -call_thread_entry_slot(void* data) -{ - const auto slot = reinterpret_cast(data); - - try - { - // Recreate the specific slot. - (*static_cast*>(slot))(); - } - catch (Glib::Threads::Thread::Exit&) - { - // Just exit from the thread. The Threads::Thread::Exit exception - // is our sane C++ replacement of g_thread_exit(). - } - catch (...) - { - Glib::exception_handlers_invoke(); - } - - delete slot; - return nullptr; -} - -} // extern "C" - -} // anonymous namespace - -namespace Glib -{ - -namespace Threads -{ - -/**** Glib::Threads::Thread ************************************************/ - -// static -Thread* -Thread::create(const sigc::slot& slot, const std::string& name) -{ - // Make a copy of slot on the heap. - const auto slot_copy = new sigc::slot(slot); - - GError* error = nullptr; - auto thread = g_thread_try_new( - name.empty() ? nullptr : name.c_str(), &call_thread_entry_slot, slot_copy, &error); - - if (error) - { - delete slot_copy; - Glib::Error::throw_exception(error); - } - if (!thread) - { - delete slot_copy; - } - return reinterpret_cast(thread); -} - -// static -Thread* -Thread::create(const sigc::slot& slot) -{ - return create(slot, std::string()); -} - -// static -Thread* -Thread::self() -{ - return reinterpret_cast(g_thread_self()); -} - -void -Thread::join() -{ - g_thread_join(reinterpret_cast(this)); -} - -// static -void -Thread::yield() -{ - g_thread_yield(); -} - -GThread* -Thread::gobj() -{ - return reinterpret_cast(this); -} - -const GThread* -Thread::gobj() const -{ - return reinterpret_cast(this); -} - -Thread* -wrap(GThread* gobject) -{ - return reinterpret_cast(gobject); -} - -/**** Glib::Threads::Mutex *************************************************/ - -Mutex::Mutex() -{ - g_mutex_init(&gobject_); -} - -Mutex::~Mutex() -{ - g_mutex_clear(&gobject_); -} - -void -Mutex::lock() -{ - g_mutex_lock(&gobject_); -} - -bool -Mutex::trylock() -{ - return g_mutex_trylock(&gobject_); -} - -void -Mutex::unlock() -{ - g_mutex_unlock(&gobject_); -} - -Mutex* -wrap(GMutex* gobject) -{ - return reinterpret_cast(gobject); -} - -/**** Glib::Threads::RecMutex **********************************************/ - -RecMutex::RecMutex() -{ - g_rec_mutex_init(&gobject_); -} - -RecMutex::~RecMutex() -{ - g_rec_mutex_clear(&gobject_); -} - -void -RecMutex::lock() -{ - g_rec_mutex_lock(&gobject_); -} - -bool -RecMutex::trylock() -{ - return g_rec_mutex_trylock(&gobject_); -} - -void -RecMutex::unlock() -{ - g_rec_mutex_unlock(&gobject_); -} - -RecMutex* -wrap(GRecMutex* gobject) -{ - return reinterpret_cast(gobject); -} - -/**** Glib::Threads::RWLock ************************************************/ - -void -RWLock::reader_lock() -{ - g_rw_lock_reader_lock(&gobject_); -} - -bool -RWLock::reader_trylock() -{ - return g_rw_lock_reader_trylock(&gobject_); -} - -void -RWLock::reader_unlock() -{ - g_rw_lock_reader_unlock(&gobject_); -} - -void -RWLock::writer_lock() -{ - g_rw_lock_writer_lock(&gobject_); -} - -bool -RWLock::writer_trylock() -{ - return g_rw_lock_writer_trylock(&gobject_); -} - -void -RWLock::writer_unlock() -{ - g_rw_lock_writer_unlock(&gobject_); -} - -RWLock::RWLock() -{ - g_rw_lock_init(&gobject_); -} - -RWLock::~RWLock() -{ - g_rw_lock_clear(&gobject_); -} - -/**** Glib::Threads::Cond **************************************************/ - -Cond::Cond() -{ - g_cond_init(&gobject_); -} - -Cond::~Cond() -{ - g_cond_clear(&gobject_); -} - -void -Cond::signal() -{ - g_cond_signal(&gobject_); -} - -void -Cond::broadcast() -{ - g_cond_broadcast(&gobject_); -} - -void -Cond::wait(Mutex& mutex) -{ - g_cond_wait(&gobject_, mutex.gobj()); -} - -bool -Cond::wait_until(Mutex& mutex, gint64 end_time) -{ - return g_cond_wait_until(&gobject_, mutex.gobj(), end_time); -} - -} // namespace Threads - -} // namespace Glib diff --git a/glib/src/threads.hg b/glib/src/threads.hg deleted file mode 100644 index 6340f45..0000000 --- a/glib/src/threads.hg +++ /dev/null @@ -1,932 +0,0 @@ -/* Copyright (C) 2002 The gtkmm 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) -_CONFIGINCLUDE(glibmmconfig.h) - -_IS_DEPRECATED // This whole file is deprecated. - -#m4 _PUSH(SECTION_CC_PRE_INCLUDES) -// Don't let glibmm.h include thread.h. Pretend that it's already included. -// glib.h can then be included with G_DISABLE_DEPRECATED defined, and -// the compiler can react if deprecated glib functions are used. -#define _GLIBMM_THREAD_H -#m4 _POP() - -#include -#include -#include -#include -#include - -namespace Glib -{ - -/** - * @deprecated The entire Glib::Threads API is deprecated in favor of the - * standard C++ concurrency API in C++11 and C++14. - */ -namespace Threads -{ -//The GMMPROC_EXTRA_NAMESPACE() macro is a hint to generate_wrap_init.pl to put it in the Threads sub-namespace -_GMMPROC_EXTRA_NAMESPACE(Threads) - -/** @defgroup Threads Threads - * %Thread abstraction; including threads, different mutexes, - * conditions and thread private data. - * - * @deprecated The entire Glib::Threads API is deprecated in favor of the - * standard C++ concurrency API in C++11 and C++14. - * @{ - */ - -/// @deprecated Please use std::lock_guard or std::unique_lock instead. -enum NotLock { NOT_LOCK }; - -/// @deprecated Please use std::lock_guard or std::unique_lock instead. -enum TryLock { TRY_LOCK }; - -class Mutex; -class RecMutex; -class RWLock; - -/** %Exception class for thread-related errors. - * - * @deprecated Please use std::lock_guard or std::unique_lock instead. - */ -_WRAP_GERROR(ThreadError, GThreadError, G_THREAD_ERROR, NO_GTYPE) - - -/** Represents a running thread. - * An instance of this class can only be obtained with create(), self(), - * or wrap(GThread*). It's not possible to delete a Thread object. - * You must call join() to avoid a memory leak. - * - * @note g_thread_exit() is not wrapped, because that function exits a thread - * without any cleanup. That's especially dangerous in C++ code, since the - * destructors of automatic objects won't be invoked. Instead, you can throw - * a Threads::Thread::Exit exception, which will be caught by the internal thread - * entry function. - * - * @note The thread entry slot doesn't have the void* return value that a - * GThreadFunc has. If you want to return any data from your thread, - * you can pass an additional output argument to the thread's entry slot. - * - * @deprecated Please use std::thread instead. - */ -class Thread -{ -public: - - Thread(const Thread&) = delete; - Thread& operator=(const Thread&) = delete; - - class Exit; - - //See http://bugzilla.gnome.org/show_bug.cgi?id=512348 about the sigc::trackable issue. - // TODO: At the next ABI break, consider changing const sigc::slot& slot - // to const std::function& func, if it can be assumed that all supported - // compilers understand the C++11 template class std::function<>. - /** Creates a new thread. - * You can wait for this thread's termination by calling join(). - * - * The new thread executes the function or method @a slot points to. You can - * pass additional arguments using sigc::bind(). If the thread was created - * successfully, it is returned, otherwise a Threads::ThreadError exception is thrown. - * - * Because sigc::trackable is not thread-safe, if the slot represents a - * non-static class method and is created by sigc::mem_fun(), the class concerned - * should not derive from sigc::trackable. You can use, say, boost::bind() or, - * in C++11, std::bind() or a C++11 lambda expression instead of sigc::mem_fun(). - * - * @param slot A slot to execute in the new thread. - * @return The new Thread* on success. - * @throw Glib::Threads::ThreadError - */ - static Thread* create(const sigc::slot& slot); - - // TODO: At next ABI break, remove the single parameter create - // method and default name to std::string() - - /** Creates a new named thread. - * You can wait for this thread's termination by calling join(). - * - * The new thread executes the function or method @a slot points to. You can - * pass additional arguments using sigc::bind(). If the thread was created - * successfully, it is returned, otherwise a Threads::ThreadError exception is thrown. - * - * Because sigc::trackable is not thread-safe, if the slot represents a - * non-static class method and is created by sigc::mem_fun(), the class concerned - * should not derive from sigc::trackable. You can use, say, boost::bind() or, - * in C++11, std::bind() or a C++11 lambda expression instead of sigc::mem_fun(). - * - * The @a name can be useful for discriminating threads in a debugger. - * It is not used for other purposes and does not have to be unique. - * Some systems restrict the length of @a name to 16 bytes. - * - * @param slot A slot to execute in the new thread. - * @param name A name for the new thread. - * @return The new Thread* on success. - * @throw Glib::Threads::ThreadError - * - * @newin{2,36} - */ - static Thread* create(const sigc::slot& slot, const std::string& name); - - /** Returns the Thread* corresponding to the calling thread. - * @return The current thread. - */ - static Thread* self(); - - /** Waits until the thread finishes. - * Waits until the thread finishes, i.e. the slot, as given to create(), - * returns or g_thread_exit() is called by the thread. (Calling - * g_thread_exit() in a C++ program should be avoided.) All resources of - * the thread including the Glib::Threads::Thread object are released. - */ - void join(); - - /** Gives way to other threads waiting to be scheduled. - * This function is often used as a method to make busy wait less evil. But - * in most cases, you will encounter, there are better methods to do that. - * So in general you shouldn't use this function. - */ - static void yield(); - - GThread* gobj(); - const GThread* gobj() const; - -private: - // Glib::Thread can neither be constructed nor deleted. - Thread(); - void operator delete(void*, std::size_t); -}; - -/** %Exception class used to exit from a thread. - * @code - * throw Glib::Threads::Thread::Exit(); - * @endcode - * Write this if you want to exit from a thread created by Threads::Thread::create(). - * Of course you must make sure not to catch Threads::Thread::Exit by accident, i.e. - * when using catch(...) somewhere in your code. - * - * @deprecated Please use std::thread instead. - */ -class Thread::Exit -{}; - -/** A C++ wrapper for the C object. - * - * @param gobject The C instance. - * @return The C++ wrapper. - * - * @relates Glib::Threads::Thread - * - * @deprecated Please use std::thread instead. - */ -Thread* wrap(GThread* gobject); - -/** Represents a mutex (mutual exclusion). - * It can be used to protect data against shared access. Try to use - * Mutex::Lock instead of calling lock() and unlock() directly -- - * it will make your life much easier. - * - * @note Glib::Threads::Mutex is not recursive, i.e. a thread will deadlock, if it - * already has locked the mutex while calling lock(). Use Glib::Threads::RecMutex - * instead, if you need recursive mutexes. - * - * @deprecated Please use std::mutex instead. - */ -class Mutex -{ -public: - class Lock; - - Mutex(); - - Mutex(const Mutex&) = delete; - Mutex& operator=(const Mutex&) = delete; - - ~Mutex(); - - /** Locks the mutex. - * If mutex is already locked by another thread, the current thread will - * block until mutex is unlocked by the other thread. - * @see Mutex::Lock - */ - void lock(); - - /** Tries to lock the mutex. - * If the mutex is already locked by another thread, it immediately returns - * @c false. Otherwise it locks the mutex and returns @c true. - * @return Whether the mutex could be locked. - * @see Mutex::Lock - */ - bool trylock(); - - /** Unlocks the mutex. - * If another thread is blocked in a lock() call for this mutex, it will be - * woken and can lock the mutex itself. - * @see Mutex::Lock - */ - void unlock(); - - GMutex* gobj() { return &gobject_; } - -private: - GMutex gobject_; -}; - -/** Utility class for exception-safe mutex locking. - * @par Usage example: - * @code - * { - * Glib::Threads::Mutex::Lock lock(mutex); // calls mutex.lock() - * do_something(); - * } // the destructor calls mutex.unlock() - * @endcode - * As you can see, the compiler takes care of the unlocking. This is not - * only exception-safe but also much less error-prone. You could even - * return while still holding the lock and it will be released - * properly. - * - * @deprecated Please use std::lock_guard or std::unique_lock instead. - */ -class Mutex::Lock -{ -public: - explicit inline Lock(Mutex& mutex); - inline Lock(Mutex& mutex, NotLock); - inline Lock(Mutex& mutex, TryLock); - - Lock(const Mutex::Lock&) = delete; - Mutex::Lock& operator=(const Mutex::Lock&) = delete; - - inline ~Lock(); - - inline void acquire(); - inline bool try_acquire(); - inline void release(); - inline bool locked() const; - -private: - Mutex& mutex_; - bool locked_; -}; - -/** 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); - -/** This represents a recursive mutex. - * It is similar to a Mutex with the difference - * that it is possible to lock a RecMutex multiple times in the same - * thread without deadlock. When doing so, care has to be taken to - * unlock the recursive mutex as often as it has been locked. - * - * @deprecated Please use std::recursive_mutex instead. - */ -class RecMutex -{ -public: - class Lock; - - RecMutex(); - - RecMutex(const RecMutex&) = delete; - RecMutex& operator=(const RecMutex&) = delete; - - ~RecMutex(); - - void lock(); - bool trylock(); - void unlock(); - - GRecMutex* gobj() { return &gobject_; } - -private: - GRecMutex gobject_; -}; - -/** Utility class for exception-safe locking of recursive mutexes. - * - * @deprecated Please use std::lock_guard or std::unique_lock instead. - */ -class RecMutex::Lock -{ -public: - explicit inline Lock(RecMutex& mutex); - inline Lock(RecMutex& mutex, NotLock); - inline Lock(RecMutex& mutex, TryLock); - - Lock(const RecMutex::Lock&) = delete; - RecMutex::Lock& operator=(const RecMutex::Lock&) = delete; - - inline ~Lock(); - - inline void acquire(); - inline bool try_acquire(); - inline void release(); - inline bool locked() const; - -private: - RecMutex& mutex_; - bool locked_; -}; - -/** 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); - -/** This represents a reader-writer lock. - * It is similar to a Mutex in that it allows - * multiple threads to coordinate access to a shared resource. - * - * The difference to a mutex is that a reader-writer lock discriminates - * between read-only ('reader') and full ('writer') access. While only - * one thread at a time is allowed write access (by holding the 'writer' - * lock via writer_lock()), multiple threads can gain - * simultaneous read-only access (by holding the 'reader' lock via - * reader_lock()). - * - * @deprecated Please use std::lock_guard or std::unique_lock instead, with std::shared_timed_mutex. - */ -class RWLock -{ -public: - class ReaderLock; - class WriterLock; - - RWLock(); - - RWLock(const RWLock&) = delete; - RWLock& operator=(const RWLock&) = delete; - - ~RWLock(); - - void reader_lock(); - bool reader_trylock(); - void reader_unlock(); - - void writer_lock(); - bool writer_trylock(); - void writer_unlock(); - - GRWLock* gobj() { return &gobject_; } - -private: - GRWLock gobject_; -}; - -/** Utility class for exception-safe locking of read/write locks. - * - * @deprecated Please use std::lock_guard or std::unique_lock instead, with std::shared_timed_mutex. - */ -class RWLock::ReaderLock -{ -public: - explicit inline ReaderLock(RWLock& rwlock); - inline ReaderLock(RWLock& rwlock, NotLock); - inline ReaderLock(RWLock& rwlock, TryLock); - - ReaderLock(const RWLock::ReaderLock&) = delete; - RWLock::ReaderLock& operator=(const RWLock::ReaderLock&) = delete; - - inline ~ReaderLock(); - - inline void acquire(); - inline bool try_acquire(); - inline void release(); - inline bool locked() const; - -private: - RWLock& rwlock_; - bool locked_; -}; - -/** Utility class for exception-safe locking of read/write locks. - * - * @deprecated Please use std::lock_guard or std::unique_lock instead, with std::shared_timed_mutex. - */ -class RWLock::WriterLock -{ -public: - explicit inline WriterLock(RWLock& rwlock); - inline WriterLock(RWLock& rwlock, NotLock); - inline WriterLock(RWLock& rwlock, TryLock); - - WriterLock(const RWLock::WriterLock&) = delete; - RWLock::WriterLock& operator=(const RWLock::WriterLock&) = delete; - - inline ~WriterLock(); - - inline void acquire(); - inline bool try_acquire(); - inline void release(); - inline bool locked() const; - -private: - RWLock& rwlock_; - bool locked_; -}; - -/** An opaque data structure to represent a condition. - * A @a Cond is an object that threads can block on, if they find a certain - * condition to be false. If other threads change the state of this condition - * they can signal the @a Cond, such that the waiting thread is woken up. - * - * @deprecated Please use std::condition_variable instead. - * - * @par Usage example: - * @code - * Glib::Threads::Cond data_cond; - * Glib::Threads::Mutex data_mutex; - * void* current_data = nullptr; - * - * void push_data(void* data) - * { - * Glib::Threads::Mutex::Lock lock(data_mutex); - * - * current_data = data; - * data_cond.signal(); - * } - * - * void* pop_data() - * { - * Glib::Threads::Mutex::Lock lock(data_mutex); - * - * while (!current_data) - * data_cond.wait(data_mutex); - * - * void* const data = current_data; - * current_data = nullptr; - * - * return data; - * } - * @endcode - */ -class Cond -{ -public: - Cond(); - - Cond(const Cond&) = delete; - Cond& operator=(const Cond&) = delete; - - ~Cond(); - - /** If threads are waiting for this @a Cond, exactly one of them is woken up. - * It is good practice to hold the same lock as the waiting thread, while calling - * this method, though not required. - */ - void signal(); - - /** If threads are waiting for this @a Cond, all of them are woken up. - * It is good practice to hold the same lock as the waiting threads, while calling - * this method, though not required. - */ - void broadcast(); - - /** Waits until this thread is woken up on this @a Cond. - * The mutex is unlocked before falling asleep and locked again before resuming. - * - * @param mutex A @a Mutex that is currently locked. - * - * @note It is important to use the @a wait() and @a wait_until() methods - * only inside a loop, which checks for the condition to be true as it is not - * guaranteed that the waiting thread will find it fulfilled, even if the signaling - * thread left the condition in that state. This is because another thread can have - * altered the condition, before the waiting thread got the chance to be woken up, - * even if the condition itself is protected by a @a Mutex. - */ - void wait(Mutex& mutex); - - /** Waits until this thread is woken up on this @a Cond, but not longer - * than until the time specified by @a end_time. - * The mutex is unlocked before falling asleep and locked again before resuming. - * - * @par Usage example: - * Extending the example presented in the documentation of class Cond. - * @code - * void* pop_data_timed() - * { - * Glib::Threads::Mutex::Lock lock(data_mutex); - * - * // Wait at most 5 seconds. - * const gint64 end_time = g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND; - * while (!current_data) - * if (!data_cond.wait_until(data_mutex, end_time) - * return nullptr; // timeout - * - * void* const data = current_data; - * current_data = nullptr; - * - * return data; - * } - * @endcode - * The end time is calculated once, before entering the loop, and reused. - * This is the motivation behind the use of absolute time. If a relative time - * of 5 seconds were passed directly to the call and a spurious wakeup - * occurred, the program would have to start over waiting again, which would - * lead to a total wait time of more than 5 seconds. - * - * @param mutex A @a Mutex that is currently locked. - * @param end_time The monotonic time to wait until, in microseconds. - * See g_get_monotonic_time(). - * @return true if the condition variable was signalled (or in the case - * of a spurious wakeup), false if @a end_time has passed. - * - * @note It is important to use the @a wait() and @a wait_until() methods - * only inside a loop, which checks for the condition to be true as it is not - * guaranteed that the waiting thread will find it fulfilled, even if the signaling - * thread left the condition in that state. This is because another thread can have - * altered the condition, before the waiting thread got the chance to be woken up, - * even if the condition itself is protected by a @a Mutex. - */ - bool wait_until(Mutex& mutex, gint64 end_time); - - GCond* gobj() { return &gobject_; } - -private: - GCond gobject_; -}; - -/** Thread-local data pointer. - * - * It is recommended that all instances of this class are statically allocated. - * The first time an instance is used (get(), set() or replace() is called) - * glib allocates a scarce OS resource that cannot be deallocated. - * - * @deprecated Please use the thread_local keyword instead. - */ -template -class Private -{ -public: - Private(const Private&) = delete; - Private& operator=(const Private&) = delete; - - using DestructorFunc = void (*) (void*); - - /** Deletes static_cast(data) - */ - static void delete_ptr(void* data); - - /** Constructor. - * - * @param destructor_func Function pointer, or nullptr. If @a destructor_func is not nullptr - * and the stored data pointer is not nullptr, this function is called when replace() - * is called and when the thread exits. - */ - explicit inline Private(DestructorFunc destructor_func = &Private::delete_ptr); - - /** Gets the pointer stored in the calling thread. - * - * @return If no value has yet been set in this thread, nullptr is returned. - */ - inline T* get(); - - /** Sets the pointer in the calling thread without calling destructor_func(). - */ - inline void set(T* data); - - /** Sets the pointer in the calling thread and calls destructor_func(). - * If a function pointer (and not nullptr) was specified in the constructor, and - * the stored data pointer before the call to replace() is not nullptr, then - * destructor_func() is called with this old pointer value. - * - * @newin{2,32} - */ - inline void replace(T* data); - - GPrivate* gobj() { return gobject_; } - -private: - GPrivate gobject_; -}; - -/** @} group Threads */ - -/*! A glibmm thread example. - * @example thread/thread.cc - */ - - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -/***************************************************************************/ -/* inline implementation */ -/***************************************************************************/ - -/**** Glib::Threads::Mutex::Lock *******************************************/ - -inline -Mutex::Lock::Lock(Mutex& mutex) -: - mutex_ (mutex), - locked_ (true) -{ - mutex_.lock(); -} - -inline -Mutex::Lock::Lock(Mutex& mutex, NotLock) -: - mutex_ (mutex), - locked_ (false) -{} - -inline -Mutex::Lock::Lock(Mutex& mutex, TryLock) -: - mutex_ (mutex), - locked_ (mutex.trylock()) -{} - -inline -Mutex::Lock::~Lock() -{ - if(locked_) - mutex_.unlock(); -} - -inline -void Mutex::Lock::acquire() -{ - mutex_.lock(); - locked_ = true; -} - -inline -bool Mutex::Lock::try_acquire() -{ - locked_ = mutex_.trylock(); - return locked_; -} - -inline -void Mutex::Lock::release() -{ - mutex_.unlock(); - locked_ = false; -} - -inline -bool Mutex::Lock::locked() const -{ - return locked_; -} - - -/**** Glib::Threads::RecMutex::Lock ****************************************/ - -inline -RecMutex::Lock::Lock(RecMutex& mutex) -: - mutex_ (mutex), - locked_ (true) -{ - mutex_.lock(); -} - -inline -RecMutex::Lock::Lock(RecMutex& mutex, NotLock) -: - mutex_ (mutex), - locked_ (false) -{} - -inline -RecMutex::Lock::Lock(RecMutex& mutex, TryLock) -: - mutex_ (mutex), - locked_ (mutex.trylock()) -{} - -inline -RecMutex::Lock::~Lock() -{ - if(locked_) - mutex_.unlock(); -} - -inline -void RecMutex::Lock::acquire() -{ - mutex_.lock(); - locked_ = true; -} - -inline -bool RecMutex::Lock::try_acquire() -{ - locked_ = mutex_.trylock(); - return locked_; -} - -inline -void RecMutex::Lock::release() -{ - mutex_.unlock(); - locked_ = false; -} - -inline -bool RecMutex::Lock::locked() const -{ - return locked_; -} - - -/**** Glib::Threads::RWLock::ReaderLock ************************************/ - -inline -RWLock::ReaderLock::ReaderLock(RWLock& rwlock) -: - rwlock_ (rwlock), - locked_ (true) -{ - rwlock_.reader_lock(); -} - -inline -RWLock::ReaderLock::ReaderLock(RWLock& rwlock, NotLock) -: - rwlock_ (rwlock), - locked_ (false) -{} - -inline -RWLock::ReaderLock::ReaderLock(RWLock& rwlock, TryLock) -: - rwlock_ (rwlock), - locked_ (rwlock.reader_trylock()) -{} - -inline -RWLock::ReaderLock::~ReaderLock() -{ - if(locked_) - rwlock_.reader_unlock(); -} - -inline -void RWLock::ReaderLock::acquire() -{ - rwlock_.reader_lock(); - locked_ = true; -} - -inline -bool RWLock::ReaderLock::try_acquire() -{ - locked_ = rwlock_.reader_trylock(); - return locked_; -} - -inline -void RWLock::ReaderLock::release() -{ - rwlock_.reader_unlock(); - locked_ = false; -} - -inline -bool RWLock::ReaderLock::locked() const -{ - return locked_; -} - - -/**** Glib::Threads::RWLock::WriterLock ************************************/ - -inline -RWLock::WriterLock::WriterLock(RWLock& rwlock) -: - rwlock_ (rwlock), - locked_ (true) -{ - rwlock_.writer_lock(); -} - -inline -RWLock::WriterLock::WriterLock(RWLock& rwlock, NotLock) -: - rwlock_ (rwlock), - locked_ (false) -{} - -inline -RWLock::WriterLock::WriterLock(RWLock& rwlock, TryLock) -: - rwlock_ (rwlock), - locked_ (rwlock.writer_trylock()) -{} - -inline -RWLock::WriterLock::~WriterLock() -{ - if(locked_) - rwlock_.writer_unlock(); -} - -inline -void RWLock::WriterLock::acquire() -{ - rwlock_.writer_lock(); - locked_ = true; -} - -inline -bool RWLock::WriterLock::try_acquire() -{ - locked_ = rwlock_.writer_trylock(); - return locked_; -} - -inline -void RWLock::WriterLock::release() -{ - rwlock_.writer_unlock(); - locked_ = false; -} - -inline -bool RWLock::WriterLock::locked() const -{ - return locked_; -} - -/**** Glib::Threads::Private ********************************************/ - -// static -template -void Private::delete_ptr(void* data) -{ - delete static_cast(data); -} - -template inline -Private::Private(typename Private::DestructorFunc destructor_func) -{ - // gobject_ = G_PRIVATE_INIT(destructor_func); - // does not compile with --enable-warnings=fatal. - // GPrivate is a struct, and G_PRIVATE_INIT is an initializer of type { ... }. - // G_PRIVATE_INIT can be used only in initializations. - const GPrivate temp = G_PRIVATE_INIT(destructor_func); - gobject_ = temp; -} - -template inline -T* Private::get() -{ - return static_cast(g_private_get(&gobject_)); -} - -template inline -void Private::set(T* data) -{ - g_private_set(&gobject_, data); -} - -template inline -void Private::replace(T* data) -{ - g_private_replace(&gobject_, data); -} - -#endif /* DOXYGEN_SHOULD_SKIP_THIS */ - -} //namespace Threads - -} // namespace Glib diff --git a/glib/src/valuearray.ccg b/glib/src/valuearray.ccg deleted file mode 100644 index e50323f..0000000 --- a/glib/src/valuearray.ccg +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (C) 2002-2009 The gtkmm 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 - -static int -ValueArray_Compare_glibmm_callback(gconstpointer a, gconstpointer b, gpointer user_data) -{ - Glib::ValueArray::SlotCompare* the_slot = static_cast(user_data); - - try - { - return (*the_slot)( - *reinterpret_cast(a), *reinterpret_cast(b)); - } - catch (...) - { - Glib::exception_handlers_invoke(); - } - - return 0; -} - -namespace Glib -{ - -ValueArray::ValueArray() : gobject_(g_value_array_new(0)) -{ -} - -ValueArray::ValueArray(guint n_preallocated) : gobject_(g_value_array_new(n_preallocated)) -{ -} - -bool -ValueArray::get_nth(guint index, Glib::ValueBase& value) -{ - const auto g_value = g_value_array_get_nth(gobj(), index); - - if (g_value) - { - value.init(g_value); - return true; - } - else - return false; -} - -Glib::ValueArray& -ValueArray::append(const Glib::ValueBase& value) -{ - g_value_array_append(gobj(), value.gobj()); - return *this; -} - -Glib::ValueArray& -ValueArray::prepend(const Glib::ValueBase& value) -{ - g_value_array_prepend(gobj(), value.gobj()); - return *this; -} - -Glib::ValueArray& -ValueArray::insert(guint index, const Glib::ValueBase& value) -{ - g_value_array_insert(gobj(), index, value.gobj()); - return *this; -} - -Glib::ValueArray& -ValueArray::remove(guint index) -{ - g_value_array_remove(gobj(), index); - return *this; -} - -Glib::ValueArray& -ValueArray::sort(const SlotCompare& compare_func) -{ - SlotCompare slot_copy(compare_func); - g_value_array_sort_with_data(gobj(), &ValueArray_Compare_glibmm_callback, &slot_copy); - return *this; -} - -} // Glib namespace diff --git a/glib/src/valuearray.hg b/glib/src/valuearray.hg deleted file mode 100644 index c1b5638..0000000 --- a/glib/src/valuearray.hg +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (C) 2002-2009 The gtkmm 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. - */ - -_CONFIGINCLUDE(glibmmconfig.h) - -_DEFS(glibmm,glib) - -#include -#include -#include - -#m4 _PUSH(SECTION_CC_PRE_INCLUDES) -#undef G_DISABLE_DEPRECATED -#define GLIB_DISABLE_DEPRECATION_WARNINGS 1 -#m4 _POP() - -_IS_DEPRECATED // This whole file is deprecated. - -namespace Glib -{ - -/** A container structure to maintain an array of generic values. - * The prime purpose of a ValueArray is for it to be used as an object property - * that holds an array of values. A ValueArray wraps an array of ValueBase - * elements. - * - * @newin{2,22} - * - * @deprecated Use std::vector or std::vector< Glib::Value<> > - * instead of Glib::ValueArray. - */ -class ValueArray -{ - _CLASS_BOXEDTYPE(ValueArray, GValueArray, NONE, g_value_array_copy, g_value_array_free) - _IGNORE(g_value_array_copy, g_value_array_free) - _CUSTOM_DEFAULT_CTOR - -public: - /** For example, - * int on_compare(const Glib::ValueBase& v1, const Glib::ValueBase& v2);. - * The compare function should return -1 if v1 < v2, 0 if v1 == v2, and 1 if - * v1 > v2. - */ - using SlotCompare = sigc::slot; - - /** Default constructor. Constructs a new array with no pre-allocation. - */ - ValueArray(); - - /** Constructs a new array with pre-allocation. - */ - ValueArray(guint n_preallocated); - - /** Return the value at @a index contained in the value array. - * @param index Index of the value of interest. - * @param value An uninitialized ValueBase in which to store the result. If - * the get is successful, @a value will be valid, otherwise it will remain - * uninitialized. - * @return whether the get was successful or not. - */ - bool get_nth(guint index, Glib::ValueBase& value); - _IGNORE(g_value_array_get_nth) - - _WRAP_METHOD_DOCS_ONLY(g_value_array_append) - Glib::ValueArray& append(const Glib::ValueBase& value); - - _WRAP_METHOD_DOCS_ONLY(g_value_array_prepend) - Glib::ValueArray& prepend(const Glib::ValueBase& value); - - _WRAP_METHOD_DOCS_ONLY(g_value_array_insert) - Glib::ValueArray& insert(guint index, const Glib::ValueBase& value); - - _WRAP_METHOD_DOCS_ONLY(g_value_array_remove) - Glib::ValueArray& remove(guint index); - - _WRAP_METHOD_DOCS_ONLY(g_value_array_sort) - Glib::ValueArray& sort(const SlotCompare& compare_func); - _IGNORE(g_value_array_sort_with_data) -}; - -} //namespace Glib diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg index 9c47dea..37576c0 100644 --- a/glib/src/variant.ccg +++ b/glib/src/variant.ccg @@ -28,10 +28,13 @@ 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; @@ -155,7 +158,9 @@ VariantContainerBase::create_tuple(const std::vector& children) var_ptr* const var_array = new var_ptr[children.size()]; for (std::vector::size_type i = 0; i < children.size(); i++) + { var_array[i] = const_cast(children[i].gobj()); + } VariantContainerBase result = VariantContainerBase(g_variant_new_tuple(var_array, children.size())); @@ -194,11 +199,12 @@ VariantContainerBase::get_child(VariantBase& child, gsize index) const // VariantContainerBase has no method variant_type() template <> VariantContainerBase -VariantBase::cast_dynamic(const VariantBase& v) noexcept(false) +VariantBase::cast_dynamic(const VariantBase& v) throw(std::bad_cast) { if (!v.gobj()) + { return VariantContainerBase(); - + } if (v.get_type().is_container()) { return VariantContainerBase(const_cast(v.gobj()), true); @@ -221,9 +227,7 @@ VariantContainerBase::get_maybe(VariantBase& maybe) const return true; } else - { return false; - } } VariantIter @@ -245,13 +249,6 @@ VariantContainerBase::get_iter(const VariantType& container_variant_type) const /****************** Specializations ***********************************/ -_DEPRECATE_IFDEF_START -VariantBase::operator const void*() const -{ - return gobj() ? GINT_TO_POINTER(1) : nullptr; -} -_DEPRECATE_IFDEF_END - VariantBase::operator bool() const { return gobj() ? GINT_TO_POINTER(1) : nullptr; @@ -335,7 +332,7 @@ Variant::get() const // See http://library.gnome.org/devel/glib/unstable/glib-GVariant.html#g-variant-get-string template <> Variant -VariantBase::cast_dynamic>(const VariantBase& v) noexcept(false) +VariantBase::cast_dynamic>(const VariantBase& v) throw(std::bad_cast) { if (!v.gobj()) { @@ -384,7 +381,7 @@ Variant::create(const std::string& data) // See http://library.gnome.org/devel/glib/unstable/glib-GVariant.html#g-variant-get-string template <> Variant -VariantBase::cast_dynamic>(const VariantBase& v) noexcept(false) +VariantBase::cast_dynamic>(const VariantBase& v) throw(std::bad_cast) { if (!v.gobj()) { @@ -452,7 +449,9 @@ Variant::create(const type_vec_ustring& data) // Add the elements of the vector into the builder. for (const auto& str : data) + { g_variant_builder_add(builder, element_variant_type.get_string().c_str(), str.c_str()); + } // Create the variant using the builder. auto result = @@ -487,6 +486,7 @@ Variant::get() const for (gsize i = 0; i < n_children; i++) { GVariant* gvariant = g_variant_get_child_value(const_cast(gobj()), i); + result.emplace_back(Glib::Variant(gvariant).get()); } @@ -527,7 +527,9 @@ Variant::create(const type_vec_string& data) // Add the elements of the vector into the string array. for (type_vec_string::size_type i = 0; i < data.size(); i++) + { str_array[i] = g_strdup(data[i].c_str()); + } // Terminate the string array. str_array[data.size()] = nullptr; @@ -548,7 +550,9 @@ Variant::create_from_object_paths(const type_vec_string& data) // Add the elements of the vector into the string array. for (type_vec_string::size_type i = 0; i < data.size(); i++) + { str_array[i] = g_strdup(data[i].c_str()); + } // Terminate the string array. str_array[data.size()] = nullptr; @@ -586,6 +590,7 @@ Variant::get() const for (gsize i = 0; i < n_children; i++) { GVariant* gvariant = g_variant_get_child_value(const_cast(gobj()), i); + result.emplace_back(Glib::Variant(gvariant).get()); } diff --git a/glib/src/variant.hg b/glib/src/variant.hg index de10195..7749a34 100644 --- a/glib/src/variant.hg +++ b/glib/src/variant.hg @@ -95,29 +95,6 @@ class VariantBase g_variant_get, g_variant_get_va) public: -_DEPRECATE_IFDEF_START - /** This typedef is just to make it more obvious that - * our operator const void* should be used like operator bool(). - * - * @deprecated Use the explicit operator bool() instead. - */ - using BoolExpr = const void*; - - /** Test whether the Variant has an underlying instance. - * - * Mimics usage of pointers: - * @code - * if (variant) - * do_something(); - * @endcode - * - * @deprecated Use the explicit operator bool() instead. - * - * @newin{2,36} - */ - operator BoolExpr() const; -_DEPRECATE_IFDEF_END - /** Test whether the Variant has an underlying instance. * * @newin{2,50} @@ -146,7 +123,6 @@ _DEPRECATE_IFDEF_END _WRAP_METHOD(GVariantClass classify() const, g_variant_classify) _WRAP_METHOD(gsize get_size() const, g_variant_get_size) - _WRAP_METHOD(gconstpointer get_data(), g_variant_get_data, deprecated "Use the const version instead.") _WRAP_METHOD(gconstpointer get_data() const, g_variant_get_data, newin "2,46") _WRAP_METHOD(Glib::RefPtr get_data_as_bytes() const, g_variant_get_data_as_bytes, newin "2,46") _WRAP_METHOD(void store(gpointer data) const, g_variant_store) @@ -225,7 +201,7 @@ _DEPRECATE_IFDEF_END * @throws std::bad_cast if the Variant was not of the expected type. */ template - static V_CastTo cast_dynamic(const VariantBase& v) noexcept(false); + static V_CastTo cast_dynamic(const VariantBase& v) throw(std::bad_cast); _IGNORE(g_variant_dict_new) @@ -271,7 +247,7 @@ private: template V_CastTo VariantBase::cast_dynamic(const VariantBase& v) -noexcept(false) +throw(std::bad_cast) { if(!(v.gobj())) { @@ -340,8 +316,8 @@ public: _WRAP_METHOD(static bool is_signature(const std::string& string), g_variant_is_signature) }; -/** The base class for multiple-item Variants, such as Variants containing - * tuples or arrays, and also for maybe-typed (i.e. nullable) Variant types. +/** The base class from which multiple-item Variants derive, such as Variants + * containing tuples or arrays. * * @newin{2,28} * @ingroup Variant @@ -411,12 +387,11 @@ public: DataType get_child(gsize index = 0) const; */ - /** If this is a maybe-typed instance, try to extract its value. If there is - * no value (the value is nothing), return falsetrue is returned. + /** If this is a maybe-typed instance, extract its value. If the value is + * Nothing, then this function returns false. * - * @param maybe A place in which to return the value, if it isn’t - * nothing. + * @param maybe A place in which to return the value (the value may be + * 0). * @newin{2,28} */ bool get_maybe(VariantBase& maybe) const; @@ -433,7 +408,7 @@ protected: template<> VariantContainerBase VariantBase::cast_dynamic(const VariantBase& v) -noexcept(false); +throw(std::bad_cast); /** Template class used for the specialization of the Variant<> classes. * @newin{2,28} @@ -449,9 +424,6 @@ public: /****************** Specializations ***********************************/ /** Specialization of Variant containing a VariantBase. - * Perhaps the main use of this is as a maybe-typed (i.e. nullable) Variant, as - * it inherits methods create_maybe() and get_maybe() from VariantContainerBase. - * * @newin{2,28} * @ingroup Variant */ @@ -594,7 +566,7 @@ public: //TODO: When we can break ABI, remove this template specialization. template<> Variant VariantBase::cast_dynamic< Variant >(const VariantBase& v) -noexcept(false); +throw(std::bad_cast); /** Specialization of Variant containing a std::string, for variants of type * bytestring, string, object path, or signature. @@ -643,7 +615,7 @@ public: //TODO: When we can break ABI, remove this template specialization. template<> Variant VariantBase::cast_dynamic< Variant >(const VariantBase& v) -noexcept(false); +throw(std::bad_cast); /** Specialization of Variant containing a dictionary entry. See also * Variant< std::map >. @@ -757,7 +729,7 @@ public: _IGNORE(g_variant_get_fixed_array) /** Gets a VariantIter of the Variant. - * @return the VariantIter. + * @return the VaraintIter. * @newin{2,28} */ VariantIter get_iter() const; @@ -821,7 +793,7 @@ public: _IGNORE(g_variant_get_strv, g_variant_dup_strv) /** Gets a VariantIter of the Variant. - * @return the VariantIter. + * @return the VaraintIter. * @newin{2,28} */ VariantIter get_iter() const; @@ -897,7 +869,7 @@ public: _IGNORE(g_variant_get_objv, g_variant_dup_objv) /** Gets a VariantIter of the Variant. - * @return the VariantIter. + * @return the VaraintIter. * @newin{2,28} */ VariantIter get_iter() const; @@ -972,7 +944,7 @@ public: std::map get() const; /** Gets a VariantIter of the Variant. - * @return the VariantIter. + * @return the VaraintIter. * @newin{2,28} */ VariantIter get_iter() const; diff --git a/tests/Makefile.am b/tests/Makefile.am index 2cb35ab..bbe85ae 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -22,6 +22,7 @@ check_PROGRAMS = \ giomm_ioerror_and_iodbuserror/test \ giomm_memoryinputstream/test \ giomm_simple/test \ + giomm_stream_vfuncs/test \ giomm_asyncresult_sourceobject/test \ giomm_tls_client/test \ giomm_listmodel/test \ @@ -38,7 +39,6 @@ check_PROGRAMS = \ glibmm_ustring_compose/test \ glibmm_ustring_format/test \ glibmm_value/test \ - glibmm_valuearray/test \ glibmm_variant/test \ glibmm_vector/test \ glibmm_bool_vector/test \ @@ -56,8 +56,9 @@ glibmm_includes = -I$(top_builddir)/glib $(if $(srcdir:.=),-I$(top_srcdir)/glib) giomm_includes = -I$(top_builddir)/gio $(if $(srcdir:.=),-I$(top_srcdir)/gio) local_cppflags = -I$(top_builddir) $(glibmm_includes) $(giomm_includes) +cxxflags_disable_deprecated = $(GLIBMM_WXXFLAGS) -DGLIBMM_DISABLE_DEPRECATED -DGIOMM_DISABLE_DEPRECATED AM_CPPFLAGS = $(local_cppflags) $(GIOMM_CFLAGS) -AM_CXXFLAGS = $(GLIBMM_WXXFLAGS) -DGLIBMM_DISABLE_DEPRECATED -DGIOMM_DISABLE_DEPRECATED +AM_CXXFLAGS = $(GLIBMM_WXXFLAGS) $(cxxflags_disable_deprecated) local_libglibmm = $(top_builddir)/glib/glibmm/libglibmm-$(GLIBMM_API_VERSION).la @@ -78,6 +79,9 @@ giomm_memoryinputstream_test_LDADD = $(giomm_ldadd) giomm_simple_test_SOURCES = giomm_simple/main.cc giomm_simple_test_LDADD = $(giomm_ldadd) +giomm_stream_vfuncs_test_SOURCES = giomm_stream_vfuncs/main.cc +giomm_stream_vfuncs_test_LDADD = $(giomm_ldadd) + giomm_asyncresult_sourceobject_test_SOURCES = giomm_asyncresult_sourceobject/main.cc giomm_asyncresult_sourceobject_test_LDADD = $(giomm_ldadd) @@ -96,6 +100,8 @@ glibmm_interface_implementation_test_SOURCES = glibmm_interface_implementation/m glibmm_interface_implementation_test_LDADD = $(giomm_ldadd) glibmm_interface_move_test_SOURCES = glibmm_interface_move/main.cc +glibmm_interface_move_test_CXXFLAGS = $(GLIBMM_INTERFACE_TEST_WXXFLAGS) $(cxxflags_disable_deprecated) + glibmm_mainloop_test_SOURCES = glibmm_mainloop/main.cc glibmm_nodetree_test_SOURCES = glibmm_nodetree/main.cc glibmm_object_move_test_SOURCES = glibmm_object_move/main.cc @@ -103,7 +109,6 @@ glibmm_objectbase_move_test_SOURCES = glibmm_objectbase_move/main.cc glibmm_ustring_compose_test_SOURCES = glibmm_ustring_compose/main.cc glibmm_ustring_format_test_SOURCES = glibmm_ustring_format/main.cc glibmm_value_test_SOURCES = glibmm_value/glibmm_value.cc glibmm_value/main.cc -glibmm_valuearray_test_SOURCES = glibmm_valuearray/main.cc glibmm_variant_test_SOURCES = glibmm_variant/main.cc glibmm_vector_test_SOURCES = glibmm_vector/main.cc glibmm_vector_test_LDADD = $(giomm_ldadd) diff --git a/tests/giomm_stream_vfuncs/main.cc b/tests/giomm_stream_vfuncs/main.cc new file mode 100644 index 0000000..f70a1fa --- /dev/null +++ b/tests/giomm_stream_vfuncs/main.cc @@ -0,0 +1,170 @@ +/* Copyright (C) 2016 The giomm 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, see . + */ + +#include +#include +#include +#include + +// A simple custom stream that base64 encodes data. +// Do not copy it to your code, because it's very slow. +class Base64OutputStream : public Gio::FilterOutputStream +{ +public: + unsigned get_column_width() const { return column_width; } + void set_column_width(unsigned cw) { column_width = cw; } + static Glib::RefPtr create(const Glib::RefPtr& base_stream) + { + return Glib::RefPtr(new Base64OutputStream(base_stream)); + } + +protected: + Base64OutputStream(const Glib::RefPtr& base_stream) + : Gio::FilterOutputStream(base_stream), column(0), bit_count(0), bit_buffer(0), column_width(72) {} + + gssize write_vfunc(const void* buffer, gsize count, const Glib::RefPtr& cancellable) override + { + char const *byte = (char const *) buffer; + for (unsigned i = 0; i < count; ++i, ++byte) + { + // kindergarten implementation, because the object is not performance :) + bit_buffer <<= 8; + bit_buffer |= (*byte & 0xff); + bit_count += 8; + + if (bit_count == 24) + { + clear_pending(); // TODO why is this necessary to avoid an outstanding op. exception? + flush(cancellable); + set_pending(); + bit_count = 0; + } + + if (cancellable && cancellable->is_cancelled()) + throw Gio::Error(Gio::Error::CANCELLED, "Operation cancelled"); + } + return count; + } + + bool flush_vfunc(const Glib::RefPtr& cancellable) override + { + if (bit_count != 24) + return true; + char to_write[5]; + gsize len = 4; + + for (unsigned i=0; i<4; ++i) + { + unsigned index = (bit_buffer & (0x3f<<(i*6))) >> (i*6); + to_write[3-i] = base64_encode_str[index]; + } + column += 4; + // Yes, I know this is completely wrong. + if (column >= column_width) + { + column = 0; + to_write[4] = '\n'; + ++len; + } + + get_base_stream()->write(&to_write, len, cancellable); + + bit_count = 0; + bit_buffer = 0; + + return true; + } + + bool close_vfunc(const Glib::RefPtr& cancellable) override + { + char to_write[5] = "===="; + //get any last bytes (1 or 2) out of the buffer + switch (bit_count) + { + case 16: + bit_buffer <<= 2; //pad to make 18 bits + to_write[0] = base64_encode_str[(bit_buffer & (0x3f << 12)) >> 12]; + to_write[1] = base64_encode_str[(bit_buffer & (0x3f << 6)) >> 6]; + to_write[2] = base64_encode_str[bit_buffer & 0x3f]; + break; + + case 8: + bit_buffer <<= 4; //pad to make 12 bits + to_write[0] = base64_encode_str[(bit_buffer & (0x3f << 6)) >> 6]; + to_write[1] = base64_encode_str[bit_buffer & 0x3f]; + break; + } + + if (bit_count > 0) + { + get_base_stream()->write(&to_write, 5, cancellable); + } + else + { + // null terminate output + get_base_stream()->write("", 1, cancellable); + } + if (get_close_base_stream()) + get_base_stream()->close(cancellable); + + return true; + } + +private: + static char const *const base64_encode_str; + unsigned column; + unsigned bit_count; + unsigned bit_buffer; + unsigned column_width; +}; + +char const *const Base64OutputStream::base64_encode_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +int main(int, char**) +{ + Glib::init(); + Gio::init(); + + try + { + char result[256]; + Glib::RefPtr memory_chunk = Gio::MemoryOutputStream::create(result, 256, nullptr, nullptr); + Glib::RefPtr base64 = Base64OutputStream::create(memory_chunk); + + std::string data = "Custom GIO streams are cool!"; + + base64->set_close_base_stream(true); + base64->write(data); + base64->close(); + + const std::string base64_should_be("Q3VzdG9tIEdJTyBzdHJlYW1zIGFyZSBjb29sIQ=="); + std::cout << "Original data: " << data << std::endl; + std::cout << "base64-encoded data: " << result << std::endl; + std::cout << "base64 should be: " << base64_should_be << std::endl; + if (base64_should_be != result) + { + std::cout << "Not correct!" << std::endl; + return EXIT_FAILURE; + } + } + catch (Gio::Error e) + { + std::cout << "Gio error: " << e.what() << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/tests/glibmm_valuearray/main.cc b/tests/glibmm_valuearray/main.cc deleted file mode 100644 index b9fc12a..0000000 --- a/tests/glibmm_valuearray/main.cc +++ /dev/null @@ -1,102 +0,0 @@ -// Glib::ValueArray is deprecated, but let's keep the test. -// The recommended replacement is std::vector<> which requires no test here. -#undef GLIBMM_DISABLE_DEPRECATED - -#include -#include - -#ifdef GLIBMM_DISABLE_DEPRECATED -int -main(int, char**) -{ - // If glibmm is configured with --disable-deprecated-api, GLIBMM_DISABLE_DEPRECATED - // is defined in glibmm.h (actually in glibmmconfig.h). The undef at the start of - // this file has no effect. - return 77; // Tell automake's test harness to skip this test. -} - -#else - -// Use this line if you want debug output: -// std::ostream& ostr = std::cout; - -// This seems nicer and more useful than putting an ifdef around the use of ostr: -std::stringstream debug; -std::ostream& ostr = debug; - -int -on_compare(const Glib::ValueBase& v1, const Glib::ValueBase& v2) -{ - const Glib::Value& intVal1 = static_cast&>(v1); - const Glib::Value& intVal2 = static_cast&>(v2); - - int int1 = intVal1.get(); - int int2 = intVal2.get(); - - if (int1 < int2) - return -1; - else if (int1 == int2) - return EXIT_SUCCESS; - else - return 1; -} - -int -main(int, char**) -{ - const int VALUES_COUNT = 10; - - Glib::init(); - - Glib::Value values[VALUES_COUNT]; - Glib::ValueArray array; - - for (int i = 0; i < VALUES_COUNT; i++) - { - values[i].init(Glib::Value::value_type()); - values[i].set(i + 1); // (i + 1) ==> Set to natural counting numbers. - array.prepend(values[i]); - } - - ostr << "Array members before sorting:" << std::endl; - - for (int i = 0; i < VALUES_COUNT; i++) - { - Glib::ValueBase value; - - if (!array.get_nth(i, value)) - { - std::cerr << "Error getting element " << i << " of value array." << std::endl; - return EXIT_FAILURE; - break; - } - - auto int_val = static_cast&>(value); - ostr << int_val.get() << " "; - } - ostr << std::endl; // End of line for list of array elements. - - // Sort array and remove last element: - array.sort(sigc::ptr_fun(&on_compare)).remove(VALUES_COUNT - 1); - - ostr << "Array members after sorting without last element:" << std::endl; - - for (int i = 0; i < VALUES_COUNT - 1; i++) - { - Glib::ValueBase value; - - if (!array.get_nth(i, value)) - { - std::cerr << "Error getting element " << i << " of value array." << std::endl; - return EXIT_FAILURE; - break; - } - - auto int_val = static_cast&>(value); - ostr << int_val.get() << " "; - } - ostr << std::endl; // End of line for list of array elements. - - return EXIT_SUCCESS; -} -#endif // GLIBMM_DISABLE_DEPRECATED diff --git a/tools/Makefile.am b/tools/Makefile.am index af53de8..e0f6818 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -34,16 +34,16 @@ dist_noinst_DATA = README TODO dist_noinst_SCRIPTS = enum.pl noinst_PROGRAMS = extra_defs_gen/generate_defs_glib extra_defs_gen/generate_defs_gio -lib_LTLIBRARIES = extra_defs_gen/libglibmm_generate_extra_defs-2.4.la +lib_LTLIBRARIES = extra_defs_gen/libglibmm_generate_extra_defs-2.52.la extradefs_includedir = $(includedir)/$(GLIBMM_MODULE_NAME)/glibmm_generate_extra_defs extradefs_include_HEADERS = extra_defs_gen/generate_extra_defs.h extradefs_ldflags = -no-undefined -version-info $(LIBGLIBMM_SO_VERSION) -extra_defs_gen_libglibmm_generate_extra_defs_2_4_la_SOURCES = extra_defs_gen/generate_extra_defs.cc -extra_defs_gen_libglibmm_generate_extra_defs_2_4_la_LDFLAGS = $(extradefs_ldflags) -extra_defs_gen_libglibmm_generate_extra_defs_2_4_la_LIBADD = $(GLIBMM_LIBS) +extra_defs_gen_libglibmm_generate_extra_defs_2_52_la_SOURCES = extra_defs_gen/generate_extra_defs.cc +extra_defs_gen_libglibmm_generate_extra_defs_2_52_la_LDFLAGS = $(extradefs_ldflags) +extra_defs_gen_libglibmm_generate_extra_defs_2_52_la_LIBADD = $(GLIBMM_LIBS) extra_defs_gen_generate_defs_glib_SOURCES = extra_defs_gen/generate_defs_glib.cc extra_defs_gen_generate_defs_glib_LDADD = $(GLIBMM_LIBS) $(lib_LTLIBRARIES) diff --git a/tools/m4/signal.m4 b/tools/m4/signal.m4 index 5b680f4..d121b15 100644 --- a/tools/m4/signal.m4 +++ b/tools/m4/signal.m4 @@ -24,17 +24,17 @@ ifelse(`$9',,,`_DEPRECATE_IFDEF_START ')dnl ifelse($13,,`dnl no detail_name $10 - Glib::SignalProxy< $5`'_COMMA_PREFIX($6) > signal_$4`'(); + Glib::SignalProxy<$5`'($6)> signal_$4`'(); ',dnl detail_name $14,0,`dnl $10 - Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) > signal_$4`'(const Glib::ustring& $13 = Glib::ustring()); + Glib::SignalProxyDetailedAnyType<$5`'($6)> signal_$4`'(const Glib::ustring& $13 = Glib::ustring()); ',`dnl detail_name and two_signal_methods $10 - Glib::SignalProxy< $5`'_COMMA_PREFIX($6) > signal_$4`'(); + Glib::SignalProxy<$5`'($6)> signal_$4`'(); $10 - Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) > signal_$4`'(const Glib::ustring& $13); + Glib::SignalProxyDetailedAnyType<$5`'($6)> signal_$4`'(const Glib::ustring& $13); ')dnl end detail_name ifelse(`$9',,,`_DEPRECATE_IFDEF_END ')dnl @@ -65,7 +65,7 @@ ifelse($8,`1',,`dnl Do not generate the implementation if it should be custom: static $2 __CPPNAME__`'_signal_$4_callback`'(__CNAME__`'* self, _COMMA_SUFFIX($3)`'void* data) { using namespace __NAMESPACE__; - using SlotType = sigc::slot< $5`'_COMMA_PREFIX($6) >; + using SlotType = sigc::slot<$5`'($6)>; auto obj = dynamic_cast<__CPPNAME__*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self)); // Do not try to call a signal on a disassociated wrapper. @@ -107,7 +107,7 @@ ifelse($2,void,,`dnl else static $2 __CPPNAME__`'_signal_$4_notify_callback`'(__CNAME__`'* self, _COMMA_SUFFIX($3)`' void* data) { using namespace __NAMESPACE__; - using SlotType = sigc::slot< void`'_COMMA_PREFIX($6) >; + using SlotType = sigc::slot; auto obj = dynamic_cast<__CPPNAME__*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self)); // Do not try to call a signal on a disassociated wrapper. @@ -161,25 +161,25 @@ ifelse(`$11',,,`#ifdef $11' ifelse(`$9',,,`_DEPRECATE_IFDEF_START ')dnl ifelse($13,,`dnl no detail_name -Glib::SignalProxy< $5`'_COMMA_PREFIX($6) > __CPPNAME__::signal_$4`'() +Glib::SignalProxy<$5`'($6)> __CPPNAME__::signal_$4`'() { - return Glib::SignalProxy< $5`'_COMMA_PREFIX($6) >(this, &__CPPNAME__`'_signal_$4_info); + return Glib::SignalProxy<$5`'($6) >(this, &__CPPNAME__`'_signal_$4_info); } ',dnl detail_name $14,0,`dnl -Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) > __CPPNAME__::signal_$4`'(const Glib::ustring& $13) +Glib::SignalProxyDetailedAnyType<$5`'($6)> __CPPNAME__::signal_$4`'(const Glib::ustring& $13) { - return Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) >(this, &__CPPNAME__`'_signal_$4_info, $13); + return Glib::SignalProxyDetailedAnyType<$5`'($6)>(this, &__CPPNAME__`'_signal_$4_info, $13); } ',`dnl detail_name and two_signal_methods -Glib::SignalProxy< $5`'_COMMA_PREFIX($6) > __CPPNAME__::signal_$4`'() +Glib::SignalProxy<$5`'($6)> __CPPNAME__::signal_$4`'() { - return Glib::SignalProxy< $5`'_COMMA_PREFIX($6) >(this, &__CPPNAME__`'_signal_$4_info); + return Glib::SignalProxy<$5`'($6)>(this, &__CPPNAME__`'_signal_$4_info); } -Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) > __CPPNAME__::signal_$4`'(const Glib::ustring& $13) +Glib::SignalProxyDetailedAnyType<$5`'($6)> __CPPNAME__::signal_$4`'(const Glib::ustring& $13) { - return Glib::SignalProxyDetailedAnyType< $5`'_COMMA_PREFIX($6) >(this, &__CPPNAME__`'_signal_$4_info, $13); + return Glib::SignalProxyDetailedAnyType<$5`'($6)>(this, &__CPPNAME__`'_signal_$4_info, $13); } ')dnl end detail_name ifelse(`$9',,,`_DEPRECATE_IFDEF_END diff --git a/tools/test_scripts/testheaders.sh b/tools/test_scripts/testheaders.sh index 150ada4..1c9e274 100755 --- a/tools/test_scripts/testheaders.sh +++ b/tools/test_scripts/testheaders.sh @@ -5,9 +5,9 @@ # files that it depends on. # Example: In glibmm, go to directory glibmm, and run -# tools/test_scripts/testheaders.sh -I glib glibmm-2.4 gio # compile glibmm/gio/giomm/*.h -# tools/test_scripts/testheaders.sh glibmm-2.4 glib gio # compile glibmm/glib/glibmm/*.h and glibmm/gio/giomm/*.h -# tools/test_scripts/testheaders.sh -I glib -I gio glibmm-2.4 glib/glibmm/ustring.h # compile glibmm/glib/glibmm/ustring.h +# tools/test_scripts/testheaders.sh -I glib glibmm-2.52 gio # compile glibmm/gio/giomm/*.h +# tools/test_scripts/testheaders.sh glibmm-2.52 glib gio # compile glibmm/glib/glibmm/*.h and glibmm/gio/giomm/*.h +# tools/test_scripts/testheaders.sh -I glib -I gio glibmm-2.52 glib/glibmm/ustring.h # compile glibmm/glib/glibmm/ustring.h # Usage: testheaders.sh [-I]... [ | ]... # -I is added to the g++ command.