[glibmm] Glib::IOCondition: Add an IO_ prefix to the enumerator names
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Glib::IOCondition: Add an IO_ prefix to the enumerator names
- Date: Tue, 5 Sep 2017 18:14:43 +0000 (UTC)
commit 15e912f92aef0083d7d0e80718bf8bf5112e063c
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Tue Sep 5 20:12:54 2017 +0200
Glib::IOCondition: Add an IO_ prefix to the enumerator names
IN and OUT can be preprocessor macros. IO_ is added to the enumerator names.
E.g. Glib::IOCondition::IN is replaced by Glib::IOCondition::IO_IN.
These enumerator names will be the same as before we used enum class.
Bug 786717
examples/iochannel_stream/main.cc | 4 ++--
examples/network/resolver.cc | 2 +-
examples/network/socket-client.cc | 4 ++--
examples/network/socket-server.cc | 6 +++---
glib/glibmm/dispatcher.cc | 8 ++++----
glib/src/iochannel.hg | 13 +++++++++++--
6 files changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/examples/iochannel_stream/main.cc b/examples/iochannel_stream/main.cc
index 2cdfd2f..4fad426 100644
--- a/examples/iochannel_stream/main.cc
+++ b/examples/iochannel_stream/main.cc
@@ -43,7 +43,7 @@ Glib::RefPtr<Glib::MainLoop> mainloop;
bool
MyCallback(Glib::IOCondition io_condition)
{
- if ((io_condition & Glib::IOCondition::IN) != Glib::IOCondition::IN)
+ if ((io_condition & Glib::IOCondition::IO_IN) != Glib::IOCondition::IO_IN)
{
std::cerr << "Invalid fifo response" << std::endl;
}
@@ -88,7 +88,7 @@ int main(/* int argc, char *argv[] */)
}
input_stream.attach(read_fd);
- input_stream.connect(sigc::ptr_fun(MyCallback), Glib::IOCondition::IN);
+ input_stream.connect(sigc::ptr_fun(MyCallback), Glib::IOCondition::IO_IN);
// and last but not least - run the application main loop
mainloop->run();
diff --git a/examples/network/resolver.cc b/examples/network/resolver.cc
index d145a63..a651a1a 100644
--- a/examples/network/resolver.cc
+++ b/examples/network/resolver.cc
@@ -464,7 +464,7 @@ main(int argc, char** argv)
signal(SIGINT, interrupted);
chan = Glib::IOChannel::create_from_fd(cancel_fds[0]);
- const auto source = chan->create_watch(Glib::IOCondition::IN);
+ const auto source = chan->create_watch(Glib::IOCondition::IO_IN);
watch_conn = source->connect(sigc::bind(sigc::ptr_fun(async_cancel), cancellable));
#endif
diff --git a/examples/network/socket-client.cc b/examples/network/socket-client.cc
index aacbd6b..5a3718a 100644
--- a/examples/network/socket-client.cc
+++ b/examples/network/socket-client.cc
@@ -272,7 +272,7 @@ main(int argc, char* argv[])
buffer[to_send] = '\0';
while (to_send > 0)
{
- ensure_condition(socket, "send", cancellable, Glib::IOCondition::OUT);
+ ensure_condition(socket, "send", cancellable, Glib::IOCondition::IO_OUT);
try
{
if (use_udp)
@@ -305,7 +305,7 @@ main(int argc, char* argv[])
to_send -= size;
}
- ensure_condition(socket, "receive", cancellable, Glib::IOCondition::IN);
+ ensure_condition(socket, "receive", cancellable, Glib::IOCondition::IO_IN);
try
{
if (use_udp)
diff --git a/examples/network/socket-server.cc b/examples/network/socket-server.cc
index 59dd115..a0e6bd1 100644
--- a/examples/network/socket-server.cc
+++ b/examples/network/socket-server.cc
@@ -218,7 +218,7 @@ main(int argc, char* argv[])
std::cout << Glib::ustring::compose("listening on port %1...\n", port);
- ensure_condition(socket, "accept", cancellable, Glib::IOCondition::IN);
+ ensure_condition(socket, "accept", cancellable, Glib::IOCondition::IO_IN);
try
{
new_socket = socket->accept(cancellable);
@@ -257,7 +257,7 @@ main(int argc, char* argv[])
gchar buffer[4096] = {};
gssize size;
- ensure_condition(recv_socket, "receive", cancellable, Glib::IOCondition::IN);
+ ensure_condition(recv_socket, "receive", cancellable, Glib::IOCondition::IO_IN);
try
{
if (use_udp)
@@ -289,7 +289,7 @@ main(int argc, char* argv[])
while (to_send > 0)
{
- ensure_condition(recv_socket, "send", cancellable, Glib::IOCondition::OUT);
+ ensure_condition(recv_socket, "send", cancellable, Glib::IOCondition::IO_OUT);
try
{
if (use_udp)
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index 36d7235..d5a96de 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -221,10 +221,10 @@ DispatchNotifier::DispatchNotifier(const Glib::RefPtr<MainContext>& context)
// The following code is equivalent to
// context_->signal_io().connect(
- // sigc::mem_fun(*this, &DispatchNotifier::pipe_io_handler), fd, Glib::IOCondition::IN);
+ // sigc::mem_fun(*this, &DispatchNotifier::pipe_io_handler), fd, Glib::IOCondition::IO_IN);
// except for source->set_can_recurse(true).
- const auto source = IOSource::create(fd, Glib::IOCondition::IN);
+ const auto source = IOSource::create(fd, Glib::IOCondition::IO_IN);
// If the signal emission in pipe_io_handler() starts a new main loop,
// the event source shall not be blocked while that loop runs. (E.g. while
@@ -403,10 +403,10 @@ DispatchNotifier::pipe_is_empty()
#ifdef G_OS_WIN32
return notify_queue_.empty();
#else
- PollFD poll_fd(fd_receiver_, Glib::IOCondition::IN);
+ PollFD poll_fd(fd_receiver_, Glib::IOCondition::IO_IN);
// GPollFD*, number of file descriptors to poll, timeout (ms)
g_poll(poll_fd.gobj(), 1, 0);
- return static_cast<int>(poll_fd.get_revents() & Glib::IOCondition::IN) == 0;
+ return static_cast<int>(poll_fd.get_revents() & Glib::IOCondition::IO_IN) == 0;
#endif
}
diff --git a/glib/src/iochannel.hg b/glib/src/iochannel.hg
index 0752bce..2cc840f 100644
--- a/glib/src/iochannel.hg
+++ b/glib/src/iochannel.hg
@@ -39,6 +39,9 @@ _WRAP_ENUM(IOStatus, GIOStatus, NO_GTYPE, s#^EOF$#ENDOFFILE#)
_WRAP_ENUM(IOFlags, GIOFlags, NO_GTYPE)
+// Glib::IOCondition::IN and Glib::IOCondition::OUT would be problematic.
+// IN and OUT can be preprocessor macros.
+// See https://bugzilla.gnome.org/show_bug.cgi?id=786717
/** @enum IOCondition
* A bitwise combination representing an I/O condition to watch for on an
* event source.
@@ -46,11 +49,17 @@ _WRAP_ENUM(IOFlags, GIOFlags, NO_GTYPE)
* on UNIX (see <tt>man 2 poll</tt>). To test for individual flags, do
* something like this:
* @code
- * if ((condition & Glib::IOCondition::OUT) == Glib::IOCondition::OUT)
+ * if ((condition & Glib::IOCondition::IO_OUT) == Glib::IOCondition::IO_OUT)
* do_some_output();
* @endcode
*/
-_WRAP_ENUM(IOCondition, GIOCondition, NO_GTYPE)
+_WRAP_ENUM(IOCondition, GIOCondition, NO_GTYPE,
+ s#^IN$#IO_IN#,
+ s#^OUT$#IO_OUT#,
+ s#^PRI$#IO_PRI#,
+ s#^ERR$#IO_ERR#,
+ s#^HUP$#IO_HUP#,
+ s#^NVAL$#IO_NVAL#)
/** Exception class for IOChannel errors.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]