[glibmm] Fix some TODO comments
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Fix some TODO comments
- Date: Wed, 13 Dec 2017 17:15:33 +0000 (UTC)
commit 184749e8a0aa16ebae1e7397db0d5c755031aca5
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Wed Dec 13 18:12:04 2017 +0100
Fix some TODO comments
* gio/src/actionmap.ccg: Use the Glib::VariantBase::cast_dynamic<>()
syntax for calling the static member function.
* gio/src/emblemedicon.hg: Add a const version of get_emblems().
* gio/src/networkmonitor.hg: Add class documentation.
* gio/src/tlsclientconnection.hg:
* gio/src/tlsfiledatabase.hg:
* gio/src/tlsserverconnection.hg: Remove "TODO:" from some comments where
there's really nothing to do.
* glib/src/miscutils.ccg: get_system_data_dirs(), get_system_config_dirs():
Use Glib::ArrayHandler<std::string>::array_to_vector().
* glib/src/optioncontext.hg: Make it explicit that OptionContext is not
copyable.
* glib/src/varianttype.hg: Rename _get_string_length() to get_string_length().
The leading underscore looks like a mistake.
Remove the comment "Use something instead of gsize?" gsize is used in
many methods in glibmm and gtkmm.
gio/src/actionmap.ccg | 6 ++----
gio/src/emblemedicon.hg | 6 +++---
gio/src/networkmonitor.hg | 9 ++++++++-
gio/src/tlsclientconnection.hg | 8 ++++++--
gio/src/tlsfiledatabase.hg | 8 +++++---
gio/src/tlsserverconnection.hg | 7 +++++--
glib/src/miscutils.ccg | 34 +++-------------------------------
glib/src/optioncontext.hg | 5 ++---
glib/src/varianttype.hg | 5 ++---
9 files changed, 36 insertions(+), 52 deletions(-)
---
diff --git a/gio/src/actionmap.ccg b/gio/src/actionmap.ccg
index ecb1209..c39a242 100644
--- a/gio/src/actionmap.ccg
+++ b/gio/src/actionmap.ccg
@@ -80,8 +80,7 @@ static void
on_action_radio_string(
const Glib::VariantBase& parameter, const Gio::ActionMap::ActivateWithStringParameterSlot& slot)
{
- // TODO: This syntax is odd:
- const auto variantDerived = parameter.cast_dynamic<Glib::Variant<Glib::ustring>>(parameter);
+ const auto variantDerived = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(parameter);
const auto str = variantDerived.get();
slot(str);
}
@@ -105,8 +104,7 @@ static void
on_action_radio_int(
const Glib::VariantBase& parameter, const Gio::ActionMap::ActivateWithIntParameterSlot& slot)
{
- // TODO: This syntax is odd:
- const auto variantDerived = parameter.cast_dynamic<Glib::Variant<int>>(parameter);
+ const auto variantDerived = Glib::VariantBase::cast_dynamic<Glib::Variant<int>>(parameter);
const auto str = variantDerived.get();
slot(str);
}
diff --git a/gio/src/emblemedicon.hg b/gio/src/emblemedicon.hg
index 4665e39..de9a291 100644
--- a/gio/src/emblemedicon.hg
+++ b/gio/src/emblemedicon.hg
@@ -79,9 +79,9 @@ public:
#m4
_CONVERSION(`GList*',`std::vector<Glib::RefPtr<Emblem>>',`Glib::ListHandler<Glib::RefPtr<Emblem>>::list_to_vector($3,
Glib::OWNERSHIP_NONE)')
_WRAP_METHOD(std::vector<Glib::RefPtr<Emblem>> get_emblems(), g_emblemed_icon_get_emblems)
-
-//TODO: #m4 _CONVERSION(`GList*',`std::vector<Glib::RefPtr<const Emblem>>',`$2($3, Glib::OWNERSHIP_NONE)')
-// _WRAP_METHOD(std::vector<Glib::RefPtr<const Emblem>> get_emblems() const, g_emblemed_icon_get_emblems,
constversion)
+ dnl// Can't use the constversion parameter in _WRAP_METHOD() when a vector is returned.
+#m4 _CONVERSION(`GList*',`std::vector<Glib::RefPtr<const Emblem>>',`Glib::ListHandler<Glib::RefPtr<const
Emblem>>::list_to_vector($3, Glib::OWNERSHIP_NONE)')
+ _WRAP_METHOD(std::vector<Glib::RefPtr<const Emblem>> get_emblems() const, g_emblemed_icon_get_emblems)
_WRAP_METHOD(void add_emblem(const Glib::RefPtr<Emblem>& emblem), g_emblemed_icon_add_emblem)
_WRAP_METHOD(void clear_emblems(), g_emblemed_icon_clear_emblems)
diff --git a/gio/src/networkmonitor.hg b/gio/src/networkmonitor.hg
index 4ed6fc9..d46cbba 100644
--- a/gio/src/networkmonitor.hg
+++ b/gio/src/networkmonitor.hg
@@ -34,8 +34,15 @@ namespace Gio
_WRAP_ENUM(NetworkConnectivity, GNetworkConnectivity, NO_GTYPE)
-/** TODO
+/** Network status monitor.
*
+ * %NetworkMonitor provides an easy-to-use cross-platform API
+ * for monitoring network connectivity. On Linux, the available
+ * implementations are based on the kernel's netlink interface and
+ * on NetworkManager.
+ *
+ * There is also an implementation for use inside Flatpak sandboxes.
+
* @newin{2,44}
*/
class NetworkMonitor : public Glib::Interface
diff --git a/gio/src/tlsclientconnection.hg b/gio/src/tlsclientconnection.hg
index 40af030..8a166d0 100644
--- a/gio/src/tlsclientconnection.hg
+++ b/gio/src/tlsclientconnection.hg
@@ -31,6 +31,10 @@ namespace Gio
class SocketConnectable;
+// It's unusual that a subclass of Glib::Object is a base class of an interface.
+// For a discussion, see https://bugzilla.gnome.org/show_bug.cgi?id=776537
+// especially the last paragraph of comment 6.
+
/** TlsClientConnection - TLS client-side connection.
* TlsClientConnection is the client-side subclass of TlsConnection,
* representing a client-side TLS connection.
@@ -44,8 +48,8 @@ class TlsClientConnection
_CUSTOM_CTOR_CAST
public:
- //TODO: It's not possible to use _WRAP_CTOR/_WRAP_CREATE to wrap the new
- //function because this is an interface.
+ // It's not possible to use _WRAP_CTOR/_WRAP_CREATE to wrap the new
+ // function because this is an interface.
#m4 _CONVERSION(`GIOStream*',`Glib::RefPtr<TlsClientConnection>',`Glib::wrap(G_TLS_CLIENT_CONNECTION($3))')
_WRAP_METHOD(static Glib::RefPtr<TlsClientConnection> create(const Glib::RefPtr<IOStream>& base_io_stream,
const Glib::RefPtr<const SocketConnectable>& server_identity{?}), g_tls_client_connection_new, errthrow)
diff --git a/gio/src/tlsfiledatabase.hg b/gio/src/tlsfiledatabase.hg
index bed39f8..0113229 100644
--- a/gio/src/tlsfiledatabase.hg
+++ b/gio/src/tlsfiledatabase.hg
@@ -28,6 +28,9 @@ typedef struct _GTlsFileDatabaseInterface GTlsFileDatabaseInterface;
namespace Gio
{
+// It's unusual that a subclass of Glib::Object is a base class of an interface.
+// For a discussion, see https://bugzilla.gnome.org/show_bug.cgi?id=776537
+// especially the last paragraph of comment 6.
/** TlsFileDatabase - TLS file based database type.
* TlsFileDatabase is implemented by TlsDatabase objects which load their
@@ -43,9 +46,8 @@ class TlsFileDatabase
_CLASS_INTERFACE(TlsFileDatabase, GTlsFileDatabase, G_TLS_FILE_DATABASE, GTlsFileDatabaseInterface)
public:
- //TODO: It is not possible to use _WRAP_CTOR()/WRAP_CREATE() here because this
- //class is an interface.
- // So, should we make it possible to use them? murrayc.
+ // It's not possible to use _WRAP_CTOR/_WRAP_CREATE to wrap the new
+ // function because this is an interface.
#m4 _CONVERSION(`GTlsDatabase*',`Glib::RefPtr<TlsFileDatabase>',`Glib::wrap(G_TLS_FILE_DATABASE($3))')
_WRAP_METHOD(static Glib::RefPtr<TlsFileDatabase> create(const std::string& anchors),
g_tls_file_database_new, errthrow)
diff --git a/gio/src/tlsserverconnection.hg b/gio/src/tlsserverconnection.hg
index a9b52a4..67bd0a9 100644
--- a/gio/src/tlsserverconnection.hg
+++ b/gio/src/tlsserverconnection.hg
@@ -28,6 +28,9 @@ typedef struct _GTlsServerConnectionInterface GTlsServerConnectionInterface;
namespace Gio
{
+// It's unusual that a subclass of Glib::Object is a base class of an interface.
+// For a discussion, see https://bugzilla.gnome.org/show_bug.cgi?id=776537
+// especially the last paragraph of comment 6.
/** TlsServerConnection - TLS server-side connection.
* TlsServerConnection is the server-side subclass of TlsConnection,
@@ -40,8 +43,8 @@ class TlsServerConnection : public Glib::Interface, public TlsConnection
_CUSTOM_CTOR_CAST
public:
- //TODO: It's not possible to use _WRAP_CTOR/_WRAP_CREATE to wrap the new
- //function because this is an interface.
+ // It's not possible to use _WRAP_CTOR/_WRAP_CREATE to wrap the new
+ // function because this is an interface.
#m4 _CONVERSION(`GIOStream*',`Glib::RefPtr<TlsServerConnection>',`Glib::wrap(G_TLS_SERVER_CONNECTION($3))')
_WRAP_METHOD(static Glib::RefPtr<IOStream> create(const Glib::RefPtr<IOStream>& base_io_stream, const
Glib::RefPtr<TlsCertificate>& certificate), g_tls_server_connection_new, errthrow)
diff --git a/glib/src/miscutils.ccg b/glib/src/miscutils.ccg
index abd2dac..90043af 100644
--- a/glib/src/miscutils.ccg
+++ b/glib/src/miscutils.ccg
@@ -77,13 +77,7 @@ unsetenv(const std::string& variable)
std::vector<std::string>
listenv()
{
- char** value = g_listenv();
- char** end = value;
- while (*end)
- {
- ++end;
- }
- return Glib::ArrayHandler<std::string>::array_to_vector(value, end - value, Glib::OWNERSHIP_DEEP);
+ return Glib::ArrayHandler<std::string>::array_to_vector(g_listenv(), Glib::OWNERSHIP_DEEP);
}
std::string
@@ -137,35 +131,13 @@ get_user_config_dir()
std::vector<std::string>
get_system_data_dirs()
{
- // TODO: Use a utility function:
- std::vector<std::string> result;
- const char* const* cresult = g_get_system_data_dirs();
- if (!cresult)
- return result;
-
- for (const gchar* const* iter = cresult; *iter != nullptr; ++iter)
- {
- result.emplace_back(convert_const_gchar_ptr_to_stdstring(*iter));
- }
-
- return result;
+ return Glib::ArrayHandler<std::string>::array_to_vector(g_get_system_data_dirs(), Glib::OWNERSHIP_NONE);
}
std::vector<std::string>
get_system_config_dirs()
{
- // TODO: Use a utility function:
- std::vector<std::string> result;
- const char* const* cresult = g_get_system_config_dirs();
- if (!cresult)
- return result;
-
- for (const gchar* const* iter = cresult; *iter != nullptr; ++iter)
- {
- result.emplace_back(convert_const_gchar_ptr_to_stdstring(*iter));
- }
-
- return result;
+ return Glib::ArrayHandler<std::string>::array_to_vector(g_get_system_config_dirs(), Glib::OWNERSHIP_NONE);
}
std::string
diff --git a/glib/src/optioncontext.hg b/glib/src/optioncontext.hg
index 914fdf1..9672650 100644
--- a/glib/src/optioncontext.hg
+++ b/glib/src/optioncontext.hg
@@ -98,9 +98,8 @@ public:
//so it should be used carefully. For instance you could not access data in a derived class via this
second instance.
explicit OptionContext(GOptionContext* castitem, bool take_ownership = false);
- //TODO?:
- //OptionContext(const OptionContext& other) = delete;
- //OptionContext& operator=(const OptionContext& other) = delete;
+ OptionContext(const OptionContext& other) = delete;
+ OptionContext& operator=(const OptionContext& other) = delete;
OptionContext(OptionContext&& other) noexcept;
OptionContext& operator=(OptionContext&& other) noexcept;
diff --git a/glib/src/varianttype.hg b/glib/src/varianttype.hg
index fb0e6e3..ba16db7 100644
--- a/glib/src/varianttype.hg
+++ b/glib/src/varianttype.hg
@@ -125,9 +125,8 @@ public:
_WRAP_METHOD(static VariantType create_dict_entry(const VariantType& key, const VariantType& value),
g_variant_type_new_dict_entry)
- //TODO: Use something instead of gsize?
- _WRAP_METHOD(gsize _get_string_length() const, g_variant_type_get_string_length)
- dnl wrapped by hand, because g_variant_type_peek_string does not return a C string.
+ _WRAP_METHOD(gsize get_string_length() const, g_variant_type_get_string_length)
+ dnl// wrapped by hand, because g_variant_type_peek_string does not return a nul-terminated C string.
_WRAP_METHOD_DOCS_ONLY(g_variant_type_peek_string)
std::string get_string() const;
_IGNORE(g_variant_type_dup_string)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]