[glibmm] Run clang-format on glib .cc files.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Run clang-format on glib .cc files.
- Date: Sat, 27 Feb 2016 14:42:59 +0000 (UTC)
commit c720818cb538c7b31fd918bfd5e69db6428b4645
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Feb 26 20:48:51 2016 +0100
Run clang-format on glib .cc files.
glib/glibmm/arrayhandle.cc | 10 +-
glib/glibmm/base64.cc | 16 +-
glib/glibmm/class.cc | 105 ++--
glib/glibmm/containers.cc | 4 +-
glib/glibmm/debug.cc | 1 -
glib/glibmm/dispatcher.cc | 187 ++++----
glib/glibmm/error.cc | 83 ++--
glib/glibmm/exception.cc | 8 +-
glib/glibmm/exceptionhandler.cc | 50 +-
glib/glibmm/init.cc | 3 +-
glib/glibmm/interface.cc | 87 ++--
glib/glibmm/main.cc | 692 +++++++++++++-----------
glib/glibmm/object.cc | 166 +++---
glib/glibmm/objectbase.cc | 195 ++++---
glib/glibmm/pattern.cc | 27 +-
glib/glibmm/property.cc | 78 ++--
glib/glibmm/propertyproxy.cc | 1 -
glib/glibmm/propertyproxy_base.cc | 60 ++-
glib/glibmm/quark.cc | 41 +-
glib/glibmm/random.cc | 34 +-
glib/glibmm/sarray.cc | 1 -
glib/glibmm/signalproxy.cc | 88 ++--
glib/glibmm/signalproxy_connectionnode.cc | 54 +-
glib/glibmm/streamiochannel.cc | 79 ++--
glib/glibmm/stringutils.cc | 50 +-
glib/glibmm/threadpool.cc | 103 ++--
glib/glibmm/timer.cc | 27 +-
glib/glibmm/timeval.cc | 45 +-
glib/glibmm/ustring.cc | 824 ++++++++++++++++-------------
glib/glibmm/utility.cc | 9 +-
glib/glibmm/value.cc | 128 +++--
glib/glibmm/value_custom.cc | 51 +-
glib/glibmm/vectorutils.cc | 32 +-
glib/glibmm/wrap.cc | 85 ++--
34 files changed, 1833 insertions(+), 1591 deletions(-)
---
diff --git a/glib/glibmm/arrayhandle.cc b/glib/glibmm/arrayhandle.cc
index 95a67eb..0e798cc 100644
--- a/glib/glibmm/arrayhandle.cc
+++ b/glib/glibmm/arrayhandle.cc
@@ -20,15 +20,15 @@
namespace Glib
{
-ArrayHandle<bool,Container_Helpers::TypeTraits<bool> >::~ArrayHandle() noexcept
+ArrayHandle<bool, Container_Helpers::TypeTraits<bool>>::~ArrayHandle() noexcept
{
- if(parray_ && ownership_ != Glib::OWNERSHIP_NONE)
+ if (parray_ && ownership_ != Glib::OWNERSHIP_NONE)
{
- if(ownership_ != Glib::OWNERSHIP_SHALLOW)
+ if (ownership_ != Glib::OWNERSHIP_SHALLOW)
{
// Deep ownership: release each container element.
- const CType *const pend = parray_ + size_;
- for(const CType* p = parray_; p != pend; ++p)
+ const CType* const pend = parray_ + size_;
+ for (const CType* p = parray_; p != pend; ++p)
Tr::release_c_type(*p);
}
g_free(const_cast<CType*>(parray_));
diff --git a/glib/glibmm/base64.cc b/glib/glibmm/base64.cc
index ba951e3..27ba466 100644
--- a/glib/glibmm/base64.cc
+++ b/glib/glibmm/base64.cc
@@ -22,7 +22,8 @@
namespace Glib
{
-std::string Base64::encode(const std::string& source, bool break_lines)
+std::string
+Base64::encode(const std::string& source, bool break_lines)
{
/* The output buffer must be large enough to fit all the data that will be
written to it. Due to the way base64 encodes you will need at least:
@@ -31,17 +32,17 @@ std::string Base64::encode(const std::string& source, bool break_lines)
((len / 3 + 1) * 4 + 4) / 72 + 1 bytes of extra space.
*/
gsize length = (source.length() / 3 + 1) * 4 + 1; // + 1 for the terminating zero
- length += ((length / 72) + 1); // in case break_lines = true
- const auto buf = make_unique_ptr_gfree((char*) g_malloc(length));
+ length += ((length / 72) + 1); // in case break_lines = true
+ const auto buf = make_unique_ptr_gfree((char*)g_malloc(length));
gint state = 0, save = 0;
const guchar* src = reinterpret_cast<const unsigned char*>(source.data());
- gsize out = g_base64_encode_step (src, source.length(), break_lines,
- buf.get(), &state, &save);
- out += g_base64_encode_close(break_lines, buf.get()+out, &state, &save);
+ gsize out = g_base64_encode_step(src, source.length(), break_lines, buf.get(), &state, &save);
+ out += g_base64_encode_close(break_lines, buf.get() + out, &state, &save);
return std::string(buf.get(), buf.get() + out);
}
-std::string Base64::decode(const std::string& source)
+std::string
+Base64::decode(const std::string& source)
{
gsize size;
const auto buf = make_unique_ptr_gfree((char*)g_base64_decode(source.c_str(), &size));
@@ -49,4 +50,3 @@ std::string Base64::decode(const std::string& source)
}
} // namespace Glib
-
diff --git a/glib/glibmm/class.cc b/glib/glibmm/class.cc
index bbaf37f..66349a1 100644
--- a/glib/glibmm/class.cc
+++ b/glib/glibmm/class.cc
@@ -25,48 +25,49 @@
namespace Glib
{
-void Class::register_derived_type(GType base_type)
+void
+Class::register_derived_type(GType base_type)
{
return register_derived_type(base_type, nullptr);
}
-void Class::register_derived_type(GType base_type, GTypeModule* module)
+void
+Class::register_derived_type(GType base_type, GTypeModule* module)
{
- if(gtype_)
+ if (gtype_)
return; // already initialized
- //0 is not a valid GType.
- //It would lead to a crash later.
- //We allow this, failing silently, to make life easier for gstreamermm.
- if(base_type == 0)
+ // 0 is not a valid GType.
+ // It would lead to a crash later.
+ // We allow this, failing silently, to make life easier for gstreamermm.
+ if (base_type == 0)
return; // already initialized
- GTypeQuery base_query = { 0, nullptr, 0, 0, };
+ GTypeQuery base_query = {
+ 0, nullptr, 0, 0,
+ };
g_type_query(base_type, &base_query);
- //GTypeQuery::class_size is guint but GTypeInfo::class_size is guint16.
- const guint16 class_size =
- (guint16)base_query.class_size;
+ // GTypeQuery::class_size is guint but GTypeInfo::class_size is guint16.
+ const guint16 class_size = (guint16)base_query.class_size;
- //GTypeQuery::instance_size is guint but GTypeInfo::instance_size is guint16.
- const guint16 instance_size =
- (guint16)base_query.instance_size;
+ // GTypeQuery::instance_size is guint but GTypeInfo::instance_size is guint16.
+ const guint16 instance_size = (guint16)base_query.instance_size;
- const GTypeInfo derived_info =
- {
+ const GTypeInfo derived_info = {
class_size,
nullptr, // base_init
nullptr, // base_finalize
- class_init_func_, //Set by the caller ( *_Class::init() ).
+ class_init_func_, // Set by the caller ( *_Class::init() ).
nullptr, // class_finalize
nullptr, // class_data
instance_size,
- 0, // n_preallocs
+ 0, // n_preallocs
nullptr, // instance_init
nullptr, // value_table
};
- if(!(base_query.type_name))
+ if (!(base_query.type_name))
{
g_critical("Class::register_derived_type(): base_query.type_name is NULL.");
return;
@@ -74,28 +75,31 @@ void Class::register_derived_type(GType base_type, GTypeModule* module)
gchar* derived_name = g_strconcat("gtkmm__", base_query.type_name, nullptr);
- if(module)
- gtype_ = g_type_module_register_type(module, base_type, derived_name, &derived_info, GTypeFlags(0));
+ if (module)
+ gtype_ =
+ g_type_module_register_type(module, base_type, derived_name, &derived_info, GTypeFlags(0));
else
gtype_ = g_type_register_static(base_type, derived_name, &derived_info, GTypeFlags(0));
g_free(derived_name);
}
-GType Class::clone_custom_type(const char* custom_type_name) const
+GType
+Class::clone_custom_type(const char* custom_type_name) const
{
return clone_custom_type(custom_type_name, interface_class_vector_type());
}
-GType Class::clone_custom_type(const char* custom_type_name,
- const interface_class_vector_type& interface_classes) const
+GType
+Class::clone_custom_type(
+ const char* custom_type_name, const interface_class_vector_type& interface_classes) const
{
- std::string full_name ("gtkmm__CustomObject_");
+ std::string full_name("gtkmm__CustomObject_");
Glib::append_canonical_typename(full_name, custom_type_name);
GType custom_type = g_type_from_name(full_name.c_str());
- if(!custom_type)
+ if (!custom_type)
{
g_return_val_if_fail(gtype_ != 0, 0);
@@ -103,36 +107,35 @@ GType Class::clone_custom_type(const char* custom_type_name,
// so that g_type_class_peek_parent() works correctly.
const GType base_type = g_type_parent(gtype_);
- GTypeQuery base_query = { 0, nullptr, 0, 0, };
+ GTypeQuery base_query = {
+ 0, nullptr, 0, 0,
+ };
g_type_query(base_type, &base_query);
- //GTypeQuery::class_size is guint but GTypeInfo::class_size is guint16.
- const guint16 class_size =
- (guint16)base_query.class_size;
+ // GTypeQuery::class_size is guint but GTypeInfo::class_size is guint16.
+ const guint16 class_size = (guint16)base_query.class_size;
- //GTypeQuery::instance_size is guint but GTypeInfo::instance_size is guint16.
- const guint16 instance_size =
- (guint16)base_query.instance_size;
+ // GTypeQuery::instance_size is guint but GTypeInfo::instance_size is guint16.
+ const guint16 instance_size = (guint16)base_query.instance_size;
- const GTypeInfo derived_info =
- {
+ const GTypeInfo derived_info = {
class_size,
- nullptr, // base_init
+ nullptr, // base_init
&Class::custom_class_base_finalize_function, // base_finalize
&Class::custom_class_init_function,
nullptr, // class_finalize
- this, // class_data
+ this, // class_data
instance_size,
- 0, // n_preallocs
+ 0, // n_preallocs
nullptr, // instance_init
nullptr, // value_table
};
- custom_type = g_type_register_static(
- base_type, full_name.c_str(), &derived_info, GTypeFlags(0));
+ custom_type =
+ g_type_register_static(base_type, full_name.c_str(), &derived_info, GTypeFlags(0));
- //Add derived versions of interfaces, if the C type implements any interfaces.
- //For instance, TreeModel_Class::add_interface().
+ // Add derived versions of interfaces, if the C type implements any interfaces.
+ // For instance, TreeModel_Class::add_interface().
for (interface_class_vector_type::size_type i = 0; i < interface_classes.size(); i++)
{
const Interface_Class* interface_class = interface_classes[i];
@@ -150,17 +153,18 @@ GType Class::clone_custom_type(const char* custom_type_name,
GQuark Class::iface_properties_quark = g_quark_from_string("gtkmm_CustomObject_iface_properties");
// static
-void Class::custom_class_base_finalize_function(void* g_class)
+void
+Class::custom_class_base_finalize_function(void* g_class)
{
const GType gtype = G_TYPE_FROM_CLASS(g_class);
// Free the data related to the interface properties for the custom type, if any.
- iface_properties_type* props = static_cast<iface_properties_type*>(
- g_type_get_qdata(gtype, iface_properties_quark));
+ iface_properties_type* props =
+ static_cast<iface_properties_type*>(g_type_get_qdata(gtype, iface_properties_quark));
- if(props)
+ if (props)
{
- for(iface_properties_type::size_type i = 0; i < props->size(); i++)
+ for (iface_properties_type::size_type i = 0; i < props->size(); i++)
{
g_value_unset((*props)[i]);
g_free((*props)[i]);
@@ -170,10 +174,11 @@ void Class::custom_class_base_finalize_function(void* g_class)
}
// static
-void Class::custom_class_init_function(void* g_class, void* class_data)
+void
+Class::custom_class_init_function(void* g_class, void* class_data)
{
// The class_data pointer is set to 'this' by clone_custom_type().
- const Class *const self = static_cast<Class*>(class_data);
+ const Class* const self = static_cast<Class*>(class_data);
g_return_if_fail(self->class_init_func_ != nullptr);
@@ -181,7 +186,7 @@ void Class::custom_class_init_function(void* g_class, void* class_data)
// the vfunc and default signal handler callbacks.
(*self->class_init_func_)(g_class, nullptr);
- GObjectClass *const gobject_class = static_cast<GObjectClass*>(g_class);
+ GObjectClass* const gobject_class = static_cast<GObjectClass*>(g_class);
gobject_class->get_property = &Glib::custom_get_property_callback;
gobject_class->set_property = &Glib::custom_set_property_callback;
diff --git a/glib/glibmm/containers.cc b/glib/glibmm/containers.cc
index 07c61cd..fa265af 100644
--- a/glib/glibmm/containers.cc
+++ b/glib/glibmm/containers.cc
@@ -28,6 +28,4 @@ namespace Glib
gpointer glibmm_null_pointer = nullptr;
-
-} //namespace Glib
-
+} // namespace Glib
diff --git a/glib/glibmm/debug.cc b/glib/glibmm/debug.cc
index 0a5a0af..4fc3699 100644
--- a/glib/glibmm/debug.cc
+++ b/glib/glibmm/debug.cc
@@ -18,4 +18,3 @@
*/
#include <glibmm/debug.h>
-
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index f0ea19d..d77cfc5 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -27,13 +27,13 @@
#include <utility> // For std::move()
#ifdef G_OS_WIN32
-# include <windows.h>
-# include <io.h>
-# include <direct.h>
-# include <list>
-# include <mutex>
+#include <windows.h>
+#include <io.h>
+#include <direct.h>
+#include <list>
+#include <mutex>
#else
-# include <unistd.h>
+#include <unistd.h>
#endif
// EINTR is not defined on Tru64. I have tried including these:
@@ -44,7 +44,7 @@
// for "tru64 EINTR" returns lots of hits telling me that handling EINTR is
// actually a requirement on Tru64. So it must exist.
#if defined(_tru64) && !defined(EINTR)
-# define EINTR 0 /* TODO: should use the real define */
+#define EINTR 0 /* TODO: should use the real define */
#endif
namespace
@@ -52,62 +52,64 @@ namespace
struct DispatchNotifyData
{
- Glib::Dispatcher* dispatcher;
+ Glib::Dispatcher* dispatcher;
Glib::DispatchNotifier* notifier;
- DispatchNotifyData()
- : dispatcher (nullptr), notifier (nullptr) {}
+ DispatchNotifyData() : dispatcher(nullptr), notifier(nullptr) {}
- DispatchNotifyData(Glib::Dispatcher* d, Glib::DispatchNotifier* n)
- : dispatcher (d), notifier (n) {}
+ DispatchNotifyData(Glib::Dispatcher* d, Glib::DispatchNotifier* n) : dispatcher(d), notifier(n) {}
};
-static void warn_failed_pipe_io(const char* what)
+static void
+warn_failed_pipe_io(const char* what)
{
#ifdef G_OS_WIN32
- const char *const message = g_win32_error_message(GetLastError());
+ const char* const message = g_win32_error_message(GetLastError());
#else
- const char *const message = g_strerror(errno);
+ const char* const message = g_strerror(errno);
#endif
g_critical("Error in inter-thread communication: %s() failed: %s", what, message);
}
#ifdef G_OS_WIN32
-static void fd_close_and_invalidate(HANDLE& fd)
+static void
+fd_close_and_invalidate(HANDLE& fd)
{
- if(fd != 0)
+ if (fd != 0)
{
- if(!CloseHandle(fd))
+ if (!CloseHandle(fd))
warn_failed_pipe_io("CloseHandle");
fd = 0;
}
}
-#else /* !G_OS_WIN32 */
+#else /* !G_OS_WIN32 */
/*
* Set the close-on-exec flag on the file descriptor,
* so that it won't be leaked if a new process is spawned.
*/
-static void fd_set_close_on_exec(int fd)
+static void
+fd_set_close_on_exec(int fd)
{
const int flags = fcntl(fd, F_GETFD, 0);
- if(flags < 0 || fcntl(fd, F_SETFD, unsigned(flags) | FD_CLOEXEC) < 0)
+ if (flags < 0 || fcntl(fd, F_SETFD, unsigned(flags) | FD_CLOEXEC) < 0)
warn_failed_pipe_io("fcntl");
}
-static void fd_close_and_invalidate(int& fd)
+static void
+fd_close_and_invalidate(int& fd)
{
- if(fd >= 0)
+ if (fd >= 0)
{
int result;
do
result = close(fd);
- while(G_UNLIKELY(result < 0) && errno == EINTR);
+ while (G_UNLIKELY(result < 0) && errno == EINTR);
- if(G_UNLIKELY(result < 0))
+ if (G_UNLIKELY(result < 0))
warn_failed_pipe_io("close");
fd = -1;
@@ -131,8 +133,7 @@ public:
static DispatchNotifier* reference_instance(
const Glib::RefPtr<MainContext>& context, const Dispatcher* dispatcher);
- static void unreference_instance(
- DispatchNotifier* notifier, const Dispatcher* dispatcher);
+ static void unreference_instance(DispatchNotifier* notifier, const Dispatcher* dispatcher);
void send_notification(Dispatcher* dispatcher);
@@ -144,17 +145,17 @@ protected:
private:
static thread_local DispatchNotifier* thread_specific_instance_;
- std::set<const Dispatcher*> deleted_dispatchers_;
+ std::set<const Dispatcher*> deleted_dispatchers_;
- long ref_count_;
- Glib::RefPtr<MainContext> context_;
+ long ref_count_;
+ Glib::RefPtr<MainContext> context_;
#ifdef G_OS_WIN32
- std::mutex mutex_;
+ std::mutex mutex_;
std::list<DispatchNotifyData> notify_queue_;
- HANDLE fd_receiver_;
+ HANDLE fd_receiver_;
#else
- int fd_receiver_;
- int fd_sender_;
+ int fd_receiver_;
+ int fd_sender_;
#endif
void create_pipe();
@@ -168,17 +169,16 @@ private:
thread_local DispatchNotifier* DispatchNotifier::thread_specific_instance_ = nullptr;
DispatchNotifier::DispatchNotifier(const Glib::RefPtr<MainContext>& context)
-:
- deleted_dispatchers_(),
- ref_count_ (0),
- context_ (context),
+: deleted_dispatchers_(),
+ ref_count_(0),
+ context_(context),
#ifdef G_OS_WIN32
- mutex_ (),
- notify_queue_ (),
- fd_receiver_ (0)
+ mutex_(),
+ notify_queue_(),
+ fd_receiver_(0)
#else
- fd_receiver_ (-1),
- fd_sender_ (-1)
+ fd_receiver_(-1),
+ fd_sender_(-1)
#endif
{
create_pipe();
@@ -205,11 +205,11 @@ DispatchNotifier::DispatchNotifier(const Glib::RefPtr<MainContext>& context)
source->connect(sigc::mem_fun(*this, &DispatchNotifier::pipe_io_handler));
g_source_attach(source->gobj(), context_->gobj());
}
- catch(...)
+ catch (...)
{
-# ifndef G_OS_WIN32
+#ifndef G_OS_WIN32
fd_close_and_invalidate(fd_sender_);
-# endif
+#endif
fd_close_and_invalidate(fd_receiver_);
throw;
@@ -224,7 +224,8 @@ DispatchNotifier::~DispatchNotifier() noexcept
fd_close_and_invalidate(fd_receiver_);
}
-void DispatchNotifier::create_pipe()
+void
+DispatchNotifier::create_pipe()
{
#ifdef G_OS_WIN32
@@ -233,11 +234,11 @@ void DispatchNotifier::create_pipe()
// we can closely match the behavior on Unix in pipe_io_handler().
const HANDLE event = CreateEvent(0, TRUE, FALSE, 0);
- if(!event)
+ if (!event)
{
GError* const error = g_error_new(G_FILE_ERROR, G_FILE_ERROR_FAILED,
- "Failed to create event for inter-thread communication: %s",
- g_win32_error_message(GetLastError()));
+ "Failed to create event for inter-thread communication: %s",
+ g_win32_error_message(GetLastError()));
throw Glib::FileError(error);
}
@@ -247,11 +248,10 @@ void DispatchNotifier::create_pipe()
int filedes[2] = { -1, -1 };
- if(pipe(filedes) < 0)
+ if (pipe(filedes) < 0)
{
GError* const error = g_error_new(G_FILE_ERROR, g_file_error_from_errno(errno),
- "Failed to create pipe for inter-thread communication: %s",
- g_strerror(errno));
+ "Failed to create pipe for inter-thread communication: %s", g_strerror(errno));
throw Glib::FileError(error);
}
@@ -259,18 +259,19 @@ void DispatchNotifier::create_pipe()
fd_set_close_on_exec(filedes[1]);
fd_receiver_ = filedes[0];
- fd_sender_ = filedes[1];
+ fd_sender_ = filedes[1];
#endif /* !G_OS_WIN32 */
}
// static
-DispatchNotifier* DispatchNotifier::reference_instance
- (const Glib::RefPtr<MainContext>& context, const Dispatcher* dispatcher)
+DispatchNotifier*
+DispatchNotifier::reference_instance(
+ const Glib::RefPtr<MainContext>& context, const Dispatcher* dispatcher)
{
DispatchNotifier* instance = thread_specific_instance_;
- if(!instance)
+ if (!instance)
{
instance = new DispatchNotifier(context);
thread_specific_instance_ = instance;
@@ -286,7 +287,7 @@ DispatchNotifier* DispatchNotifier::reference_instance
// Not ideal, but perhaps the best that can be done without breaking ABI.
// The alternative would be to remove the following erase(), and risk not
// delivering messages sent to the new dispatcher.
- //TODO: When we can break ABI, a better solution without this drawback can
+ // TODO: When we can break ABI, a better solution without this drawback can
// be implemented. See https://bugzilla.gnome.org/show_bug.cgi?id=651942
// especially comment 16.
instance->deleted_dispatchers_.erase(dispatcher);
@@ -298,8 +299,8 @@ DispatchNotifier* DispatchNotifier::reference_instance
}
// static
-void DispatchNotifier::unreference_instance(
- DispatchNotifier* notifier, const Dispatcher* dispatcher)
+void
+DispatchNotifier::unreference_instance(DispatchNotifier* notifier, const Dispatcher* dispatcher)
{
DispatchNotifier* const instance = thread_specific_instance_;
@@ -314,7 +315,7 @@ void DispatchNotifier::unreference_instance(
// Keep its address, so pipe_io_handler() can avoid delivering messages to it.
instance->deleted_dispatchers_.insert(dispatcher);
- if(--instance->ref_count_ <= 0)
+ if (--instance->ref_count_ <= 0)
{
g_return_if_fail(instance->ref_count_ == 0); // could be < 0 if messed up
@@ -323,31 +324,32 @@ void DispatchNotifier::unreference_instance(
}
}
-void DispatchNotifier::send_notification(Dispatcher* dispatcher)
+void
+DispatchNotifier::send_notification(Dispatcher* dispatcher)
{
#ifdef G_OS_WIN32
{
- const std::lock_guard<std::mutex> lock (mutex_);
+ const std::lock_guard<std::mutex> lock(mutex_);
const bool was_empty = notify_queue_.empty();
notify_queue_.emplace_back(DispatchNotifyData(dispatcher, this));
- if(was_empty)
+ if (was_empty)
{
// The event will stay in signaled state until it is reset
// in pipe_io_handler() after processing the last queued event.
- if(!SetEvent(fd_receiver_))
+ if (!SetEvent(fd_receiver_))
warn_failed_pipe_io("SetEvent");
}
}
#else /* !G_OS_WIN32 */
- DispatchNotifyData data (dispatcher, this);
+ DispatchNotifyData data(dispatcher, this);
gssize n_written;
do
n_written = write(fd_sender_, &data, sizeof(data));
- while(G_UNLIKELY(n_written < 0) && errno == EINTR);
+ while (G_UNLIKELY(n_written < 0) && errno == EINTR);
// All data must be written in a single call to write(), otherwise we cannot
// guarantee reentrancy since another thread might be scheduled between two
@@ -363,13 +365,14 @@ void DispatchNotifier::send_notification(Dispatcher* dispatcher)
// The minimum value allowed by POSIX for PIPE_BUF is 512, so we are on safe
// grounds here.
- if(G_UNLIKELY(n_written != sizeof(data)))
+ if (G_UNLIKELY(n_written != sizeof(data)))
warn_failed_pipe_io("write");
#endif /* !G_OS_WIN32 */
}
-bool DispatchNotifier::pipe_is_empty()
+bool
+DispatchNotifier::pipe_is_empty()
{
#ifdef G_OS_WIN32
return notify_queue_.empty();
@@ -387,13 +390,13 @@ bool DispatchNotifier::pipe_io_handler(Glib::IOCondition)
#ifdef G_OS_WIN32
{
- const std::lock_guard<std::mutex> lock (mutex_);
+ const std::lock_guard<std::mutex> lock(mutex_);
// Should never be empty at this point, but let's allow for bogus
// notifications with no data available anyway; just to be safe.
- if(notify_queue_.empty())
+ if (notify_queue_.empty())
{
- if(!ResetEvent(fd_receiver_))
+ if (!ResetEvent(fd_receiver_))
warn_failed_pipe_io("ResetEvent");
return true;
@@ -405,28 +408,28 @@ bool DispatchNotifier::pipe_io_handler(Glib::IOCondition)
// Handle only a single event with each invocation of the I/O handler,
// and reset to nonsignaled state only after the last event in the queue
// has been processed. This matches the behavior on Unix.
- if(notify_queue_.empty())
+ if (notify_queue_.empty())
{
- if(!ResetEvent(fd_receiver_))
+ if (!ResetEvent(fd_receiver_))
warn_failed_pipe_io("ResetEvent");
}
}
-#else /* !G_OS_WIN32 */
+#else /* !G_OS_WIN32 */
gssize n_read;
do
n_read = read(fd_receiver_, &data, sizeof(data));
- while(G_UNLIKELY(n_read < 0) && errno == EINTR);
+ while (G_UNLIKELY(n_read < 0) && errno == EINTR);
// Pipe I/O of a block size not greater than PIPE_BUF should be atomic.
// See the comment on atomicity in send_notification() for details.
- if(G_UNLIKELY(n_read != sizeof(data)))
+ if (G_UNLIKELY(n_read != sizeof(data)))
{
// Should probably never be zero, but for safety let's allow for bogus
// notifications when no data is actually available. Although in fact
// the read() should block in that case.
- if(n_read != 0)
+ if (n_read != 0)
warn_failed_pipe_io("read");
return true;
@@ -457,7 +460,7 @@ bool DispatchNotifier::pipe_io_handler(Glib::IOCondition)
{
data.dispatcher->signal_(); // emit
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
@@ -468,38 +471,40 @@ bool DispatchNotifier::pipe_io_handler(Glib::IOCondition)
/**** Glib::Dispatcher *****************************************************/
Dispatcher::Dispatcher()
-:
- signal_ (),
- notifier_ (DispatchNotifier::reference_instance(MainContext::get_default(), this))
-{}
+: signal_(), notifier_(DispatchNotifier::reference_instance(MainContext::get_default(), this))
+{
+}
Dispatcher::Dispatcher(const Glib::RefPtr<MainContext>& context)
-:
- signal_ (),
- notifier_ (DispatchNotifier::reference_instance(context, this))
-{}
+: signal_(), notifier_(DispatchNotifier::reference_instance(context, this))
+{
+}
Dispatcher::~Dispatcher() noexcept
{
DispatchNotifier::unreference_instance(notifier_, this);
}
-void Dispatcher::emit()
+void
+Dispatcher::emit()
{
notifier_->send_notification(this);
}
-void Dispatcher::operator()()
+void
+Dispatcher::operator()()
{
notifier_->send_notification(this);
}
-sigc::connection Dispatcher::connect(const sigc::slot<void>& slot)
+sigc::connection
+Dispatcher::connect(const sigc::slot<void>& slot)
{
return signal_.connect(slot);
}
-sigc::connection Dispatcher::connect(sigc::slot<void>&& slot)
+sigc::connection
+Dispatcher::connect(sigc::slot<void>&& slot)
{
return signal_.connect(std::move(slot));
}
diff --git a/glib/glibmm/error.cc b/glib/glibmm/error.cc
index fb7d210..34ea87a 100644
--- a/glib/glibmm/error.cc
+++ b/glib/glibmm/error.cc
@@ -27,47 +27,45 @@
namespace
{
-typedef std::map<GQuark,Glib::Error::ThrowFunc> ThrowFuncTable;
+typedef std::map<GQuark, Glib::Error::ThrowFunc> ThrowFuncTable;
static ThrowFuncTable* throw_func_table = nullptr;
} // anonymous namespace
-
namespace Glib
{
-Error::Error()
-:
- gobject_ (nullptr)
-{}
+Error::Error() : gobject_(nullptr)
+{
+}
Error::Error(GQuark error_domain, int error_code, const Glib::ustring& message)
-:
- gobject_ (g_error_new_literal(error_domain, error_code, message.c_str()))
-{}
+: gobject_(g_error_new_literal(error_domain, error_code, message.c_str()))
+{
+}
Error::Error(GError* gobject, bool take_copy)
-:
- gobject_ ((take_copy && gobject) ? g_error_copy(gobject) : gobject)
-{}
+: gobject_((take_copy && gobject) ? g_error_copy(gobject) : gobject)
+{
+}
Error::Error(const Error& other)
-:
- Exception(other),
- gobject_ ((other.gobject_) ? g_error_copy(other.gobject_) : nullptr)
-{}
+: Exception(other), gobject_((other.gobject_) ? g_error_copy(other.gobject_) : nullptr)
+{
+}
-Error& Error::operator=(const Error& other)
+Error&
+Error::operator=(const Error& other)
{
- if(gobject_ != other.gobject_)
+ if (gobject_ != other.gobject_)
{
- if(gobject_)
+ if (gobject_)
{
g_error_free(gobject_);
gobject_ = nullptr;
}
- if(other.gobject_)
+ if (other.gobject_)
{
gobject_ = g_error_copy(other.gobject_);
}
@@ -77,25 +75,28 @@ Error& Error::operator=(const Error& other)
Error::~Error() noexcept
{
- if(gobject_)
+ if (gobject_)
g_error_free(gobject_);
}
-GQuark Error::domain() const
+GQuark
+Error::domain() const
{
g_return_val_if_fail(gobject_ != nullptr, 0);
return gobject_->domain;
}
-int Error::code() const
+int
+Error::code() const
{
g_return_val_if_fail(gobject_ != nullptr, -1);
return gobject_->code;
}
-Glib::ustring Error::what() const
+Glib::ustring
+Error::what() const
{
g_return_val_if_fail(gobject_ != nullptr, "");
g_return_val_if_fail(gobject_->message != nullptr, "");
@@ -103,31 +104,36 @@ Glib::ustring Error::what() const
return gobject_->message;
}
-bool Error::matches(GQuark error_domain, int error_code) const
+bool
+Error::matches(GQuark error_domain, int error_code) const
{
return g_error_matches(gobject_, error_domain, error_code);
}
-GError* Error::gobj()
+GError*
+Error::gobj()
{
return gobject_;
}
-const GError* Error::gobj() const
+const GError*
+Error::gobj() const
{
return gobject_;
}
-void Error::propagate(GError** dest)
+void
+Error::propagate(GError** dest)
{
g_propagate_error(dest, gobject_);
gobject_ = nullptr;
}
// static
-void Error::register_init()
+void
+Error::register_init()
{
- if(!throw_func_table)
+ if (!throw_func_table)
{
throw_func_table = new ThrowFuncTable();
Glib::wrap_register_init();
@@ -136,9 +142,10 @@ void Error::register_init()
}
// static
-void Error::register_cleanup()
+void
+Error::register_cleanup()
{
- if(throw_func_table)
+ if (throw_func_table)
{
delete throw_func_table;
throw_func_table = nullptr;
@@ -146,7 +153,8 @@ void Error::register_cleanup()
}
// static
-void Error::register_domain(GQuark error_domain, Error::ThrowFunc throw_func)
+void
+Error::register_domain(GQuark error_domain, Error::ThrowFunc throw_func)
{
g_assert(throw_func_table != nullptr);
@@ -154,15 +162,16 @@ void Error::register_domain(GQuark error_domain, Error::ThrowFunc throw_func)
}
// static, noreturn
-void Error::throw_exception(GError* gobject)
+void
+Error::throw_exception(GError* gobject)
{
g_assert(gobject != nullptr);
// Just in case Gtk::Main hasn't been instantiated yet.
- if(!throw_func_table)
+ if (!throw_func_table)
register_init();
- if(const ThrowFunc throw_func = (*throw_func_table)[gobject->domain])
+ if (const ThrowFunc throw_func = (*throw_func_table)[gobject->domain])
{
(*throw_func)(gobject);
g_assert_not_reached();
@@ -170,7 +179,7 @@ void Error::throw_exception(GError* gobject)
g_warning("Glib::Error::throw_exception():\n "
"unknown error domain '%s': throwing generic Glib::Error exception\n",
- (gobject->domain) ? g_quark_to_string(gobject->domain) : "(null)");
+ (gobject->domain) ? g_quark_to_string(gobject->domain) : "(null)");
// Doesn't copy, because error-returning functions return a newly allocated GError for us.
throw Glib::Error(gobject);
diff --git a/glib/glibmm/exception.cc b/glib/glibmm/exception.cc
index bf81ee0..b1e9322 100644
--- a/glib/glibmm/exception.cc
+++ b/glib/glibmm/exception.cc
@@ -26,18 +26,18 @@
#include <glibmm/exception.h>
-
namespace Glib
{
Exception::~Exception() noexcept
-{}
+{
+}
-Glib::ustring Exception::what() const
+Glib::ustring
+Exception::what() const
{
g_assert_not_reached();
return Glib::ustring();
}
} // namespace Glib
-
diff --git a/glib/glibmm/exceptionhandler.cc b/glib/glibmm/exceptionhandler.cc
index faad2a0..c12e199 100644
--- a/glib/glibmm/exceptionhandler.cc
+++ b/glib/glibmm/exceptionhandler.cc
@@ -26,7 +26,6 @@
#include <exception>
#include <list>
-
namespace
{
@@ -36,27 +35,27 @@ typedef sigc::signal<void> HandlerList;
// to avoid thread synchronization problems.
static thread_local HandlerList* thread_specific_handler_list = nullptr;
-
-static void glibmm_exception_warning(const GError* error)
+static void
+glibmm_exception_warning(const GError* error)
{
g_assert(error != nullptr);
g_critical("\n"
- "unhandled exception (type Glib::Error) in signal handler:\n"
- "domain: %s\n"
- "code : %d\n"
- "what : %s\n",
- g_quark_to_string(error->domain), error->code,
- (error->message) ? error->message : "(null)");
+ "unhandled exception (type Glib::Error) in signal handler:\n"
+ "domain: %s\n"
+ "code : %d\n"
+ "what : %s\n",
+ g_quark_to_string(error->domain), error->code, (error->message) ? error->message : "(null)");
}
-static void glibmm_unexpected_exception()
+static void
+glibmm_unexpected_exception()
{
try
{
throw; // re-throw current exception
}
- catch(const Glib::Error& error)
+ catch (const Glib::Error& error)
{
// Access the GError directly, to avoid possible exceptions from C++ code.
glibmm_exception_warning(error.gobj());
@@ -65,13 +64,14 @@ static void glibmm_unexpected_exception()
// program seems too harsh. Instead, give control back to the main loop.
return;
}
- catch(const std::exception& except)
+ catch (const std::exception& except)
{
g_error("\n"
- "unhandled exception (type std::exception) in signal handler:\n"
- "what: %s\n", except.what());
+ "unhandled exception (type std::exception) in signal handler:\n"
+ "what: %s\n",
+ except.what());
}
- catch(...)
+ catch (...)
{
g_error("\nunhandled exception (type unknown) in signal handler\n");
}
@@ -79,15 +79,15 @@ static void glibmm_unexpected_exception()
} // anonymous namespace
-
namespace Glib
{
-sigc::connection add_exception_handler(const sigc::slot<void>& slot)
+sigc::connection
+add_exception_handler(const sigc::slot<void>& slot)
{
HandlerList* handler_list = thread_specific_handler_list;
- if(!handler_list)
+ if (!handler_list)
{
handler_list = new HandlerList();
thread_specific_handler_list = handler_list;
@@ -98,7 +98,8 @@ sigc::connection add_exception_handler(const sigc::slot<void>& slot)
}
// internal
-void exception_handlers_invoke() noexcept
+void
+exception_handlers_invoke() noexcept
{
// This function will be called from our GLib signal handler proxies
// if an exception has been caught. It's not possible to throw C++
@@ -113,15 +114,15 @@ void exception_handlers_invoke() noexcept
// handled. If there are no more handlers in the list and the exception
// is still unhandled, call glibmm_unexpected_exception().
- if(HandlerList *const handler_list = thread_specific_handler_list)
+ if (HandlerList* const handler_list = thread_specific_handler_list)
{
HandlerList::iterator pslot = handler_list->slots().begin();
- while(pslot != handler_list->slots().end())
+ while (pslot != handler_list->slots().end())
{
// Calling an empty slot would mean ignoring the exception,
// thus we have to check for dead slots explicitly.
- if(pslot->empty())
+ if (pslot->empty())
{
pslot = handler_list->slots().erase(pslot);
continue;
@@ -133,7 +134,7 @@ void exception_handlers_invoke() noexcept
{
(*pslot)();
}
- catch(...) // unhandled, try next slot
+ catch (...) // unhandled, try next slot
{
++pslot;
continue;
@@ -150,6 +151,3 @@ void exception_handlers_invoke() noexcept
}
} // namespace Glib
-
-
-
diff --git a/glib/glibmm/init.cc b/glib/glibmm/init.cc
index 9255560..cc3b84c 100644
--- a/glib/glibmm/init.cc
+++ b/glib/glibmm/init.cc
@@ -21,7 +21,8 @@
namespace Glib
{
-void init()
+void
+init()
{
// Also calls Glib::wrap_register_init() and Glib::wrap_init().
Glib::Error::register_init();
diff --git a/glib/glibmm/interface.cc b/glib/glibmm/interface.cc
index f592d1b..0ce998b 100644
--- a/glib/glibmm/interface.cc
+++ b/glib/glibmm/interface.cc
@@ -18,44 +18,44 @@
#include <glibmm/interface.h>
#include <glibmm/private/interface_p.h>
-
namespace Glib
{
/**** Glib::Interface_Class ************************************************/
-void Interface_Class::add_interface(GType instance_type) const
+void
+Interface_Class::add_interface(GType instance_type) const
{
- //This check is disabled, because it checks whether any of the types's bases implement the interface, not
just the specific type.
- //if( !g_type_is_a(instance_type, gtype_) ) //For convenience, don't complain about calling this twice.
+ // This check is disabled, because it checks whether any of the types's bases implement the
+ // interface, not just the specific type.
+ // if( !g_type_is_a(instance_type, gtype_) ) //For convenience, don't complain about calling this
+ // twice.
//{
- const GInterfaceInfo interface_info =
- {
- class_init_func_,
- nullptr, // interface_finalize
- nullptr, // interface_data
- };
+ const GInterfaceInfo interface_info = {
+ class_init_func_,
+ nullptr, // interface_finalize
+ nullptr, // interface_data
+ };
- g_type_add_interface_static(instance_type, gtype_, &interface_info);
+ g_type_add_interface_static(instance_type, gtype_, &interface_info);
//}
}
-
/**** Interface Glib::Interface ********************************************/
Interface::Interface(const Interface_Class& interface_class)
{
- //gobject_ will be set in the Object constructor.
- //Any instantiable class that derives from Interface should also inherit from Object.
+ // gobject_ will be set in the Object constructor.
+ // Any instantiable class that derives from Interface should also inherit from Object.
- if(custom_type_name_ && !is_anonymous_custom_())
+ if (custom_type_name_ && !is_anonymous_custom_())
{
if (gobject_)
{
- GObjectClass *const instance_class = G_OBJECT_GET_CLASS(gobject_);
+ GObjectClass* const instance_class = G_OBJECT_GET_CLASS(gobject_);
const GType iface_type = interface_class.get_type();
- if(!g_type_interface_peek(instance_class, iface_type))
+ if (!g_type_interface_peek(instance_class, iface_type))
{
void* const g_iface = g_type_default_interface_ref(iface_type);
@@ -65,7 +65,7 @@ Interface::Interface(const Interface_Class& interface_class)
Class::iface_properties_type* props = static_cast<Class::iface_properties_type*>(
g_type_get_qdata(custom_type, Class::iface_properties_quark));
- if(!props)
+ if (!props)
{
props = new Class::iface_properties_type();
g_type_set_qdata(custom_type, Class::iface_properties_quark, props);
@@ -76,7 +76,7 @@ Interface::Interface(const Interface_Class& interface_class)
guint n_iface_props = 0;
GParamSpec** iface_props = g_object_interface_list_properties(g_iface, &n_iface_props);
- for(guint p = 0; p < n_iface_props; p++)
+ for (guint p = 0; p < n_iface_props; p++)
{
GValue* g_value = g_new0(GValue, 1);
g_value_init(g_value, iface_props[p]->value_type);
@@ -111,48 +111,53 @@ Interface::Interface(GObject* castitem)
}
Interface::Interface()
-{}
+{
+}
Interface::Interface(Interface&& src) noexcept
-: sigc::trackable(std::move(src)), //not actually called because it's a virtual base
- ObjectBase(std::move(src)) //not actually called because it's a virtual base
+ : sigc::trackable(std::move(src)), // not actually called because it's a virtual base
+ ObjectBase(std::move(src)) // not actually called because it's a virtual base
{
- //We don't call initialize_move() because we
- //want the derived move constructor to only cause it
- //to be called once, so we just let it be called
- //by the implementing class, such as Gtk::Entry (implementing Gtk::Editable
- //and Gtk::CellEditable), via the call to Object::Object(Object&& src).
- //ObjectBase::initialize_move(src.gobject_, &src);
+ // We don't call initialize_move() because we
+ // want the derived move constructor to only cause it
+ // to be called once, so we just let it be called
+ // by the implementing class, such as Gtk::Entry (implementing Gtk::Editable
+ // and Gtk::CellEditable), via the call to Object::Object(Object&& src).
+ // ObjectBase::initialize_move(src.gobject_, &src);
}
-Interface& Interface::operator=(Interface&& /* src */) noexcept
+Interface&
+Interface::operator=(Interface&& /* src */) noexcept
{
- //We don't call ObjectBase::operator=(ObjectBase&& src) because we
- //want the derived move assignment operator to only cause it
- //to be called once, so we just let it be called
- //by the implementing class, such as Gtk::Entry (implementing Gtk::Editable
- //and Gtk::CellEditable), via the call to Object::operator=(Object&& src).
- //ObjectBase::operator=(std::move(src));
+ // We don't call ObjectBase::operator=(ObjectBase&& src) because we
+ // want the derived move assignment operator to only cause it
+ // to be called once, so we just let it be called
+ // by the implementing class, such as Gtk::Entry (implementing Gtk::Editable
+ // and Gtk::CellEditable), via the call to Object::operator=(Object&& src).
+ // ObjectBase::operator=(std::move(src));
return *this;
}
Interface::~Interface() noexcept
-{}
+{
+}
-GType Interface::get_type()
+GType
+Interface::get_type()
{
return G_TYPE_INTERFACE;
}
-GType Interface::get_base_type()
+GType
+Interface::get_base_type()
{
return G_TYPE_INTERFACE;
}
-RefPtr<ObjectBase> wrap_interface(GObject* object, bool take_copy)
+RefPtr<ObjectBase>
+wrap_interface(GObject* object, bool take_copy)
{
- return Glib::RefPtr<ObjectBase>( wrap_auto(object, take_copy) );
+ return Glib::RefPtr<ObjectBase>(wrap_auto(object, take_copy));
}
} // namespace Glib
-
diff --git a/glib/glibmm/main.cc b/glib/glibmm/main.cc
index 483b377..8148120 100644
--- a/glib/glibmm/main.cc
+++ b/glib/glibmm/main.cc
@@ -18,11 +18,11 @@
#include <glibmmconfig.h> // May define GLIBMM_DISABLE_DEPRECATED
#ifndef GLIBMM_DISABLE_DEPRECATED
-//Include glibmm/thread.h first because we need it to be first to include <glib.h>,
-//so we can do an undef trick to still use deprecated API in the header:
+// Include glibmm/thread.h first because we need it to be first to include <glib.h>,
+// so we can do an undef trick to still use deprecated API in the header:
#include <glibmm/thread.h>
#include <glibmm/threads.h>
-#endif //GLIBMM_DISABLE_DEPRECATED
+#endif // GLIBMM_DISABLE_DEPRECATED
#include <glibmm/main.h>
#include <glibmm/exceptionhandler.h>
@@ -34,26 +34,25 @@
namespace
{
#ifdef GLIBMM_DISABLE_DEPRECATED
-void time64_to_time_val(gint64 time64, Glib::TimeVal& time_val)
+void
+time64_to_time_val(gint64 time64, Glib::TimeVal& time_val)
{
// This function is not guaranteed to convert correctly if time64 is negative.
const long seconds = static_cast<long>(time64 / G_GINT64_CONSTANT(1000000));
- const long microseconds = static_cast<long>(time64 -
- static_cast<gint64>(seconds) * G_GINT64_CONSTANT(1000000));
+ const long microseconds =
+ static_cast<long>(time64 - static_cast<gint64>(seconds) * G_GINT64_CONSTANT(1000000));
time_val = Glib::TimeVal(seconds, microseconds);
}
-#endif //GLIBMM_DISABLE_DEPRECATED
+#endif // GLIBMM_DISABLE_DEPRECATED
-//TODO: At the next ABI break, replace ExtraSourceData by new data members in Source.
+// 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
// g_atomic_*() functions on these data elements.
// These are new data members that can't be added to Glib::Source now,
// because it would break ABI.
struct ExtraSourceData
{
- ExtraSourceData()
- : ref_count(1), keep_wrapper(2)
- {}
+ ExtraSourceData() : ref_count(1), keep_wrapper(2) {}
int ref_count;
// When both Source::unreference() and SourceCallbackData::destroy_notify_callback()
// have decreased keep_wrapper, it's time to delete the C++ wrapper.
@@ -71,7 +70,7 @@ public:
explicit inline SourceConnectionNode(const sigc::slot_base& slot);
static void* notify(void* data);
- static void destroy_notify_callback(void* data);
+ static void destroy_notify_callback(void* data);
inline void install(GSource* source);
inline sigc::slot_base* get_slot();
@@ -81,18 +80,16 @@ private:
GSource* source_;
};
-inline
-SourceConnectionNode::SourceConnectionNode(const sigc::slot_base& slot)
-:
- slot_ (slot),
- source_ (nullptr)
+inline SourceConnectionNode::SourceConnectionNode(const sigc::slot_base& slot)
+: slot_(slot), source_(nullptr)
{
slot_.set_parent(this, &SourceConnectionNode::notify);
}
-void* SourceConnectionNode::notify(void* data)
+void*
+SourceConnectionNode::notify(void* data)
{
- SourceConnectionNode *const self = static_cast<SourceConnectionNode*>(data);
+ SourceConnectionNode* const self = static_cast<SourceConnectionNode*>(data);
// if there is no object, this call was triggered from destroy_notify_handler(),
// because we set self->source_ to nullptr there:
@@ -110,9 +107,10 @@ void* SourceConnectionNode::notify(void* data)
}
// static
-void SourceConnectionNode::destroy_notify_callback(void* data)
+void
+SourceConnectionNode::destroy_notify_callback(void* data)
{
- SourceConnectionNode *const self = static_cast<SourceConnectionNode*>(data);
+ SourceConnectionNode* const self = static_cast<SourceConnectionNode*>(data);
if (self)
{
@@ -123,19 +121,18 @@ void SourceConnectionNode::destroy_notify_callback(void* data)
}
}
-inline
-void SourceConnectionNode::install(GSource* source)
+inline void
+SourceConnectionNode::install(GSource* source)
{
source_ = source;
}
-inline
-sigc::slot_base* SourceConnectionNode::get_slot()
+inline sigc::slot_base*
+SourceConnectionNode::get_slot()
{
return &slot_;
}
-
/* We use the callback data member of GSource to store both a pointer to our
* wrapper and a pointer to the connection node that is currently being used.
* The one and only SourceCallbackData object of a Glib::Source is constructed
@@ -154,30 +151,30 @@ struct SourceCallbackData
SourceConnectionNode* node;
};
-inline
-SourceCallbackData::SourceCallbackData(Glib::Source* wrapper_)
-:
- wrapper (wrapper_),
- node (nullptr)
-{}
+inline SourceCallbackData::SourceCallbackData(Glib::Source* wrapper_)
+: wrapper(wrapper_), node(nullptr)
+{
+}
-void SourceCallbackData::set_node(SourceConnectionNode* node_)
+void
+SourceCallbackData::set_node(SourceConnectionNode* node_)
{
- if(node)
+ if (node)
SourceConnectionNode::destroy_notify_callback(node);
node = node_;
}
// static
-void SourceCallbackData::destroy_notify_callback(void* data)
+void
+SourceCallbackData::destroy_notify_callback(void* data)
{
- SourceCallbackData *const self = static_cast<SourceCallbackData*>(data);
+ SourceCallbackData* const self = static_cast<SourceCallbackData*>(data);
- if(self->node)
+ if (self->node)
SourceConnectionNode::destroy_notify_callback(self->node);
- if(self->wrapper)
+ if (self->wrapper)
{
std::unique_lock<std::mutex> lock(extra_source_data_mutex);
if (--extra_source_data[self->wrapper].keep_wrapper == 0)
@@ -192,10 +189,10 @@ void SourceCallbackData::destroy_notify_callback(void* data)
delete self;
}
-
/* Retrieve the callback data from a wrapped GSource object.
*/
-static SourceCallbackData* glibmm_source_get_callback_data(GSource* source)
+static SourceCallbackData*
+glibmm_source_get_callback_data(GSource* source)
{
g_return_val_if_fail(source->callback_funcs != nullptr, nullptr);
@@ -216,7 +213,8 @@ static SourceCallbackData* glibmm_source_get_callback_data(GSource* source)
* than some random pointer. That also allows for sanity checks
* here as well as in Source::dispatch_vfunc().
*/
-static gboolean glibmm_dummy_source_callback(void*)
+static gboolean
+glibmm_dummy_source_callback(void*)
{
g_assert_not_reached();
return 0;
@@ -226,16 +224,17 @@ static gboolean glibmm_dummy_source_callback(void*)
* and SignalIdle::connect(). These don't use Glib::Source, to avoid the
* unnecessary overhead of a completely unused wrapper object.
*/
-static gboolean glibmm_source_callback(void* data)
+static gboolean
+glibmm_source_callback(void* data)
{
- SourceConnectionNode *const conn_data = static_cast<SourceConnectionNode*>(data);
+ SourceConnectionNode* const conn_data = static_cast<SourceConnectionNode*>(data);
try
{
// Recreate the specific slot from the generic slot node.
return (*static_cast<sigc::slot<bool>*>(conn_data->get_slot()))();
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
@@ -246,7 +245,8 @@ static gboolean glibmm_source_callback(void* data)
* and SignalIdle::connect_once(). These don't use Glib::Source, to avoid the
* unnecessary overhead of a completely unused wrapper object.
*/
-static gboolean glibmm_source_callback_once(void* data)
+static gboolean
+glibmm_source_callback_once(void* data)
{
SourceConnectionNode* const conn_data = static_cast<SourceConnectionNode*>(data);
@@ -255,25 +255,26 @@ static gboolean glibmm_source_callback_once(void* data)
// Recreate the specific slot from the generic slot node.
(*static_cast<sigc::slot<void>*>(conn_data->get_slot()))();
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
return 0; // Destroy the event source after one call
}
-static gboolean glibmm_iosource_callback(GIOChannel*, GIOCondition condition, void* data)
+static gboolean
+glibmm_iosource_callback(GIOChannel*, GIOCondition condition, void* data)
{
- SourceCallbackData *const callback_data = static_cast<SourceCallbackData*>(data);
+ SourceCallbackData* const callback_data = static_cast<SourceCallbackData*>(data);
g_return_val_if_fail(callback_data->node != nullptr, 0);
try
{
// Recreate the specific slot from the generic slot node.
- return (*static_cast<sigc::slot<bool, Glib::IOCondition>*>(callback_data->node->get_slot()))
- ((Glib::IOCondition) condition);
+ return (*static_cast<sigc::slot<bool, Glib::IOCondition>*>(callback_data->node->get_slot()))(
+ (Glib::IOCondition)condition);
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
@@ -284,31 +285,33 @@ static gboolean glibmm_iosource_callback(GIOChannel*, GIOCondition condition, vo
* These don't use Glib::Source, to avoid the unnecessary overhead
* of a completely unused wrapper object.
*/
-static gboolean glibmm_child_watch_callback(GPid pid, gint child_status, void* data)
+static gboolean
+glibmm_child_watch_callback(GPid pid, gint child_status, void* data)
{
- SourceConnectionNode *const conn_data = static_cast<SourceConnectionNode*>(data);
+ SourceConnectionNode* const conn_data = static_cast<SourceConnectionNode*>(data);
- try {
- //Recreate the specific slot from the generic slot node.
+ try
+ {
+ // Recreate the specific slot from the generic slot node.
(*static_cast<sigc::slot<void, GPid, int>*>(conn_data->get_slot()))(pid, child_status);
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
return 0;
}
-static void glibmm_signal_connect_once(const sigc::slot<void>& slot, int priority,
- GSource* source, GMainContext* context)
+static void
+glibmm_signal_connect_once(
+ const sigc::slot<void>& slot, int priority, GSource* source, GMainContext* context)
{
SourceConnectionNode* const conn_node = new SourceConnectionNode(slot);
if (priority != G_PRIORITY_DEFAULT)
g_source_set_priority(source, priority);
- g_source_set_callback(
- source, &glibmm_source_callback_once, conn_node,
+ g_source_set_callback(source, &glibmm_source_callback_once, conn_node,
&SourceConnectionNode::destroy_notify_callback);
conn_node->install(source);
@@ -316,31 +319,32 @@ static void glibmm_signal_connect_once(const sigc::slot<void>& slot, int priorit
g_source_unref(source); // GMainContext holds a reference
}
-gboolean glibmm_main_context_invoke_callback(void* data)
+gboolean
+glibmm_main_context_invoke_callback(void* data)
{
- sigc::slot_base *const slot = reinterpret_cast<sigc::slot_base*>(data);
+ sigc::slot_base* const slot = reinterpret_cast<sigc::slot_base*>(data);
try
{
// Recreate the specific slot from the generic slot node.
return (*static_cast<sigc::slot<bool>*>(slot))();
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
return 0;
}
-void glibmm_main_context_invoke_destroy_notify_callback(void* data)
+void
+glibmm_main_context_invoke_destroy_notify_callback(void* data)
{
- sigc::slot_base *const slot = reinterpret_cast<sigc::slot_base*>(data);
+ sigc::slot_base* const slot = reinterpret_cast<sigc::slot_base*>(data);
delete slot;
}
} // anonymous namespace
-
namespace Glib
{
@@ -348,49 +352,45 @@ namespace Glib
PollFD::PollFD()
{
- gobject_.fd = 0;
- gobject_.events = 0;
+ gobject_.fd = 0;
+ gobject_.events = 0;
gobject_.revents = 0;
}
PollFD::PollFD(int fd)
{
- gobject_.fd = fd;
- gobject_.events = 0;
+ gobject_.fd = fd;
+ gobject_.events = 0;
gobject_.revents = 0;
}
PollFD::PollFD(int fd, IOCondition events)
{
- gobject_.fd = fd;
- gobject_.events = events;
+ gobject_.fd = fd;
+ gobject_.events = events;
gobject_.revents = 0;
}
-
/**** Glib::SignalTimeout **************************************************/
-inline
-SignalTimeout::SignalTimeout(GMainContext* context)
-:
- context_ (context)
-{}
+inline SignalTimeout::SignalTimeout(GMainContext* context) : context_(context)
+{
+}
/* Note that this is our equivalent of g_timeout_add(). */
-sigc::connection SignalTimeout::connect(const sigc::slot<bool>& slot,
- unsigned int interval, int priority)
+sigc::connection
+SignalTimeout::connect(const sigc::slot<bool>& slot, unsigned int interval, int priority)
{
- SourceConnectionNode *const conn_node = new SourceConnectionNode(slot);
- const sigc::connection connection (*conn_node->get_slot());
+ SourceConnectionNode* const conn_node = new SourceConnectionNode(slot);
+ const sigc::connection connection(*conn_node->get_slot());
- GSource *const source = g_timeout_source_new(interval);
+ GSource* const source = g_timeout_source_new(interval);
- if(priority != G_PRIORITY_DEFAULT)
+ if (priority != G_PRIORITY_DEFAULT)
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, &SourceConnectionNode::destroy_notify_callback);
conn_node->install(source);
g_source_attach(source, context_);
@@ -399,28 +399,27 @@ sigc::connection SignalTimeout::connect(const sigc::slot<bool>& slot,
return connection;
}
-void SignalTimeout::connect_once(const sigc::slot<void>& slot,
- unsigned int interval, int priority)
+void
+SignalTimeout::connect_once(const sigc::slot<void>& slot, unsigned int interval, int priority)
{
GSource* const source = g_timeout_source_new(interval);
glibmm_signal_connect_once(slot, priority, source, context_);
}
/* Note that this is our equivalent of g_timeout_add_seconds(). */
-sigc::connection SignalTimeout::connect_seconds(const sigc::slot<bool>& slot,
- unsigned int interval, int priority)
+sigc::connection
+SignalTimeout::connect_seconds(const sigc::slot<bool>& slot, unsigned int interval, int priority)
{
- SourceConnectionNode *const conn_node = new SourceConnectionNode(slot);
- const sigc::connection connection (*conn_node->get_slot());
+ SourceConnectionNode* const conn_node = new SourceConnectionNode(slot);
+ const sigc::connection connection(*conn_node->get_slot());
- GSource *const source = g_timeout_source_new_seconds(interval);
+ GSource* const source = g_timeout_source_new_seconds(interval);
- if(priority != G_PRIORITY_DEFAULT)
+ if (priority != G_PRIORITY_DEFAULT)
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, &SourceConnectionNode::destroy_notify_callback);
conn_node->install(source);
g_source_attach(source, context_);
@@ -429,40 +428,39 @@ sigc::connection SignalTimeout::connect_seconds(const sigc::slot<bool>& slot,
return connection;
}
-void SignalTimeout::connect_seconds_once(const sigc::slot<void>& slot,
- unsigned int interval, int priority)
+void
+SignalTimeout::connect_seconds_once(
+ const sigc::slot<void>& slot, unsigned int interval, int priority)
{
GSource* const source = g_timeout_source_new_seconds(interval);
glibmm_signal_connect_once(slot, priority, source, context_);
}
-SignalTimeout signal_timeout()
+SignalTimeout
+signal_timeout()
{
return SignalTimeout(nullptr); // nullptr means default context
}
-
/**** Glib::SignalIdle *****************************************************/
-inline
-SignalIdle::SignalIdle(GMainContext* context)
-:
- context_ (context)
-{}
+inline SignalIdle::SignalIdle(GMainContext* context) : context_(context)
+{
+}
-sigc::connection SignalIdle::connect(const sigc::slot<bool>& slot, int priority)
+sigc::connection
+SignalIdle::connect(const sigc::slot<bool>& slot, int priority)
{
- SourceConnectionNode *const conn_node = new SourceConnectionNode(slot);
- const sigc::connection connection (*conn_node->get_slot());
+ SourceConnectionNode* const conn_node = new SourceConnectionNode(slot);
+ const sigc::connection connection(*conn_node->get_slot());
- GSource *const source = g_idle_source_new();
+ GSource* const source = g_idle_source_new();
- if(priority != G_PRIORITY_DEFAULT)
+ if (priority != G_PRIORITY_DEFAULT)
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, &SourceConnectionNode::destroy_notify_callback);
conn_node->install(source);
g_source_attach(source, context_);
@@ -471,32 +469,32 @@ sigc::connection SignalIdle::connect(const sigc::slot<bool>& slot, int priority)
return connection;
}
-void SignalIdle::connect_once(const sigc::slot<void>& slot, int priority)
+void
+SignalIdle::connect_once(const sigc::slot<void>& slot, int priority)
{
GSource* const source = g_idle_source_new();
glibmm_signal_connect_once(slot, priority, source, context_);
}
-SignalIdle signal_idle()
+SignalIdle
+signal_idle()
{
return SignalIdle(nullptr); // nullptr means default context
}
-
/**** Glib::SignalIO *******************************************************/
-inline
-SignalIO::SignalIO(GMainContext* context)
-:
- context_ (context)
-{}
+inline SignalIO::SignalIO(GMainContext* context) : context_(context)
+{
+}
-sigc::connection SignalIO::connect(const sigc::slot<bool,IOCondition>& slot,
- int fd, IOCondition condition, int priority)
+sigc::connection
+SignalIO::connect(
+ const sigc::slot<bool, IOCondition>& slot, int fd, IOCondition condition, int priority)
{
const auto source = IOSource::create(fd, condition);
- if(priority != G_PRIORITY_DEFAULT)
+ if (priority != G_PRIORITY_DEFAULT)
source->set_priority(priority);
const sigc::connection connection = source->connect(slot);
@@ -506,13 +504,13 @@ sigc::connection SignalIO::connect(const sigc::slot<bool,IOCondition>& slot,
return connection;
}
-sigc::connection SignalIO::connect(const sigc::slot<bool,IOCondition>& slot,
- const Glib::RefPtr<IOChannel>& channel,
- IOCondition condition, int priority)
+sigc::connection
+SignalIO::connect(const sigc::slot<bool, IOCondition>& slot, const Glib::RefPtr<IOChannel>& channel,
+ IOCondition condition, int priority)
{
const auto source = IOSource::create(channel, condition);
- if(priority != G_PRIORITY_DEFAULT)
+ if (priority != G_PRIORITY_DEFAULT)
source->set_priority(priority);
const sigc::connection connection = source->connect(slot);
@@ -522,33 +520,31 @@ sigc::connection SignalIO::connect(const sigc::slot<bool,IOCondition>& slot,
return connection;
}
-SignalIO signal_io()
+SignalIO
+signal_io()
{
return SignalIO(nullptr); // nullptr means default context
}
/**** Glib::SignalChildWatch **************************************************/
-inline
-SignalChildWatch::SignalChildWatch(GMainContext* context)
-:
- context_ (context)
-{}
+inline SignalChildWatch::SignalChildWatch(GMainContext* context) : context_(context)
+{
+}
-sigc::connection SignalChildWatch::connect(const sigc::slot<void, GPid, int>& slot,
- GPid pid, int priority)
+sigc::connection
+SignalChildWatch::connect(const sigc::slot<void, GPid, int>& slot, GPid pid, int priority)
{
- SourceConnectionNode *const conn_node = new SourceConnectionNode(slot);
+ SourceConnectionNode* const conn_node = new SourceConnectionNode(slot);
const sigc::connection connection(*conn_node->get_slot());
- GSource *const source = g_child_watch_source_new(pid);
+ GSource* const source = g_child_watch_source_new(pid);
- if(priority != G_PRIORITY_DEFAULT)
+ 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,
+ &SourceConnectionNode::destroy_notify_callback);
conn_node->install(source);
g_source_attach(source, context_);
@@ -557,7 +553,8 @@ sigc::connection SignalChildWatch::connect(const sigc::slot<void, GPid, int>& sl
return connection;
}
-SignalChildWatch signal_child_watch()
+SignalChildWatch
+signal_child_watch()
{
return SignalChildWatch(nullptr); // nullptr means default context
}
@@ -565,326 +562,375 @@ SignalChildWatch signal_child_watch()
/**** Glib::MainContext ****************************************************/
// static
-Glib::RefPtr<MainContext> MainContext::create()
+Glib::RefPtr<MainContext>
+MainContext::create()
{
return Glib::RefPtr<MainContext>(reinterpret_cast<MainContext*>(g_main_context_new()));
}
// static
-Glib::RefPtr<MainContext> MainContext::get_default()
+Glib::RefPtr<MainContext>
+MainContext::get_default()
{
return Glib::wrap(g_main_context_default(), true);
}
-bool MainContext::iteration(bool may_block)
+bool
+MainContext::iteration(bool may_block)
{
return g_main_context_iteration(gobj(), may_block);
}
-bool MainContext::pending()
+bool
+MainContext::pending()
{
return g_main_context_pending(gobj());
}
-void MainContext::wakeup()
+void
+MainContext::wakeup()
{
g_main_context_wakeup(gobj());
}
-bool MainContext::acquire()
+bool
+MainContext::acquire()
{
return g_main_context_acquire(gobj());
}
#ifndef GLIBMM_DISABLE_DEPRECATED
-bool MainContext::wait(Glib::Cond& cond, Glib::Mutex& mutex)
+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)
+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
+#endif // GLIBMM_DISABLE_DEPRECATED
-void MainContext::release()
+void
+MainContext::release()
{
g_main_context_release(gobj());
}
-bool MainContext::prepare(int& priority)
+bool
+MainContext::prepare(int& priority)
{
return g_main_context_prepare(gobj(), &priority);
}
-bool MainContext::prepare()
+bool
+MainContext::prepare()
{
return g_main_context_prepare(gobj(), nullptr);
}
-void MainContext::query(int max_priority, int& timeout, std::vector<PollFD>& fds)
+void
+MainContext::query(int max_priority, int& timeout, std::vector<PollFD>& fds)
{
- if(fds.empty())
+ if (fds.empty())
fds.resize(8); // rather bogus number, but better than 0
- for(;;)
+ for (;;)
{
const int size_before = fds.size();
const int size_needed = g_main_context_query(
- gobj(), max_priority, &timeout, reinterpret_cast<GPollFD*>(&fds.front()), size_before);
+ gobj(), max_priority, &timeout, reinterpret_cast<GPollFD*>(&fds.front()), size_before);
fds.resize(size_needed);
- if(size_needed <= size_before)
+ if (size_needed <= size_before)
break;
}
}
-bool MainContext::check(int max_priority, std::vector<PollFD>& fds)
+bool
+MainContext::check(int max_priority, std::vector<PollFD>& fds)
{
- if(!fds.empty())
- return g_main_context_check(gobj(), max_priority, reinterpret_cast<GPollFD*>(&fds.front()), fds.size());
+ if (!fds.empty())
+ return g_main_context_check(
+ gobj(), max_priority, reinterpret_cast<GPollFD*>(&fds.front()), fds.size());
else
return false;
}
-void MainContext::dispatch()
+void
+MainContext::dispatch()
{
g_main_context_dispatch(gobj());
}
-void MainContext::set_poll_func(GPollFunc poll_func)
+void
+MainContext::set_poll_func(GPollFunc poll_func)
{
g_main_context_set_poll_func(gobj(), poll_func);
}
-GPollFunc MainContext::get_poll_func()
+GPollFunc
+MainContext::get_poll_func()
{
return g_main_context_get_poll_func(gobj());
}
-void MainContext::add_poll(PollFD& fd, int priority)
+void
+MainContext::add_poll(PollFD& fd, int priority)
{
g_main_context_add_poll(gobj(), fd.gobj(), priority);
}
-void MainContext::remove_poll(PollFD& fd)
+void
+MainContext::remove_poll(PollFD& fd)
{
g_main_context_remove_poll(gobj(), fd.gobj());
}
-void MainContext::invoke(const sigc::slot<bool>& slot, int priority)
+void
+MainContext::invoke(const sigc::slot<bool>& slot, int priority)
{
// Make a copy of slot on the heap.
sigc::slot_base* const slot_copy = new sigc::slot<bool>(slot);
- g_main_context_invoke_full(gobj(), priority, glibmm_main_context_invoke_callback,
- slot_copy, glibmm_main_context_invoke_destroy_notify_callback);
+ g_main_context_invoke_full(gobj(), priority, glibmm_main_context_invoke_callback, slot_copy,
+ glibmm_main_context_invoke_destroy_notify_callback);
}
-SignalTimeout MainContext::signal_timeout()
+SignalTimeout
+MainContext::signal_timeout()
{
return SignalTimeout(gobj());
}
-SignalIdle MainContext::signal_idle()
+SignalIdle
+MainContext::signal_idle()
{
return SignalIdle(gobj());
}
-SignalIO MainContext::signal_io()
+SignalIO
+MainContext::signal_io()
{
return SignalIO(gobj());
}
-SignalChildWatch MainContext::signal_child_watch()
+SignalChildWatch
+MainContext::signal_child_watch()
{
return SignalChildWatch(gobj());
}
-void MainContext::reference() const
+void
+MainContext::reference() const
{
g_main_context_ref(reinterpret_cast<GMainContext*>(const_cast<MainContext*>(this)));
}
-void MainContext::unreference() const
+void
+MainContext::unreference() const
{
g_main_context_unref(reinterpret_cast<GMainContext*>(const_cast<MainContext*>(this)));
}
-GMainContext* MainContext::gobj()
+GMainContext*
+MainContext::gobj()
{
return reinterpret_cast<GMainContext*>(this);
}
-const GMainContext* MainContext::gobj() const
+const GMainContext*
+MainContext::gobj() const
{
return reinterpret_cast<const GMainContext*>(this);
}
-GMainContext* MainContext::gobj_copy() const
+GMainContext*
+MainContext::gobj_copy() const
{
reference();
return const_cast<GMainContext*>(gobj());
}
-Glib::RefPtr<MainContext> wrap(GMainContext* gobject, bool take_copy)
+Glib::RefPtr<MainContext>
+wrap(GMainContext* gobject, bool take_copy)
{
- if(take_copy && gobject)
+ if (take_copy && gobject)
g_main_context_ref(gobject);
return Glib::RefPtr<MainContext>(reinterpret_cast<MainContext*>(gobject));
}
-
/**** Glib::MainLoop *******************************************************/
-Glib::RefPtr<MainLoop> MainLoop::create(bool is_running)
+Glib::RefPtr<MainLoop>
+MainLoop::create(bool is_running)
{
- return Glib::RefPtr<MainLoop>(
- reinterpret_cast<MainLoop*>(g_main_loop_new(nullptr, is_running)));
+ return Glib::RefPtr<MainLoop>(reinterpret_cast<MainLoop*>(g_main_loop_new(nullptr, is_running)));
}
-Glib::RefPtr<MainLoop> MainLoop::create(const Glib::RefPtr<MainContext>& context, bool is_running)
+Glib::RefPtr<MainLoop>
+MainLoop::create(const Glib::RefPtr<MainContext>& context, bool is_running)
{
return Glib::RefPtr<MainLoop>(
- reinterpret_cast<MainLoop*>(g_main_loop_new(Glib::unwrap(context), is_running)));
+ reinterpret_cast<MainLoop*>(g_main_loop_new(Glib::unwrap(context), is_running)));
}
-void MainLoop::run()
+void
+MainLoop::run()
{
g_main_loop_run(gobj());
}
-void MainLoop::quit()
+void
+MainLoop::quit()
{
g_main_loop_quit(gobj());
}
-bool MainLoop::is_running()
+bool
+MainLoop::is_running()
{
return g_main_loop_is_running(gobj());
}
-Glib::RefPtr<MainContext> MainLoop::get_context()
+Glib::RefPtr<MainContext>
+MainLoop::get_context()
{
return Glib::wrap(g_main_loop_get_context(gobj()), true);
}
-//static:
-int MainLoop::depth()
+// static:
+int
+MainLoop::depth()
{
return g_main_depth();
}
-void MainLoop::reference() const
+void
+MainLoop::reference() const
{
g_main_loop_ref(reinterpret_cast<GMainLoop*>(const_cast<MainLoop*>(this)));
}
-void MainLoop::unreference() const
+void
+MainLoop::unreference() const
{
g_main_loop_unref(reinterpret_cast<GMainLoop*>(const_cast<MainLoop*>(this)));
}
-GMainLoop* MainLoop::gobj()
+GMainLoop*
+MainLoop::gobj()
{
return reinterpret_cast<GMainLoop*>(this);
}
-const GMainLoop* MainLoop::gobj() const
+const GMainLoop*
+MainLoop::gobj() const
{
return reinterpret_cast<const GMainLoop*>(this);
}
-GMainLoop* MainLoop::gobj_copy() const
+GMainLoop*
+MainLoop::gobj_copy() const
{
reference();
return const_cast<GMainLoop*>(gobj());
}
-Glib::RefPtr<MainLoop> wrap(GMainLoop* gobject, bool take_copy)
+Glib::RefPtr<MainLoop>
+wrap(GMainLoop* gobject, bool take_copy)
{
- if(take_copy && gobject)
+ if (take_copy && gobject)
g_main_loop_ref(gobject);
return Glib::RefPtr<MainLoop>(reinterpret_cast<MainLoop*>(gobject));
}
-
/**** Glib::Source *********************************************************/
// static
-const GSourceFuncs Source::vfunc_table_ =
-{
- &Source::prepare_vfunc,
- &Source::check_vfunc,
- &Source::dispatch_vfunc,
+const GSourceFuncs Source::vfunc_table_ = {
+ &Source::prepare_vfunc, &Source::check_vfunc, &Source::dispatch_vfunc,
nullptr, // finalize_vfunc // We can't use finalize_vfunc because there is no way
- // to store a pointer to our wrapper anywhere in GSource so
- // that it persists until finalize_vfunc would be called from here.
+ // to store a pointer to our wrapper anywhere in GSource so
+ // that it persists until finalize_vfunc would be called from here.
nullptr, // closure_callback
nullptr, // closure_marshal
};
-unsigned int Source::attach(const Glib::RefPtr<MainContext>& context)
+unsigned int
+Source::attach(const Glib::RefPtr<MainContext>& context)
{
return g_source_attach(gobject_, Glib::unwrap(context));
}
-unsigned int Source::attach()
+unsigned int
+Source::attach()
{
return g_source_attach(gobject_, nullptr);
}
-void Source::destroy()
+void
+Source::destroy()
{
g_source_destroy(gobject_);
}
-void Source::set_priority(int priority)
+void
+Source::set_priority(int priority)
{
g_source_set_priority(gobject_, priority);
}
-int Source::get_priority() const
+int
+Source::get_priority() const
{
return g_source_get_priority(gobject_);
}
-void Source::set_can_recurse(bool can_recurse)
+void
+Source::set_can_recurse(bool can_recurse)
{
g_source_set_can_recurse(gobject_, can_recurse);
}
-bool Source::get_can_recurse() const
+bool
+Source::get_can_recurse() const
{
return g_source_get_can_recurse(gobject_);
}
-unsigned int Source::get_id() const
+unsigned int
+Source::get_id() const
{
return g_source_get_id(gobject_);
}
-Glib::RefPtr<MainContext> Source::get_context()
+Glib::RefPtr<MainContext>
+Source::get_context()
{
return Glib::wrap(g_source_get_context(gobject_), true);
}
-GSource* Source::gobj_copy() const
+GSource*
+Source::gobj_copy() const
{
return g_source_ref(gobject_);
}
-void Source::reference() const
+void
+Source::reference() const
{
std::lock_guard<std::mutex> lock(extra_source_data_mutex);
++extra_source_data[this].ref_count;
}
-void Source::unreference() const
+void
+Source::unreference() const
{
std::unique_lock<std::mutex> lock(extra_source_data_mutex);
if (--extra_source_data[this].ref_count == 0)
@@ -911,24 +957,18 @@ void Source::unreference() const
}
}
-Source::Source()
-:
- gobject_ (g_source_new(const_cast<GSourceFuncs*>(&vfunc_table_), sizeof(GSource)))
+Source::Source() : gobject_(g_source_new(const_cast<GSourceFuncs*>(&vfunc_table_), sizeof(GSource)))
{
- g_source_set_callback(
- gobject_, &glibmm_dummy_source_callback,
- new SourceCallbackData(this), // our persistent callback data object
- &SourceCallbackData::destroy_notify_callback);
+ g_source_set_callback(gobject_, &glibmm_dummy_source_callback,
+ new SourceCallbackData(this), // our persistent callback data object
+ &SourceCallbackData::destroy_notify_callback);
}
-Source::Source(GSource* cast_item, GSourceFunc callback_func)
-:
- gobject_ (cast_item)
+Source::Source(GSource* cast_item, GSourceFunc callback_func) : gobject_(cast_item)
{
- g_source_set_callback(
- gobject_, callback_func,
- new SourceCallbackData(this), // our persistent callback data object
- &SourceCallbackData::destroy_notify_callback);
+ g_source_set_callback(gobject_, callback_func,
+ new SourceCallbackData(this), // our persistent callback data object
+ &SourceCallbackData::destroy_notify_callback);
}
Source::~Source() noexcept
@@ -937,12 +977,12 @@ Source::~Source() noexcept
// gobject_ before deleting. However, we might also get to this point if
// a derived ctor threw an exception, and then we need to unref manually.
- if(gobject_)
+ if (gobject_)
{
- SourceCallbackData *const data = glibmm_source_get_callback_data(gobject_);
+ SourceCallbackData* const data = glibmm_source_get_callback_data(gobject_);
data->wrapper = nullptr;
- GSource *const tmp_gobject = gobject_;
+ GSource* const tmp_gobject = gobject_;
gobject_ = nullptr;
g_source_unref(tmp_gobject);
@@ -951,60 +991,67 @@ Source::~Source() noexcept
}
}
-sigc::connection Source::connect_generic(const sigc::slot_base& slot)
+sigc::connection
+Source::connect_generic(const sigc::slot_base& slot)
{
- SourceConnectionNode *const conn_node = new SourceConnectionNode(slot);
- const sigc::connection connection (*conn_node->get_slot());
+ SourceConnectionNode* const conn_node = new SourceConnectionNode(slot);
+ const sigc::connection connection(*conn_node->get_slot());
// Don't override the callback data. Reuse the existing one
// calling SourceCallbackData::set_node() to register conn_node.
- SourceCallbackData *const data = glibmm_source_get_callback_data(gobject_);
+ SourceCallbackData* const data = glibmm_source_get_callback_data(gobject_);
data->set_node(conn_node);
conn_node->install(gobject_);
return connection;
}
-void Source::add_poll(Glib::PollFD& poll_fd)
+void
+Source::add_poll(Glib::PollFD& poll_fd)
{
g_source_add_poll(gobject_, poll_fd.gobj());
}
-void Source::remove_poll(Glib::PollFD& poll_fd)
+void
+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)
+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
+#endif // GLIBMM_DISABLE_DEPRECATED
-gint64 Source::get_time() const
+gint64
+Source::get_time() const
{
return g_source_get_time(const_cast<GSource*>(gobject_));
}
inline // static
-Source* Source::get_wrapper(GSource* source)
+ Source*
+ Source::get_wrapper(GSource* source)
{
- SourceCallbackData *const data = glibmm_source_get_callback_data(source);
+ SourceCallbackData* const data = glibmm_source_get_callback_data(source);
return data->wrapper;
}
// static
-gboolean Source::prepare_vfunc(GSource* source, int* timeout)
+gboolean
+Source::prepare_vfunc(GSource* source, int* timeout)
{
try
{
- Source *const self = get_wrapper(source);
+ Source* const self = get_wrapper(source);
return self->prepare(*timeout);
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
@@ -1013,14 +1060,15 @@ gboolean Source::prepare_vfunc(GSource* source, int* timeout)
}
// static
-gboolean Source::check_vfunc(GSource* source)
+gboolean
+Source::check_vfunc(GSource* source)
{
try
{
- Source *const self = get_wrapper(source);
+ Source* const self = get_wrapper(source);
return self->check();
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
@@ -1029,19 +1077,20 @@ gboolean Source::check_vfunc(GSource* source)
}
// static
-gboolean Source::dispatch_vfunc(GSource*, GSourceFunc callback, void* user_data)
+gboolean
+Source::dispatch_vfunc(GSource*, GSourceFunc callback, void* user_data)
{
- SourceCallbackData *const callback_data = static_cast<SourceCallbackData*>(user_data);
+ SourceCallbackData* const callback_data = static_cast<SourceCallbackData*>(user_data);
g_return_val_if_fail(callback == &glibmm_dummy_source_callback, 0);
g_return_val_if_fail(callback_data != nullptr && callback_data->node != nullptr, 0);
try
{
- Source *const self = callback_data->wrapper;
+ Source* const self = callback_data->wrapper;
return self->dispatch(callback_data->node->get_slot());
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
@@ -1049,11 +1098,12 @@ gboolean Source::dispatch_vfunc(GSource*, GSourceFunc callback, void* user_data)
}
// static
-void Source::destroy_notify_callback(void* data)
+void
+Source::destroy_notify_callback(void* data)
{
- if(data)
+ if (data)
{
- Source *const self = static_cast<Source*>(data);
+ Source* const self = static_cast<Source*>(data);
// gobject_ is already invalid at this point.
self->gobject_ = nullptr;
@@ -1064,8 +1114,9 @@ void Source::destroy_notify_callback(void* data)
}
// static
-sigc::connection Source::attach_signal_source(const sigc::slot_base& slot, int priority,
- GSource* source, GMainContext* context, GSourceFunc callback_func)
+sigc::connection
+Source::attach_signal_source(const sigc::slot_base& slot, int priority, GSource* source,
+ GMainContext* context, GSourceFunc callback_func)
{
SourceConnectionNode* const conn_node = new SourceConnectionNode(slot);
const sigc::connection connection(*conn_node->get_slot());
@@ -1073,8 +1124,8 @@ sigc::connection Source::attach_signal_source(const sigc::slot_base& slot, int p
if (priority != G_PRIORITY_DEFAULT)
g_source_set_priority(source, priority);
- g_source_set_callback(source, callback_func, conn_node,
- &SourceConnectionNode::destroy_notify_callback);
+ g_source_set_callback(
+ source, callback_func, conn_node, &SourceConnectionNode::destroy_notify_callback);
conn_node->install(source);
g_source_attach(source, context);
@@ -1084,73 +1135,75 @@ sigc::connection Source::attach_signal_source(const sigc::slot_base& slot, int p
}
// static
-sigc::slot_base* Source::get_slot_from_connection_node(void* data)
+sigc::slot_base*
+Source::get_slot_from_connection_node(void* data)
{
return static_cast<SourceConnectionNode*>(data)->get_slot();
}
// static
-sigc::slot_base* Source::get_slot_from_callback_data(void* data)
+sigc::slot_base*
+Source::get_slot_from_callback_data(void* data)
{
SourceCallbackData* const callback_data = static_cast<SourceCallbackData*>(data);
g_return_val_if_fail(callback_data->node != nullptr, nullptr);
return callback_data->node->get_slot();
}
-
/**** Glib::TimeoutSource **************************************************/
// static
-Glib::RefPtr<TimeoutSource> TimeoutSource::create(unsigned int interval)
+Glib::RefPtr<TimeoutSource>
+TimeoutSource::create(unsigned int interval)
{
return Glib::RefPtr<TimeoutSource>(new TimeoutSource(interval));
}
-sigc::connection TimeoutSource::connect(const sigc::slot<bool>& slot)
+sigc::connection
+TimeoutSource::connect(const sigc::slot<bool>& slot)
{
return connect_generic(slot);
}
-TimeoutSource::TimeoutSource(unsigned int interval)
-:
- interval_ (interval)
+TimeoutSource::TimeoutSource(unsigned int interval) : interval_(interval)
{
expiration_.assign_current_time();
expiration_.add_milliseconds(std::min<unsigned long>(G_MAXLONG, interval_));
}
TimeoutSource::~TimeoutSource() noexcept
-{}
+{
+}
-bool TimeoutSource::prepare(int& timeout)
+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
+#endif // GLIBMM_DISABLE_DEPRECATED
Glib::TimeVal remaining = expiration_;
remaining.subtract(current_time);
- if(remaining.negative())
+ if (remaining.negative())
{
// Already expired.
timeout = 0;
}
else
{
- const unsigned long milliseconds =
- static_cast<unsigned long>(remaining.tv_sec) * 1000U +
- static_cast<unsigned long>(remaining.tv_usec) / 1000U;
+ const unsigned long milliseconds = static_cast<unsigned long>(remaining.tv_sec) * 1000U +
+ static_cast<unsigned long>(remaining.tv_usec) / 1000U;
// Set remaining milliseconds.
timeout = std::min<unsigned long>(G_MAXINT, milliseconds);
// Check if the system time has been set backwards. (remaining > interval)
- remaining.add_milliseconds(- std::min<unsigned long>(G_MAXLONG, interval_) - 1);
- if(!remaining.negative())
+ remaining.add_milliseconds(-std::min<unsigned long>(G_MAXLONG, interval_) - 1);
+ if (!remaining.negative())
{
// Oh well. Reset the expiration time to now + interval;
// this at least avoids hanging for long periods of time.
@@ -1163,45 +1216,48 @@ bool TimeoutSource::prepare(int& timeout)
return (timeout == 0);
}
-bool TimeoutSource::check()
+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
+#endif // GLIBMM_DISABLE_DEPRECATED
return (expiration_ <= current_time);
}
-bool TimeoutSource::dispatch(sigc::slot_base* slot)
+bool
+TimeoutSource::dispatch(sigc::slot_base* slot)
{
const bool again = (*static_cast<sigc::slot<bool>*>(slot))();
- if(again)
+ if (again)
{
#ifndef GLIBMM_DISABLE_DEPRECATED
get_current_time(expiration_);
#else
time64_to_time_val(get_time(), expiration_);
-#endif //GLIBMM_DISABLE_DEPRECATED
+#endif // GLIBMM_DISABLE_DEPRECATED
expiration_.add_milliseconds(std::min<unsigned long>(G_MAXLONG, interval_));
}
return again;
}
-
/**** Glib::IdleSource *****************************************************/
// static
-Glib::RefPtr<IdleSource> IdleSource::create()
+Glib::RefPtr<IdleSource>
+IdleSource::create()
{
return Glib::RefPtr<IdleSource>(new IdleSource());
}
-sigc::connection IdleSource::connect(const sigc::slot<bool>& slot)
+sigc::connection
+IdleSource::connect(const sigc::slot<bool>& slot)
{
return connect_generic(slot);
}
@@ -1212,79 +1268,85 @@ IdleSource::IdleSource()
}
IdleSource::~IdleSource() noexcept
-{}
+{
+}
-bool IdleSource::prepare(int& timeout)
+bool
+IdleSource::prepare(int& timeout)
{
timeout = 0;
return true;
}
-bool IdleSource::check()
+bool
+IdleSource::check()
{
return true;
}
-bool IdleSource::dispatch(sigc::slot_base* slot)
+bool
+IdleSource::dispatch(sigc::slot_base* slot)
{
return (*static_cast<sigc::slot<bool>*>(slot))();
}
-
/**** Glib::IOSource *******************************************************/
// static
-Glib::RefPtr<IOSource> IOSource::create(int fd, IOCondition condition)
+Glib::RefPtr<IOSource>
+IOSource::create(int fd, IOCondition condition)
{
return Glib::RefPtr<IOSource>(new IOSource(fd, condition));
}
-Glib::RefPtr<IOSource> IOSource::create(const Glib::RefPtr<IOChannel>& channel, IOCondition condition)
+Glib::RefPtr<IOSource>
+IOSource::create(const Glib::RefPtr<IOChannel>& channel, IOCondition condition)
{
return Glib::RefPtr<IOSource>(new IOSource(channel, condition));
}
-sigc::connection IOSource::connect(const sigc::slot<bool,IOCondition>& slot)
+sigc::connection
+IOSource::connect(const sigc::slot<bool, IOCondition>& slot)
{
return connect_generic(slot);
}
-IOSource::IOSource(int fd, IOCondition condition)
-:
- poll_fd_ (fd, condition)
+IOSource::IOSource(int fd, IOCondition condition) : poll_fd_(fd, condition)
{
add_poll(poll_fd_);
}
IOSource::IOSource(const Glib::RefPtr<IOChannel>& channel, IOCondition condition)
-:
- Source(g_io_create_watch(channel->gobj(), (GIOCondition) condition),
- (GSourceFunc) &glibmm_iosource_callback)
-{}
+: Source(g_io_create_watch(channel->gobj(), (GIOCondition)condition),
+ (GSourceFunc)&glibmm_iosource_callback)
+{
+}
-IOSource::IOSource(GSource* cast_item, GSourceFunc callback_func)
-:
- Source(cast_item, callback_func)
-{}
+IOSource::IOSource(GSource* cast_item, GSourceFunc callback_func) : Source(cast_item, callback_func)
+{
+}
IOSource::~IOSource() noexcept
-{}
+{
+}
-bool IOSource::prepare(int& timeout)
+bool
+IOSource::prepare(int& timeout)
{
timeout = -1;
return false;
}
-bool IOSource::check()
+bool
+IOSource::check()
{
return ((poll_fd_.get_revents() & poll_fd_.get_events()) != 0);
}
-bool IOSource::dispatch(sigc::slot_base* slot)
+bool
+IOSource::dispatch(sigc::slot_base* slot)
{
- return (*static_cast<sigc::slot<bool,IOCondition>*>(slot))
- (poll_fd_.get_revents());
+ return (*static_cast<sigc::slot<bool, IOCondition>*>(slot))(poll_fd_.get_revents());
}
} // namespace Glib
diff --git a/glib/glibmm/object.cc b/glib/glibmm/object.cc
index 502e4c8..e7f6f88 100644
--- a/glib/glibmm/object.cc
+++ b/glib/glibmm/object.cc
@@ -27,9 +27,10 @@
#include <string.h>
-//Weak references:
-//I'm not sure what the point of these are apart from being a hacky way out of circular references,
-//but maybe we could make it easier to use them by making a Java Reference Object -style class like so:
+// Weak references:
+// I'm not sure what the point of these are apart from being a hacky way out of circular references,
+// but maybe we could make it easier to use them by making a Java Reference Object -style class like
+// so:
// Glib::WeakRef<SomeDerivedObject> weakrefSomeObject(object1);
// ...
// if(weakrefSomeObject->isStillAlive())
@@ -41,20 +42,20 @@
// //Deal with it, maybe recreating the object.
// }
//
-// Without this, the coder has to define his own signal handler which sets his own isStillAlive boolean.
-// weakrefSomeObject<> could still have its own signal_destroyed signal so that coders can choose to deal
-// with the destruction as soon as it happens instead of just checking later before they try to use it.
-
+// Without this, the coder has to define his own signal handler which sets his own isStillAlive
+// boolean.
+// weakrefSomeObject<> could still have its own signal_destroyed signal so that coders can choose to
+// deal
+// with the destruction as soon as it happens instead of just checking later before they try to use
+// it.
namespace Glib
{
ConstructParams::ConstructParams(const Glib::Class& glibmm_class_)
-:
- glibmm_class (glibmm_class_),
- n_parameters (0),
- parameters (nullptr)
-{}
+: glibmm_class(glibmm_class_), n_parameters(0), parameters(nullptr)
+{
+}
/*
* The implementation is mostly copied from gobject.c, with some minor tweaks.
@@ -66,37 +67,32 @@ ConstructParams::ConstructParams(const Glib::Class& glibmm_class_)
* literals. No attempt is made to copy the string content. This is no
* different from g_object_new().
*/
-ConstructParams::ConstructParams(const Glib::Class& glibmm_class_,
- const char* first_property_name, ...)
-:
- glibmm_class (glibmm_class_),
- n_parameters (0),
- parameters (nullptr)
+ConstructParams::ConstructParams(
+ const Glib::Class& glibmm_class_, const char* first_property_name, ...)
+: glibmm_class(glibmm_class_), n_parameters(0), parameters(nullptr)
{
va_list var_args;
va_start(var_args, first_property_name);
- GObjectClass *const g_class =
- static_cast<GObjectClass*>(g_type_class_ref(glibmm_class.get_type()));
+ GObjectClass* const g_class =
+ static_cast<GObjectClass*>(g_type_class_ref(glibmm_class.get_type()));
unsigned int n_alloced_params = 0;
- char* collect_error = nullptr; // output argument of G_VALUE_COLLECT()
+ char* collect_error = nullptr; // output argument of G_VALUE_COLLECT()
- for(const char* name = first_property_name;
- name != nullptr;
- name = va_arg(var_args, char*))
+ for (const char* name = first_property_name; name != nullptr; name = va_arg(var_args, char*))
{
- GParamSpec *const pspec = g_object_class_find_property(g_class, name);
+ GParamSpec* const pspec = g_object_class_find_property(g_class, name);
- if(!pspec)
+ if (!pspec)
{
g_warning("Glib::ConstructParams::ConstructParams(): "
"object class \"%s\" has no property named \"%s\"",
- g_type_name(glibmm_class.get_type()), name);
+ g_type_name(glibmm_class.get_type()), name);
break;
}
- if(n_parameters >= n_alloced_params)
+ if (n_parameters >= n_alloced_params)
parameters = g_renew(GParameter, parameters, n_alloced_params += 8);
GParameter& param = parameters[n_parameters];
@@ -108,7 +104,7 @@ ConstructParams::ConstructParams(const Glib::Class& glibmm_class_,
g_value_init(¶m.value, G_PARAM_SPEC_VALUE_TYPE(pspec));
G_VALUE_COLLECT(¶m.value, var_args, 0, &collect_error);
- if(collect_error)
+ if (collect_error)
{
g_warning("Glib::ConstructParams::ConstructParams(): %s", collect_error);
g_free(collect_error);
@@ -126,7 +122,7 @@ ConstructParams::ConstructParams(const Glib::Class& glibmm_class_,
ConstructParams::~ConstructParams() noexcept
{
- while(n_parameters > 0)
+ while (n_parameters > 0)
g_value_unset(¶meters[--n_parameters].value);
g_free(parameters);
@@ -138,12 +134,11 @@ ConstructParams::~ConstructParams() noexcept
* to be ever actually called due to optimization.
*/
ConstructParams::ConstructParams(const ConstructParams& other)
-:
- glibmm_class (other.glibmm_class),
- n_parameters (other.n_parameters),
- parameters (g_new(GParameter, n_parameters))
+: glibmm_class(other.glibmm_class),
+ n_parameters(other.n_parameters),
+ parameters(g_new(GParameter, n_parameters))
{
- for(unsigned int i = 0; i < n_parameters; ++i)
+ for (unsigned int i = 0; i < n_parameters; ++i)
{
parameters[i].name = other.parameters[i].name;
parameters[i].value.g_type = 0;
@@ -153,12 +148,12 @@ ConstructParams::ConstructParams(const ConstructParams& other)
}
}
-
/**** Glib::Object_Class ***************************************************/
-const Glib::Class& Object_Class::init()
+const Glib::Class&
+Object_Class::init()
{
- if(!gtype_)
+ if (!gtype_)
{
class_init_func_ = &Object_Class::class_init_function;
register_derived_type(G_TYPE_OBJECT);
@@ -167,15 +162,17 @@ const Glib::Class& Object_Class::init()
return *this;
}
-void Object_Class::class_init_function(void*, void*)
-{}
+void
+Object_Class::class_init_function(void*, void*)
+{
+}
-Object* Object_Class::wrap_new(GObject* object)
+Object*
+Object_Class::wrap_new(GObject* object)
{
return new Object(object);
}
-
/**** Glib::Object *********************************************************/
// static data
@@ -187,7 +184,7 @@ Object::Object()
// derived C objects. For instance, Gtk::Object should NOT use this
// constructor.
- //g_warning("Object::Object(): Did you really mean to call this?");
+ // g_warning("Object::Object(): Did you really mean to call this?");
// If Glib::ObjectBase has been constructed with a custom typeid, we derive
// a new GType on the fly. This works because ObjectBase is a virtual base
@@ -195,7 +192,7 @@ Object::Object()
GType object_type = G_TYPE_OBJECT; // the default -- not very useful
- if(custom_type_name_ && !is_anonymous_custom_())
+ if (custom_type_name_ && !is_anonymous_custom_())
{
Class::interface_class_vector_type custom_interface_classes;
@@ -211,11 +208,10 @@ Object::Object()
object_class_.init();
// This creates a type that is derived (indirectly) from GObject.
- object_type = object_class_.clone_custom_type(
- custom_type_name_, custom_interface_classes);
+ object_type = object_class_.clone_custom_type(custom_type_name_, custom_interface_classes);
}
- void *const new_object = g_object_newv(object_type, 0, nullptr);
+ void* const new_object = g_object_newv(object_type, 0, nullptr);
// Connect the GObject and Glib::Object instances.
ObjectBase::initialize(static_cast<GObject*>(new_object));
@@ -229,7 +225,7 @@ Object::Object(const Glib::ConstructParams& construct_params)
// a new GType on the fly. This works because ObjectBase is a virtual base
// class, therefore its constructor is always executed first.
- if(custom_type_name_ && !is_anonymous_custom_())
+ if (custom_type_name_ && !is_anonymous_custom_())
{
Class::interface_class_vector_type custom_interface_classes;
@@ -243,16 +239,16 @@ Object::Object(const Glib::ConstructParams& construct_params)
}
}
- object_type = construct_params.glibmm_class.clone_custom_type(
- custom_type_name_, custom_interface_classes);
+ object_type =
+ construct_params.glibmm_class.clone_custom_type(custom_type_name_, custom_interface_classes);
}
// Create a new GObject with the specified array of construct properties.
// This works with custom types too, since those inherit the properties of
// their base class.
- void *const new_object = g_object_newv(
- object_type, construct_params.n_parameters, construct_params.parameters);
+ void* const new_object =
+ g_object_newv(object_type, construct_params.n_parameters, construct_params.parameters);
// Connect the GObject and Glib::Object instances.
ObjectBase::initialize(static_cast<GObject*>(new_object));
@@ -260,32 +256,33 @@ Object::Object(const Glib::ConstructParams& construct_params)
Object::Object(GObject* castitem)
{
- //I disabled this check because libglademm really does need to do this.
+ // I disabled this check because libglademm really does need to do this.
//(actually it tells libglade to instantiate "gtkmm_" types.
- //The 2nd instance bug will be caught elsewhere anyway.
-/*
- static const char gtkmm_prefix[] = "gtkmm__";
- const char *const type_name = G_OBJECT_TYPE_NAME(castitem);
+ // The 2nd instance bug will be caught elsewhere anyway.
+ /*
+ static const char gtkmm_prefix[] = "gtkmm__";
+ const char *const type_name = G_OBJECT_TYPE_NAME(castitem);
- if(strncmp(type_name, gtkmm_prefix, sizeof(gtkmm_prefix) - 1) == 0)
- {
- g_warning("Glib::Object::Object(GObject*): "
- "An object of type '%s' was created directly via g_object_new(). "
- "The Object::Object(const Glib::ConstructParams&) constructor "
- "should be used instead.\n"
- "This could happen if the C instance lived longer than the C++ instance, so that "
- "a second C++ instance was created automatically to wrap it. That would be a gtkmm bug that
you should report.",
- type_name);
- }
-*/
+ if(strncmp(type_name, gtkmm_prefix, sizeof(gtkmm_prefix) - 1) == 0)
+ {
+ g_warning("Glib::Object::Object(GObject*): "
+ "An object of type '%s' was created directly via g_object_new(). "
+ "The Object::Object(const Glib::ConstructParams&) constructor "
+ "should be used instead.\n"
+ "This could happen if the C instance lived longer than the C++ instance, so that "
+ "a second C++ instance was created automatically to wrap it. That would be a gtkmm
+ bug that you should report.",
+ type_name);
+ }
+ */
// Connect the GObject and Glib::Object instances.
ObjectBase::initialize(castitem);
}
Object::Object(Object&& src) noexcept
-: sigc::trackable(std::move(src)), //not actually called because it's a virtual base
- ObjectBase(std::move(src)) //not actually called because it's a virtual base
+ : sigc::trackable(std::move(src)), // not actually called because it's a virtual base
+ ObjectBase(std::move(src)) // not actually called because it's a virtual base
{
// Perhaps trackable's move constructor has not been called. Do its job here.
// (No harm is done if notify_callbacks() is called twice. The second call
@@ -294,7 +291,8 @@ Object::Object(Object&& src) noexcept
ObjectBase::initialize_move(src.gobject_, &src);
}
-Object& Object::operator=(Object&& src) noexcept
+Object&
+Object::operator=(Object&& src) noexcept
{
ObjectBase::operator=(std::move(src));
return *this;
@@ -313,43 +311,49 @@ RefPtr<Object> Object::create()
}
*/
-GType Object::get_type()
+GType
+Object::get_type()
{
return object_class_.init().get_type();
}
-GType Object::get_base_type()
+GType
+Object::get_base_type()
{
return G_TYPE_OBJECT;
}
// Data services
-void* Object::get_data(const QueryQuark& id)
+void*
+Object::get_data(const QueryQuark& id)
{
- return g_object_get_qdata(gobj(),id);
+ return g_object_get_qdata(gobj(), id);
}
-void Object::set_data(const Quark& id, void* data)
+void
+Object::set_data(const Quark& id, void* data)
{
- g_object_set_qdata(gobj(),id,data);
+ g_object_set_qdata(gobj(), id, data);
}
-void Object::set_data(const Quark& id, void* data, DestroyNotify destroy)
+void
+Object::set_data(const Quark& id, void* data, DestroyNotify destroy)
{
g_object_set_qdata_full(gobj(), id, data, destroy);
}
-void Object::remove_data(const QueryQuark& id)
+void
+Object::remove_data(const QueryQuark& id)
{
// missing in glib??
g_return_if_fail(id.id() > 0);
g_datalist_id_remove_data(&gobj()->qdata, id);
}
-void* Object::steal_data(const QueryQuark& id)
+void*
+Object::steal_data(const QueryQuark& id)
{
return g_object_steal_qdata(gobj(), id);
}
} // namespace Glib
-
diff --git a/glib/glibmm/objectbase.cc b/glib/glibmm/objectbase.cc
index c32752e..c524a16 100644
--- a/glib/glibmm/objectbase.cc
+++ b/glib/glibmm/objectbase.cc
@@ -35,7 +35,6 @@ static const char anonymous_custom_type_name[] = "gtkmm__anonymous_custom_type";
} // anonymous namespace
-
namespace Glib
{
@@ -46,33 +45,30 @@ ObjectBase::extra_object_base_data_type ObjectBase::extra_object_base_data;
std::mutex ObjectBase::extra_object_base_data_mutex;
ObjectBase::ObjectBase()
-:
- gobject_ (nullptr),
- custom_type_name_ (anonymous_custom_type_name),
- cpp_destruction_in_progress_ (false)
-{}
+: gobject_(nullptr),
+ custom_type_name_(anonymous_custom_type_name),
+ cpp_destruction_in_progress_(false)
+{
+}
ObjectBase::ObjectBase(const char* custom_type_name)
-:
- gobject_ (nullptr),
- custom_type_name_ (custom_type_name),
- cpp_destruction_in_progress_ (false)
-{}
+: gobject_(nullptr), custom_type_name_(custom_type_name), cpp_destruction_in_progress_(false)
+{
+}
ObjectBase::ObjectBase(const std::type_info& custom_type_info)
-:
- gobject_ (nullptr),
- custom_type_name_ (custom_type_info.name()),
- cpp_destruction_in_progress_ (false)
-{}
+: gobject_(nullptr), custom_type_name_(custom_type_info.name()), cpp_destruction_in_progress_(false)
+{
+}
// initialize() actually initializes the wrapper. Glib::ObjectBase is used
// as virtual base class, which means the most-derived class' ctor invokes
// the Glib::ObjectBase ctor -- thus it's useless for Glib::Object.
//
-void ObjectBase::initialize(GObject* castitem)
+void
+ObjectBase::initialize(GObject* castitem)
{
- if(gobject_)
+ if (gobject_)
{
// initialize() might be called twice when used with MI, e.g. by the ctors
// of Glib::Object and Glib::Interface. However, they must both refer to
@@ -90,9 +86,10 @@ void ObjectBase::initialize(GObject* castitem)
_set_current_wrapper(castitem);
}
-void ObjectBase::initialize_move(GObject* castitem, Glib::ObjectBase* previous_wrapper)
+void
+ObjectBase::initialize_move(GObject* castitem, Glib::ObjectBase* previous_wrapper)
{
- if(gobject_)
+ if (gobject_)
{
g_assert(gobject_ == castitem);
@@ -107,19 +104,21 @@ void ObjectBase::initialize_move(GObject* castitem, Glib::ObjectBase* previous_w
custom_type_name_ = previous_wrapper->custom_type_name_;
cpp_destruction_in_progress_ = previous_wrapper->cpp_destruction_in_progress_;
- //Clear the previous wrapper:
+ // Clear the previous wrapper:
previous_wrapper->custom_type_name_ = nullptr;
previous_wrapper->cpp_destruction_in_progress_ = false;
}
ObjectBase::ObjectBase(ObjectBase&& src) noexcept
-: sigc::trackable(std::move(src)), //not actually called because it's a virtual base
- gobject_(nullptr),
- custom_type_name_(src.custom_type_name_),
- cpp_destruction_in_progress_(src.cpp_destruction_in_progress_)
-{}
+ : sigc::trackable(std::move(src)), // not actually called because it's a virtual base
+ gobject_(nullptr),
+ custom_type_name_(src.custom_type_name_),
+ cpp_destruction_in_progress_(src.cpp_destruction_in_progress_)
+{
+}
-ObjectBase& ObjectBase::operator=(ObjectBase&& src) noexcept
+ObjectBase&
+ObjectBase::operator=(ObjectBase&& src) noexcept
{
if (this == &src)
return *this;
@@ -163,10 +162,10 @@ ObjectBase::~ObjectBase() noexcept
extra_object_base_data.erase(this);
}
- if(GObject *const gobject = gobject_)
+ if (GObject* const gobject = gobject_)
{
#ifdef GLIBMM_DEBUG_REFCOUNTING
- g_warning("(Glib::ObjectBase::~ObjectBase): gobject_ = %p", (void*) gobject_);
+ g_warning("(Glib::ObjectBase::~ObjectBase): gobject_ = %p", (void*)gobject_);
#endif
gobject_ = nullptr;
@@ -187,34 +186,38 @@ ObjectBase::~ObjectBase() noexcept
}
}
-void ObjectBase::reference() const
+void
+ObjectBase::reference() const
{
GLIBMM_DEBUG_REFERENCE(this, gobject_);
g_object_ref(gobject_);
}
-void ObjectBase::unreference() const
+void
+ObjectBase::unreference() const
{
GLIBMM_DEBUG_UNREFERENCE(this, gobject_);
g_object_unref(gobject_);
}
-GObject* ObjectBase::gobj_copy() const
+GObject*
+ObjectBase::gobj_copy() const
{
reference();
return gobject_;
}
-void ObjectBase::_set_current_wrapper(GObject* object)
+void
+ObjectBase::_set_current_wrapper(GObject* object)
{
// Store a pointer to this wrapper in the underlying instance, so that we
// never create a second wrapper for the same underlying instance. Also,
// specify a callback that will tell us when it's time to delete this C++
// wrapper instance:
- if(object)
+ if (object)
{
- if(!g_object_get_qdata(object, Glib::quark_))
+ if (!g_object_get_qdata(object, Glib::quark_))
{
g_object_set_qdata_full(object, Glib::quark_, this, &destroy_notify_callback_);
}
@@ -222,77 +225,81 @@ void ObjectBase::_set_current_wrapper(GObject* object)
{
g_warning("This object, of type %s, already has a wrapper.\n"
"You should use wrap() instead of a constructor.",
- G_OBJECT_TYPE_NAME(object));
+ G_OBJECT_TYPE_NAME(object));
}
}
}
-void ObjectBase::_move_current_wrapper(GObject* object, Glib::ObjectBase* previous_wrapper) noexcept
+void
+ObjectBase::_move_current_wrapper(GObject* object, Glib::ObjectBase* previous_wrapper) noexcept
{
- //See _set_current_wrapper().
+ // See _set_current_wrapper().
ObjectBase* current_wrapper = _get_current_wrapper(object);
- if(current_wrapper != previous_wrapper)
+ if (current_wrapper != previous_wrapper)
{
g_warning("%s: Unexpected previous wrapper, for object of type %s.\n"
"previous_wrapper=%p, current_wrapper=%p",
- G_STRFUNC, G_OBJECT_TYPE_NAME(object),
- static_cast<void*>(previous_wrapper),
- static_cast<void*>(current_wrapper));
+ G_STRFUNC, G_OBJECT_TYPE_NAME(object), static_cast<void*>(previous_wrapper),
+ static_cast<void*>(current_wrapper));
}
- //Remove the previous wrapper, without invoking destroy_notify_callback_():
+ // Remove the previous wrapper, without invoking destroy_notify_callback_():
g_object_steal_qdata(object, Glib::quark_);
- //Set the new wrapper:
+ // Set the new wrapper:
g_object_set_qdata_full(object, Glib::quark_, this, &destroy_notify_callback_);
- //Clear the previous wrapper:
+ // Clear the previous wrapper:
previous_wrapper->gobject_ = nullptr;
}
// static
-ObjectBase* ObjectBase::_get_current_wrapper(GObject* object)
+ObjectBase*
+ObjectBase::_get_current_wrapper(GObject* object)
{
- if(object)
+ if (object)
return static_cast<ObjectBase*>(g_object_get_qdata(object, Glib::quark_));
else
return nullptr;
}
// static
-void ObjectBase::destroy_notify_callback_(void* data)
+void
+ObjectBase::destroy_notify_callback_(void* data)
{
- //GLIBMM_LIFECYCLE
+ // GLIBMM_LIFECYCLE
// This method is called (indirectly) from g_object_run_dispose().
// Get the C++ instance associated with the C instance:
- ObjectBase* cppObject = static_cast<ObjectBase*>(data); //Previously set with g_object_set_qdata_full().
+ ObjectBase* cppObject =
+ static_cast<ObjectBase*>(data); // Previously set with g_object_set_qdata_full().
#ifdef GLIBMM_DEBUG_REFCOUNTING
g_warning("ObjectBase::destroy_notify_callback_: cppObject = %p, gobject_ = %p, gtypename = %s\n",
- (void*) cppObject, (void*) cppObject->gobject_, G_OBJECT_TYPE_NAME(cppObject->gobject_));
+ (void*)cppObject, (void*)cppObject->gobject_, G_OBJECT_TYPE_NAME(cppObject->gobject_));
#endif
- if(cppObject) //This will be 0 if the C++ destructor has already run.
+ if (cppObject) // This will be 0 if the C++ destructor has already run.
{
- cppObject->destroy_notify_(); //Virtual - it does different things for GObject and GtkObject.
+ cppObject->destroy_notify_(); // Virtual - it does different things for GObject and GtkObject.
}
}
-void ObjectBase::destroy_notify_()
+void
+ObjectBase::destroy_notify_()
{
- // The C instance is about to be disposed, making it unusable. Now is a
- // good time to delete the C++ wrapper of the C instance. There is no way
- // to force the disposal of the GObject (though GtkObject has
- // gtk_object_destroy()), So this is the *only* place where we delete the
- // C++ wrapper.
- //
- // This will only happen after the last unreference(), which will be done by
- // the RefPtr<> destructor. There should be no way to access the wrapper or
- // the undobjecterlying instance after that, so it's OK to delete this.
+// The C instance is about to be disposed, making it unusable. Now is a
+// good time to delete the C++ wrapper of the C instance. There is no way
+// to force the disposal of the GObject (though GtkObject has
+// gtk_object_destroy()), So this is the *only* place where we delete the
+// C++ wrapper.
+//
+// This will only happen after the last unreference(), which will be done by
+// the RefPtr<> destructor. There should be no way to access the wrapper or
+// the undobjecterlying instance after that, so it's OK to delete this.
#ifdef GLIBMM_DEBUG_REFCOUNTING
- g_warning("Glib::ObjectBase::destroy_notify_: gobject_ = %p", (void*) gobject_);
+ g_warning("Glib::ObjectBase::destroy_notify_: gobject_ = %p", (void*)gobject_);
#endif
gobject_ = nullptr; // Make sure we don't unref it again in the dtor.
@@ -300,19 +307,22 @@ void ObjectBase::destroy_notify_()
delete this;
}
-bool ObjectBase::is_anonymous_custom_() const
+bool
+ObjectBase::is_anonymous_custom_() const
{
// Doing high-speed pointer comparison is OK here.
return (custom_type_name_ == anonymous_custom_type_name);
}
-bool ObjectBase::is_derived_() const
+bool
+ObjectBase::is_derived_() const
{
// gtkmmproc-generated classes initialize this to 0 by default.
return (custom_type_name_ != nullptr);
}
-void ObjectBase::set_manage()
+void
+ObjectBase::set_manage()
{
// This is a private method and Gtk::manage() is a template function.
// Thus this will probably never run, unless you do something like:
@@ -323,32 +333,40 @@ void ObjectBase::set_manage()
"only Gtk::Object instances can be managed");
}
-bool ObjectBase::_cpp_destruction_is_in_progress() const
+bool
+ObjectBase::_cpp_destruction_is_in_progress() const
{
return cpp_destruction_in_progress_;
}
-void ObjectBase::set_property_value(const Glib::ustring& property_name, const Glib::ValueBase& value)
+void
+ObjectBase::set_property_value(const Glib::ustring& property_name, const Glib::ValueBase& value)
{
g_object_set_property(gobj(), property_name.c_str(), value.gobj());
}
-void ObjectBase::get_property_value(const Glib::ustring& property_name, Glib::ValueBase& value) const
+void
+ObjectBase::get_property_value(const Glib::ustring& property_name, Glib::ValueBase& value) const
{
g_object_get_property(const_cast<GObject*>(gobj()), property_name.c_str(), value.gobj());
}
-void ObjectBase::connect_property_changed(const Glib::ustring& property_name, const sigc::slot<void>& slot)
+void
+ObjectBase::connect_property_changed(
+ const Glib::ustring& property_name, const sigc::slot<void>& slot)
{
connect_property_changed_with_return(property_name, slot);
}
-void ObjectBase::connect_property_changed(const Glib::ustring& property_name, sigc::slot<void>&& slot)
+void
+ObjectBase::connect_property_changed(const Glib::ustring& property_name, sigc::slot<void>&& 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<void>& slot)
+sigc::connection
+ObjectBase::connect_property_changed_with_return(
+ const Glib::ustring& property_name, const sigc::slot<void>& slot)
{
// Create a proxy to hold our connection info
// This will be deleted by destroy_notify_handler.
@@ -359,7 +377,9 @@ sigc::connection ObjectBase::connect_property_changed_with_return(const Glib::us
return pConnectionNode->connect_changed(property_name);
}
-sigc::connection ObjectBase::connect_property_changed_with_return(const Glib::ustring& property_name,
sigc::slot<void>&& slot)
+sigc::connection
+ObjectBase::connect_property_changed_with_return(
+ const Glib::ustring& property_name, sigc::slot<void>&& slot)
{
// Create a proxy to hold our connection info
// This will be deleted by destroy_notify_handler.
@@ -370,28 +390,29 @@ sigc::connection ObjectBase::connect_property_changed_with_return(const Glib::us
return pConnectionNode->connect_changed(property_name);
}
-void ObjectBase::freeze_notify()
+void
+ObjectBase::freeze_notify()
{
- g_object_freeze_notify (gobj());
+ g_object_freeze_notify(gobj());
}
-void ObjectBase::thaw_notify()
+void
+ObjectBase::thaw_notify()
{
- g_object_thaw_notify (gobj());
+ g_object_thaw_notify(gobj());
}
-
-
-bool _gobject_cppinstance_already_deleted(GObject* gobject)
+bool
+_gobject_cppinstance_already_deleted(GObject* gobject)
{
- //This function is used to prevent calling wrap() on a GTK+ instance whose gtkmm instance has been deleted.
+ // This function is used to prevent calling wrap() on a GTK+ instance whose gtkmm instance has
+ // been deleted.
- if(gobject)
- return (bool)g_object_get_qdata(gobject, Glib::quark_cpp_wrapper_deleted_); //true means that something
is odd.
+ if (gobject)
+ return (bool)g_object_get_qdata(
+ gobject, Glib::quark_cpp_wrapper_deleted_); // true means that something is odd.
else
- return false; //Nothing is particularly wrong.
+ return false; // Nothing is particularly wrong.
}
-
} // namespace Glib
-
diff --git a/glib/glibmm/pattern.cc b/glib/glibmm/pattern.cc
index d679a61..8fb94fc 100644
--- a/glib/glibmm/pattern.cc
+++ b/glib/glibmm/pattern.cc
@@ -23,44 +23,45 @@
#include <glib.h>
#include <glibmm/pattern.h>
-
namespace Glib
{
PatternSpec::PatternSpec(const Glib::ustring& pattern)
-:
- gobject_ (g_pattern_spec_new(pattern.c_str()))
-{}
+: gobject_(g_pattern_spec_new(pattern.c_str()))
+{
+}
-PatternSpec::PatternSpec(GPatternSpec* gobject)
-:
- gobject_ (gobject)
-{}
+PatternSpec::PatternSpec(GPatternSpec* gobject) : gobject_(gobject)
+{
+}
PatternSpec::~PatternSpec() noexcept
{
g_pattern_spec_free(gobject_);
}
-bool PatternSpec::match(const Glib::ustring& str) const
+bool
+PatternSpec::match(const Glib::ustring& str) const
{
return g_pattern_match(gobject_, str.bytes(), str.c_str(), nullptr);
}
-bool PatternSpec::match(const Glib::ustring& str, const Glib::ustring& str_reversed) const
+bool
+PatternSpec::match(const Glib::ustring& str, const Glib::ustring& str_reversed) const
{
return g_pattern_match(gobject_, str.bytes(), str.c_str(), str_reversed.c_str());
}
-bool PatternSpec::operator==(const PatternSpec& rhs) const
+bool
+PatternSpec::operator==(const PatternSpec& rhs) const
{
return g_pattern_spec_equal(gobject_, rhs.gobject_);
}
-bool PatternSpec::operator!=(const PatternSpec& rhs) const
+bool
+PatternSpec::operator!=(const PatternSpec& rhs) const
{
return !g_pattern_spec_equal(gobject_, rhs.gobject_);
}
} // namespace Glib
-
diff --git a/glib/glibmm/property.cc b/glib/glibmm/property.cc
index 302d48a..7085900 100644
--- a/glib/glibmm/property.cc
+++ b/glib/glibmm/property.cc
@@ -22,10 +22,9 @@
#include <cstddef>
// Temporary hack till GLib gets fixed.
-#undef G_STRLOC
+#undef G_STRLOC
#define G_STRLOC __FILE__ ":" G_STRINGIFY(__LINE__)
-
namespace
{
// The task:
@@ -62,9 +61,9 @@ namespace
// a) Almost all conceivable use-cases are supported by this approach.
// b) It's comparatively efficient, and does not need a hash-table lookup.
-
// Delete the interface property values when an object of a custom type is finalized.
-void destroy_notify_obj_iface_props(void* data)
+void
+destroy_notify_obj_iface_props(void* data)
{
auto obj_iface_props = static_cast<Glib::Class::iface_properties_type*>(data);
if (obj_iface_props)
@@ -81,37 +80,40 @@ void destroy_notify_obj_iface_props(void* data)
// The type that holds pointers to the custom properties of custom types.
using custom_properties_type = std::vector<Glib::PropertyBase*>;
// The quark used for storing/getting the custom properties of custom types.
-static const GQuark custom_properties_quark = g_quark_from_string("gtkmm_CustomObject_custom_properties");
+static const GQuark custom_properties_quark =
+ g_quark_from_string("gtkmm_CustomObject_custom_properties");
// Delete the vector of pointers to custom properties when an object of
// a custom type is finalized.
-void destroy_notify_obj_custom_props(void* data)
+void
+destroy_notify_obj_custom_props(void* data)
{
// Shallow deletion. The vector does not own the objects pointed to.
delete static_cast<custom_properties_type*>(data);
}
-custom_properties_type* get_obj_custom_props(GObject* obj)
+custom_properties_type*
+get_obj_custom_props(GObject* obj)
{
- auto obj_custom_props = static_cast<custom_properties_type*>(
- g_object_get_qdata(obj, custom_properties_quark));
+ auto obj_custom_props =
+ static_cast<custom_properties_type*>(g_object_get_qdata(obj, custom_properties_quark));
if (!obj_custom_props)
{
obj_custom_props = new custom_properties_type();
- g_object_set_qdata_full(obj, custom_properties_quark, obj_custom_props,
- destroy_notify_obj_custom_props);
+ g_object_set_qdata_full(
+ obj, custom_properties_quark, obj_custom_props, destroy_notify_obj_custom_props);
}
return obj_custom_props;
}
} // anonymous namespace
-
namespace Glib
{
-void custom_get_property_callback(GObject* object, unsigned int property_id,
- GValue* value, GParamSpec* param_spec)
+void
+custom_get_property_callback(
+ GObject* object, unsigned int property_id, GValue* value, GParamSpec* param_spec)
{
// If the id is zero there is no property to get.
g_return_if_fail(property_id != 0);
@@ -138,10 +140,10 @@ void custom_get_property_callback(GObject* object, unsigned int property_id,
}
else
{
- if (Glib::ObjectBase *const wrapper = Glib::ObjectBase::_get_current_wrapper(object))
+ if (Glib::ObjectBase* const wrapper = Glib::ObjectBase::_get_current_wrapper(object))
{
- auto obj_custom_props = static_cast<custom_properties_type*>(
- g_object_get_qdata(object, custom_properties_quark));
+ auto obj_custom_props =
+ static_cast<custom_properties_type*>(g_object_get_qdata(object, custom_properties_quark));
const unsigned index = property_id - iface_props_size - 1;
if (obj_custom_props && index < obj_custom_props->size() &&
@@ -154,8 +156,9 @@ void custom_get_property_callback(GObject* object, unsigned int property_id,
}
}
-void custom_set_property_callback(GObject* object, unsigned int property_id,
- const GValue* value, GParamSpec* param_spec)
+void
+custom_set_property_callback(
+ GObject* object, unsigned int property_id, const GValue* value, GParamSpec* param_spec)
{
// If the id is zero there is no property to set.
g_return_if_fail(property_id != 0);
@@ -179,8 +182,8 @@ void custom_set_property_callback(GObject* object, unsigned int property_id,
if (!obj_iface_props)
{
obj_iface_props = new Class::iface_properties_type();
- g_object_set_qdata_full(object, Class::iface_properties_quark, obj_iface_props,
- destroy_notify_obj_iface_props);
+ g_object_set_qdata_full(
+ object, Class::iface_properties_quark, obj_iface_props, destroy_notify_obj_iface_props);
for (Class::iface_properties_type::size_type p = 0; p < iface_props_size; ++p)
{
GValue* g_value = g_new0(GValue, 1);
@@ -195,10 +198,10 @@ void custom_set_property_callback(GObject* object, unsigned int property_id,
}
else
{
- if(Glib::ObjectBase *const wrapper = Glib::ObjectBase::_get_current_wrapper(object))
+ if (Glib::ObjectBase* const wrapper = Glib::ObjectBase::_get_current_wrapper(object))
{
- auto obj_custom_props = static_cast<custom_properties_type*>(
- g_object_get_qdata(object, custom_properties_quark));
+ auto obj_custom_props =
+ static_cast<custom_properties_type*>(g_object_get_qdata(object, custom_properties_quark));
const unsigned index = property_id - iface_props_size - 1;
if (obj_custom_props && index < obj_custom_props->size() &&
@@ -214,31 +217,28 @@ void custom_set_property_callback(GObject* object, unsigned int property_id,
}
}
-
/**** Glib::PropertyBase ***************************************************/
PropertyBase::PropertyBase(Glib::Object& object, GType value_type)
-:
- object_ (&object),
- value_ (),
- param_spec_ (nullptr)
+: object_(&object), value_(), param_spec_(nullptr)
{
value_.init(value_type);
}
PropertyBase::~PropertyBase() noexcept
{
- if(param_spec_)
+ if (param_spec_)
g_param_spec_unref(param_spec_);
}
-bool PropertyBase::lookup_property(const Glib::ustring& name)
+bool
+PropertyBase::lookup_property(const Glib::ustring& name)
{
g_assert(param_spec_ == nullptr);
param_spec_ = g_object_class_find_property(G_OBJECT_GET_CLASS(object_->gobj()), name.c_str());
- if(param_spec_)
+ if (param_spec_)
{
// This property has already been installed, when another instance
// of the object_ class was constructed.
@@ -251,7 +251,8 @@ bool PropertyBase::lookup_property(const Glib::ustring& name)
return (param_spec_ != nullptr);
}
-void PropertyBase::install_property(GParamSpec* param_spec)
+void
+PropertyBase::install_property(GParamSpec* param_spec)
{
g_return_if_fail(param_spec != nullptr);
@@ -282,19 +283,22 @@ void PropertyBase::install_property(GParamSpec* param_spec)
g_param_spec_ref(param_spec_);
}
-const char* PropertyBase::get_name_internal() const
+const char*
+PropertyBase::get_name_internal() const
{
- const char *const name = g_param_spec_get_name(param_spec_);
+ const char* const name = g_param_spec_get_name(param_spec_);
g_return_val_if_fail(name != nullptr, "");
return name;
}
-Glib::ustring PropertyBase::get_name() const
+Glib::ustring
+PropertyBase::get_name() const
{
return Glib::ustring(get_name_internal());
}
-void PropertyBase::notify()
+void
+PropertyBase::notify()
{
g_object_notify_by_pspec(object_->gobj(), param_spec_);
}
diff --git a/glib/glibmm/propertyproxy.cc b/glib/glibmm/propertyproxy.cc
index cecfbc0..bd02587 100644
--- a/glib/glibmm/propertyproxy.cc
+++ b/glib/glibmm/propertyproxy.cc
@@ -21,4 +21,3 @@
*/
#include <glibmm/propertyproxy.h>
-
diff --git a/glib/glibmm/propertyproxy_base.cc b/glib/glibmm/propertyproxy_base.cc
index a0e0bd7..5b7a400 100644
--- a/glib/glibmm/propertyproxy_base.cc
+++ b/glib/glibmm/propertyproxy_base.cc
@@ -19,7 +19,6 @@
#include <glibmm/propertyproxy_base.h>
-
#include <glibmm/signalproxy_connectionnode.h>
#include <glibmm/object.h>
#include <glibmm/private/object_p.h>
@@ -28,9 +27,10 @@
namespace Glib
{
-//PropertyProxyConnectionNode implementation:
+// PropertyProxyConnectionNode implementation:
-PropertyProxyConnectionNode::PropertyProxyConnectionNode(const sigc::slot_base& slot, GObject* gobject)
+PropertyProxyConnectionNode::PropertyProxyConnectionNode(
+ const sigc::slot_base& slot, GObject* gobject)
: SignalProxyConnectionNode(slot, gobject)
{
}
@@ -40,7 +40,8 @@ PropertyProxyConnectionNode::PropertyProxyConnectionNode(sigc::slot_base&& slot,
{
}
-sigc::connection PropertyProxyConnectionNode::connect_changed(const Glib::ustring& property_name)
+sigc::connection
+PropertyProxyConnectionNode::connect_changed(const Glib::ustring& property_name)
{
// connect it to glib
// 'this' will be passed as the data argument to the callback.
@@ -52,21 +53,19 @@ sigc::connection PropertyProxyConnectionNode::connect_changed(const Glib::ustrin
return sigc::connection(slot_);
}
-void PropertyProxyConnectionNode::callback(GObject*, GParamSpec* pspec, gpointer data) //static
+void PropertyProxyConnectionNode::callback(GObject*, GParamSpec* pspec, gpointer data) // static
{
- if(pspec && data)
+ if (pspec && data)
{
- if(sigc::slot_base *const slot = SignalProxyBase::data_to_slot(data))
+ if (sigc::slot_base* const slot = SignalProxyBase::data_to_slot(data))
(*static_cast<sigc::slot<void>*>(slot))();
}
}
-
-//SignalProxyProperty implementation:
+// SignalProxyProperty implementation:
SignalProxyProperty::SignalProxyProperty(Glib::ObjectBase* obj, const gchar* property_name)
-: SignalProxyBase(obj),
- property_name_(property_name)
+: SignalProxyBase(obj), property_name_(property_name)
{
}
@@ -74,7 +73,8 @@ SignalProxyProperty::~SignalProxyProperty() noexcept
{
}
-sigc::connection SignalProxyProperty::connect(const SlotType& slot)
+sigc::connection
+SignalProxyProperty::connect(const SlotType& slot)
{
// Create a proxy to hold our connection info
// This will be deleted by destroy_notify_handler.
@@ -85,7 +85,8 @@ sigc::connection SignalProxyProperty::connect(const SlotType& slot)
return pConnectionNode->connect_changed(property_name_);
}
-sigc::connection SignalProxyProperty::connect(SlotType&& slot)
+sigc::connection
+SignalProxyProperty::connect(SlotType&& slot)
{
// Create a proxy to hold our connection info
// This will be deleted by destroy_notify_handler.
@@ -96,41 +97,42 @@ sigc::connection SignalProxyProperty::connect(SlotType&& slot)
return pConnectionNode->connect_changed(property_name_);
}
-
-//PropertyProxy_Base implementation:
+// PropertyProxy_Base implementation:
PropertyProxy_Base::PropertyProxy_Base(ObjectBase* obj, const char* property_name)
-:
- obj_ (obj),
- property_name_ (property_name)
-{}
+: obj_(obj), property_name_(property_name)
+{
+}
PropertyProxy_Base::PropertyProxy_Base(const PropertyProxy_Base& other)
-:
- obj_ (other.obj_),
- property_name_ (other.property_name_)
-{}
+: obj_(other.obj_), property_name_(other.property_name_)
+{
+}
-SignalProxyProperty PropertyProxy_Base::signal_changed()
+SignalProxyProperty
+PropertyProxy_Base::signal_changed()
{
return SignalProxyProperty(obj_, property_name_);
}
-void PropertyProxy_Base::set_property_(const Glib::ValueBase& value)
+void
+PropertyProxy_Base::set_property_(const Glib::ValueBase& value)
{
g_object_set_property(obj_->gobj(), property_name_, value.gobj());
}
-void PropertyProxy_Base::get_property_(Glib::ValueBase& value) const
+void
+PropertyProxy_Base::get_property_(Glib::ValueBase& value) const
{
g_object_get_property(obj_->gobj(), property_name_, value.gobj());
}
-void PropertyProxy_Base::reset_property_()
+void
+PropertyProxy_Base::reset_property_()
{
// Get information about the parameter:
- const GParamSpec *const pParamSpec =
- g_object_class_find_property(G_OBJECT_GET_CLASS(obj_->gobj()), property_name_);
+ const GParamSpec* const pParamSpec =
+ g_object_class_find_property(G_OBJECT_GET_CLASS(obj_->gobj()), property_name_);
g_return_if_fail(pParamSpec != nullptr);
diff --git a/glib/glibmm/quark.cc b/glib/glibmm/quark.cc
index 29458be..a528be8 100644
--- a/glib/glibmm/quark.cc
+++ b/glib/glibmm/quark.cc
@@ -24,20 +24,22 @@
namespace Glib
{
-QueryQuark::QueryQuark(const GQuark& q)
- : quark_(q)
-{}
+QueryQuark::QueryQuark(const GQuark& q) : quark_(q)
+{
+}
-QueryQuark::QueryQuark(const ustring& s)
-: quark_(g_quark_try_string(s.c_str()))
-{}
+QueryQuark::QueryQuark(const ustring& s) : quark_(g_quark_try_string(s.c_str()))
+{
+}
-QueryQuark::QueryQuark(const char* s)
-: quark_(g_quark_try_string(s))
-{}
+QueryQuark::QueryQuark(const char* s) : quark_(g_quark_try_string(s))
+{
+}
-QueryQuark& QueryQuark::operator=(const QueryQuark& q)
-{ quark_=q.quark_;
+QueryQuark&
+QueryQuark::operator=(const QueryQuark& q)
+{
+ quark_ = q.quark_;
return *this;
}
@@ -46,18 +48,17 @@ QueryQuark::operator ustring() const
return ustring(g_quark_to_string(quark_));
}
+Quark::Quark(const ustring& s) : QueryQuark(g_quark_from_string(s.c_str()))
+{
+}
-Quark::Quark(const ustring& s)
-: QueryQuark(g_quark_from_string(s.c_str()))
-{}
-
-Quark::Quark(const char* s)
-: QueryQuark(g_quark_from_string(s))
-{}
+Quark::Quark(const char* s) : QueryQuark(g_quark_from_string(s))
+{
+}
Quark::~Quark() noexcept
-{}
-
+{
+}
GQuark quark_ = 0;
GQuark quark_cpp_wrapper_deleted_ = 0;
diff --git a/glib/glibmm/random.cc b/glib/glibmm/random.cc
index 8768615..11f5cdf 100644
--- a/glib/glibmm/random.cc
+++ b/glib/glibmm/random.cc
@@ -22,54 +22,56 @@
#include <glibmm.h>
-
namespace Glib
{
-Rand::Rand()
-:
- gobject_ (g_rand_new())
-{}
+Rand::Rand() : gobject_(g_rand_new())
+{
+}
-Rand::Rand(guint32 seed)
-:
- gobject_ (g_rand_new_with_seed(seed))
-{}
+Rand::Rand(guint32 seed) : gobject_(g_rand_new_with_seed(seed))
+{
+}
Rand::~Rand() noexcept
{
g_rand_free(gobject_);
}
-void Rand::set_seed(guint32 seed)
+void
+Rand::set_seed(guint32 seed)
{
g_rand_set_seed(gobject_, seed);
}
-bool Rand::get_bool()
+bool
+Rand::get_bool()
{
return g_rand_boolean(gobject_);
}
-guint32 Rand::get_int()
+guint32
+Rand::get_int()
{
return g_rand_int(gobject_);
}
-gint32 Rand::get_int_range(gint32 begin, gint32 end)
+gint32
+Rand::get_int_range(gint32 begin, gint32 end)
{
return g_rand_int_range(gobject_, begin, end);
}
-double Rand::get_double()
+double
+Rand::get_double()
{
return g_rand_double(gobject_);
}
-double Rand::get_double_range(double begin, double end)
+double
+Rand::get_double_range(double begin, double end)
{
return g_rand_double_range(gobject_, begin, end);
}
} // namespace Glib
-
diff --git a/glib/glibmm/sarray.cc b/glib/glibmm/sarray.cc
index a7d6e31..86b6643 100644
--- a/glib/glibmm/sarray.cc
+++ b/glib/glibmm/sarray.cc
@@ -21,4 +21,3 @@
*/
#include <glibmm/sarray.h>
-
diff --git a/glib/glibmm/signalproxy.cc b/glib/glibmm/signalproxy.cc
index 52c9ed7..a7e5d9c 100644
--- a/glib/glibmm/signalproxy.cc
+++ b/glib/glibmm/signalproxy.cc
@@ -22,28 +22,25 @@
#include <glibmm/object.h>
#include <glibmm/signalproxy.h>
-
namespace Glib
{
// SignalProxyBase implementation:
-SignalProxyBase::SignalProxyBase(Glib::ObjectBase* obj)
-:
- obj_ (obj)
-{}
-
+SignalProxyBase::SignalProxyBase(Glib::ObjectBase* obj) : obj_(obj)
+{
+}
// SignalProxyNormal implementation:
SignalProxyNormal::SignalProxyNormal(Glib::ObjectBase* obj, const SignalProxyInfo* info)
-:
- SignalProxyBase (obj),
- info_ (info)
-{}
+: SignalProxyBase(obj), info_(info)
+{
+}
SignalProxyNormal::~SignalProxyNormal() noexcept
-{}
+{
+}
sigc::slot_base&
SignalProxyNormal::connect_(const sigc::slot_base& slot, bool after)
@@ -65,10 +62,9 @@ SignalProxyNormal::connect_impl_(GCallback callback, const sigc::slot_base& slot
// connect it to glib
// pConnectionNode will be passed in the data argument to the callback.
- pConnectionNode->connection_id_ = g_signal_connect_data(
- obj_->gobj(), info_->signal_name, callback, pConnectionNode,
- &SignalProxyConnectionNode::destroy_notify_handler,
- static_cast<GConnectFlags>((after) ? G_CONNECT_AFTER : 0));
+ pConnectionNode->connection_id_ = g_signal_connect_data(obj_->gobj(), info_->signal_name,
+ callback, pConnectionNode, &SignalProxyConnectionNode::destroy_notify_handler,
+ static_cast<GConnectFlags>((after) ? G_CONNECT_AFTER : 0));
return pConnectionNode->slot_;
}
@@ -81,52 +77,53 @@ SignalProxyNormal::connect_impl_(bool notify, sigc::slot_base&& slot, bool after
// connect it to glib
// pConnectionNode will be passed in the data argument to the callback.
- pConnectionNode->connection_id_ = g_signal_connect_data(
- obj_->gobj(), info_->signal_name,
- notify ? info_->notify_callback : info_->callback,
- pConnectionNode, &SignalProxyConnectionNode::destroy_notify_handler,
- static_cast<GConnectFlags>(after ? G_CONNECT_AFTER : 0));
+ pConnectionNode->connection_id_ = g_signal_connect_data(obj_->gobj(), info_->signal_name,
+ notify ? info_->notify_callback : info_->callback, pConnectionNode,
+ &SignalProxyConnectionNode::destroy_notify_handler,
+ static_cast<GConnectFlags>(after ? G_CONNECT_AFTER : 0));
return pConnectionNode->slot_;
}
-void SignalProxyNormal::emission_stop()
+void
+SignalProxyNormal::emission_stop()
{
g_signal_stop_emission_by_name(obj_->gobj(), info_->signal_name);
}
// static
-void SignalProxyNormal::slot0_void_callback(GObject* self, void* data)
+void
+SignalProxyNormal::slot0_void_callback(GObject* self, void* data)
{
// Do not try to call a signal on a disassociated wrapper.
- if(Glib::ObjectBase::_get_current_wrapper(self))
+ if (Glib::ObjectBase::_get_current_wrapper(self))
{
try
{
- if(sigc::slot_base *const slot = data_to_slot(data))
+ if (sigc::slot_base* const slot = data_to_slot(data))
(*static_cast<sigc::slot<void>*>(slot))();
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
}
}
-
// SignalProxyDetailed implementation:
-SignalProxyDetailed::SignalProxyDetailed(Glib::ObjectBase* obj,
- const SignalProxyInfo* info, const Glib::ustring& detail_name)
-:
- SignalProxyBase (obj),
- info_ (info),
- detailed_name_ (Glib::ustring(info->signal_name) +
- (detail_name.empty() ? Glib::ustring() : ("::" + detail_name)))
-{}
+SignalProxyDetailed::SignalProxyDetailed(
+ Glib::ObjectBase* obj, const SignalProxyInfo* info, const Glib::ustring& detail_name)
+: SignalProxyBase(obj),
+ info_(info),
+ detailed_name_(Glib::ustring(info->signal_name) +
+ (detail_name.empty() ? Glib::ustring() : ("::" + detail_name)))
+{
+}
SignalProxyDetailed::~SignalProxyDetailed() noexcept
-{}
+{
+}
sigc::slot_base&
SignalProxyDetailed::connect_impl_(bool notify, const sigc::slot_base& slot, bool after)
@@ -136,11 +133,10 @@ SignalProxyDetailed::connect_impl_(bool notify, const sigc::slot_base& slot, boo
// connect it to glib
// pConnectionNode will be passed in the data argument to the callback.
- pConnectionNode->connection_id_ = g_signal_connect_data(
- obj_->gobj(), detailed_name_.c_str(),
- notify ? info_->notify_callback : info_->callback,
- pConnectionNode, &SignalProxyConnectionNode::destroy_notify_handler,
- static_cast<GConnectFlags>(after ? G_CONNECT_AFTER : 0));
+ pConnectionNode->connection_id_ = g_signal_connect_data(obj_->gobj(), detailed_name_.c_str(),
+ notify ? info_->notify_callback : info_->callback, pConnectionNode,
+ &SignalProxyConnectionNode::destroy_notify_handler,
+ static_cast<GConnectFlags>(after ? G_CONNECT_AFTER : 0));
return pConnectionNode->slot_;
}
@@ -153,16 +149,16 @@ SignalProxyDetailed::connect_impl_(bool notify, sigc::slot_base&& slot, bool aft
// connect it to glib
// pConnectionNode will be passed in the data argument to the callback.
- pConnectionNode->connection_id_ = g_signal_connect_data(
- obj_->gobj(), detailed_name_.c_str(),
- notify ? info_->notify_callback : info_->callback,
- pConnectionNode, &SignalProxyConnectionNode::destroy_notify_handler,
- static_cast<GConnectFlags>(after ? G_CONNECT_AFTER : 0));
+ pConnectionNode->connection_id_ = g_signal_connect_data(obj_->gobj(), detailed_name_.c_str(),
+ notify ? info_->notify_callback : info_->callback, pConnectionNode,
+ &SignalProxyConnectionNode::destroy_notify_handler,
+ static_cast<GConnectFlags>(after ? G_CONNECT_AFTER : 0));
return pConnectionNode->slot_;
}
-void SignalProxyDetailed::emission_stop()
+void
+SignalProxyDetailed::emission_stop()
{
g_signal_stop_emission_by_name(obj_->gobj(), detailed_name_.c_str());
}
diff --git a/glib/glibmm/signalproxy_connectionnode.cc b/glib/glibmm/signalproxy_connectionnode.cc
index 21fea65..b4b517c 100644
--- a/glib/glibmm/signalproxy_connectionnode.cc
+++ b/glib/glibmm/signalproxy_connectionnode.cc
@@ -25,49 +25,49 @@ namespace Glib
{
SignalProxyConnectionNode::SignalProxyConnectionNode(const sigc::slot_base& slot, GObject* gobject)
-:
- connection_id_ (0),
- slot_ (slot),
- object_ (gobject)
+: connection_id_(0), slot_(slot), object_(gobject)
{
- //The cleanup callback will be called when the connection is disconnected.
+ // The cleanup callback will be called when the connection is disconnected.
slot_.set_parent(this, &SignalProxyConnectionNode::notify /* cleanup callback */);
}
SignalProxyConnectionNode::SignalProxyConnectionNode(sigc::slot_base&& slot, GObject* gobject)
-:
- connection_id_ (0),
- slot_ (std::move(slot)),
- object_ (gobject)
+: connection_id_(0), slot_(std::move(slot)), object_(gobject)
{
- //The cleanup callback will be called when the connection is disconnected.
+ // The cleanup callback will be called when the connection is disconnected.
slot_.set_parent(this, &SignalProxyConnectionNode::notify /* cleanup callback */);
}
// 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)
+// static
+void*
+SignalProxyConnectionNode::notify(void* data)
{
// notification from libsigc++.
SignalProxyConnectionNode* conn = static_cast<SignalProxyConnectionNode*>(data);
// If there is no object, this call was triggered from destroy_notify_handler(),
// because we set conn->object to 0 there:
- if(conn && conn->object_)
+ if (conn && conn->object_)
{
GObject* o = conn->object_;
conn->object_ = nullptr;
- if(g_signal_handler_is_connected(o, conn->connection_id_)) //We check first, because during destruction,
GTK+ sometimes seems to disconnect them for us, before we expect it to. See bug #87912
+ if (g_signal_handler_is_connected(o, conn->connection_id_)) // We check first, because during
+ // destruction, GTK+ sometimes seems
+ // to disconnect them for us, before
+ // we expect it to. See bug #87912
{
// Disconnecting triggers execution of destroy_notify_handler(), eiter immediately or later:
- // When the signal handler is currently running. (for instance, if the callback disconnects its own
connection)
- // In that case, destroy_notify_handler() will be called after this whole function has returned.
- // Anyway. destroy_notify_handler() will always be called, so we leave that to do the deletion.
-
-
- //Forget the connection:
+ // When the signal handler is currently running. (for instance, if the callback disconnects
+ // its own connection)
+ // In that case, destroy_notify_handler() will be called after this whole function has
+ // returned.
+ // Anyway. destroy_notify_handler() will always be called, so we leave that to do the
+ // deletion.
+
+ // Forget the connection:
gulong connection_id = conn->connection_id_;
conn->connection_id_ = 0;
@@ -78,21 +78,23 @@ void* SignalProxyConnectionNode::notify(void* data)
return nullptr; // apparently unused in libsigc++
}
-//static
-void SignalProxyConnectionNode::destroy_notify_handler(gpointer data, GClosure*)
+// static
+void
+SignalProxyConnectionNode::destroy_notify_handler(gpointer data, GClosure*)
{
- //glib calls this when it has finished with a glib signal connection,
- //either when the emitting object dies, or when the connection has been disconnected.
+ // glib calls this when it has finished with a glib signal connection,
+ // either when the emitting object dies, or when the connection has been disconnected.
// notification from gtk+.
SignalProxyConnectionNode* conn = static_cast<SignalProxyConnectionNode*>(data);
- if(conn)
+ if (conn)
{
// the object has already lost track of this object.
conn->object_ = nullptr;
- delete conn; // if there are connection objects referring to slot_ they are notified during destruction
of slot_
+ delete conn; // if there are connection objects referring to slot_ they are notified during
+ // destruction of slot_
}
}
diff --git a/glib/glibmm/streamiochannel.cc b/glib/glibmm/streamiochannel.cc
index da45347..9444216 100644
--- a/glib/glibmm/streamiochannel.cc
+++ b/glib/glibmm/streamiochannel.cc
@@ -29,35 +29,38 @@ namespace Glib
#ifndef GLIBMM_DISABLE_DEPRECATED
// static
-Glib::RefPtr<StreamIOChannel> StreamIOChannel::create(std::istream& stream)
+Glib::RefPtr<StreamIOChannel>
+StreamIOChannel::create(std::istream& stream)
{
return Glib::RefPtr<StreamIOChannel>(new StreamIOChannel(&stream, nullptr));
}
// static
-Glib::RefPtr<StreamIOChannel> StreamIOChannel::create(std::ostream& stream)
+Glib::RefPtr<StreamIOChannel>
+StreamIOChannel::create(std::ostream& stream)
{
return Glib::RefPtr<StreamIOChannel>(new StreamIOChannel(nullptr, &stream));
}
// static
-Glib::RefPtr<StreamIOChannel> StreamIOChannel::create(std::iostream& stream)
+Glib::RefPtr<StreamIOChannel>
+StreamIOChannel::create(std::iostream& stream)
{
return Glib::RefPtr<StreamIOChannel>(new StreamIOChannel(&stream, &stream));
}
StreamIOChannel::StreamIOChannel(std::istream* stream_in, std::ostream* stream_out)
-:
- stream_in_ (stream_in),
- stream_out_ (stream_out)
+: stream_in_(stream_in), stream_out_(stream_out)
{
get_flags_vfunc(); // initialize GIOChannel flag bits
}
StreamIOChannel::~StreamIOChannel() noexcept
-{}
+{
+}
-IOStatus StreamIOChannel::read_vfunc(char* buf, gsize count, gsize& bytes_read)
+IOStatus
+StreamIOChannel::read_vfunc(char* buf, gsize count, gsize& bytes_read)
{
g_return_val_if_fail(stream_in_ != nullptr, IO_STATUS_ERROR);
@@ -65,10 +68,10 @@ IOStatus StreamIOChannel::read_vfunc(char* buf, gsize count, gsize& bytes_read)
stream_in_->read(buf, count);
bytes_read = stream_in_->gcount();
- if(stream_in_->eof())
+ if (stream_in_->eof())
return IO_STATUS_EOF;
- if(stream_in_->fail())
+ if (stream_in_->fail())
{
throw Glib::Error(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED, "Reading from stream failed");
}
@@ -76,7 +79,8 @@ IOStatus StreamIOChannel::read_vfunc(char* buf, gsize count, gsize& bytes_read)
return IO_STATUS_NORMAL;
}
-IOStatus StreamIOChannel::write_vfunc(const char* buf, gsize count, gsize& bytes_written)
+IOStatus
+StreamIOChannel::write_vfunc(const char* buf, gsize count, gsize& bytes_written)
{
g_return_val_if_fail(stream_out_ != nullptr, IO_STATUS_ERROR);
@@ -85,7 +89,7 @@ IOStatus StreamIOChannel::write_vfunc(const char* buf, gsize count, gsize& bytes
stream_out_->clear();
stream_out_->write(buf, count);
- if(stream_out_->fail())
+ if (stream_out_->fail())
{
throw Glib::Error(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED, "Writing to stream failed");
}
@@ -95,33 +99,40 @@ IOStatus StreamIOChannel::write_vfunc(const char* buf, gsize count, gsize& bytes
return IO_STATUS_NORMAL;
}
-IOStatus StreamIOChannel::seek_vfunc(gint64 offset, SeekType type)
+IOStatus
+StreamIOChannel::seek_vfunc(gint64 offset, SeekType type)
{
std::ios::seekdir direction = std::ios::beg;
- switch(type)
+ switch (type)
{
- case SEEK_TYPE_SET: direction = std::ios::beg; break;
- case SEEK_TYPE_CUR: direction = std::ios::cur; break;
- case SEEK_TYPE_END: direction = std::ios::end; break;
+ case SEEK_TYPE_SET:
+ direction = std::ios::beg;
+ break;
+ case SEEK_TYPE_CUR:
+ direction = std::ios::cur;
+ break;
+ case SEEK_TYPE_END:
+ direction = std::ios::end;
+ break;
}
bool failed = false;
- if(stream_in_)
+ if (stream_in_)
{
stream_in_->clear();
stream_in_->seekg(offset, direction);
failed = stream_in_->fail();
}
- if(stream_out_)
+ if (stream_out_)
{
stream_out_->clear();
stream_out_->seekp(offset, direction);
failed = (failed || stream_out_->fail());
}
- if(failed)
+ if (failed)
{
throw Glib::Error(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED, "Seeking into stream failed");
}
@@ -129,23 +140,24 @@ IOStatus StreamIOChannel::seek_vfunc(gint64 offset, SeekType type)
return Glib::IO_STATUS_NORMAL;
}
-IOStatus StreamIOChannel::close_vfunc()
+IOStatus
+StreamIOChannel::close_vfunc()
{
bool failed = false;
- if(std::fstream *const fstream = dynamic_cast<std::fstream*>(stream_in_))
+ if (std::fstream* const fstream = dynamic_cast<std::fstream*>(stream_in_))
{
fstream->clear();
fstream->close();
failed = fstream->fail();
}
- else if(std::ifstream *const ifstream = dynamic_cast<std::ifstream*>(stream_in_))
+ else if (std::ifstream* const ifstream = dynamic_cast<std::ifstream*>(stream_in_))
{
ifstream->clear();
ifstream->close();
failed = ifstream->fail();
}
- else if(std::ofstream *const ofstream = dynamic_cast<std::ofstream*>(stream_out_))
+ else if (std::ofstream* const ofstream = dynamic_cast<std::ofstream*>(stream_out_))
{
ofstream->clear();
ofstream->close();
@@ -153,11 +165,11 @@ IOStatus StreamIOChannel::close_vfunc()
}
else
{
- throw Glib::Error(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED,
- "Attempt to close non-file stream");
+ throw Glib::Error(
+ G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED, "Attempt to close non-file stream");
}
- if(failed)
+ if (failed)
{
throw Glib::Error(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED, "Failed to close stream");
}
@@ -170,17 +182,18 @@ IOStatus StreamIOChannel::set_flags_vfunc(IOFlags)
return IO_STATUS_NORMAL;
}
-IOFlags StreamIOChannel::get_flags_vfunc()
+IOFlags
+StreamIOChannel::get_flags_vfunc()
{
- gobj()->is_seekable = 1;
- gobj()->is_readable = (stream_in_ != nullptr);
+ gobj()->is_seekable = 1;
+ gobj()->is_readable = (stream_in_ != nullptr);
gobj()->is_writeable = (stream_out_ != nullptr);
IOFlags flags = IO_FLAG_IS_SEEKABLE;
- if(stream_in_)
+ if (stream_in_)
flags |= IO_FLAG_IS_READABLE;
- if(stream_out_)
+ if (stream_out_)
flags |= IO_FLAG_IS_WRITEABLE;
return flags;
@@ -192,6 +205,6 @@ Glib::RefPtr<Glib::Source> StreamIOChannel::create_watch_vfunc(IOCondition)
return Glib::RefPtr<Glib::Source>();
}
-#endif //GLIBMM_DISABLE_DEPRECATED
+#endif // GLIBMM_DISABLE_DEPRECATED
} // namespace Glib
diff --git a/glib/glibmm/stringutils.cc b/glib/glibmm/stringutils.cc
index 5eb58c1..329b1b0 100644
--- a/glib/glibmm/stringutils.cc
+++ b/glib/glibmm/stringutils.cc
@@ -25,52 +25,55 @@
#include <cerrno>
#include <stdexcept>
-bool Glib::str_has_prefix(const std::string& str, const std::string& prefix)
+bool
+Glib::str_has_prefix(const std::string& str, const std::string& prefix)
{
return g_str_has_prefix(str.c_str(), prefix.c_str());
}
-bool Glib::str_has_suffix(const std::string& str, const std::string& suffix)
+bool
+Glib::str_has_suffix(const std::string& str, const std::string& suffix)
{
return g_str_has_suffix(str.c_str(), suffix.c_str());
}
-double Glib::Ascii::strtod(const std::string& str)
+double
+Glib::Ascii::strtod(const std::string& str)
{
std::string::size_type dummy;
return Glib::Ascii::strtod(str, dummy, 0);
}
-double Glib::Ascii::strtod(const std::string& str,
- std::string::size_type& end_index,
- std::string::size_type start_index)
+double
+Glib::Ascii::strtod(
+ const std::string& str, std::string::size_type& end_index, std::string::size_type start_index)
{
- if(start_index >= str.size())
+ if (start_index >= str.size())
{
throw std::out_of_range("out of range (strtod): start_index > str.size()");
}
- const char *const bufptr = str.c_str();
+ const char* const bufptr = str.c_str();
char* endptr = nullptr;
const double result = g_ascii_strtod(bufptr + start_index, &endptr);
- const int err_no = errno;
+ const int err_no = errno;
- if(err_no != 0)
+ if (err_no != 0)
{
g_return_val_if_fail(err_no == ERANGE, result);
- //Interpret the result in the event of an error:
- if(result > 0.0)
+ // Interpret the result in the event of an error:
+ if (result > 0.0)
throw std::overflow_error("overflow (strtod): positive number too large");
- if(result < 0.0)
+ if (result < 0.0)
throw std::overflow_error("overflow (strtod): negative number too large");
throw std::underflow_error("underflow (strtod): number too small");
}
- if(endptr)
+ if (endptr)
end_index = endptr - bufptr;
else
end_index = str.size();
@@ -78,38 +81,43 @@ double Glib::Ascii::strtod(const std::string& str,
return result;
}
-std::string Glib::Ascii::dtostr(double d)
+std::string
+Glib::Ascii::dtostr(double d)
{
char buf[G_ASCII_DTOSTR_BUF_SIZE];
return g_ascii_dtostr(buf, sizeof(buf), d);
}
-std::string Glib::strescape(const std::string& source)
+std::string
+Glib::strescape(const std::string& source)
{
const auto buf = make_unique_ptr_gfree(g_strescape(source.c_str(), nullptr));
return buf.get();
}
-std::string Glib::strescape(const std::string& source, const std::string& exceptions)
+std::string
+Glib::strescape(const std::string& source, const std::string& exceptions)
{
const auto buf = make_unique_ptr_gfree(g_strescape(source.c_str(), exceptions.c_str()));
return buf.get();
}
-std::string Glib::strcompress(const std::string& source)
+std::string
+Glib::strcompress(const std::string& source)
{
const auto buf = make_unique_ptr_gfree(g_strcompress(source.c_str()));
return buf.get();
}
-Glib::ustring Glib::strerror(int errnum)
+Glib::ustring
+Glib::strerror(int errnum)
{
return g_strerror(errnum);
}
-Glib::ustring Glib::strsignal(int signum)
+Glib::ustring
+Glib::strsignal(int signum)
{
return g_strsignal(signum);
}
-
diff --git a/glib/glibmm/threadpool.cc b/glib/glibmm/threadpool.cc
index 163fb19..75a6a7b 100644
--- a/glib/glibmm/threadpool.cc
+++ b/glib/glibmm/threadpool.cc
@@ -39,41 +39,45 @@ public:
ThreadPool::SlotList& operator=(const ThreadPool::SlotList&) = delete;
sigc::slot<void>* push(const sigc::slot<void>& slot);
- sigc::slot<void> pop(sigc::slot<void>* slot_ptr);
+ sigc::slot<void> pop(sigc::slot<void>* slot_ptr);
void lock_and_unlock();
private:
- Glib::Threads::Mutex mutex_;
- std::list< sigc::slot<void> > list_;
+ Glib::Threads::Mutex mutex_;
+ std::list<sigc::slot<void>> list_;
};
ThreadPool::SlotList::SlotList()
-{}
+{
+}
ThreadPool::SlotList::~SlotList() noexcept
-{}
+{
+}
-sigc::slot<void>* ThreadPool::SlotList::push(const sigc::slot<void>& slot)
+sigc::slot<void>*
+ThreadPool::SlotList::push(const sigc::slot<void>& slot)
{
- Threads::Mutex::Lock lock (mutex_);
+ Threads::Mutex::Lock lock(mutex_);
list_.emplace_back(slot);
return &list_.back();
}
-sigc::slot<void> ThreadPool::SlotList::pop(sigc::slot<void>* slot_ptr)
+sigc::slot<void>
+ThreadPool::SlotList::pop(sigc::slot<void>* slot_ptr)
{
sigc::slot<void> slot;
{
- Threads::Mutex::Lock lock (mutex_);
+ Threads::Mutex::Lock lock(mutex_);
- std::list< sigc::slot<void> >::iterator pslot = list_.begin();
- while(pslot != list_.end() && slot_ptr != &*pslot)
+ std::list<sigc::slot<void>>::iterator pslot = list_.begin();
+ while (pslot != list_.end() && slot_ptr != &*pslot)
++pslot;
- if(pslot != list_.end())
+ if (pslot != list_.end())
{
slot = *pslot;
list_.erase(pslot);
@@ -83,7 +87,8 @@ sigc::slot<void> ThreadPool::SlotList::pop(sigc::slot<void>* slot_ptr)
return slot;
}
-void ThreadPool::SlotList::lock_and_unlock()
+void
+ThreadPool::SlotList::lock_and_unlock()
{
mutex_.lock();
mutex_.unlock();
@@ -91,27 +96,27 @@ void ThreadPool::SlotList::lock_and_unlock()
} // namespace Glib
-
namespace
{
-static void call_thread_entry_slot(void* data, void* user_data)
+static void
+call_thread_entry_slot(void* data, void* user_data)
{
try
{
- Glib::ThreadPool::SlotList *const slot_list =
- static_cast<Glib::ThreadPool::SlotList*>(user_data);
+ Glib::ThreadPool::SlotList* const slot_list =
+ static_cast<Glib::ThreadPool::SlotList*>(user_data);
- sigc::slot<void> slot (slot_list->pop(static_cast<sigc::slot<void>*>(data)));
+ sigc::slot<void> slot(slot_list->pop(static_cast<sigc::slot<void>*>(data)));
slot();
}
- catch(Glib::Threads::Thread::Exit&)
+ catch (Glib::Threads::Thread::Exit&)
{
// Just exit from the thread. The Thread::Exit exception
// is our sane C++ replacement of g_thread_exit().
}
- catch(...)
+ catch (...)
{
Glib::exception_handlers_invoke();
}
@@ -119,21 +124,17 @@ static void call_thread_entry_slot(void* data, void* user_data)
} // anonymous namespace
-
namespace Glib
{
ThreadPool::ThreadPool(int max_threads, bool exclusive)
-:
- gobject_ (nullptr),
- slot_list_ (new SlotList())
+: gobject_(nullptr), slot_list_(new SlotList())
{
GError* error = nullptr;
- gobject_ = g_thread_pool_new(
- &call_thread_entry_slot, slot_list_, max_threads, exclusive, &error);
+ gobject_ = g_thread_pool_new(&call_thread_entry_slot, slot_list_, max_threads, exclusive, &error);
- if(error)
+ if (error)
{
delete slot_list_;
slot_list_ = nullptr;
@@ -143,70 +144,77 @@ ThreadPool::ThreadPool(int max_threads, bool exclusive)
ThreadPool::~ThreadPool() noexcept
{
- if(gobject_)
+ if (gobject_)
g_thread_pool_free(gobject_, 1, 1);
- if(slot_list_)
+ if (slot_list_)
{
slot_list_->lock_and_unlock();
delete slot_list_;
}
}
-void ThreadPool::push(const sigc::slot<void>& slot)
+void
+ThreadPool::push(const sigc::slot<void>& slot)
{
- sigc::slot<void> *const slot_ptr = slot_list_->push(slot);
+ sigc::slot<void>* const slot_ptr = slot_list_->push(slot);
GError* error = nullptr;
g_thread_pool_push(gobject_, slot_ptr, &error);
- if(error)
+ if (error)
{
slot_list_->pop(slot_ptr);
Glib::Error::throw_exception(error);
}
}
-void ThreadPool::set_max_threads(int max_threads)
+void
+ThreadPool::set_max_threads(int max_threads)
{
GError* error = nullptr;
g_thread_pool_set_max_threads(gobject_, max_threads, &error);
- if(error)
+ if (error)
Glib::Error::throw_exception(error);
}
-int ThreadPool::get_max_threads() const
+int
+ThreadPool::get_max_threads() const
{
return g_thread_pool_get_max_threads(gobject_);
}
-unsigned int ThreadPool::get_num_threads() const
+unsigned int
+ThreadPool::get_num_threads() const
{
return g_thread_pool_get_num_threads(gobject_);
}
-unsigned int ThreadPool::unprocessed() const
+unsigned int
+ThreadPool::unprocessed() const
{
return g_thread_pool_unprocessed(gobject_);
}
-bool ThreadPool::get_exclusive() const
+bool
+ThreadPool::get_exclusive() const
{
g_return_val_if_fail(gobject_ != nullptr, false);
return gobject_->exclusive;
}
-void ThreadPool::shutdown(bool immediately)
+void
+ThreadPool::shutdown(bool immediately)
{
- if(gobject_)
+ if (gobject_)
{
g_thread_pool_free(gobject_, immediately, 1);
gobject_ = nullptr;
}
- if(slot_list_)
+ if (slot_list_)
{
slot_list_->lock_and_unlock();
delete slot_list_;
@@ -215,25 +223,29 @@ void ThreadPool::shutdown(bool immediately)
}
// static
-void ThreadPool::set_max_unused_threads(int max_threads)
+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()
+int
+ThreadPool::get_max_unused_threads()
{
return g_thread_pool_get_max_unused_threads();
}
// static
-unsigned int ThreadPool::get_num_unused_threads()
+unsigned int
+ThreadPool::get_num_unused_threads()
{
return g_thread_pool_get_num_unused_threads();
}
// static
-void ThreadPool::stop_unused_threads()
+void
+ThreadPool::stop_unused_threads()
{
g_thread_pool_stop_unused_threads();
}
@@ -241,4 +253,3 @@ void ThreadPool::stop_unused_threads()
} // namespace Glib
#endif // GLIBMM_DISABLE_DEPRECATED
-
diff --git a/glib/glibmm/timer.cc b/glib/glibmm/timer.cc
index e48773b..ad3bd6b 100644
--- a/glib/glibmm/timer.cc
+++ b/glib/glibmm/timer.cc
@@ -23,46 +23,49 @@
namespace Glib
{
-Timer::Timer()
-:
- gobject_ (g_timer_new())
-{}
+Timer::Timer() : gobject_(g_timer_new())
+{
+}
Timer::~Timer() noexcept
{
g_timer_destroy(gobject_);
}
-void Timer::start()
+void
+Timer::start()
{
g_timer_start(gobject_);
}
-void Timer::stop()
+void
+Timer::stop()
{
g_timer_stop(gobject_);
}
-void Timer::reset()
+void
+Timer::reset()
{
g_timer_reset(gobject_);
}
-double Timer::elapsed() const
+double
+Timer::elapsed() const
{
return g_timer_elapsed(gobject_, nullptr);
}
-double Timer::elapsed(unsigned long& microseconds) const
+double
+Timer::elapsed(unsigned long& microseconds) const
{
return g_timer_elapsed(gobject_, µseconds);
}
-
-void usleep(unsigned long microseconds)
+void
+usleep(unsigned long microseconds)
{
g_usleep(microseconds);
}
} // namespace Glib
-
diff --git a/glib/glibmm/timeval.cc b/glib/glibmm/timeval.cc
index 99b6597..63e93c5 100644
--- a/glib/glibmm/timeval.cc
+++ b/glib/glibmm/timeval.cc
@@ -22,28 +22,30 @@
#include <glibmm/timeval.h>
-
namespace Glib
{
-void TimeVal::assign_current_time()
+void
+TimeVal::assign_current_time()
{
g_get_current_time(this);
}
-bool TimeVal::assign_from_iso8601(const Glib::ustring& iso_date)
+bool
+TimeVal::assign_from_iso8601(const Glib::ustring& iso_date)
{
return g_time_val_from_iso8601(iso_date.c_str(), this);
}
-void TimeVal::add(const TimeVal& rhs)
+void
+TimeVal::add(const TimeVal& rhs)
{
g_return_if_fail(tv_usec >= 0 && tv_usec < G_USEC_PER_SEC);
g_return_if_fail(rhs.tv_usec >= 0 && rhs.tv_usec < G_USEC_PER_SEC);
tv_usec += rhs.tv_usec;
- if(tv_usec >= G_USEC_PER_SEC)
+ if (tv_usec >= G_USEC_PER_SEC)
{
tv_usec -= G_USEC_PER_SEC;
++tv_sec;
@@ -52,14 +54,15 @@ void TimeVal::add(const TimeVal& rhs)
tv_sec += rhs.tv_sec;
}
-void TimeVal::subtract(const TimeVal& rhs)
+void
+TimeVal::subtract(const TimeVal& rhs)
{
g_return_if_fail(tv_usec >= 0 && tv_usec < G_USEC_PER_SEC);
g_return_if_fail(rhs.tv_usec >= 0 && rhs.tv_usec < G_USEC_PER_SEC);
tv_usec -= rhs.tv_usec;
- if(tv_usec < 0)
+ if (tv_usec < 0)
{
tv_usec += G_USEC_PER_SEC;
--tv_sec;
@@ -68,32 +71,35 @@ void TimeVal::subtract(const TimeVal& rhs)
tv_sec -= rhs.tv_sec;
}
-void TimeVal::add_seconds(long seconds)
+void
+TimeVal::add_seconds(long seconds)
{
g_return_if_fail(tv_usec >= 0 && tv_usec < G_USEC_PER_SEC);
tv_sec += seconds;
}
-void TimeVal::subtract_seconds(long seconds)
+void
+TimeVal::subtract_seconds(long seconds)
{
g_return_if_fail(tv_usec >= 0 && tv_usec < G_USEC_PER_SEC);
tv_sec -= seconds;
}
-void TimeVal::add_milliseconds(long milliseconds)
+void
+TimeVal::add_milliseconds(long milliseconds)
{
g_return_if_fail(tv_usec >= 0 && tv_usec < G_USEC_PER_SEC);
tv_usec += (milliseconds % 1000) * 1000;
- if(tv_usec < 0)
+ if (tv_usec < 0)
{
tv_usec += G_USEC_PER_SEC;
--tv_sec;
}
- else if(tv_usec >= G_USEC_PER_SEC)
+ else if (tv_usec >= G_USEC_PER_SEC)
{
tv_usec -= G_USEC_PER_SEC;
++tv_sec;
@@ -102,24 +108,28 @@ void TimeVal::add_milliseconds(long milliseconds)
tv_sec += milliseconds / 1000;
}
-void TimeVal::subtract_milliseconds(long milliseconds)
+void
+TimeVal::subtract_milliseconds(long milliseconds)
{
add_milliseconds(-1 * milliseconds);
}
-void TimeVal::add_microseconds(long microseconds)
+void
+TimeVal::add_microseconds(long microseconds)
{
g_time_val_add(this, microseconds);
}
-void TimeVal::subtract_microseconds(long microseconds)
+void
+TimeVal::subtract_microseconds(long microseconds)
{
g_time_val_add(this, -1 * microseconds);
}
-Glib::ustring TimeVal::as_iso8601() const
+Glib::ustring
+TimeVal::as_iso8601() const
{
- gchar *retval = g_time_val_to_iso8601(const_cast<Glib::TimeVal*>(this));
+ gchar* retval = g_time_val_to_iso8601(const_cast<Glib::TimeVal*>(this));
if (retval)
{
Glib::ustring iso_date(retval);
@@ -130,4 +140,3 @@ Glib::ustring TimeVal::as_iso8601() const
}
} // namespace Glib
-
diff --git a/glib/glibmm/ustring.cc b/glib/glibmm/ustring.cc
index dc89875..051764c 100644
--- a/glib/glibmm/ustring.cc
+++ b/glib/glibmm/ustring.cc
@@ -39,14 +39,12 @@ using Glib::ustring;
//
struct UnicharToUtf8
{
- char buf[6];
- ustring::size_type len;
+ char buf[6];
+ ustring::size_type len;
- explicit UnicharToUtf8(gunichar uc)
- : len (g_unichar_to_utf8(uc, buf)) {}
+ explicit UnicharToUtf8(gunichar uc) : len(g_unichar_to_utf8(uc, buf)) {}
};
-
// All utf8_*_offset() functions return npos if offset is out of range.
// The caller should decide if npos is a valid argument and just marks
// the whole string, or if it is not allowed (e.g. for start positions).
@@ -54,20 +52,20 @@ struct UnicharToUtf8
// std::string will do that for us.
// First overload: stop on '\0' character.
-static
-ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset)
+static ustring::size_type
+utf8_byte_offset(const char* str, ustring::size_type offset)
{
- if(offset == ustring::npos)
+ if (offset == ustring::npos)
return ustring::npos;
- const char *const utf8_skip = g_utf8_skip;
+ const char* const utf8_skip = g_utf8_skip;
const char* p = str;
- for(; offset != 0; --offset)
+ for (; offset != 0; --offset)
{
const unsigned int c = static_cast<unsigned char>(*p);
- if(c == 0)
+ if (c == 0)
return ustring::npos;
p += utf8_skip[c];
@@ -77,20 +75,19 @@ ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset)
}
// Second overload: stop when reaching maxlen.
-static
-ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset,
- ustring::size_type maxlen)
+static ustring::size_type
+utf8_byte_offset(const char* str, ustring::size_type offset, ustring::size_type maxlen)
{
- if(offset == ustring::npos)
+ if (offset == ustring::npos)
return ustring::npos;
- const char *const utf8_skip = g_utf8_skip;
- const char *const pend = str + maxlen;
+ const char* const utf8_skip = g_utf8_skip;
+ const char* const pend = str + maxlen;
const char* p = str;
- for(; offset != 0; --offset)
+ for (; offset != 0; --offset)
{
- if(p >= pend)
+ if (p >= pend)
return ustring::npos;
p += utf8_skip[static_cast<unsigned char>(*p)];
@@ -101,8 +98,8 @@ ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset,
// Third overload: stop when reaching str.size().
//
-inline
-ustring::size_type utf8_byte_offset(const std::string& str, ustring::size_type offset)
+inline ustring::size_type
+utf8_byte_offset(const std::string& str, ustring::size_type offset)
{
return utf8_byte_offset(str.data(), offset, str.size());
}
@@ -116,56 +113,49 @@ struct Utf8SubstrBounds
ustring::size_type n;
Utf8SubstrBounds(const std::string& str, ustring::size_type ci, ustring::size_type cn)
- :
- i (utf8_byte_offset(str, ci)),
- n (ustring::npos)
+ : i(utf8_byte_offset(str, ci)), n(ustring::npos)
{
- if(i != ustring::npos)
+ if (i != ustring::npos)
n = utf8_byte_offset(str.data() + i, cn, str.size() - i);
}
};
// Converts byte offset to UTF-8 character offset.
-inline
-ustring::size_type utf8_char_offset(const std::string& str, ustring::size_type offset)
+inline ustring::size_type
+utf8_char_offset(const std::string& str, ustring::size_type offset)
{
- if(offset == ustring::npos)
+ if (offset == ustring::npos)
return ustring::npos;
- const char *const pdata = str.data();
+ const char* const pdata = str.data();
return g_utf8_pointer_to_offset(pdata, pdata + offset);
}
-
// Helper to implement ustring::find_first_of() and find_first_not_of().
// Returns the UTF-8 character offset, or ustring::npos if not found.
-static
-ustring::size_type utf8_find_first_of(const std::string& str, ustring::size_type offset,
- const char* utf8_match, long utf8_match_size,
- bool find_not_of)
+static ustring::size_type
+utf8_find_first_of(const std::string& str, ustring::size_type offset, const char* utf8_match,
+ long utf8_match_size, bool find_not_of)
{
const ustring::size_type byte_offset = utf8_byte_offset(str, offset);
- if(byte_offset == ustring::npos)
+ if (byte_offset == ustring::npos)
return ustring::npos;
long ucs4_match_size = 0;
const auto ucs4_match =
- Glib::make_unique_ptr_gfree(
- g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
+ Glib::make_unique_ptr_gfree(g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
- const gunichar *const match_begin = ucs4_match.get();
- const gunichar *const match_end = match_begin + ucs4_match_size;
+ const gunichar* const match_begin = ucs4_match.get();
+ const gunichar* const match_end = match_begin + ucs4_match_size;
- const char *const str_begin = str.data();
- const char *const str_end = str_begin + str.size();
+ const char* const str_begin = str.data();
+ const char* const str_end = str_begin + str.size();
- for(const char* pstr = str_begin + byte_offset;
- pstr < str_end;
- pstr = g_utf8_next_char(pstr))
+ for (const char* pstr = str_begin + byte_offset; pstr < str_end; pstr = g_utf8_next_char(pstr))
{
- const gunichar *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
+ const gunichar* const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
- if((pfound != match_end) != find_not_of)
+ if ((pfound != match_end) != find_not_of)
return offset;
++offset;
@@ -176,36 +166,34 @@ ustring::size_type utf8_find_first_of(const std::string& str, ustring::size_type
// Helper to implement ustring::find_last_of() and find_last_not_of().
// Returns the UTF-8 character offset, or ustring::npos if not found.
-static
-ustring::size_type utf8_find_last_of(const std::string& str, ustring::size_type offset,
- const char* utf8_match, long utf8_match_size,
- bool find_not_of)
+static ustring::size_type
+utf8_find_last_of(const std::string& str, ustring::size_type offset, const char* utf8_match,
+ long utf8_match_size, bool find_not_of)
{
long ucs4_match_size = 0;
const auto ucs4_match =
- Glib::make_unique_ptr_gfree(
- g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
+ Glib::make_unique_ptr_gfree(g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
- const gunichar *const match_begin = ucs4_match.get();
- const gunichar *const match_end = match_begin + ucs4_match_size;
+ const gunichar* const match_begin = ucs4_match.get();
+ const gunichar* const match_end = match_begin + ucs4_match_size;
- const char *const str_begin = str.data();
+ const char* const str_begin = str.data();
const char* pstr = str_begin;
// Set pstr one byte beyond the actual start position.
const ustring::size_type byte_offset = utf8_byte_offset(str, offset);
pstr += (byte_offset < str.size()) ? byte_offset + 1 : str.size();
- while(pstr > str_begin)
+ while (pstr > str_begin)
{
// Move to previous character.
do
--pstr;
- while((static_cast<unsigned char>(*pstr) & 0xC0u) == 0x80);
+ while ((static_cast<unsigned char>(*pstr) & 0xC0u) == 0x80);
- const gunichar *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
+ const gunichar* const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
- if((pfound != match_end) != find_not_of)
+ if ((pfound != match_end) != find_not_of)
return g_utf8_pointer_to_offset(str_begin, pstr);
}
@@ -214,7 +202,6 @@ ustring::size_type utf8_find_last_of(const std::string& str, ustring::size_type
} // anonymous namespace
-
namespace Glib
{
@@ -262,11 +249,12 @@ const ustring::size_type ustring::npos = std::string::npos;
* register moves, the generated code is sufficiently close to the optimum
* with GCC 4.1.2 on x86_64.
*/
-gunichar get_unichar_from_std_iterator(std::string::const_iterator pos)
+gunichar
+get_unichar_from_std_iterator(std::string::const_iterator pos)
{
unsigned int result = static_cast<unsigned char>(*pos);
- if((result & 0x80) != 0)
+ if ((result & 0x80) != 0)
{
unsigned int mask = 0x40;
@@ -274,10 +262,9 @@ gunichar get_unichar_from_std_iterator(std::string::const_iterator pos)
{
result <<= 6;
const unsigned int c = static_cast<unsigned char>(*++pos);
- mask <<= 5;
- result += c - 0x80;
- }
- while((result & mask) != 0);
+ mask <<= 5;
+ result += c - 0x80;
+ } while ((result & mask) != 0);
result &= mask - 1;
}
@@ -285,428 +272,456 @@ gunichar get_unichar_from_std_iterator(std::string::const_iterator pos)
return result;
}
-
/**** Glib::ustring ********************************************************/
-ustring::ustring()
-:
- string_ ()
-{}
+ustring::ustring() : string_()
+{
+}
-ustring::ustring(const ustring& other)
-:
- string_ (other.string_)
-{}
+ustring::ustring(const ustring& other) : string_(other.string_)
+{
+}
-ustring::ustring(ustring&& other)
-:
- string_ (std::move(other.string_))
-{}
+ustring::ustring(ustring&& other) : string_(std::move(other.string_))
+{
+}
-ustring::ustring(const ustring& src, ustring::size_type i, ustring::size_type n)
-:
- string_ ()
+ustring::ustring(const ustring& src, ustring::size_type i, ustring::size_type n) : string_()
{
- const Utf8SubstrBounds bounds (src.string_, i, n);
+ const Utf8SubstrBounds bounds(src.string_, i, n);
string_.assign(src.string_, bounds.i, bounds.n);
}
-ustring::ustring(const char* src, ustring::size_type n)
-:
- string_ (src, utf8_byte_offset(src, n))
-{}
+ustring::ustring(const char* src, ustring::size_type n) : string_(src, utf8_byte_offset(src, n))
+{
+}
-ustring::ustring(const char* src)
-:
- string_ (src)
-{}
+ustring::ustring(const char* src) : string_(src)
+{
+}
-ustring::ustring(ustring::size_type n, gunichar uc)
-:
- string_ ()
+ustring::ustring(ustring::size_type n, gunichar uc) : string_()
{
- if(uc < 0x80)
+ if (uc < 0x80)
{
// Optimize the probably most common case.
string_.assign(n, static_cast<char>(uc));
}
else
{
- const UnicharToUtf8 conv (uc);
+ const UnicharToUtf8 conv(uc);
string_.reserve(n * conv.len);
- for(; n > 0; --n)
+ for (; n > 0; --n)
string_.append(conv.buf, conv.len);
}
}
-ustring::ustring(ustring::size_type n, char c)
-:
- string_ (n, c)
-{}
+ustring::ustring(ustring::size_type n, char c) : string_(n, c)
+{
+}
-ustring::ustring(const std::string& src)
-:
- string_ (src)
-{}
+ustring::ustring(const std::string& src) : string_(src)
+{
+}
-ustring::ustring(std::string&& src)
-:
- string_ (std::move(src))
-{}
+ustring::ustring(std::string&& src) : string_(std::move(src))
+{
+}
ustring::~ustring() noexcept
-{}
+{
+}
-void ustring::swap(ustring& other)
+void
+ustring::swap(ustring& other)
{
string_.swap(other.string_);
}
-
/**** Glib::ustring::operator=() *******************************************/
-ustring& ustring::operator=(const ustring& other)
+ustring&
+ustring::operator=(const ustring& other)
{
string_ = other.string_;
return *this;
}
-ustring& ustring::operator=(ustring&& other)
+ustring&
+ustring::operator=(ustring&& other)
{
string_ = std::move(other.string_);
return *this;
}
-ustring& ustring::operator=(const std::string& src)
+ustring&
+ustring::operator=(const std::string& src)
{
string_ = src;
return *this;
}
-ustring& ustring::operator=(std::string&& src)
+ustring&
+ustring::operator=(std::string&& src)
{
string_ = std::move(src);
return *this;
}
-ustring& ustring::operator=(const char* src)
+ustring&
+ustring::operator=(const char* src)
{
string_ = src;
return *this;
}
-ustring& ustring::operator=(gunichar uc)
+ustring&
+ustring::operator=(gunichar uc)
{
- const UnicharToUtf8 conv (uc);
+ const UnicharToUtf8 conv(uc);
string_.assign(conv.buf, conv.len);
return *this;
}
-ustring& ustring::operator=(char c)
+ustring&
+ustring::operator=(char c)
{
string_ = c;
return *this;
}
-
/**** Glib::ustring::assign() **********************************************/
-ustring& ustring::assign(const ustring& src)
+ustring&
+ustring::assign(const ustring& src)
{
string_ = src.string_;
return *this;
}
-ustring& ustring::assign(ustring&& src)
+ustring&
+ustring::assign(ustring&& src)
{
string_ = std::move(src.string_);
return *this;
}
-ustring& ustring::assign(const ustring& src, ustring::size_type i, ustring::size_type n)
+ustring&
+ustring::assign(const ustring& src, ustring::size_type i, ustring::size_type n)
{
- const Utf8SubstrBounds bounds (src.string_, i, n);
+ const Utf8SubstrBounds bounds(src.string_, i, n);
string_.assign(src.string_, bounds.i, bounds.n);
return *this;
}
-ustring& ustring::assign(const char* src, ustring::size_type n)
+ustring&
+ustring::assign(const char* src, ustring::size_type n)
{
string_.assign(src, utf8_byte_offset(src, n));
return *this;
}
-ustring& ustring::assign(const char* src)
+ustring&
+ustring::assign(const char* src)
{
string_ = src;
return *this;
}
-ustring& ustring::assign(ustring::size_type n, gunichar uc)
+ustring&
+ustring::assign(ustring::size_type n, gunichar uc)
{
- ustring temp (n, uc);
+ ustring temp(n, uc);
string_.swap(temp.string_);
return *this;
}
-ustring& ustring::assign(ustring::size_type n, char c)
+ustring&
+ustring::assign(ustring::size_type n, char c)
{
string_.assign(n, c);
return *this;
}
-
/**** Glib::ustring::operator+=() ******************************************/
-ustring& ustring::operator+=(const ustring& src)
+ustring&
+ustring::operator+=(const ustring& src)
{
string_ += src.string_;
return *this;
}
-ustring& ustring::operator+=(const char* src)
+ustring&
+ustring::operator+=(const char* src)
{
string_ += src;
return *this;
}
-ustring& ustring::operator+=(gunichar uc)
+ustring&
+ustring::operator+=(gunichar uc)
{
- const UnicharToUtf8 conv (uc);
+ const UnicharToUtf8 conv(uc);
string_.append(conv.buf, conv.len);
return *this;
}
-ustring& ustring::operator+=(char c)
+ustring&
+ustring::operator+=(char c)
{
string_ += c;
return *this;
}
-
/**** Glib::ustring::push_back() *******************************************/
-void ustring::push_back(gunichar uc)
+void
+ustring::push_back(gunichar uc)
{
- const UnicharToUtf8 conv (uc);
+ const UnicharToUtf8 conv(uc);
string_.append(conv.buf, conv.len);
}
-void ustring::push_back(char c)
+void
+ustring::push_back(char c)
{
string_ += c;
}
-
/**** Glib::ustring::append() **********************************************/
-ustring& ustring::append(const ustring& src)
+ustring&
+ustring::append(const ustring& src)
{
string_ += src.string_;
return *this;
}
-ustring& ustring::append(const ustring& src, ustring::size_type i, ustring::size_type n)
+ustring&
+ustring::append(const ustring& src, ustring::size_type i, ustring::size_type n)
{
- const Utf8SubstrBounds bounds (src.string_, i, n);
+ const Utf8SubstrBounds bounds(src.string_, i, n);
string_.append(src.string_, bounds.i, bounds.n);
return *this;
}
-ustring& ustring::append(const char* src, ustring::size_type n)
+ustring&
+ustring::append(const char* src, ustring::size_type n)
{
string_.append(src, utf8_byte_offset(src, n));
return *this;
}
-ustring& ustring::append(const char* src)
+ustring&
+ustring::append(const char* src)
{
string_ += src;
return *this;
}
-ustring& ustring::append(ustring::size_type n, gunichar uc)
+ustring&
+ustring::append(ustring::size_type n, gunichar uc)
{
string_.append(ustring(n, uc).string_);
return *this;
}
-ustring& ustring::append(ustring::size_type n, char c)
+ustring&
+ustring::append(ustring::size_type n, char c)
{
string_.append(n, c);
return *this;
}
-
/**** Glib::ustring::insert() **********************************************/
-ustring& ustring::insert(ustring::size_type i, const ustring& src)
+ustring&
+ustring::insert(ustring::size_type i, const ustring& src)
{
string_.insert(utf8_byte_offset(string_, i), src.string_);
return *this;
}
-ustring& ustring::insert(ustring::size_type i, const ustring& src,
- ustring::size_type i2, ustring::size_type n)
+ustring&
+ustring::insert(
+ ustring::size_type i, const ustring& src, ustring::size_type i2, ustring::size_type n)
{
- const Utf8SubstrBounds bounds2 (src.string_, i2, n);
+ const Utf8SubstrBounds bounds2(src.string_, i2, n);
string_.insert(utf8_byte_offset(string_, i), src.string_, bounds2.i, bounds2.n);
return *this;
}
-ustring& ustring::insert(ustring::size_type i, const char* src, ustring::size_type n)
+ustring&
+ustring::insert(ustring::size_type i, const char* src, ustring::size_type n)
{
string_.insert(utf8_byte_offset(string_, i), src, utf8_byte_offset(src, n));
return *this;
}
-ustring& ustring::insert(ustring::size_type i, const char* src)
+ustring&
+ustring::insert(ustring::size_type i, const char* src)
{
string_.insert(utf8_byte_offset(string_, i), src);
return *this;
}
-ustring& ustring::insert(ustring::size_type i, ustring::size_type n, gunichar uc)
+ustring&
+ustring::insert(ustring::size_type i, ustring::size_type n, gunichar uc)
{
string_.insert(utf8_byte_offset(string_, i), ustring(n, uc).string_);
return *this;
}
-ustring& ustring::insert(ustring::size_type i, ustring::size_type n, char c)
+ustring&
+ustring::insert(ustring::size_type i, ustring::size_type n, char c)
{
string_.insert(utf8_byte_offset(string_, i), n, c);
return *this;
}
-ustring::iterator ustring::insert(ustring::iterator p, gunichar uc)
+ustring::iterator
+ustring::insert(ustring::iterator p, gunichar uc)
{
const size_type offset = p.base() - string_.begin();
- const UnicharToUtf8 conv (uc);
+ const UnicharToUtf8 conv(uc);
string_.insert(offset, conv.buf, conv.len);
return iterator(string_.begin() + offset);
}
-ustring::iterator ustring::insert(ustring::iterator p, char c)
+ustring::iterator
+ustring::insert(ustring::iterator p, char c)
{
return iterator(string_.insert(p.base(), c));
}
-void ustring::insert(ustring::iterator p, ustring::size_type n, gunichar uc)
+void
+ustring::insert(ustring::iterator p, ustring::size_type n, gunichar uc)
{
string_.insert(p.base() - string_.begin(), ustring(n, uc).string_);
}
-void ustring::insert(ustring::iterator p, ustring::size_type n, char c)
+void
+ustring::insert(ustring::iterator p, ustring::size_type n, char c)
{
string_.insert(p.base(), n, c);
}
-
/**** Glib::ustring::replace() *********************************************/
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n, const ustring& src)
+ustring&
+ustring::replace(ustring::size_type i, ustring::size_type n, const ustring& src)
{
- const Utf8SubstrBounds bounds (string_, i, n);
+ const Utf8SubstrBounds bounds(string_, i, n);
string_.replace(bounds.i, bounds.n, src.string_);
return *this;
}
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- const ustring& src, ustring::size_type i2, ustring::size_type n2)
+ustring&
+ustring::replace(ustring::size_type i, ustring::size_type n, const ustring& src,
+ ustring::size_type i2, ustring::size_type n2)
{
- const Utf8SubstrBounds bounds (string_, i, n);
- const Utf8SubstrBounds bounds2 (src.string_, i2, n2);
+ const Utf8SubstrBounds bounds(string_, i, n);
+ const Utf8SubstrBounds bounds2(src.string_, i2, n2);
string_.replace(bounds.i, bounds.n, src.string_, bounds2.i, bounds2.n);
return *this;
}
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- const char* src, ustring::size_type n2)
+ustring&
+ustring::replace(ustring::size_type i, ustring::size_type n, const char* src, ustring::size_type n2)
{
- const Utf8SubstrBounds bounds (string_, i, n);
+ const Utf8SubstrBounds bounds(string_, i, n);
string_.replace(bounds.i, bounds.n, src, utf8_byte_offset(src, n2));
return *this;
}
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n, const char* src)
+ustring&
+ustring::replace(ustring::size_type i, ustring::size_type n, const char* src)
{
- const Utf8SubstrBounds bounds (string_, i, n);
+ const Utf8SubstrBounds bounds(string_, i, n);
string_.replace(bounds.i, bounds.n, src);
return *this;
}
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- ustring::size_type n2, gunichar uc)
+ustring&
+ustring::replace(ustring::size_type i, ustring::size_type n, ustring::size_type n2, gunichar uc)
{
- const Utf8SubstrBounds bounds (string_, i, n);
+ const Utf8SubstrBounds bounds(string_, i, n);
string_.replace(bounds.i, bounds.n, ustring(n2, uc).string_);
return *this;
}
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- ustring::size_type n2, char c)
+ustring&
+ustring::replace(ustring::size_type i, ustring::size_type n, ustring::size_type n2, char c)
{
- const Utf8SubstrBounds bounds (string_, i, n);
+ const Utf8SubstrBounds bounds(string_, i, n);
string_.replace(bounds.i, bounds.n, n2, c);
return *this;
}
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend, const ustring& src)
+ustring&
+ustring::replace(ustring::iterator pbegin, ustring::iterator pend, const ustring& src)
{
string_.replace(pbegin.base(), pend.base(), src.string_);
return *this;
}
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend,
- const char* src, ustring::size_type n)
+ustring&
+ustring::replace(
+ ustring::iterator pbegin, ustring::iterator pend, const char* src, ustring::size_type n)
{
string_.replace(pbegin.base(), pend.base(), src, utf8_byte_offset(src, n));
return *this;
}
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend, const char* src)
+ustring&
+ustring::replace(ustring::iterator pbegin, ustring::iterator pend, const char* src)
{
string_.replace(pbegin.base(), pend.base(), src);
return *this;
}
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend,
- ustring::size_type n, gunichar uc)
+ustring&
+ustring::replace(
+ ustring::iterator pbegin, ustring::iterator pend, ustring::size_type n, gunichar uc)
{
string_.replace(pbegin.base(), pend.base(), ustring(n, uc).string_);
return *this;
}
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend,
- ustring::size_type n, char c)
+ustring&
+ustring::replace(ustring::iterator pbegin, ustring::iterator pend, ustring::size_type n, char c)
{
string_.replace(pbegin.base(), pend.base(), n, c);
return *this;
}
-
/**** Glib::ustring::erase() ***********************************************/
-void ustring::clear()
+void
+ustring::clear()
{
string_.erase();
}
-ustring& ustring::erase(ustring::size_type i, ustring::size_type n)
+ustring&
+ustring::erase(ustring::size_type i, ustring::size_type n)
{
- const Utf8SubstrBounds bounds (string_, i, n);
+ const Utf8SubstrBounds bounds(string_, i, n);
string_.erase(bounds.i, bounds.n);
return *this;
}
-ustring& ustring::erase()
+ustring&
+ustring::erase()
{
string_.erase();
return *this;
}
-ustring::iterator ustring::erase(ustring::iterator p)
+ustring::iterator
+ustring::erase(ustring::iterator p)
{
ustring::iterator iter_end = p;
++iter_end;
@@ -714,47 +729,52 @@ ustring::iterator ustring::erase(ustring::iterator p)
return iterator(string_.erase(p.base(), iter_end.base()));
}
-ustring::iterator ustring::erase(ustring::iterator pbegin, ustring::iterator pend)
+ustring::iterator
+ustring::erase(ustring::iterator pbegin, ustring::iterator pend)
{
return iterator(string_.erase(pbegin.base(), pend.base()));
}
-
/**** Glib::ustring::compare() *********************************************/
-int ustring::compare(const ustring& rhs) const
+int
+ustring::compare(const ustring& rhs) const
{
return g_utf8_collate(string_.c_str(), rhs.string_.c_str());
}
-int ustring::compare(const char* rhs) const
+int
+ustring::compare(const char* rhs) const
{
return g_utf8_collate(string_.c_str(), rhs);
}
-int ustring::compare(ustring::size_type i, ustring::size_type n, const ustring& rhs) const
+int
+ustring::compare(ustring::size_type i, ustring::size_type n, const ustring& rhs) const
{
return ustring(*this, i, n).compare(rhs);
}
-int ustring::compare(ustring::size_type i, ustring::size_type n,
- const ustring& rhs, ustring::size_type i2, ustring::size_type n2) const
+int
+ustring::compare(ustring::size_type i, ustring::size_type n, const ustring& rhs,
+ ustring::size_type i2, ustring::size_type n2) const
{
return ustring(*this, i, n).compare(ustring(rhs, i2, n2));
}
-int ustring::compare(ustring::size_type i, ustring::size_type n,
- const char* rhs, ustring::size_type n2) const
+int
+ustring::compare(
+ ustring::size_type i, ustring::size_type n, const char* rhs, ustring::size_type n2) const
{
return ustring(*this, i, n).compare(ustring(rhs, n2));
}
-int ustring::compare(ustring::size_type i, ustring::size_type n, const char* rhs) const
+int
+ustring::compare(ustring::size_type i, ustring::size_type n, const char* rhs) const
{
return ustring(*this, i, n).compare(rhs);
}
-
/**** Glib::ustring -- index access ****************************************/
ustring::value_type ustring::operator[](ustring::size_type i) const
@@ -762,7 +782,8 @@ ustring::value_type ustring::operator[](ustring::size_type i) const
return g_utf8_get_char(g_utf8_offset_to_pointer(string_.data(), i));
}
-ustring::value_type ustring::at(ustring::size_type i) const
+ustring::value_type
+ustring::at(ustring::size_type i) const
{
const size_type byte_offset = utf8_byte_offset(string_, i);
@@ -770,183 +791,204 @@ ustring::value_type ustring::at(ustring::size_type i) const
return g_utf8_get_char(&string_.at(byte_offset));
}
-
/**** Glib::ustring -- iterator access *************************************/
-ustring::iterator ustring::begin()
+ustring::iterator
+ustring::begin()
{
return iterator(string_.begin());
}
-ustring::iterator ustring::end()
+ustring::iterator
+ustring::end()
{
return iterator(string_.end());
}
-ustring::const_iterator ustring::begin() const
+ustring::const_iterator
+ustring::begin() const
{
return const_iterator(string_.begin());
}
-ustring::const_iterator ustring::end() const
+ustring::const_iterator
+ustring::end() const
{
return const_iterator(string_.end());
}
-ustring::reverse_iterator ustring::rbegin()
+ustring::reverse_iterator
+ustring::rbegin()
{
return reverse_iterator(iterator(string_.end()));
}
-ustring::reverse_iterator ustring::rend()
+ustring::reverse_iterator
+ustring::rend()
{
return reverse_iterator(iterator(string_.begin()));
}
-ustring::const_reverse_iterator ustring::rbegin() const
+ustring::const_reverse_iterator
+ustring::rbegin() const
{
return const_reverse_iterator(const_iterator(string_.end()));
}
-ustring::const_reverse_iterator ustring::rend() const
+ustring::const_reverse_iterator
+ustring::rend() const
{
return const_reverse_iterator(const_iterator(string_.begin()));
}
-
/**** Glib::ustring::find() ************************************************/
-ustring::size_type ustring::find(const ustring& str, ustring::size_type i) const
+ustring::size_type
+ustring::find(const ustring& str, ustring::size_type i) const
{
return utf8_char_offset(string_, string_.find(str.string_, utf8_byte_offset(string_, i)));
}
-ustring::size_type ustring::find(const char* str, ustring::size_type i, ustring::size_type n) const
+ustring::size_type
+ustring::find(const char* str, ustring::size_type i, ustring::size_type n) const
{
- return utf8_char_offset(string_, string_.find(str, utf8_byte_offset(string_, i),
- utf8_byte_offset(str, n)));
+ return utf8_char_offset(
+ string_, string_.find(str, utf8_byte_offset(string_, i), utf8_byte_offset(str, n)));
}
-ustring::size_type ustring::find(const char* str, ustring::size_type i) const
+ustring::size_type
+ustring::find(const char* str, ustring::size_type i) const
{
return utf8_char_offset(string_, string_.find(str, utf8_byte_offset(string_, i)));
}
-ustring::size_type ustring::find(gunichar uc, ustring::size_type i) const
+ustring::size_type
+ustring::find(gunichar uc, ustring::size_type i) const
{
- const UnicharToUtf8 conv (uc);
+ const UnicharToUtf8 conv(uc);
return utf8_char_offset(string_, string_.find(conv.buf, utf8_byte_offset(string_, i), conv.len));
}
-ustring::size_type ustring::find(char c, ustring::size_type i) const
+ustring::size_type
+ustring::find(char c, ustring::size_type i) const
{
return utf8_char_offset(string_, string_.find(c, utf8_byte_offset(string_, i)));
}
-
/**** Glib::ustring::rfind() ***********************************************/
-ustring::size_type ustring::rfind(const ustring& str, ustring::size_type i) const
+ustring::size_type
+ustring::rfind(const ustring& str, ustring::size_type i) const
{
return utf8_char_offset(string_, string_.rfind(str.string_, utf8_byte_offset(string_, i)));
}
-ustring::size_type ustring::rfind(const char* str, ustring::size_type i,
- ustring::size_type n) const
+ustring::size_type
+ustring::rfind(const char* str, ustring::size_type i, ustring::size_type n) const
{
- return utf8_char_offset(string_, string_.rfind(str, utf8_byte_offset(string_, i),
- utf8_byte_offset(str, n)));
+ return utf8_char_offset(
+ string_, string_.rfind(str, utf8_byte_offset(string_, i), utf8_byte_offset(str, n)));
}
-ustring::size_type ustring::rfind(const char* str, ustring::size_type i) const
+ustring::size_type
+ustring::rfind(const char* str, ustring::size_type i) const
{
return utf8_char_offset(string_, string_.rfind(str, utf8_byte_offset(string_, i)));
}
-ustring::size_type ustring::rfind(gunichar uc, ustring::size_type i) const
+ustring::size_type
+ustring::rfind(gunichar uc, ustring::size_type i) const
{
- const UnicharToUtf8 conv (uc);
+ const UnicharToUtf8 conv(uc);
return utf8_char_offset(string_, string_.rfind(conv.buf, utf8_byte_offset(string_, i), conv.len));
}
-ustring::size_type ustring::rfind(char c, ustring::size_type i) const
+ustring::size_type
+ustring::rfind(char c, ustring::size_type i) const
{
return utf8_char_offset(string_, string_.rfind(c, utf8_byte_offset(string_, i)));
}
-
/**** Glib::ustring::find_first_of() ***************************************/
-ustring::size_type ustring::find_first_of(const ustring& match, ustring::size_type i) const
+ustring::size_type
+ustring::find_first_of(const ustring& match, ustring::size_type i) const
{
return utf8_find_first_of(string_, i, match.string_.data(), match.string_.size(), false);
}
-ustring::size_type ustring::find_first_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
+ustring::size_type
+ustring::find_first_of(const char* match, ustring::size_type i, ustring::size_type n) const
{
return utf8_find_first_of(string_, i, match, n, false);
}
-ustring::size_type ustring::find_first_of(const char* match, ustring::size_type i) const
+ustring::size_type
+ustring::find_first_of(const char* match, ustring::size_type i) const
{
return utf8_find_first_of(string_, i, match, -1, false);
}
-ustring::size_type ustring::find_first_of(gunichar uc, ustring::size_type i) const
+ustring::size_type
+ustring::find_first_of(gunichar uc, ustring::size_type i) const
{
return find(uc, i);
}
-ustring::size_type ustring::find_first_of(char c, ustring::size_type i) const
+ustring::size_type
+ustring::find_first_of(char c, ustring::size_type i) const
{
return find(c, i);
}
-
/**** Glib::ustring::find_last_of() ****************************************/
-ustring::size_type ustring::find_last_of(const ustring& match, ustring::size_type i) const
+ustring::size_type
+ustring::find_last_of(const ustring& match, ustring::size_type i) const
{
return utf8_find_last_of(string_, i, match.string_.data(), match.string_.size(), false);
}
-ustring::size_type ustring::find_last_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
+ustring::size_type
+ustring::find_last_of(const char* match, ustring::size_type i, ustring::size_type n) const
{
return utf8_find_last_of(string_, i, match, n, false);
}
-ustring::size_type ustring::find_last_of(const char* match, ustring::size_type i) const
+ustring::size_type
+ustring::find_last_of(const char* match, ustring::size_type i) const
{
return utf8_find_last_of(string_, i, match, -1, false);
}
-ustring::size_type ustring::find_last_of(gunichar uc, ustring::size_type i) const
+ustring::size_type
+ustring::find_last_of(gunichar uc, ustring::size_type i) const
{
return rfind(uc, i);
}
-ustring::size_type ustring::find_last_of(char c, ustring::size_type i) const
+ustring::size_type
+ustring::find_last_of(char c, ustring::size_type i) const
{
return rfind(c, i);
}
-
/**** Glib::ustring::find_first_not_of() ***********************************/
-ustring::size_type ustring::find_first_not_of(const ustring& match, ustring::size_type i) const
+ustring::size_type
+ustring::find_first_not_of(const ustring& match, ustring::size_type i) const
{
return utf8_find_first_of(string_, i, match.string_.data(), match.string_.size(), true);
}
-ustring::size_type ustring::find_first_not_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
+ustring::size_type
+ustring::find_first_not_of(const char* match, ustring::size_type i, ustring::size_type n) const
{
return utf8_find_first_of(string_, i, match, n, true);
}
-ustring::size_type ustring::find_first_not_of(const char* match, ustring::size_type i) const
+ustring::size_type
+ustring::find_first_not_of(const char* match, ustring::size_type i) const
{
return utf8_find_first_of(string_, i, match, -1, true);
}
@@ -954,59 +996,58 @@ ustring::size_type ustring::find_first_not_of(const char* match, ustring::size_t
// Unfortunately, all of the find_*_not_of() methods for single
// characters need their own special implementation.
//
-ustring::size_type ustring::find_first_not_of(gunichar uc, ustring::size_type i) const
+ustring::size_type
+ustring::find_first_not_of(gunichar uc, ustring::size_type i) const
{
const size_type bi = utf8_byte_offset(string_, i);
- if(bi != npos)
+ if (bi != npos)
{
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
+ const char* const pbegin = string_.data();
+ const char* const pend = pbegin + string_.size();
- for(const char* p = pbegin + bi;
- p < pend;
- p = g_utf8_next_char(p), ++i)
+ for (const char *p = pbegin + bi; p < pend; p = g_utf8_next_char(p), ++i)
{
- if(g_utf8_get_char(p) != uc)
+ if (g_utf8_get_char(p) != uc)
return i;
}
}
return npos;
}
-ustring::size_type ustring::find_first_not_of(char c, ustring::size_type i) const
+ustring::size_type
+ustring::find_first_not_of(char c, ustring::size_type i) const
{
const size_type bi = utf8_byte_offset(string_, i);
- if(bi != npos)
+ if (bi != npos)
{
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
+ const char* const pbegin = string_.data();
+ const char* const pend = pbegin + string_.size();
- for(const char* p = pbegin + bi;
- p < pend;
- p = g_utf8_next_char(p), ++i)
+ for (const char *p = pbegin + bi; p < pend; p = g_utf8_next_char(p), ++i)
{
- if(*p != c)
+ if (*p != c)
return i;
}
}
return npos;
}
-
/**** Glib::ustring::find_last_not_of() ************************************/
-ustring::size_type ustring::find_last_not_of(const ustring& match, ustring::size_type i) const
+ustring::size_type
+ustring::find_last_not_of(const ustring& match, ustring::size_type i) const
{
return utf8_find_last_of(string_, i, match.string_.data(), match.string_.size(), true);
}
-ustring::size_type ustring::find_last_not_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
+ustring::size_type
+ustring::find_last_not_of(const char* match, ustring::size_type i, ustring::size_type n) const
{
return utf8_find_last_of(string_, i, match, n, true);
}
-ustring::size_type ustring::find_last_not_of(const char* match, ustring::size_type i) const
+ustring::size_type
+ustring::find_last_not_of(const char* match, ustring::size_type i) const
{
return utf8_find_last_of(string_, i, match, -1, true);
}
@@ -1014,107 +1055,114 @@ ustring::size_type ustring::find_last_not_of(const char* match, ustring::size_ty
// Unfortunately, all of the find_*_not_of() methods for single
// characters need their own special implementation.
//
-ustring::size_type ustring::find_last_not_of(gunichar uc, ustring::size_type i) const
+ustring::size_type
+ustring::find_last_not_of(gunichar uc, ustring::size_type i) const
{
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
- size_type i_cur = 0;
+ const char* const pbegin = string_.data();
+ const char* const pend = pbegin + string_.size();
+ size_type i_cur = 0;
size_type i_found = npos;
- for(const char* p = pbegin;
- p < pend && i_cur <= i;
- p = g_utf8_next_char(p), ++i_cur)
+ for (const char *p = pbegin; p < pend && i_cur <= i; p = g_utf8_next_char(p), ++i_cur)
{
- if(g_utf8_get_char(p) != uc)
+ if (g_utf8_get_char(p) != uc)
i_found = i_cur;
}
return i_found;
}
-ustring::size_type ustring::find_last_not_of(char c, ustring::size_type i) const
+ustring::size_type
+ustring::find_last_not_of(char c, ustring::size_type i) const
{
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
- size_type i_cur = 0;
+ const char* const pbegin = string_.data();
+ const char* const pend = pbegin + string_.size();
+ size_type i_cur = 0;
size_type i_found = npos;
- for(const char* p = pbegin;
- p < pend && i_cur <= i;
- p = g_utf8_next_char(p), ++i_cur)
+ for (const char *p = pbegin; p < pend && i_cur <= i; p = g_utf8_next_char(p), ++i_cur)
{
- if(*p != c)
+ if (*p != c)
i_found = i_cur;
}
return i_found;
}
-
/**** Glib::ustring -- get size and resize *********************************/
-bool ustring::empty() const
+bool
+ustring::empty() const
{
return string_.empty();
}
-ustring::size_type ustring::size() const
+ustring::size_type
+ustring::size() const
{
- const char *const pdata = string_.data();
+ const char* const pdata = string_.data();
return g_utf8_pointer_to_offset(pdata, pdata + string_.size());
}
-ustring::size_type ustring::length() const
+ustring::size_type
+ustring::length() const
{
- const char *const pdata = string_.data();
+ const char* const pdata = string_.data();
return g_utf8_pointer_to_offset(pdata, pdata + string_.size());
}
-ustring::size_type ustring::bytes() const
+ustring::size_type
+ustring::bytes() const
{
return string_.size();
}
-ustring::size_type ustring::capacity() const
+ustring::size_type
+ustring::capacity() const
{
return string_.capacity();
}
-ustring::size_type ustring::max_size() const
+ustring::size_type
+ustring::max_size() const
{
return string_.max_size();
}
-void ustring::resize(ustring::size_type n, gunichar uc)
+void
+ustring::resize(ustring::size_type n, gunichar uc)
{
const size_type size_now = size();
- if(n < size_now)
+ if (n < size_now)
erase(n, npos);
- else if(n > size_now)
+ else if (n > size_now)
append(n - size_now, uc);
}
-void ustring::resize(ustring::size_type n, char c)
+void
+ustring::resize(ustring::size_type n, char c)
{
const size_type size_now = size();
- if(n < size_now)
+ if (n < size_now)
erase(n, npos);
- else if(n > size_now)
+ else if (n > size_now)
string_.append(n - size_now, c);
}
-void ustring::reserve(ustring::size_type n)
+void
+ustring::reserve(ustring::size_type n)
{
string_.reserve(n);
}
-
/**** Glib::ustring -- C string access *************************************/
-const char* ustring::data() const
+const char*
+ustring::data() const
{
return string_.data();
}
-const char* ustring::c_str() const
+const char*
+ustring::c_str() const
{
return string_.c_str();
}
@@ -1122,23 +1170,25 @@ const char* ustring::c_str() const
// Note that copy() requests UTF-8 character offsets as
// parameters, but returns the number of copied bytes.
//
-ustring::size_type ustring::copy(char* dest, ustring::size_type n, ustring::size_type i) const
+ustring::size_type
+ustring::copy(char* dest, ustring::size_type n, ustring::size_type i) const
{
- const Utf8SubstrBounds bounds (string_, i, n);
+ const Utf8SubstrBounds bounds(string_, i, n);
return string_.copy(dest, bounds.n, bounds.i);
}
-
/**** Glib::ustring -- UTF-8 utilities *************************************/
-bool ustring::validate() const
+bool
+ustring::validate() const
{
return (g_utf8_validate(string_.data(), string_.size(), nullptr) != 0);
}
-bool ustring::validate(ustring::iterator& first_invalid)
+bool
+ustring::validate(ustring::iterator& first_invalid)
{
- const char *const pdata = string_.data();
+ const char* const pdata = string_.data();
const char* valid_end = pdata;
const int is_valid = g_utf8_validate(pdata, string_.size(), &valid_end);
@@ -1146,9 +1196,10 @@ bool ustring::validate(ustring::iterator& first_invalid)
return (is_valid != 0);
}
-bool ustring::validate(ustring::const_iterator& first_invalid) const
+bool
+ustring::validate(ustring::const_iterator& first_invalid) const
{
- const char *const pdata = string_.data();
+ const char* const pdata = string_.data();
const char* valid_end = pdata;
const int is_valid = g_utf8_validate(pdata, string_.size(), &valid_end);
@@ -1156,55 +1207,62 @@ bool ustring::validate(ustring::const_iterator& first_invalid) const
return (is_valid != 0);
}
-bool ustring::is_ascii() const
+bool
+ustring::is_ascii() const
{
const char* p = string_.data();
- const char *const pend = p + string_.size();
+ const char* const pend = p + string_.size();
- for(; p != pend; ++p)
+ for (; p != pend; ++p)
{
- if((static_cast<unsigned char>(*p) & 0x80u) != 0)
+ if ((static_cast<unsigned char>(*p) & 0x80u) != 0)
return false;
}
return true;
}
-ustring ustring::normalize(NormalizeMode mode) const
+ustring
+ustring::normalize(NormalizeMode mode) const
{
- const auto buf = make_unique_ptr_gfree(g_utf8_normalize(string_.data(), string_.size(),
- static_cast<GNormalizeMode>(int(mode))));
+ const auto buf = make_unique_ptr_gfree(
+ g_utf8_normalize(string_.data(), string_.size(), static_cast<GNormalizeMode>(int(mode))));
return ustring(buf.get());
}
-ustring ustring::uppercase() const
+ustring
+ustring::uppercase() const
{
const auto buf = make_unique_ptr_gfree(g_utf8_strup(string_.data(), string_.size()));
return ustring(buf.get());
}
-ustring ustring::lowercase() const
+ustring
+ustring::lowercase() const
{
const auto buf = make_unique_ptr_gfree(g_utf8_strdown(string_.data(), string_.size()));
return ustring(buf.get());
}
-ustring ustring::casefold() const
+ustring
+ustring::casefold() const
{
const auto buf = make_unique_ptr_gfree(g_utf8_casefold(string_.data(), string_.size()));
return ustring(buf.get());
}
-std::string ustring::collate_key() const
+std::string
+ustring::collate_key() const
{
const auto buf = make_unique_ptr_gfree(g_utf8_collate_key(string_.data(), string_.size()));
return std::string(buf.get());
}
-std::string ustring::casefold_collate_key() const
+std::string
+ustring::casefold_collate_key() const
{
- char *const casefold_buf = g_utf8_casefold(string_.data(), string_.size());
- char *const key_buf = g_utf8_collate_key(casefold_buf, -1);
+ char* const casefold_buf = g_utf8_casefold(string_.data(), string_.size());
+ char* const key_buf = g_utf8_collate_key(casefold_buf, -1);
g_free(casefold_buf);
return std::string(make_unique_ptr_gfree(key_buf).get());
}
@@ -1212,7 +1270,8 @@ std::string ustring::casefold_collate_key() const
/**** Glib::ustring -- Message formatting **********************************/
// static
-ustring ustring::compose_argv(const Glib::ustring& fmt, int argc, const ustring* const* argv)
+ustring
+ustring::compose_argv(const Glib::ustring& fmt, int argc, const ustring* const* argv)
{
std::string::size_type result_size = fmt.raw().size();
@@ -1251,7 +1310,7 @@ ustring ustring::compose_argv(const Glib::ustring& fmt, int argc, const ustring*
result.append(start, next - start);
g_warning("invalid substitution \"%s\" in fmt string \"%s\"",
- result.c_str() + result.size() - (next - stop), pfmt);
+ result.c_str() + result.size() - (next - stop), pfmt);
start = next;
}
}
@@ -1264,57 +1323,58 @@ ustring ustring::compose_argv(const Glib::ustring& fmt, int argc, const ustring*
/**** Glib::ustring::SequenceToString **************************************/
-ustring::SequenceToString<Glib::ustring::iterator,gunichar>
- ::SequenceToString(Glib::ustring::iterator pbegin, Glib::ustring::iterator pend)
-:
- std::string(pbegin.base(), pend.base())
-{}
+ustring::SequenceToString<Glib::ustring::iterator, gunichar>::SequenceToString(
+ Glib::ustring::iterator pbegin, Glib::ustring::iterator pend)
+: std::string(pbegin.base(), pend.base())
+{
+}
-ustring::SequenceToString<Glib::ustring::const_iterator,gunichar>
- ::SequenceToString(Glib::ustring::const_iterator pbegin, Glib::ustring::const_iterator pend)
-:
- std::string(pbegin.base(), pend.base())
-{}
+ustring::SequenceToString<Glib::ustring::const_iterator, gunichar>::SequenceToString(
+ Glib::ustring::const_iterator pbegin, Glib::ustring::const_iterator pend)
+: std::string(pbegin.base(), pend.base())
+{
+}
/**** Glib::ustring::FormatStream ******************************************/
-ustring::FormatStream::FormatStream()
-:
- stream_ ()
-{}
+ustring::FormatStream::FormatStream() : stream_()
+{
+}
ustring::FormatStream::~FormatStream() noexcept
-{}
+{
+}
-ustring ustring::FormatStream::to_string() const
+ustring
+ustring::FormatStream::to_string() const
{
GError* error = nullptr;
#ifdef GLIBMM_HAVE_WIDE_STREAM
const std::wstring str = stream_.str();
-# if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
+#if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
// Avoid going through iconv if wchar_t always contains UCS-4.
glong n_bytes = 0;
- const auto buf = make_unique_ptr_gfree(g_ucs4_to_utf8(reinterpret_cast<const gunichar*>(str.data()),
- str.size(), nullptr, &n_bytes, &error));
-# elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
+ const auto buf = make_unique_ptr_gfree(g_ucs4_to_utf8(
+ reinterpret_cast<const gunichar*>(str.data()), str.size(), nullptr, &n_bytes, &error));
+#elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
// Avoid going through iconv if wchar_t always contains UTF-16.
glong n_bytes = 0;
- const auto buf = make_unique_ptr_gfree(g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(str.data()),
- str.size(), nullptr, &n_bytes, &error));
-# else
+ const auto buf = make_unique_ptr_gfree(g_utf16_to_utf8(
+ reinterpret_cast<const gunichar2*>(str.data()), str.size(), nullptr, &n_bytes, &error));
+#else
gsize n_bytes = 0;
const auto buf = make_unique_ptr_gfree(g_convert(reinterpret_cast<const char*>(str.data()),
- str.size() * sizeof(std::wstring::value_type),
- "UTF-8", "WCHAR_T", nullptr, &n_bytes, &error));
-# endif /* !(__STDC_ISO_10646__ || G_OS_WIN32) */
+ str.size() * sizeof(std::wstring::value_type), "UTF-8", "WCHAR_T", nullptr, &n_bytes, &error));
+#endif /* !(__STDC_ISO_10646__ || G_OS_WIN32) */
-#else /* !GLIBMM_HAVE_WIDE_STREAM */
+#else /* !GLIBMM_HAVE_WIDE_STREAM */
const std::string str = stream_.str();
gsize n_bytes = 0;
- const auto buf = make_unique_ptr_gfree(g_locale_to_utf8(str.data(), str.size(), 0, &n_bytes, &error));
+ const auto buf =
+ make_unique_ptr_gfree(g_locale_to_utf8(str.data(), str.size(), 0, &n_bytes, &error));
#endif /* !GLIBMM_HAVE_WIDE_STREAM */
if (error)
@@ -1327,14 +1387,16 @@ ustring ustring::FormatStream::to_string() const
/**** Glib::ustring -- stream I/O operators ********************************/
-std::istream& operator>>(std::istream& is, Glib::ustring& utf8_string)
+std::istream&
+operator>>(std::istream& is, Glib::ustring& utf8_string)
{
std::string str;
is >> str;
GError* error = nullptr;
gsize n_bytes = 0;
- const auto buf = make_unique_ptr_gfree(g_locale_to_utf8(str.data(), str.size(), nullptr, &n_bytes,
&error));
+ const auto buf =
+ make_unique_ptr_gfree(g_locale_to_utf8(str.data(), str.size(), nullptr, &n_bytes, &error));
if (error)
{
@@ -1346,11 +1408,12 @@ std::istream& operator>>(std::istream& is, Glib::ustring& utf8_string)
return is;
}
-std::ostream& operator<<(std::ostream& os, const Glib::ustring& utf8_string)
+std::ostream&
+operator<<(std::ostream& os, const Glib::ustring& utf8_string)
{
GError* error = nullptr;
- const auto buf = make_unique_ptr_gfree(g_locale_from_utf8(utf8_string.raw().data(),
- utf8_string.raw().size(), nullptr, nullptr, &error));
+ const auto buf = make_unique_ptr_gfree(g_locale_from_utf8(
+ utf8_string.raw().data(), utf8_string.raw().size(), nullptr, nullptr, &error));
if (error)
{
Glib::Error::throw_exception(error);
@@ -1370,7 +1433,8 @@ std::ostream& operator<<(std::ostream& os, const Glib::ustring& utf8_string)
#ifdef GLIBMM_HAVE_WIDE_STREAM
-std::wistream& operator>>(std::wistream& is, ustring& utf8_string)
+std::wistream&
+operator>>(std::wistream& is, ustring& utf8_string)
{
GError* error = nullptr;
@@ -1380,18 +1444,17 @@ std::wistream& operator>>(std::wistream& is, ustring& utf8_string)
#if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
// Avoid going through iconv if wchar_t always contains UCS-4.
glong n_bytes = 0;
- const auto buf = make_unique_ptr_gfree(g_ucs4_to_utf8(reinterpret_cast<const gunichar*>(wstr.data()),
- wstr.size(), nullptr, &n_bytes, &error));
+ const auto buf = make_unique_ptr_gfree(g_ucs4_to_utf8(
+ reinterpret_cast<const gunichar*>(wstr.data()), wstr.size(), nullptr, &n_bytes, &error));
#elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
// Avoid going through iconv if wchar_t always contains UTF-16.
glong n_bytes = 0;
- const auto buf = make_unique_ptr_gfree(g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(wstr.data()),
- wstr.size(), nullptr, &n_bytes, &error));
+ const auto buf = make_unique_ptr_gfree(g_utf16_to_utf8(
+ reinterpret_cast<const gunichar2*>(wstr.data()), wstr.size(), nullptr, &n_bytes, &error));
#else
gsize n_bytes = 0;
const auto buf = make_unique_ptr_gfree(g_convert(reinterpret_cast<const char*>(wstr.data()),
- wstr.size() * sizeof(std::wstring::value_type),
- "UTF-8", "WCHAR_T", nullptr, &n_bytes, &error));
+ wstr.size() * sizeof(std::wstring::value_type), "UTF-8", "WCHAR_T", nullptr, &n_bytes, &error));
#endif // !(__STDC_ISO_10646__ || G_OS_WIN32)
if (error)
@@ -1404,21 +1467,22 @@ std::wistream& operator>>(std::wistream& is, ustring& utf8_string)
return is;
}
-std::wostream& operator<<(std::wostream& os, const ustring& utf8_string)
+std::wostream&
+operator<<(std::wostream& os, const ustring& utf8_string)
{
GError* error = nullptr;
#if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
// Avoid going through iconv if wchar_t always contains UCS-4.
- const auto buf = make_unique_ptr_gfree(g_utf8_to_ucs4(utf8_string.raw().data(),
- utf8_string.raw().size(), nullptr, nullptr, &error));
+ const auto buf = make_unique_ptr_gfree(
+ g_utf8_to_ucs4(utf8_string.raw().data(), utf8_string.raw().size(), nullptr, nullptr, &error));
#elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
// Avoid going through iconv if wchar_t always contains UTF-16.
- const auto buf = make_unique_ptr_gfree(g_utf8_to_utf16(utf8_string.raw().data(),
- utf8_string.raw().size(), nullptr, nullptr, &error));
+ const auto buf = make_unique_ptr_gfree(
+ g_utf8_to_utf16(utf8_string.raw().data(), utf8_string.raw().size(), nullptr, nullptr, &error));
#else
- const auto buf = make_unique_ptr_gfree(g_convert(utf8_string.raw().data(), utf8_string.raw().size(),
- "WCHAR_T", "UTF-8", nullptr, nullptr, &error));
+ const auto buf = make_unique_ptr_gfree(g_convert(utf8_string.raw().data(),
+ utf8_string.raw().size(), "WCHAR_T", "UTF-8", nullptr, nullptr, &error));
#endif // !(__STDC_ISO_10646__ || G_OS_WIN32)
if (error)
diff --git a/glib/glibmm/utility.cc b/glib/glibmm/utility.cc
index f950249..172ff7a 100644
--- a/glib/glibmm/utility.cc
+++ b/glib/glibmm/utility.cc
@@ -21,8 +21,8 @@
#include <glibmm/utility.h>
-
-void Glib::append_canonical_typename(std::string& dest, const char* type_name)
+void
+Glib::append_canonical_typename(std::string& dest, const char* type_name)
{
const std::string::size_type offset = dest.size();
dest += type_name;
@@ -30,10 +30,9 @@ void Glib::append_canonical_typename(std::string& dest, const char* type_name)
std::string::iterator p = dest.begin() + offset;
const std::string::iterator pend = dest.end();
- for(; p != pend; ++p)
+ for (; p != pend; ++p)
{
- if(!(g_ascii_isalnum(*p) || *p == '_' || *p == '-'))
+ if (!(g_ascii_isalnum(*p) || *p == '_' || *p == '-'))
*p = '+';
}
}
-
diff --git a/glib/glibmm/value.cc b/glib/glibmm/value.cc
index 53551d0..62d5947 100644
--- a/glib/glibmm/value.cc
+++ b/glib/glibmm/value.cc
@@ -34,16 +34,18 @@ ValueBase::ValueBase()
std::memset(&gobject_, 0, sizeof(GValue));
}
-void ValueBase::init(GType type)
+void
+ValueBase::init(GType type)
{
g_value_init(&gobject_, type);
}
-void ValueBase::init(const GValue* value)
+void
+ValueBase::init(const GValue* value)
{
g_value_init(&gobject_, G_VALUE_TYPE(value));
- if(value)
+ if (value)
g_value_copy(value, &gobject_);
}
@@ -55,7 +57,8 @@ ValueBase::ValueBase(const ValueBase& other)
g_value_copy(&other.gobject_, &gobject_);
}
-ValueBase& ValueBase::operator=(const ValueBase& other)
+ValueBase&
+ValueBase::operator=(const ValueBase& other)
{
// g_value_copy() prevents self-assignment and deletes the destination.
g_value_copy(&other.gobject_, &gobject_);
@@ -67,181 +70,190 @@ ValueBase::~ValueBase() noexcept
g_value_unset(&gobject_);
}
-void ValueBase::reset()
+void
+ValueBase::reset()
{
g_value_reset(&gobject_);
}
-
/**** Glib::ValueBase_Boxed ************************************************/
// static
-GType ValueBase_Boxed::value_type()
+GType
+ValueBase_Boxed::value_type()
{
return G_TYPE_BOXED;
}
-void ValueBase_Boxed::set_boxed(const void* data)
+void
+ValueBase_Boxed::set_boxed(const void* data)
{
g_value_set_boxed(&gobject_, data);
}
-void* ValueBase_Boxed::get_boxed() const
+void*
+ValueBase_Boxed::get_boxed() const
{
return g_value_get_boxed(&gobject_);
}
-GParamSpec* ValueBase_Boxed::create_param_spec(const Glib::ustring& name) const
+GParamSpec*
+ValueBase_Boxed::create_param_spec(const Glib::ustring& name) const
{
- return g_param_spec_boxed(
- name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_),
- GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
+ return g_param_spec_boxed(name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_),
+ GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
}
-
/**** Glib::ValueBase_Object ***********************************************/
// static
-GType ValueBase_Object::value_type()
+GType
+ValueBase_Object::value_type()
{
return G_TYPE_OBJECT;
}
-void ValueBase_Object::set_object(Glib::ObjectBase* data)
+void
+ValueBase_Object::set_object(Glib::ObjectBase* data)
{
g_value_set_object(&gobject_, (data) ? data->gobj() : nullptr);
}
-Glib::ObjectBase* ValueBase_Object::get_object() const
+Glib::ObjectBase*
+ValueBase_Object::get_object() const
{
- GObject *const data = static_cast<GObject*>(g_value_get_object(&gobject_));
+ GObject* const data = static_cast<GObject*>(g_value_get_object(&gobject_));
return Glib::wrap_auto(data, false);
}
-Glib::RefPtr<Glib::ObjectBase> ValueBase_Object::get_object_copy() const
+Glib::RefPtr<Glib::ObjectBase>
+ValueBase_Object::get_object_copy() const
{
- GObject *const data = static_cast<GObject*>(g_value_get_object(&gobject_));
+ GObject* const data = static_cast<GObject*>(g_value_get_object(&gobject_));
return Glib::RefPtr<Glib::ObjectBase>(Glib::wrap_auto(data, true));
}
-GParamSpec* ValueBase_Object::create_param_spec(const Glib::ustring& name) const
+GParamSpec*
+ValueBase_Object::create_param_spec(const Glib::ustring& name) const
{
// Glib::Value_Pointer<> derives from Glib::ValueBase_Object, because
// we don't know beforehand whether a certain type is derived from
// Glib::Object or not. To keep create_param_spec() out of the template
// struggle, we dispatch here at runtime.
- if(G_VALUE_HOLDS_OBJECT(&gobject_))
+ if (G_VALUE_HOLDS_OBJECT(&gobject_))
{
- return g_param_spec_object(
- name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_),
- GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
+ return g_param_spec_object(name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_),
+ GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
}
else
{
g_return_val_if_fail(G_VALUE_HOLDS_POINTER(&gobject_), nullptr);
return g_param_spec_pointer(
- name.c_str(), nullptr, nullptr,
- GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
+ name.c_str(), nullptr, nullptr, GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
}
}
-
/**** Glib::ValueBase_Enum *************************************************/
// static
-GType ValueBase_Enum::value_type()
+GType
+ValueBase_Enum::value_type()
{
return G_TYPE_ENUM;
}
-void ValueBase_Enum::set_enum(int data)
+void
+ValueBase_Enum::set_enum(int data)
{
g_value_set_enum(&gobject_, data);
}
-int ValueBase_Enum::get_enum() const
+int
+ValueBase_Enum::get_enum() const
{
return g_value_get_enum(&gobject_);
}
-GParamSpec* ValueBase_Enum::create_param_spec(const Glib::ustring& name) const
+GParamSpec*
+ValueBase_Enum::create_param_spec(const Glib::ustring& name) const
{
- return g_param_spec_enum(
- name.c_str(), nullptr, nullptr,
- G_VALUE_TYPE(&gobject_), g_value_get_enum(&gobject_),
- GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
+ return g_param_spec_enum(name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_),
+ g_value_get_enum(&gobject_), GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
}
-
/**** Glib::ValueBase_Flags ************************************************/
// static
-GType ValueBase_Flags::value_type()
+GType
+ValueBase_Flags::value_type()
{
return G_TYPE_FLAGS;
}
-void ValueBase_Flags::set_flags(unsigned int data)
+void
+ValueBase_Flags::set_flags(unsigned int data)
{
g_value_set_flags(&gobject_, data);
}
-unsigned int ValueBase_Flags::get_flags() const
+unsigned int
+ValueBase_Flags::get_flags() const
{
return g_value_get_flags(&gobject_);
}
-GParamSpec* ValueBase_Flags::create_param_spec(const Glib::ustring& name) const
+GParamSpec*
+ValueBase_Flags::create_param_spec(const Glib::ustring& name) const
{
- return g_param_spec_flags(
- name.c_str(), nullptr, nullptr,
- G_VALUE_TYPE(&gobject_), g_value_get_flags(&gobject_),
- GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
+ return g_param_spec_flags(name.c_str(), nullptr, nullptr, G_VALUE_TYPE(&gobject_),
+ g_value_get_flags(&gobject_), GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
}
-
/**** Glib::ValueBase_String ***********************************************/
// static
-GType ValueBase_String::value_type()
+GType
+ValueBase_String::value_type()
{
return G_TYPE_STRING;
}
-void ValueBase_String::set_cstring(const char* data)
+void
+ValueBase_String::set_cstring(const char* data)
{
g_value_set_string(&gobject_, data);
}
-const char* ValueBase_String::get_cstring() const
+const char*
+ValueBase_String::get_cstring() const
{
- if(const char *const data = g_value_get_string(&gobject_))
+ if (const char* const data = g_value_get_string(&gobject_))
return data;
else
return "";
}
-GParamSpec* ValueBase_String::create_param_spec(const Glib::ustring& name) const
+GParamSpec*
+ValueBase_String::create_param_spec(const Glib::ustring& name) const
{
- return g_param_spec_string(
- name.c_str(), nullptr, nullptr, get_cstring(),
- GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
+ return g_param_spec_string(name.c_str(), nullptr, nullptr, get_cstring(),
+ GParamFlags(G_PARAM_READABLE | G_PARAM_WRITABLE));
}
-
/**** Glib::Value<std::string> *********************************************/
-void Value<std::string>::set(const std::string& data)
+void
+Value<std::string>::set(const std::string& data)
{
g_value_set_string(&gobject_, data.c_str());
}
-
/**** Glib::Value<Glib::ustring> *******************************************/
-void Value<Glib::ustring>::set(const Glib::ustring& data)
+void
+Value<Glib::ustring>::set(const Glib::ustring& data)
{
g_value_set_string(&gobject_, data.c_str());
}
diff --git a/glib/glibmm/value_custom.cc b/glib/glibmm/value_custom.cc
index 1c680f4..1d1e3a1 100644
--- a/glib/glibmm/value_custom.cc
+++ b/glib/glibmm/value_custom.cc
@@ -22,30 +22,28 @@
#include <glibmm/utility.h>
#include <glib.h>
-
namespace
{
-static void warn_already_registered(const char* location, const std::string& full_name)
+static void
+warn_already_registered(const char* location, const std::string& full_name)
{
g_warning("file %s: (%s): The type name `%s' has been registered already.\n"
"This is not supposed to happen -- please send a mail with detailed "
"information about your platform to gtkmm-list gnome org Thanks.\n",
- __FILE__, location, full_name.c_str());
+ __FILE__, location, full_name.c_str());
}
} // anonymous namespace
-
namespace Glib
{
-GType custom_boxed_type_register(const char* type_name,
- ValueInitFunc init_func,
- ValueFreeFunc free_func,
- ValueCopyFunc copy_func)
+GType
+custom_boxed_type_register(
+ const char* type_name, ValueInitFunc init_func, ValueFreeFunc free_func, ValueCopyFunc copy_func)
{
- std::string full_name ("glibmm__CustomBoxed_");
+ std::string full_name("glibmm__CustomBoxed_");
Glib::append_canonical_typename(full_name, type_name);
// Templates of the same type _might_ be duplicated when instantiated in
@@ -57,7 +55,7 @@ GType custom_boxed_type_register(const char* type_name,
// If this turns out to be common behaviour on some platform the warning
// should be removed.
- if(const GType existing_type = g_type_from_name(full_name.c_str()))
+ if (const GType existing_type = g_type_from_name(full_name.c_str()))
{
warn_already_registered("Glib::custom_boxed_type_register", full_name);
return existing_type;
@@ -66,11 +64,8 @@ GType custom_boxed_type_register(const char* type_name,
// Via GTypeValueTable, we can teach GValue how to instantiate,
// destroy, and copy arbitrary objects of the C++ type.
- const GTypeValueTable value_table =
- {
- init_func,
- free_func,
- copy_func,
+ const GTypeValueTable value_table = {
+ init_func, free_func, copy_func,
nullptr, // value_peek_pointer
nullptr, // collect_format
nullptr, // collect_value
@@ -78,16 +73,15 @@ GType custom_boxed_type_register(const char* type_name,
nullptr, // lcopy_value
};
- const GTypeInfo type_info =
- {
- 0, // class_size
+ const GTypeInfo type_info = {
+ 0, // class_size
nullptr, // base_init
nullptr, // base_finalize
nullptr, // class_init_func
nullptr, // class_finalize
nullptr, // class_data
- 0, // instance_size
- 0, // n_preallocs
+ 0, // instance_size
+ 0, // n_preallocs
nullptr, // instance_init
&value_table,
};
@@ -99,9 +93,10 @@ GType custom_boxed_type_register(const char* type_name,
return g_type_register_static(G_TYPE_BOXED, full_name.c_str(), &type_info, GTypeFlags(0));
}
-GType custom_pointer_type_register(const char* type_name)
+GType
+custom_pointer_type_register(const char* type_name)
{
- std::string full_name ("glibmm__CustomPointer_");
+ std::string full_name("glibmm__CustomPointer_");
Glib::append_canonical_typename(full_name, type_name);
// Templates of the same type _might_ be duplicated when instantiated in
@@ -113,22 +108,21 @@ GType custom_pointer_type_register(const char* type_name)
// If this turns out to be common behaviour on some platform the warning
// should be removed.
- if(const GType existing_type = g_type_from_name(full_name.c_str()))
+ if (const GType existing_type = g_type_from_name(full_name.c_str()))
{
warn_already_registered("Glib::custom_pointer_type_register", full_name);
return existing_type;
}
- const GTypeInfo type_info =
- {
- 0, // class_size
+ const GTypeInfo type_info = {
+ 0, // class_size
nullptr, // base_init
nullptr, // base_finalize
nullptr, // class_init_func
nullptr, // class_finalize
nullptr, // class_data
- 0, // instance_size
- 0, // n_preallocs
+ 0, // instance_size
+ 0, // n_preallocs
nullptr, // instance_init
nullptr, // value_table
};
@@ -140,5 +134,4 @@ GType custom_pointer_type_register(const char* type_name)
return g_type_register_static(G_TYPE_POINTER, full_name.c_str(), &type_info, GTypeFlags(0));
}
-
} // namespace Glib
diff --git a/glib/glibmm/vectorutils.cc b/glib/glibmm/vectorutils.cc
index f013b54..8a8e711 100644
--- a/glib/glibmm/vectorutils.cc
+++ b/glib/glibmm/vectorutils.cc
@@ -23,12 +23,13 @@ namespace Glib
namespace Container_Helpers
{
-gboolean* create_bool_array(std::vector<bool>::const_iterator pbegin, std::size_t size)
+gboolean*
+create_bool_array(std::vector<bool>::const_iterator pbegin, std::size_t size)
{
- gboolean *const array(static_cast<gboolean*>(g_malloc((size + 1) * sizeof(gboolean))));
- gboolean *const array_end(array + size);
+ gboolean* const array(static_cast<gboolean*>(g_malloc((size + 1) * sizeof(gboolean))));
+ gboolean* const array_end(array + size);
- for(gboolean* pdest(array); pdest != array_end; ++pdest)
+ for (gboolean* pdest(array); pdest != array_end; ++pdest)
{
*pdest = *pbegin;
++pbegin;
@@ -42,10 +43,11 @@ gboolean* create_bool_array(std::vector<bool>::const_iterator pbegin, std::size_
/**** Glib::ArrayHandler<bool> ************************/
-ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::VectorType
-ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::array_to_vector(const CType* array,
std::size_t array_size, Glib::OwnershipType ownership)
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool>>::VectorType
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool>>::array_to_vector(
+ const CType* array, std::size_t array_size, Glib::OwnershipType ownership)
{
- if(array)
+ if (array)
{
// it will handle destroying data depending on passed ownership.
ArrayKeeperType keeper(array, array_size, ownership);
@@ -54,23 +56,27 @@ ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::array_to_vector(
#else
VectorType temp;
temp.reserve(array_size);
- Glib::Container_Helpers::fill_container(temp, ArrayIteratorType(array), ArrayIteratorType(array +
array_size));
+ Glib::Container_Helpers::fill_container(
+ temp, ArrayIteratorType(array), ArrayIteratorType(array + array_size));
return temp;
#endif
}
return VectorType();
}
-ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::VectorType
-ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::array_to_vector(const CType* array,
Glib::OwnershipType ownership)
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool>>::VectorType
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool>>::array_to_vector(
+ const CType* array, Glib::OwnershipType ownership)
{
return array_to_vector(array, Glib::Container_Helpers::compute_array_size2(array), ownership);
}
-ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::ArrayKeeperType
-ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool> >::vector_to_array(const VectorType& vector)
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool>>::ArrayKeeperType
+ArrayHandler<bool, Glib::Container_Helpers::TypeTraits<bool>>::vector_to_array(
+ const VectorType& vector)
{
- return ArrayKeeperType(Glib::Container_Helpers::create_bool_array(vector.begin(), vector.size()),
vector.size(), Glib::OWNERSHIP_SHALLOW);
+ return ArrayKeeperType(Glib::Container_Helpers::create_bool_array(vector.begin(), vector.size()),
+ vector.size(), Glib::OWNERSHIP_SHALLOW);
}
} // namespace Glib
diff --git a/glib/glibmm/wrap.cc b/glib/glibmm/wrap.cc
index 18725a9..67861d6 100644
--- a/glib/glibmm/wrap.cc
+++ b/glib/glibmm/wrap.cc
@@ -42,22 +42,23 @@ static WrapFuncTable* wrap_func_table = nullptr;
} // anonymous namespace
-
namespace Glib
{
-void wrap_register_init()
+void
+wrap_register_init()
{
// g_type_init() is deprecated as of 2.36.
// g_type_init();
- if(!Glib::quark_)
+ if (!Glib::quark_)
{
Glib::quark_ = g_quark_from_static_string("glibmm__Glib::quark_");
- Glib::quark_cpp_wrapper_deleted_ =
g_quark_from_static_string("glibmm__Glib::quark_cpp_wrapper_deleted_");
+ Glib::quark_cpp_wrapper_deleted_ =
+ g_quark_from_static_string("glibmm__Glib::quark_cpp_wrapper_deleted_");
}
- if(!wrap_func_table)
+ if (!wrap_func_table)
{
// Make the first element a dummy so we can detect unregistered types.
// g_type_get_qdata() returns NULL if no data has been set up.
@@ -65,9 +66,10 @@ void wrap_register_init()
}
}
-void wrap_register_cleanup()
+void
+wrap_register_cleanup()
{
- if(wrap_func_table)
+ if (wrap_func_table)
{
delete wrap_func_table;
wrap_func_table = nullptr;
@@ -77,12 +79,13 @@ void wrap_register_cleanup()
// Register the unique wrap_new() function of a new C++ wrapper type.
// The GType argument specifies the parent C type to wrap from.
//
-void wrap_register(GType type, WrapNewFunction func)
+void
+wrap_register(GType type, WrapNewFunction func)
{
- //0 is not a valid GType.
- //It would lead to a critical warning in g_type_set_qdata().
- //We allow this, failing silently, to make life easier for gstreamermm.
- if(type == 0)
+ // 0 is not a valid GType.
+ // It would lead to a critical warning in g_type_set_qdata().
+ // We allow this, failing silently, to make life easier for gstreamermm.
+ if (type == 0)
return;
const guint idx = wrap_func_table->size();
@@ -92,27 +95,29 @@ void wrap_register(GType type, WrapNewFunction func)
g_type_set_qdata(type, Glib::quark_, GUINT_TO_POINTER(idx));
}
-
-static Glib::ObjectBase* wrap_create_new_wrapper(GObject* object)
+static Glib::ObjectBase*
+wrap_create_new_wrapper(GObject* object)
{
g_return_val_if_fail(wrap_func_table != nullptr, nullptr);
- const bool gtkmm_wrapper_already_deleted = (bool)g_object_get_qdata((GObject*)object,
Glib::quark_cpp_wrapper_deleted_);
- if(gtkmm_wrapper_already_deleted)
+ const bool gtkmm_wrapper_already_deleted =
+ (bool)g_object_get_qdata((GObject*)object, Glib::quark_cpp_wrapper_deleted_);
+ if (gtkmm_wrapper_already_deleted)
{
- g_warning("Glib::wrap_create_new_wrapper: Attempted to create a 2nd C++ wrapper for a C instance whose
C++ wrapper has been deleted.");
+ g_warning("Glib::wrap_create_new_wrapper: Attempted to create a 2nd C++ wrapper for a C "
+ "instance whose C++ wrapper has been deleted.");
return nullptr;
}
// Traverse upwards through the inheritance hierarchy
// to find the most-specialized wrap_new() for this GType.
//
- for(GType type = G_OBJECT_TYPE(object); type != 0; type = g_type_parent(type))
+ for (GType type = G_OBJECT_TYPE(object); type != 0; type = g_type_parent(type))
{
// Look up the wrap table index stored in the type's static data.
// If a wrap_new() has been registered for the type then call it.
//
- if(const gpointer idx = g_type_get_qdata(type, Glib::quark_))
+ if (const gpointer idx = g_type_get_qdata(type, Glib::quark_))
{
const Glib::WrapNewFunction func = (*wrap_func_table)[GPOINTER_TO_UINT(idx)];
return (*func)(object);
@@ -122,10 +127,11 @@ static Glib::ObjectBase* wrap_create_new_wrapper(GObject* object)
return nullptr;
}
-static gboolean gtype_wraps_interface(GType implementer_type, GType interface_type)
+static gboolean
+gtype_wraps_interface(GType implementer_type, GType interface_type)
{
guint n_ifaces = 0;
- GType *ifaces = g_type_interfaces (implementer_type, &n_ifaces);
+ GType* ifaces = g_type_interfaces(implementer_type, &n_ifaces);
gboolean found = FALSE;
while (n_ifaces-- && !found)
@@ -133,26 +139,29 @@ static gboolean gtype_wraps_interface(GType implementer_type, GType interface_ty
found = (ifaces[n_ifaces] == interface_type);
}
- g_free (ifaces);
+ g_free(ifaces);
return found;
}
-Glib::ObjectBase* wrap_create_new_wrapper_for_interface(GObject* object, GType interface_gtype)
+Glib::ObjectBase*
+wrap_create_new_wrapper_for_interface(GObject* object, GType interface_gtype)
{
g_return_val_if_fail(wrap_func_table != nullptr, nullptr);
- const bool gtkmm_wrapper_already_deleted = (bool)g_object_get_qdata((GObject*)object,
Glib::quark_cpp_wrapper_deleted_);
- if(gtkmm_wrapper_already_deleted)
+ const bool gtkmm_wrapper_already_deleted =
+ (bool)g_object_get_qdata((GObject*)object, Glib::quark_cpp_wrapper_deleted_);
+ if (gtkmm_wrapper_already_deleted)
{
- g_warning("Glib::wrap_create_new_wrapper: Attempted to create a 2nd C++ wrapper for a C instance whose
C++ wrapper has been deleted.");
+ g_warning("Glib::wrap_create_new_wrapper: Attempted to create a 2nd C++ wrapper for a C "
+ "instance whose C++ wrapper has been deleted.");
return nullptr;
}
// Traverse upwards through the inheritance hierarchy
// to find the most-specialized wrap_new() for this GType.
//
- for(GType type = G_OBJECT_TYPE(object); type != 0; type = g_type_parent(type))
+ for (GType type = G_OBJECT_TYPE(object); type != 0; type = g_type_parent(type))
{
// Look up the wrap table index stored in the type's static data.
// If a wrap_new() has been registered for the type then call it.
@@ -160,7 +169,7 @@ Glib::ObjectBase* wrap_create_new_wrapper_for_interface(GObject* object, GType i
// so that the C++ instance is likely to inherit from the appropriate class too.
//
const gpointer idx = g_type_get_qdata(type, Glib::quark_);
- if(idx && gtype_wraps_interface(type, interface_gtype))
+ if (idx && gtype_wraps_interface(type, interface_gtype))
{
const Glib::WrapNewFunction func = (*wrap_func_table)[GPOINTER_TO_UINT(idx)];
return (*func)(object);
@@ -170,42 +179,44 @@ Glib::ObjectBase* wrap_create_new_wrapper_for_interface(GObject* object, GType i
return nullptr;
}
-
// This is a factory function that converts any type to
// its C++ wrapper instance by looking up a wrap_new() function in a map.
//
-ObjectBase* wrap_auto(GObject* object, bool take_copy)
+ObjectBase*
+wrap_auto(GObject* object, bool take_copy)
{
- if(!object)
+ if (!object)
return nullptr;
// Look up current C++ wrapper instance:
ObjectBase* pCppObject = ObjectBase::_get_current_wrapper(object);
- if(!pCppObject)
+ if (!pCppObject)
{
// There's not already a wrapper: generate a new C++ instance.
pCppObject = wrap_create_new_wrapper(object);
- if(!pCppObject)
+ if (!pCppObject)
{
- g_warning("Failed to wrap object of type '%s'. Hint: this error is commonly caused by failing to call
a library init() function.", G_OBJECT_TYPE_NAME(object));
+ g_warning("Failed to wrap object of type '%s'. Hint: this error is commonly caused by "
+ "failing to call a library init() function.",
+ G_OBJECT_TYPE_NAME(object));
return nullptr;
}
}
// take_copy=true is used where the GTK+ function doesn't do
// an extra ref for us, and always for plain struct members.
- if(take_copy)
+ if (take_copy)
pCppObject->reference();
return pCppObject;
}
-Glib::RefPtr<Object> wrap(GObject* object, bool take_copy /* = false */)
+Glib::RefPtr<Object>
+wrap(GObject* object, bool take_copy /* = false */)
{
return Glib::RefPtr<Object>(dynamic_cast<Object*>(wrap_auto(object, take_copy)));
}
} /* namespace Glib */
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]