diff options
author | Murray Cumming <murrayc@murrayc.com> | 2012-09-15 22:07:46 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2012-09-15 22:07:46 +0200 |
commit | 3990fbe43137ab174503140d922d5aed19432093 (patch) | |
tree | 7ded8225a3443edeb14c1fd7d890ff99726a594c | |
parent | 383bd19cb932099871805ea0abe557e5ed4abae2 (diff) | |
download | glibmm-3990fbe43137ab174503140d922d5aed19432093.tar.gz |
Simplified lots of code by using the {?} _WRAP_METHOD() syntax.
* gio/src/application.[hg|ccg]:
* gio/src/bufferedinputstream.[hg|ccg]:
* gio/src/datainputstream.[hg|ccg]:
* gio/src/dataoutputstream.[hg|ccg]:
* gio/src/dbusconnection.[hg|ccg]:
* gio/src/fileenumerator.[hg|ccg]:
* gio/src/initable.[hg|ccg]:
* gio/src/inputstream.[hg|ccg]:
* gio/src/iostream.[hg|ccg]:
* gio/src/outputstream.[hg|ccg]:
* gio/src/resolver.[hg|ccg]:
* gio/src/seekable.[hg|ccg]:
* gio/src/socket.[hg|ccg]:
* gio/src/socketaddressenumerator.[hg|ccg]:
* gio/src/socketclient.[hg|ccg]: This relatively new gmmproc syntax lets
us avoid the manual implementations and declarations just to have
overloads without the Cancellable parameters.
* gio/src/unixconnection.hg: This had no method overloads without
Cancellable parameters but now it does.
32 files changed, 81 insertions, 941 deletions
@@ -1,5 +1,29 @@ 2012-09-15 Murray Cumming <murrayc@murrayc.com> + Simplified lots of code by using the {?} _WRAP_METHOD() syntax. + + * gio/src/application.[hg|ccg]: + * gio/src/bufferedinputstream.[hg|ccg]: + * gio/src/datainputstream.[hg|ccg]: + * gio/src/dataoutputstream.[hg|ccg]: + * gio/src/dbusconnection.[hg|ccg]: + * gio/src/fileenumerator.[hg|ccg]: + * gio/src/initable.[hg|ccg]: + * gio/src/inputstream.[hg|ccg]: + * gio/src/iostream.[hg|ccg]: + * gio/src/outputstream.[hg|ccg]: + * gio/src/resolver.[hg|ccg]: + * gio/src/seekable.[hg|ccg]: + * gio/src/socket.[hg|ccg]: + * gio/src/socketaddressenumerator.[hg|ccg]: + * gio/src/socketclient.[hg|ccg]: This relatively new gmmproc syntax lets + us avoid the manual implementations and declarations just to have + overloads without the Cancellable parameters. + * gio/src/unixconnection.hg: This had no method overloads without + Cancellable parameters but now it does. + +2012-09-15 Murray Cumming <murrayc@murrayc.com> + Gio::File: Correct the commit again * gio/src/file.[hg|ccg]: make_directory() was missing a {?}. diff --git a/gio/src/application.ccg b/gio/src/application.ccg index 8913b5ff..f11e4543 100644 --- a/gio/src/application.ccg +++ b/gio/src/application.ccg @@ -207,14 +207,4 @@ void Application::open(const Glib::RefPtr<Gio::File>& file, const Glib::ustring& open(files, hint); } -bool Application::register_application() -{ - GError* gerror = 0; - bool retvalue = g_application_register(gobj(), NULL, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - } // namespace Gio diff --git a/gio/src/application.hg b/gio/src/application.hg index d76f68e0..093d7b76 100644 --- a/gio/src/application.hg +++ b/gio/src/application.hg @@ -132,10 +132,7 @@ public: _WRAP_METHOD(bool is_remote() const, g_application_get_is_remote) //Renamed from register() because that is a C++ keyword. - _WRAP_METHOD(bool register_application(const Glib::RefPtr<Gio::Cancellable>& cancellable), g_application_register, errthrow) - - /// Non-cancellable version of register_application(). - bool register_application(); + _WRAP_METHOD(bool register_application(const Glib::RefPtr<Gio::Cancellable>& cancellable{?}), g_application_register, errthrow) _WRAP_METHOD(void hold(), g_application_hold) _WRAP_METHOD(void release(), g_application_release) diff --git a/gio/src/bufferedinputstream.ccg b/gio/src/bufferedinputstream.ccg index abfccda1..b015f9a9 100644 --- a/gio/src/bufferedinputstream.ccg +++ b/gio/src/bufferedinputstream.ccg @@ -28,16 +28,6 @@ Glib::RefPtr<BufferedInputStream> BufferedInputStream::create_sized(const Glib:: return Glib::RefPtr<Gio::BufferedInputStream>(new BufferedInputStream(base_stream, buffer_size)); } -gssize BufferedInputStream::fill(gssize count) -{ - GError* gerror = 0; - const gssize retvalue = g_buffered_input_stream_fill(const_cast<GBufferedInputStream*>(gobj()), count, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - void BufferedInputStream::fill_async(const SlotAsyncReady& slot, gssize count, const Glib::RefPtr<Cancellable>& cancellable, @@ -73,16 +63,4 @@ void BufferedInputStream::fill_async(const SlotAsyncReady& slot, slot_copy); } -int BufferedInputStream::read_byte() -{ - GError* gerror = 0; - const int retvalue = g_buffered_input_stream_read_byte(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; - -} - - } // namespace Gio diff --git a/gio/src/bufferedinputstream.hg b/gio/src/bufferedinputstream.hg index 598053c4..340087ed 100644 --- a/gio/src/bufferedinputstream.hg +++ b/gio/src/bufferedinputstream.hg @@ -72,11 +72,7 @@ public: _WRAP_METHOD(gsize get_available() const, g_buffered_input_stream_get_available) _WRAP_METHOD(gsize peek(void* buffer, gsize offset, gsize count) const, g_buffered_input_stream_peek) _WRAP_METHOD(const void* peek_buffer(gsize& count) const, g_buffered_input_stream_peek_buffer) - _WRAP_METHOD(gssize fill(gssize count, const Glib::RefPtr<Cancellable>& cancellable), g_buffered_input_stream_fill, errthrow) - - /** non-cancellable version of fill() - */ - gssize fill(gssize count); + _WRAP_METHOD(gssize fill(gssize count, const Glib::RefPtr<Cancellable>& cancellable{?}), g_buffered_input_stream_fill, errthrow) _IGNORE(g_buffered_input_stream_fill_async) @@ -108,11 +104,7 @@ public: _WRAP_METHOD(gssize fill_finish(const Glib::RefPtr<AsyncResult>& result), g_buffered_input_stream_fill_finish, errthrow) - _WRAP_METHOD(int read_byte(const Glib::RefPtr<Cancellable>& cancellable), g_buffered_input_stream_read_byte, errthrow) - - /** Non-cancellable version of read_byte(). - */ - int read_byte(); + _WRAP_METHOD(int read_byte(const Glib::RefPtr<Cancellable>& cancellable{?}), g_buffered_input_stream_read_byte, errthrow) _WRAP_PROPERTY("buffer-size", guint) diff --git a/gio/src/datainputstream.ccg b/gio/src/datainputstream.ccg index f71c8f71..485c7b1e 100644 --- a/gio/src/datainputstream.ccg +++ b/gio/src/datainputstream.ccg @@ -24,76 +24,6 @@ namespace Gio { -guchar DataInputStream::read_byte() -{ - GError* gerror = 0; - const guchar retvalue = g_data_input_stream_read_byte(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -gint16 DataInputStream::read_int16() -{ - GError* gerror = 0; - const gint16 retvalue = g_data_input_stream_read_int16(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -guint16 DataInputStream::read_uint16() -{ - GError* gerror = 0; - const guint16 retvalue = g_data_input_stream_read_uint16(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -gint32 DataInputStream::read_int32() -{ - GError* gerror = 0; - const gint32 retvalue = g_data_input_stream_read_int32(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -guint32 DataInputStream::read_uint32() -{ - GError* gerror = 0; - const guint32 retvalue = g_data_input_stream_read_uint32(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -gint64 DataInputStream::read_int64() -{ - GError* gerror = 0; - const gint64 retvalue = g_data_input_stream_read_int64(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -guint64 DataInputStream::read_uint64() -{ - GError* gerror = 0; - const guint64 retvalue = g_data_input_stream_read_uint64(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - bool DataInputStream::read_line(std::string& line, const Glib::RefPtr<Cancellable>& cancellable) { GError* gerror = 0; diff --git a/gio/src/datainputstream.hg b/gio/src/datainputstream.hg index 9a9a9100..965d721d 100644 --- a/gio/src/datainputstream.hg +++ b/gio/src/datainputstream.hg @@ -50,47 +50,19 @@ public: _WRAP_METHOD(void set_newline_type(DataStreamNewlineType type), g_data_input_stream_set_newline_type) _WRAP_METHOD(DataStreamNewlineType get_newline_type() const, g_data_input_stream_get_newline_type) - _WRAP_METHOD(guchar read_byte(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_byte, errthrow) + _WRAP_METHOD(guchar read_byte(const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_input_stream_read_byte, errthrow) - /** non-cancellable version of read_byte() - */ - guchar read_byte(); - - _WRAP_METHOD(gint16 read_int16(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_int16, errthrow) - /** non-cancellable version of read_int16() - */ - gint16 read_int16(); + _WRAP_METHOD(gint16 read_int16(const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_input_stream_read_int16, errthrow) - _WRAP_METHOD(guint16 read_uint16(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_uint16, errthrow) + _WRAP_METHOD(guint16 read_uint16(const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_input_stream_read_uint16, errthrow) -//TODO: Real documentation: - /** non-cancellable version of read_uint16() - */ - guint16 read_uint16(); + _WRAP_METHOD(gint32 read_int32(const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_input_stream_read_int32, errthrow) - _WRAP_METHOD(gint32 read_int32(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_int32, errthrow) + _WRAP_METHOD(guint32 read_uint32(const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_input_stream_read_uint32, errthrow) - /** non-cancellable version of read_int32() - */ - gint32 read_int32(); - - _WRAP_METHOD(guint32 read_uint32(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_uint32, errthrow) - /** non-cancellable version of read_uint32() - */ - guint32 read_uint32(); - - _WRAP_METHOD(gint64 read_int64(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_int64, errthrow) - - /** non-cancellable version of read_int64() - */ - gint64 read_int64(); - - _WRAP_METHOD(guint64 read_uint64(const Glib::RefPtr<Cancellable>& cancellable), g_data_input_stream_read_uint64, errthrow) - - /** non-cancellable version of read_uint64() - */ - guint64 read_uint64(); + _WRAP_METHOD(gint64 read_int64(const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_input_stream_read_int64, errthrow) + _WRAP_METHOD(guint64 read_uint64(const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_input_stream_read_uint64, errthrow) //Note that we return a bool because we can't use std::string to distinguish between an empty string and a NULL. diff --git a/gio/src/dataoutputstream.ccg b/gio/src/dataoutputstream.ccg index fe7f96ac..5e41c705 100644 --- a/gio/src/dataoutputstream.ccg +++ b/gio/src/dataoutputstream.ccg @@ -23,87 +23,4 @@ namespace Gio { -bool DataOutputStream::put_byte(guchar data) -{ - GError* gerror = 0; - const guchar retvalue = g_data_output_stream_put_byte(gobj(), data, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool DataOutputStream::put_int16(gint16 data) -{ - GError* gerror = 0; - const gint16 retvalue = g_data_output_stream_put_int16(gobj(), data, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool DataOutputStream::put_uint16(guint16 data) -{ - GError* gerror = 0; - const guint16 retvalue = g_data_output_stream_put_uint16(gobj(), data, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool DataOutputStream::put_int32(gint32 data) -{ - GError* gerror = 0; - const gint32 retvalue = g_data_output_stream_put_int32(gobj(), data, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool DataOutputStream::put_uint32(guint32 data) -{ - GError* gerror = 0; - const guint32 retvalue = g_data_output_stream_put_uint32(gobj(), data, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool DataOutputStream::put_int64(gint64 data) -{ - GError* gerror = 0; - const gint64 retvalue = g_data_output_stream_put_int64(gobj(), data, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool DataOutputStream::put_uint64(guint64 data) -{ - GError* gerror = 0; - guint64 retvalue = g_data_output_stream_put_uint64(gobj(), data, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool DataOutputStream::put_string(std::string str) -{ - GError* gerror = 0; - const bool retval = g_data_output_stream_put_string(gobj(), - str.c_str (), - 0, - &gerror); - if(gerror) - ::Glib::Error::throw_exception(gerror); - return retval; -} - - } // namespace Gio diff --git a/gio/src/dataoutputstream.hg b/gio/src/dataoutputstream.hg index 1bf382d6..95c398af 100644 --- a/gio/src/dataoutputstream.hg +++ b/gio/src/dataoutputstream.hg @@ -48,49 +48,21 @@ public: _WRAP_METHOD(void set_byte_order(DataStreamByteOrder order), g_data_output_stream_set_byte_order) _WRAP_METHOD(DataStreamByteOrder get_byte_order() const, g_data_output_stream_get_byte_order) - _WRAP_METHOD(bool put_byte(guchar data, const Glib::RefPtr<Cancellable>& cancellable), g_data_output_stream_put_byte, errthrow) + _WRAP_METHOD(bool put_byte(guchar data, const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_output_stream_put_byte, errthrow) - /** non-cancellable version of put_byte() - */ - bool put_byte(guchar data); + _WRAP_METHOD(bool put_int16(gint16 data, const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_output_stream_put_int16, errthrow) - _WRAP_METHOD(bool put_int16(gint16 data, const Glib::RefPtr<Cancellable>& cancellable), g_data_output_stream_put_int16, errthrow) - /** non-cancellable version of put_int16() - */ - bool put_int16(gint16 data); + _WRAP_METHOD(bool put_uint16(guint16 data, const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_output_stream_put_uint16, errthrow) - _WRAP_METHOD(bool put_uint16(guint16 data, const Glib::RefPtr<Cancellable>& cancellable), g_data_output_stream_put_uint16, errthrow) - /** non-cancellable version of put_uint16() - */ - bool put_uint16(guint16 data); + _WRAP_METHOD(bool put_int32(gint32 data, const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_output_stream_put_int32, errthrow) - _WRAP_METHOD(bool put_int32(gint32 data, const Glib::RefPtr<Cancellable>& cancellable), g_data_output_stream_put_int32, errthrow) + _WRAP_METHOD(bool put_uint32(guint32 data, const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_output_stream_put_uint32, errthrow) - /** non-cancellable version of put_int32() - */ - bool put_int32(gint32 data); + _WRAP_METHOD(bool put_int64(gint64 data, const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_output_stream_put_int64, errthrow) - _WRAP_METHOD(bool put_uint32(guint32 data, const Glib::RefPtr<Cancellable>& cancellable), g_data_output_stream_put_uint32, errthrow) - /** non-cancellable version of put_uint32() - */ - bool put_uint32(guint32 data); + _WRAP_METHOD(bool put_uint64(guint64 data, const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_output_stream_put_uint64, errthrow) - _WRAP_METHOD(bool put_int64(gint64 data, const Glib::RefPtr<Cancellable>& cancellable), g_data_output_stream_put_int64, errthrow) - /** non-cancellable version of put_int64() - */ - bool put_int64(gint64 data); - - _WRAP_METHOD(bool put_uint64(guint64 data, const Glib::RefPtr<Cancellable>& cancellable), g_data_output_stream_put_uint64, errthrow) - - /** non-cancellable version of put_uint64() - */ - bool put_uint64(guint64 data); - - _WRAP_METHOD(bool put_string(std::string str, const Glib::RefPtr<Cancellable>& cancellable), g_data_output_stream_put_string, errthrow) - - /** non-cancellable version of put_string() - */ - bool put_string(std::string str); + _WRAP_METHOD(bool put_string(std::string str, const Glib::RefPtr<Cancellable>& cancellable{?}), g_data_output_stream_put_string, errthrow) _WRAP_PROPERTY("byte-order", DataStreamByteOrder) }; diff --git a/gio/src/dbusconnection.ccg b/gio/src/dbusconnection.ccg index 0f0eca03..930097e0 100644 --- a/gio/src/dbusconnection.ccg +++ b/gio/src/dbusconnection.ccg @@ -492,20 +492,6 @@ void Connection::get(BusType bus_type, const SlotAsyncReady& slot) slot_copy); } -//static -Glib::RefPtr<Connection> Connection::get_sync(BusType bus_type) -{ - GError* gerror = 0; - - GDBusConnection* result = g_bus_get_sync(static_cast<GBusType>(bus_type), - 0, & gerror); - - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return Glib::wrap(result); -} - void Connection::close() { g_dbus_connection_close(gobj(), 0, 0, 0); @@ -531,14 +517,6 @@ void Connection::close(const SlotAsyncReady& slot) slot_copy); } -void Connection::close_sync() -{ - GError* gerror = 0; - g_dbus_connection_close_sync(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); -} - void Connection::flush() { g_dbus_connection_flush(gobj(), 0, 0, 0); @@ -564,14 +542,6 @@ void Connection::flush(const SlotAsyncReady& slot) slot_copy); } -void Connection::flush_sync() -{ - GError* gerror = 0; - g_dbus_connection_flush_sync(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); -} - bool Connection::send_message(const Glib::RefPtr<Message>& message, SendMessageFlags flags) { diff --git a/gio/src/dbusconnection.hg b/gio/src/dbusconnection.hg index 8aa17c19..d4ab3cda 100644 --- a/gio/src/dbusconnection.hg +++ b/gio/src/dbusconnection.hg @@ -223,10 +223,7 @@ public: /// @throw Glib::Error. _WRAP_METHOD(static Glib::RefPtr<Connection> get_finish(const Glib::RefPtr<AsyncResult>& res), g_bus_get_finish, errthrow) - _WRAP_METHOD(static Glib::RefPtr<Connection> get_sync(BusType bus_type, const Glib::RefPtr<Cancellable>& cancellable), g_bus_get_sync, errthrow) - - /// A Non-cancellable version of get_sync(). - static Glib::RefPtr<Connection> get_sync(BusType bus_type); + _WRAP_METHOD(static Glib::RefPtr<Connection> get_sync(BusType bus_type, const Glib::RefPtr<Cancellable>& cancellable{?}), g_bus_get_sync, errthrow) _WRAP_METHOD_DOCS_ONLY(g_dbus_connection_new) static void create(const Glib::RefPtr<IOStream>& stream, @@ -426,17 +423,7 @@ public: _WRAP_METHOD(bool close_finish(const Glib::RefPtr<AsyncResult>& result), g_dbus_connection_close_finish, errthrow) - /** Synchronously closees the connection. The calling thread is blocked - * until this is done. See close() for the asynchronous version of this - * method and more details about what it does. - * - * @newin{2,28} - * - * @throw Glib::Error. - */ - void close_sync(); - - _WRAP_METHOD(void close_sync(const Glib::RefPtr<Cancellable>& cancellable), g_dbus_connection_close_sync, errthrow) + _WRAP_METHOD(void close_sync(const Glib::RefPtr<Cancellable>& cancellable{?}), g_dbus_connection_close_sync, errthrow) /** Asynchronously flushes the connection, that is, writes all queued * outgoing message to the transport and then flushes the transport (using @@ -493,17 +480,7 @@ public: _WRAP_METHOD(bool flush_finish(const Glib::RefPtr<AsyncResult>& result), g_dbus_connection_flush_finish, errthrow) - /** Synchronously flushes the connection. The calling thread is blocked - * until this is done. See flush() for the asynchronous version of this - * method and more details about what it does. - * - * @newin{2,28} - * - * @throw Glib::Error. - */ - void flush_sync(); - - _WRAP_METHOD(void flush_sync(const Glib::RefPtr<Cancellable>& cancellable), g_dbus_connection_flush_sync, errthrow) + _WRAP_METHOD(void flush_sync(const Glib::RefPtr<Cancellable>& cancellable{?}), g_dbus_connection_flush_sync, errthrow) _WRAP_METHOD(bool get_exit_on_close() const, g_dbus_connection_get_exit_on_close) _WRAP_METHOD(void set_exit_on_close(bool exit_on_close = true), g_dbus_connection_set_exit_on_close) diff --git a/gio/src/fileenumerator.ccg b/gio/src/fileenumerator.ccg index 840efc4e..49a893af 100644 --- a/gio/src/fileenumerator.ccg +++ b/gio/src/fileenumerator.ccg @@ -91,24 +91,4 @@ FileEnumerator::close_async(int io_priority, slot_copy); } -Glib::RefPtr<FileInfo> FileEnumerator::next_file() -{ - GError* gerror = 0; - Glib::RefPtr<FileInfo> retvalue = Glib::wrap(g_file_enumerator_next_file(gobj(), 0, &(gerror))); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool FileEnumerator::close() -{ - GError* gerror = 0; - bool retvalue = g_file_enumerator_close(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - } // namespace Gio diff --git a/gio/src/fileenumerator.hg b/gio/src/fileenumerator.hg index 8d705629..439971f8 100644 --- a/gio/src/fileenumerator.hg +++ b/gio/src/fileenumerator.hg @@ -54,29 +54,14 @@ class FileEnumerator : public Glib::Object _CLASS_GOBJECT(FileEnumerator, GFileEnumerator, G_FILE_ENUMERATOR, Glib::Object, GObject) public: - _WRAP_METHOD(Glib::RefPtr<FileInfo> next_file(const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(Glib::RefPtr<FileInfo> next_file(const Glib::RefPtr<Cancellable>& cancellable{?}), g_file_enumerator_next_file, errthrow) - /** - * @return A FileInfo or an empty RefPtr on error or end of enumerator. - */ - Glib::RefPtr<FileInfo> next_file(); - - _WRAP_METHOD(bool close(const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(bool close(const Glib::RefPtr<Cancellable>& cancellable{?}), g_file_enumerator_close, errthrow) - /** Releases all resources used by this enumerator, making the - * enumerator throw a Gio::Error with CLOSED on all calls. - * - * This will be automatically called when the last reference - * is dropped, but you might want to call this method to make sure resources - * are released as early as possible. - * @return #<tt>true</tt> on success or an empty RefPtr on error. - */ - bool close(); - /** Request information for a number of files from the enumerator asynchronously. * When all I/O for the operation is finished the callback slot will be called with the requested information. diff --git a/gio/src/initable.ccg b/gio/src/initable.ccg index e58c2ed7..b3b3256c 100644 --- a/gio/src/initable.ccg +++ b/gio/src/initable.ccg @@ -24,12 +24,4 @@ namespace Gio { -void Initable::init() -{ - GError *gerror = 0; - g_initable_init(gobj(), 0, &gerror); - if (gerror) - ::Glib::Error::throw_exception(gerror); -} - } // namespace Gio diff --git a/gio/src/initable.hg b/gio/src/initable.hg index 5ab4e9ac..535c6471 100644 --- a/gio/src/initable.hg +++ b/gio/src/initable.hg @@ -56,12 +56,9 @@ class Initable : public Glib::Interface _CLASS_INTERFACE(Initable, GInitable, G_INITABLE, GInitableIface) protected: - _WRAP_METHOD(void init(const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(void init(const Glib::RefPtr<Cancellable>& cancellable{?}), g_initable_init, errthrow) - /// Non-cancellable version of init(). - void init(); - _WRAP_VFUNC(bool init(const Glib::RefPtr<Cancellable>& cancellable, GError** error), "init") }; diff --git a/gio/src/inputstream.ccg b/gio/src/inputstream.ccg index b2eb22da..d82ca182 100644 --- a/gio/src/inputstream.ccg +++ b/gio/src/inputstream.ccg @@ -25,47 +25,6 @@ namespace Gio { -gssize InputStream::read(void* buffer, gsize count) -{ - GError* gerror = 0; - gssize retvalue = g_input_stream_read(gobj(), buffer, count, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - - -bool InputStream::read_all(void* buffer, gsize count, gsize& bytes_read) -{ - GError* gerror = 0; - bool retvalue = g_input_stream_read_all(gobj(), buffer, count, &(bytes_read), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -gssize InputStream::skip(gsize count) -{ - GError* gerror = 0; - gssize retvalue = g_input_stream_skip(gobj(), count, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool InputStream::close() -{ - GError* gerror = 0; - bool retvalue = g_input_stream_close(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - void InputStream::read_async(void* buffer, gsize count, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority) { diff --git a/gio/src/inputstream.hg b/gio/src/inputstream.hg index 89fefd42..acfb9d35 100644 --- a/gio/src/inputstream.hg +++ b/gio/src/inputstream.hg @@ -43,28 +43,10 @@ class InputStream : public Glib::Object _CLASS_GOBJECT(InputStream, GInputStream, G_INPUT_STREAM, Glib::Object, GObject) public: - _WRAP_METHOD(gssize read(void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(gssize read(void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable{?}), g_input_stream_read, errthrow) - /** Tries to read @a count bytes from the stream into the buffer starting at - * @a buffer. Will block during this read. - * - * If count is zero returns zero and does nothing. A value of @a count - * larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. - * - * On success, the number of bytes read into the buffer is returned. - * It is not an error if this is not the same as the requested size, as it - * can happen e.g. near the end of a file. Zero is returned on end of file - * (or if @a count is zero), but never otherwise. - * - * On error -1 is returned. - * @param buffer A buffer to read data into (which should be at least count bytes long). - * @param count The number of bytes that will be read from the stream. - * @return Number of bytes read, or -1 on error. - */ - gssize read(void* buffer, gsize count); - //TODO: for glibmm 2.17/18, we should decide whether to provide a read() // function as below, which would presumably read until EOL, or one with // an additional size parameter, at the same time taking into account @@ -72,30 +54,10 @@ public: //TODO: gssize read(std::string& buffer, const Glib::RefPtr<Cancellable>& cancellable); //TODO: gssize read(std::string& buffer); - _WRAP_METHOD(bool read_all(void* buffer, gsize count, gsize& bytes_read, const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(bool read_all(void* buffer, gsize count, gsize& bytes_read, const Glib::RefPtr<Cancellable>& cancellable{?}), g_input_stream_read_all, errthrow) - /** Tries to read @a count bytes from the stream into the buffer starting at - * @a buffer. Will block during this read. - * - * This function is similar to read(), except it tries to - * read as many bytes as requested, only stopping on an error or end of stream. - * - * On a successful read of @a count bytes, or if we reached the end of the - * stream, <tt>true</tt> is returned, and @a bytes_read is set to the number of bytes - * read into @a buffer . - * - * If there is an error during the operation <tt>false</tt> is returned and a Gio::Error - * is thrown to indicate the error status, @a bytes_read is updated to contain - * the number of bytes read into @a buffer before the error occured. - * @param buffer A buffer to read data into (which should be at least count bytes long). - * @param count The number of bytes that will be read from the stream. - * @param bytes_read Location to store the number of bytes that was read from the stream. - * @return <tt>true</tt> on success, <tt>false</tt> if there was an error. - */ - bool read_all(void* buffer, gsize count, gsize& bytes_read); - //TODO: bool read_all(std::string& buffer, gsize count, gsize& bytes_read, const Glib::RefPtr<Cancellable>& cancellable); //TODO: bool read_all(std::string& buffer, gsize count, gsize& bytes_read) @@ -118,49 +80,14 @@ public: - _WRAP_METHOD(gssize skip(gsize count, const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(gssize skip(gsize count, const Glib::RefPtr<Cancellable>& cancellable{?}), g_input_stream_skip, errthrow) - /** Tries to skip @a count bytes from the stream. Will block during the operation. - * - * This is identical to read(), from a behaviour standpoint, - * but the bytes that are skipped are not returned to the user. Some - * streams have an implementation that is more efficient than reading the data. - * - * This function is optional for inherited classes, as the default implementation - * emulates it using read. - * - * @param count The number of bytes that will be skipped from the stream. - * @return Number of bytes skipped, or -1 on error. - */ - gssize skip(gsize count); - - _WRAP_METHOD(bool close(const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(bool close(const Glib::RefPtr<Cancellable>& cancellable{?}), g_input_stream_close, errthrow) - /** Closes the stream, releasing resources related to it. - * - * Once the stream is closed, all other operations will throw a Gio::Error with CLOSED. - * Closing a stream multiple times will not return an error. - * - * Streams will be automatically closed when the last reference - * is dropped, but you might want to call this make sure resources - * are released as early as possible. - * - * Some streams might keep the backing store of the stream (e.g. a file descriptor) - * open after the stream is closed. See the documentation for the individual - * stream for details. - * - * On failure the first error that happened will be reported, but the close - * operation will finish as much as possible. A stream that failed to - * close will still throw a Gio::Error with CLOSED for all operations. Still, it - * is important to check and report the error to the user. - * - * @return <tt>true</tt> on success, <tt>false</tt> on failure. - */ - bool close(); /** Request an asynchronous read of @a count bytes from the stream into the buffer * starting at @a buffer. When the operation is finished @a slot will be called. diff --git a/gio/src/iostream.ccg b/gio/src/iostream.ccg index 91696a83..6dc2b5af 100644 --- a/gio/src/iostream.ccg +++ b/gio/src/iostream.ccg @@ -25,19 +25,6 @@ namespace Gio { - - -bool IOStream::close() -{ - GError* gerror = 0; - bool retvalue = g_io_stream_close(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - - void IOStream::close_async(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority) { diff --git a/gio/src/iostream.hg b/gio/src/iostream.hg index af5f60f9..083ea900 100644 --- a/gio/src/iostream.hg +++ b/gio/src/iostream.hg @@ -43,9 +43,7 @@ class IOStream : public Glib::Object public: _WRAP_METHOD(Glib::RefPtr<InputStream> get_input_stream(), g_io_stream_get_input_stream, refreturn) _WRAP_METHOD(Glib::RefPtr<OutputStream> get_output_stream(), g_io_stream_get_output_stream, refreturn) - _WRAP_METHOD(bool close(const Glib::RefPtr<Cancellable>& cancellable), g_io_stream_close, errthrow) - -bool close(); + _WRAP_METHOD(bool close(const Glib::RefPtr<Cancellable>& cancellable{?}), g_io_stream_close, errthrow) void close_async(const SlotAsyncReady&slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority=Glib::PRIORITY_DEFAULT); void close_async(const SlotAsyncReady& slot, int io_priority = Glib::PRIORITY_DEFAULT); diff --git a/gio/src/outputstream.ccg b/gio/src/outputstream.ccg index e0c9e381..d991bf7f 100644 --- a/gio/src/outputstream.ccg +++ b/gio/src/outputstream.ccg @@ -152,17 +152,6 @@ OutputStream::close_async(const SlotAsyncReady& slot, int io_priority) slot_copy); } - -gssize OutputStream::write(const void* buffer, gsize count) -{ - GError* gerror = 0; - gssize retvalue = g_output_stream_write(gobj(), buffer, count, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - gssize OutputStream::write(const std::string& buffer, const Glib::RefPtr<Cancellable>& cancellable) { GError* gerror = 0; @@ -183,16 +172,6 @@ gssize OutputStream::write(const std::string& buffer) return retvalue; } -bool OutputStream::write_all(const void* buffer, gsize count, gsize& bytes_written) -{ - GError* gerror = 0; - bool retvalue = g_output_stream_write_all(gobj(), buffer, count, &(bytes_written), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - bool OutputStream::write_all(const std::string& buffer, gsize& bytes_written, const Glib::RefPtr<Cancellable>& cancellable) { GError* gerror = 0; @@ -266,24 +245,4 @@ gssize OutputStream::splice(const Glib::RefPtr<InputStream>& source, OutputStrea return retvalue; } -bool OutputStream::flush() -{ - GError* gerror = 0; - bool retvalue = g_output_stream_flush(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -bool OutputStream::close() -{ - GError* gerror = 0; - bool retvalue = g_output_stream_close(gobj(), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - } // namespace Gio diff --git a/gio/src/outputstream.hg b/gio/src/outputstream.hg index ec3c9403..bcda7c9c 100644 --- a/gio/src/outputstream.hg +++ b/gio/src/outputstream.hg @@ -42,7 +42,7 @@ class OutputStream : public Glib::Object public: - _WRAP_METHOD(gssize write(const void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(gssize write(const void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable{?}), g_output_stream_write, errthrow) @@ -60,25 +60,6 @@ public: * * On error -1 is returned. * @param buffer The buffer containing the data to write. - * @param count The number of bytes to write. - * @return Number of bytes written, or -1 on error. - */ - gssize write(const void* buffer, gsize count); - - /** Tries to write @a count bytes from @a buffer into the stream. Will block - * during the operation. - * - * If count is zero returns zero and does nothing. A value of @a count - * larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. - * - * On success, the number of bytes written to the stream is returned. - * It is not an error if this is not the same as the requested size, as it - * can happen e.g. on a partial i/o error, or if the there is not enough - * storage in the stream. All writes either block until at least one byte - * is written, so zero is never returned (unless @a count is zero). - * - * On error -1 is returned. - * @param buffer The buffer containing the data to write. * @param cancellable Cancellable object. * @return Number of bytes written, or -1 on error. */ @@ -102,7 +83,7 @@ public: gssize write(const std::string& buffer); - _WRAP_METHOD(bool write_all(const void* buffer, gsize count, gsize& bytes_written, const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(bool write_all(const void* buffer, gsize count, gsize& bytes_written, const Glib::RefPtr<Cancellable>& cancellable{?}), g_output_stream_write_all, errthrow) @@ -119,26 +100,6 @@ public: * is set to indicate the error status, @a bytes_written is updated to contain * the number of bytes written into the stream before the error occured. * @param buffer The buffer containing the data to write. - * @param count The number of bytes to write. - * @param bytes_written Location to store the number of bytes that was - * written to the stream. - * @return <tt>true</tt> on success, <tt>false</tt> if there was an error. - */ - bool write_all(const void* buffer, gsize count, gsize& bytes_written); - - /** Tries to write @a count bytes from @a buffer into the stream. Will block - * during the operation. - * - * This function is similar to write(), except it tries to - * write as many bytes as requested, only stopping on an error. - * - * On a successful write of @a count bytes, <tt>true</tt> is returned, and @a bytes_written - * is set to @a count . - * - * If there is an error during the operation <tt>false</tt> is returned and @a error - * is set to indicate the error status, @a bytes_written is updated to contain - * the number of bytes written into the stream before the error occured. - * @param buffer The buffer containing the data to write. * @param bytes_written Location to store the number of bytes that was * written to the stream. * @param cancellable Cancellable object. @@ -164,8 +125,8 @@ public: * @return <tt>true</tt> on success, <tt>false</tt> if there was an error. */ bool write_all(const std::string& buffer, gsize& bytes_written); - - _WRAP_METHOD(gssize write_bytes(const Glib::RefPtr<const Glib::Bytes>& bytes, const Glib::RefPtr<Cancellable>& cancellable), g_output_stream_write_bytes, errthrow) + + _WRAP_METHOD(gssize write_bytes(const Glib::RefPtr<const Glib::Bytes>& bytes, const Glib::RefPtr<Cancellable>& cancellable{?}), g_output_stream_write_bytes, errthrow) //TODO: Documentation. /** @@ -201,61 +162,14 @@ public: gssize splice(const Glib::RefPtr<InputStream>& source, OutputStreamSpliceFlags flags = OUTPUT_STREAM_SPLICE_NONE); _IGNORE(g_output_stream_splice) - _WRAP_METHOD(bool flush(const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(bool flush(const Glib::RefPtr<Cancellable>& cancellable{?}), g_output_stream_flush, errthrow) - /** Flushed any outstanding buffers in the stream. Will block during - * the operation. Closing the stream will implicitly cause a flush. - * - * This function is optional for inherited classes. - * - * The operation can be cancelled by - * triggering the cancellable object from another thread. If the operation - * was cancelled, a Gio::Error with CANCELLED will be thrown. - * @param cancellable Optional cancellable object. - * @return <tt>true</tt> on success, <tt>false</tt> on error. - */ - bool flush(); - - _WRAP_METHOD(bool close(const Glib::RefPtr<Cancellable>& cancellable), + _WRAP_METHOD(bool close(const Glib::RefPtr<Cancellable>& cancellable{?}), g_output_stream_close, errthrow) - /** Closes the stream, releasing resources related to it. - * - * Once the stream is closed, all other operations will throw a Gio::Error with CLOSED. - * Closing a stream multiple times will not return an error. - * - * Closing a stream will automatically flush any outstanding buffers in the - * stream. - * - * Streams will be automatically closed when the last reference - * is dropped, but you might want to call make sure resources - * are released as early as possible. - * - * Some streams might keep the backing store of the stream (e.g. a file descriptor) - * open after the stream is closed. See the documentation for the individual - * stream for details. - * - * On failure the first error that happened will be reported, but the close - * operation will finish as much as possible. A stream that failed to - * close will still throw a Gio::Error with CLOSED for all operations. Still, it - * is important to check and report the error to the user, otherwise - * there might be a loss of data as all data might not be written. - * - * The operation can be cancelled by - * triggering the cancellable object from another thread. If the operation - * was cancelled, a Gio::Error with CANCELLED will be thrown. - * Cancelling a close will still leave the stream closed, but there some streams - * can use a faster close that doesn't block to e.g. check errors. On - * cancellation (as with any error) there is no guarantee that all written - * data will reach the target. - * @param cancellable Optional cancellable object. - * @return <tt>true</tt> on success, <tt>false</tt> on failure. - */ - bool close(); - /** Request an asynchronous write of @a count bytes from @a buffer into * the stream. When the operation is finished @a slot will be called. * You can then call write_finish() to get the result of the diff --git a/gio/src/resolver.ccg b/gio/src/resolver.ccg index 25b7c352..f3065d6e 100644 --- a/gio/src/resolver.ccg +++ b/gio/src/resolver.ccg @@ -34,39 +34,6 @@ void Resolver::set_default(const Glib::RefPtr<Resolver>& resolver) g_resolver_set_default(Glib::unwrap(resolver)); } -Glib::ListHandle< Glib::RefPtr<InetAddress> > Resolver::lookup_by_name(const Glib::ustring& hostname) -{ - GError* gerror = 0; - Glib::ListHandle< Glib::RefPtr<InetAddress> > retvalue = Glib::ListHandle< Glib::RefPtr<InetAddress> >(g_resolver_lookup_by_name(gobj(), hostname.c_str(), 0, &(gerror)), Glib::OWNERSHIP_DEEP); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; - -} - -Glib::ustring Resolver::lookup_by_address(const Glib::RefPtr<InetAddress>& address) -{ - GError* gerror = 0; - Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_resolver_lookup_by_address(gobj(), const_cast<GInetAddress*>(Glib::unwrap(address)), 0, &(gerror))); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; - -} - -ListHandle_SrvTarget Resolver::lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain) -{ - GError* gerror = 0; - ListHandle_SrvTarget retvalue = ListHandle_SrvTarget(g_resolver_lookup_service(gobj(), service.c_str(), protocol.c_str(), domain.c_str(), 0, &(gerror)), Glib::OWNERSHIP_DEEP); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; - -} - void Resolver::lookup_by_name_async(const Glib::ustring& hostname, const SlotAsyncReady& slot, diff --git a/gio/src/resolver.hg b/gio/src/resolver.hg index 61cc6428..66ff18f4 100644 --- a/gio/src/resolver.hg +++ b/gio/src/resolver.hg @@ -59,20 +59,7 @@ public: _IGNORE(g_resolver_free_addresses) #m4 _CONVERSION(`GList*',`Glib::ListHandle< Glib::RefPtr<InetAddress> >',`$2($3, Glib::OWNERSHIP_DEEP)') - _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<InetAddress> > lookup_by_name(const Glib::ustring& hostname, const Glib::RefPtr<Cancellable>& cancellable), g_resolver_lookup_by_name, errthrow) - - /** Synchronously resolves hostname to determine its associated IP address(es). - * @a hostname may be an ASCII-only or UTF-8 hostname, or the textual form of an IP address (in which case this just becomes a wrapper around InetAddress:create_from_string()). - * - * On success, this will return a list of InetAddress, sorted in order of preference. (That is, you should attempt to connect to the first address first, then the second if the first fails, etc.) - * - * If the DNS resolution fails, a ResolverError exception will be thrown. - * - * If you are planning to connect to a socket on the resolved IP address, it may be easier to create a NetworkAddress and use its SocketConnectable base class. - * - * @param hostname hostname The hostname to look up. - */ - Glib::ListHandle< Glib::RefPtr<InetAddress> > lookup_by_name(const Glib::ustring& hostname); + _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<InetAddress> > lookup_by_name(const Glib::ustring& hostname, const Glib::RefPtr<Cancellable>& cancellable{?}), g_resolver_lookup_by_name, errthrow) /** Begins asynchronously resolving hostname to determine its associated IP address(es), and eventually calls @a slot, which must call * lookup_by_name_finish() to get the result. See lookup_by_name() for more details. @@ -94,16 +81,7 @@ public: _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<InetAddress> > lookup_by_name_finish(const Glib::RefPtr<AsyncResult>& result), g_resolver_lookup_by_name_finish, errthrow) - _WRAP_METHOD(Glib::ustring lookup_by_address(const Glib::RefPtr<InetAddress>& address, const Glib::RefPtr<Cancellable>& cancellable), g_resolver_lookup_by_address, errthrow) - - /** Synchronously reverse-resolves an address to determine its associated hostname. - * - * If the DNS resolution fails then a ResolverError exception will be thrown. - * - * @param address The address to reverse-resolve. - * @result A hostname (either ASCII-only, or in ASCII-encoded form), or an empty string on error. - */ - Glib::ustring lookup_by_address(const Glib::RefPtr<InetAddress>& address); + _WRAP_METHOD(Glib::ustring lookup_by_address(const Glib::RefPtr<InetAddress>& address, const Glib::RefPtr<Cancellable>& cancellable{?}), g_resolver_lookup_by_address, errthrow) /** Begins asynchronously reverse-resolving an address to determine its associated hostname, and eventually calls callback, which must call * lookup_by_address_finish() to get the final result. @@ -128,24 +106,8 @@ public: _WRAP_METHOD(Glib::ustring lookup_by_address_finish(const Glib::RefPtr<AsyncResult>& result), g_resolver_lookup_by_address_finish, errthrow) #m4 _CONVERSION(`GList*',`ListHandle_SrvTarget',`$2($3, Glib::OWNERSHIP_DEEP)') - _WRAP_METHOD(ListHandle_SrvTarget lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, const Glib::RefPtr<Cancellable>& cancellable), g_resolver_lookup_service, errthrow) + _WRAP_METHOD(ListHandle_SrvTarget lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, const Glib::RefPtr<Cancellable>& cancellable{?}), g_resolver_lookup_service, errthrow) - /** Synchronously performs a DNS SRV lookup for the given service and protocol in the given domain and returns an list of SrvTargets. - * @a domain may be an ASCII-only or UTF-8 hostname. Note also that the service and protocol arguments do not include the leading underscore that appears in the actual DNS entry. - * - * On success, this will return a list of SrvTargets, sorted in order of preference. - * (That is, you should attempt to connect to the first target first, then the second if the first fails, etc.) - * - * If the DNS resolution fails a ResolverError exception will be thrown. - * - * If you are planning to connect to the service, it is usually easier to create a NetworkService and use its SocketConnectable base class interface. \ - * - * @param service The service type to look up (eg, "ldap"). - * @param protocol The networking protocol to use for service (eg, "tcp") - * @param domain The DNS domain to look up the service in. - */ - ListHandle_SrvTarget lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain); - /** Begins asynchronously performing a DNS SRV lookup for the given service and protocol in the given domain, and eventually calls callback, * which must call lookup_service_finish() to get the final result. See glookup_service() for more details. * diff --git a/gio/src/seekable.ccg b/gio/src/seekable.ccg index 52534f61..193bbeb8 100644 --- a/gio/src/seekable.ccg +++ b/gio/src/seekable.ccg @@ -22,28 +22,5 @@ namespace Gio { - -bool Seekable::seek(goffset offset, Glib::SeekType type) -{ - GError* gerror = 0; - bool retvalue = g_seekable_seek(gobj(), offset, ((GSeekType)(type)), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - - -bool Seekable::truncate(goffset offset) -{ - GError* gerror = 0; - bool retvalue = g_seekable_truncate(gobj(), offset, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - - } // namespace Gio diff --git a/gio/src/seekable.hg b/gio/src/seekable.hg index 43277c49..941fd928 100644 --- a/gio/src/seekable.hg +++ b/gio/src/seekable.hg @@ -52,30 +52,15 @@ public: _WRAP_METHOD(goffset tell() const, g_seekable_tell) _WRAP_METHOD(bool can_seek() const, g_seekable_can_seek) - _WRAP_METHOD(bool seek(goffset offset, Glib::SeekType type, const Glib::RefPtr<Cancellable>& cancellable), g_seekable_seek, errthrow) + _WRAP_METHOD(bool seek(goffset offset, Glib::SeekType type, const Glib::RefPtr<Cancellable>& cancellable{?}), g_seekable_seek, errthrow) //TODO: Document the exception in the C API: https://bugzilla.gnome.org/show_bug.cgi?id=509990#c1 - /** Seeks in the stream by the given @a offset, modified by @a type . - * - * @param offset A #goffset. - * @param type A Glib::SeekType. - * @return <tt>true</tt> if successful. If an error - * has occurred, this function will return <tt>false</tt>. - */ - bool seek(goffset offset, Glib::SeekType type); _WRAP_METHOD(bool can_truncate() const, g_seekable_can_truncate) - _WRAP_METHOD(bool truncate(goffset offset, const Glib::RefPtr<Cancellable>& cancellable), g_seekable_truncate, errthrow) + _WRAP_METHOD(bool truncate(goffset offset, const Glib::RefPtr<Cancellable>& cancellable{?}), g_seekable_truncate, errthrow) //TODO: Document the exception in the C API: https://bugzilla.gnome.org/show_bug.cgi?id=509990#c1 - /** Truncates a stream with a given #offset. - * - * @param offset A #goffset. - * @return <tt>true</tt> if successful. If an error - * has occured, this function will return <tt>false</tt>. - */ - bool truncate(goffset offset); //_WRAP_VFUNC(goffset tell() const, tell) //_WRAP_VFUNC(goffset can_seek() const, can_seek) diff --git a/gio/src/socket.ccg b/gio/src/socket.ccg index 6b2efcdd..db7b095f 100644 --- a/gio/src/socket.ccg +++ b/gio/src/socket.ccg @@ -53,63 +53,6 @@ Glib::RefPtr<Socket> Socket::create_from_fd(int fd, const Glib::RefPtr<Cancellab return Glib::RefPtr<Socket>(new Socket(fd, cancellable)); } - -void Socket::connect(const Glib::RefPtr<SocketAddress>& address) -{ - GError* gerror = 0; - g_socket_connect(gobj(), const_cast<GSocketAddress*>(Glib::unwrap(address)), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); -} - -Glib::RefPtr<Socket> Socket::accept() -{ - GError* gerror = 0; - Glib::RefPtr<Socket> retvalue = Glib::wrap(g_socket_accept(gobj(), 0, &(gerror))); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -gssize Socket::receive(char* buffer, gsize size) -{ - GError* gerror = 0; - gssize retvalue = g_socket_receive(gobj(), buffer, size, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -gssize Socket::send(const gchar* buffer, gsize size) -{ - GError* gerror = 0; - gssize retvalue = g_socket_send(gobj(), buffer, size, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -gssize Socket::send_to(const Glib::RefPtr<SocketAddress>& address, const char* buffer, gsize size) -{ - GError* gerror = 0; - gssize retvalue = g_socket_send_to(gobj(), const_cast<GSocketAddress*>(Glib::unwrap(address)), buffer, size, 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -void Socket::condition_wait(Glib::IOCondition condition) -{ - GError* gerror = 0; - g_socket_condition_wait(gobj(), ((GIOCondition)(condition)), 0, &(gerror)); - if(gerror) - ::Glib::Error::throw_exception(gerror); -} - gssize Socket::receive_from(Glib::RefPtr<SocketAddress>& address, char* buffer, gsize size, const Glib::RefPtr<Cancellable>& cancellable) { GError* gerror = 0; diff --git a/gio/src/socket.hg b/gio/src/socket.hg index e29739b9..17eb6f9f 100644 --- a/gio/src/socket.hg +++ b/gio/src/socket.hg @@ -120,19 +120,16 @@ public: //TODO: Write custom documetation, mentioning, for instance, the exception, instead of a bool return. _WRAP_METHOD(void bind(const Glib::RefPtr<SocketAddress>& address, bool allow_reuse), g_socket_bind, errthrow) _WRAP_METHOD(void listen(), g_socket_listen, errthrow) - _WRAP_METHOD(Glib::RefPtr<Socket> accept(const Glib::RefPtr<Cancellable>& cancellable), g_socket_accept, errthrow) - Glib::RefPtr<Socket> accept(); + _WRAP_METHOD(Glib::RefPtr<Socket> accept(const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_accept, errthrow) //TODO: Write custom documetation, mentioning, for instance, the exception, instead of a bool return. - _WRAP_METHOD(void connect(const Glib::RefPtr<SocketAddress>& address, const Glib::RefPtr<Cancellable>& cancellable), g_socket_connect, errthrow) - void connect(const Glib::RefPtr<SocketAddress>& address); + _WRAP_METHOD(void connect(const Glib::RefPtr<SocketAddress>& address, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_connect, errthrow) // FIXME: it doesn't really seem like this is a proper use of exceptions... _WRAP_METHOD(void check_connect_result(), g_socket_check_connect_result, errthrow) // TODO: std::string overload? - _WRAP_METHOD(gssize receive(char* buffer, gsize size, const Glib::RefPtr<Cancellable>& cancellable), g_socket_receive, errthrow) - gssize receive(char* buffer, gsize size); + _WRAP_METHOD(gssize receive(char* buffer, gsize size, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_receive, errthrow) _IGNORE(g_socket_receive_from) gssize receive_from(Glib::RefPtr<SocketAddress>& address, char* buffer, gsize size, const Glib::RefPtr<Cancellable>& cancellable); @@ -140,12 +137,10 @@ public: // TODO: wrap g_socket_receive_message -- figure out this GInputVector thing // TODO: std::string overload? - _WRAP_METHOD(gssize send(const gchar* buffer, gsize size, const Glib::RefPtr<Cancellable>& cancellable), g_socket_send, errthrow) - gssize send(const gchar* buffer, gsize size); + _WRAP_METHOD(gssize send(const gchar* buffer, gsize size, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_send, errthrow) // TODO: std::string overload? - _WRAP_METHOD(gssize send_to(const Glib::RefPtr<SocketAddress>& address, const char* buffer, gsize size, const Glib::RefPtr<Cancellable>& cancellable), g_socket_send_to, errthrow) - gssize send_to(const Glib::RefPtr<SocketAddress>& address, const char* buffer, gsize size); + _WRAP_METHOD(gssize send_to(const Glib::RefPtr<SocketAddress>& address, const char* buffer, gsize size, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_send_to, errthrow) // TODO: wrap g_socket_send_message -- figure out this GOutputVector thing _WRAP_METHOD(void close(), g_socket_close, errthrow) @@ -160,16 +155,13 @@ public: // This won't work because Glib::Source is abstract, and Glib::IOSource has no // constructor that takes a GSource* //#m4 _CONVERSION(`GSource*',`Glib::RefPtr<Glib::Source>',`Glib::RefPtr<Glib::Source>(new ::Glib::Source($3))') - //_WRAP_METHOD(Glib::RefPtr<Glib::Source> create_source(Glib::IOCondition condition, const Glib::RefPtr<Cancellable>& cancellable), g_socket_create_source) + //_WRAP_METHOD(Glib::RefPtr<Glib::Source> create_source(Glib::IOCondition condition, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_create_source) _WRAP_METHOD(gssize get_available_bytes() const, g_socket_get_available_bytes) _WRAP_METHOD(Glib::IOCondition condition_check(Glib::IOCondition condition), g_socket_condition_check) - _WRAP_METHOD(void condition_wait(Glib::IOCondition condition, const Glib::RefPtr<Cancellable>& cancellable), g_socket_condition_wait, errthrow) - - //TODO: Documentation. - void condition_wait(Glib::IOCondition condition); + _WRAP_METHOD(void condition_wait(Glib::IOCondition condition, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_condition_wait, errthrow) _WRAP_METHOD(void condition_timed_wait(Glib::IOCondition condition, gint64 timeout, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_condition_timed_wait, errthrow) diff --git a/gio/src/socketaddressenumerator.ccg b/gio/src/socketaddressenumerator.ccg index 301c3fd7..b783ec8a 100644 --- a/gio/src/socketaddressenumerator.ccg +++ b/gio/src/socketaddressenumerator.ccg @@ -39,15 +39,4 @@ namespace Gio { slot_copy); } - Glib::RefPtr<SocketAddress> - SocketAddressEnumerator::next() - { - GError* gerror = 0; - Glib::RefPtr<SocketAddress> retvalue = Glib::wrap(g_socket_address_enumerator_next(gobj(), 0, &(gerror))); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; - - } } // namespace Gio diff --git a/gio/src/socketaddressenumerator.hg b/gio/src/socketaddressenumerator.hg index 6056c7cb..cf483d94 100644 --- a/gio/src/socketaddressenumerator.hg +++ b/gio/src/socketaddressenumerator.hg @@ -39,21 +39,7 @@ class SocketAddressEnumerator : public Glib::Object _CLASS_GOBJECT(SocketAddressEnumerator, GSocketAddressEnumerator, G_SOCKET_ADDRESS_ENUMERATOR, Glib::Object, GObject) public: - _WRAP_METHOD(Glib::RefPtr<SocketAddress> next(const Glib::RefPtr<Cancellable>& cancellable), g_socket_address_enumerator_next, errthrow) - - /** Retrieves the next SocketAddress from the enumerator. - * Note that this may block for some amount of time. (Eg, a NetworkAddress may need to do a DNS lookup before it can return an address.) - * Use next_async() if you need to avoid blocking. - * - * If this enumerator is expected to yield addresses, but for some reason is unable to (eg, because of a DNS error), - * then the first call to next() will throw an exception. However, if the first call to next() succeeds, then any further internal errors - * will be ignored. - * - * When there are no further addresses, an exception will be thrown. - * - * @result A SocketAddress - */ - Glib::RefPtr<SocketAddress> next(); + _WRAP_METHOD(Glib::RefPtr<SocketAddress> next(const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_address_enumerator_next, errthrow) /** Asynchronously retrieves the next SocketAddress from the enumerator and then calls @a slot, * which must call next_finish() to get the result. diff --git a/gio/src/socketclient.ccg b/gio/src/socketclient.ccg index b4456b5a..ec970358 100644 --- a/gio/src/socketclient.ccg +++ b/gio/src/socketclient.ccg @@ -131,46 +131,6 @@ SocketClient::connect_to_service_async(const Glib::ustring& domain, slot_copy); } -Glib::RefPtr<SocketConnection> SocketClient::connect(const Glib::RefPtr<SocketConnectable>& connectable) -{ - GError* gerror = 0; - Glib::RefPtr<SocketConnection> retvalue = Glib::wrap(g_socket_client_connect(gobj(), const_cast<GSocketConnectable*>(Glib::unwrap(connectable)), 0, &(gerror))); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -Glib::RefPtr<SocketConnection> SocketClient::connect_to_host(const Glib::ustring& host_and_port, guint16 default_port) -{ - GError* gerror = 0; - Glib::RefPtr<SocketConnection> retvalue = Glib::wrap(g_socket_client_connect_to_host(gobj(), host_and_port.c_str(), default_port, 0, &(gerror))); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -Glib::RefPtr<SocketConnection> SocketClient::connect_to_service(const Glib::ustring& domain, const Glib::ustring& service) -{ - GError* gerror = 0; - Glib::RefPtr<SocketConnection> retvalue = Glib::wrap(g_socket_client_connect_to_service(gobj(), domain.c_str(), service.c_str(), 0, &(gerror))); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - -Glib::RefPtr<SocketConnection> SocketClient::connect_to_uri(const Glib::ustring& uri, guint16 default_port) -{ - GError* gerror = 0; - Glib::RefPtr<SocketConnection> retvalue = Glib::wrap(g_socket_client_connect_to_uri(gobj(), uri.c_str(), default_port, 0, &(gerror))); - if(gerror) - ::Glib::Error::throw_exception(gerror); - - return retvalue; -} - void SocketClient::connect_to_uri_async(const Glib::ustring& uri, guint16 default_port, const Glib::RefPtr<Cancellable>& cancellable, diff --git a/gio/src/socketclient.hg b/gio/src/socketclient.hg index bb594005..b46121f8 100644 --- a/gio/src/socketclient.hg +++ b/gio/src/socketclient.hg @@ -68,51 +68,13 @@ public: _WRAP_METHOD(Glib::RefPtr<const SocketAddress> get_local_address() const, g_socket_client_get_local_address, constversion) _WRAP_METHOD(void set_local_address(const Glib::RefPtr<SocketAddress>& address), g_socket_client_set_local_address) - _WRAP_METHOD(Glib::RefPtr<SocketConnection> connect(const Glib::RefPtr<SocketConnectable>& connectable, const Glib::RefPtr<Cancellable>& cancellable), g_socket_client_connect, errthrow) -Glib::RefPtr<SocketConnection> connect(const Glib::RefPtr<SocketConnectable>& connectable); + _WRAP_METHOD(Glib::RefPtr<SocketConnection> connect(const Glib::RefPtr<SocketConnectable>& connectable, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_client_connect, errthrow) - _WRAP_METHOD(Glib::RefPtr<SocketConnection> connect_to_host(const Glib::ustring& host_and_port, guint16 default_port, const Glib::RefPtr<Cancellable>& cancellable), g_socket_client_connect_to_host, errthrow) + _WRAP_METHOD(Glib::RefPtr<SocketConnection> connect_to_host(const Glib::ustring& host_and_port, guint16 default_port, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_client_connect_to_host, errthrow) - /** This is a helper function for connect(). - * This attempts to create a TCP connection to the named host. - * - * @a host_and_port may be in any of a number of recognised formats; an IPv6 address, an IPv4 address, or a domain name (in which case a DNS lookup is performed). Quoting with [] is supported for all address types. A port override may be specified in the usual way with a colon. Ports may be given as decimal numbers or symbolic names (in which case an /etc/services lookup is performed). - * - * If no port override is given in @a host_and_port then default_port will be used as the port number to connect to. - * - * In general, @a host_and_port is expected to be provided by the user (allowing them to give the hostname, and a port overide if necessary) and default_port is expected to be provided by the application. - * - * In the case that an IP address is given, a single connection attempt is made. In the case that a name is given, multiple connection attempts may be made, in turn and according to the number of address records in DNS, until a connection succeeds. - * - * Upon a successful connection, a new SocketConnection is constructed and returned. - * - * In the event of any failure (DNS error, service not found, no hosts connectable) an exception is thrown. - * - * @param host_and_port The name and optionally port of the host to connect to. - * @param default_port The default port to connect to. - */ - Glib::RefPtr<SocketConnection> connect_to_host(const Glib::ustring& host_and_port, guint16 default_port); - - _WRAP_METHOD(Glib::RefPtr<SocketConnection> connect_to_service(const Glib::ustring& domain, const Glib::ustring& service, const Glib::RefPtr<Cancellable>& cancellable), g_socket_client_connect_to_service, errthrow) -Glib::RefPtr<SocketConnection> connect_to_service(const Glib::ustring& domain, const Glib::ustring& service); + _WRAP_METHOD(Glib::RefPtr<SocketConnection> connect_to_service(const Glib::ustring& domain, const Glib::ustring& service, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_client_connect_to_service, errthrow) - _WRAP_METHOD(Glib::RefPtr<SocketConnection> connect_to_uri(const Glib::ustring& uri, guint16 default_port, const Glib::RefPtr<Cancellable>& cancellable), g_socket_client_connect_to_uri, errthrow) - - /** This is a helper function for connect(). - * This attempts to create a TCP connection with a network URI. - * - * @a uri may be any valid URI containing an "authority" (hostname/port) component. If a port is not specified in the URI, default_port will be used. TLS will be negotiated if "tls" is true. (GSocketClient does not know to automatically assume TLS for certain URI schemes.) - * - * Using this rather than connect() or connect_to_host() allows SocketClient to determine when to use application-specific proxy protocols. - * - * Upon a successful connection, a new SocketConnection is constructed and returned. - * - * In the event of any failure (DNS error, service not found, no hosts connectable) an exception is thrown. - * - * @param uri A network URI - * @param default_port The default port to connect to. - */ - Glib::RefPtr<SocketConnection> connect_to_uri(const Glib::ustring& uri, guint16 default_port); + _WRAP_METHOD(Glib::RefPtr<SocketConnection> connect_to_uri(const Glib::ustring& uri, guint16 default_port, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_client_connect_to_uri, errthrow) _WRAP_METHOD_DOCS_ONLY(g_socket_client_connect_async) void connect_async(const Glib::RefPtr<SocketConnectable>& connectable, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot); diff --git a/gio/src/unixconnection.hg b/gio/src/unixconnection.hg index ea89434b..1f1d0367 100644 --- a/gio/src/unixconnection.hg +++ b/gio/src/unixconnection.hg @@ -44,12 +44,12 @@ class UnixConnection : public Gio::SocketConnection _GTKMMPROC_WIN32_NO_WRAP public: - _WRAP_METHOD(bool send_fd(int fd, const Glib::RefPtr<Cancellable>& cancellable), g_unix_connection_send_fd, errthrow) - _WRAP_METHOD(int receive_fd(const Glib::RefPtr<Cancellable>& cancellable), g_unix_connection_receive_fd, errthrow) + _WRAP_METHOD(bool send_fd(int fd, const Glib::RefPtr<Cancellable>& cancellable{?}), g_unix_connection_send_fd, errthrow) + _WRAP_METHOD(int receive_fd(const Glib::RefPtr<Cancellable>& cancellable{?}), g_unix_connection_receive_fd, errthrow) - _WRAP_METHOD(Glib::RefPtr<Credentials> receive_credentials(const Glib::RefPtr<Cancellable>& cancellable), g_unix_connection_receive_credentials, errthrow) - _WRAP_METHOD(Glib::RefPtr<const Credentials> receive_credentials(const Glib::RefPtr<Cancellable>& cancellable) const, g_unix_connection_receive_credentials, errthrow, constversion) - _WRAP_METHOD(bool send_credentials(const Glib::RefPtr<Cancellable>& cancellable), g_unix_connection_send_credentials, errthrow) + _WRAP_METHOD(Glib::RefPtr<Credentials> receive_credentials(const Glib::RefPtr<Cancellable>& cancellable{?}), g_unix_connection_receive_credentials, errthrow) + _WRAP_METHOD(Glib::RefPtr<const Credentials> receive_credentials(const Glib::RefPtr<Cancellable>& cancellable{?}) const, g_unix_connection_receive_credentials, errthrow, constversion) + _WRAP_METHOD(bool send_credentials(const Glib::RefPtr<Cancellable>& cancellable{?}), g_unix_connection_send_credentials, errthrow) }; } // namespace Gio |