[glibmm] Glib::IOChannel, StreamIOChannel: Remove deprecated parts



commit bc8d88079391a8f4f336ea16585b8ed1bcd46358
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Sun Mar 19 19:34:37 2017 +0100

    Glib::IOChannel, StreamIOChannel: Remove deprecated parts
    
    * glib/glibmm.h: Remove streamiochannel.h.
    * glib/glibmm/filelist.am: Remove streamiochannel.[cc|h].
    * glib/glibmm/streamiochannel.[cc|h]: Removed files.
    * glib/src/iochannel.[ccg|hg]: Remove the default constructor and the
    deprecated virtual functions. In .ccg, remove the local GlibmmIOChannel
    class. It's useless without the virtual functions, as is the default ctor.

 glib/glibmm.h                  |    1 -
 glib/glibmm/filelist.am        |    2 -
 glib/glibmm/streamiochannel.cc |  210 ------------------------------
 glib/glibmm/streamiochannel.h  |   63 ---------
 glib/src/iochannel.ccg         |  281 +---------------------------------------
 glib/src/iochannel.hg          |   49 -------
 6 files changed, 3 insertions(+), 603 deletions(-)
---
diff --git a/glib/glibmm.h b/glib/glibmm.h
index f3e01c1..f6226d6 100644
--- a/glib/glibmm.h
+++ b/glib/glibmm.h
@@ -109,7 +109,6 @@
 #include <glibmm/iochannel.h>
 #include <glibmm/init.h>
 #include <glibmm/keyfile.h>
-#include <glibmm/streamiochannel.h>
 #include <glibmm/listhandle.h>
 #include <glibmm/main.h>
 #include <glibmm/markup.h>
diff --git a/glib/glibmm/filelist.am b/glib/glibmm/filelist.am
index d250d9d..5cdfec4 100644
--- a/glib/glibmm/filelist.am
+++ b/glib/glibmm/filelist.am
@@ -27,7 +27,6 @@ glibmm_files_extra_cc =                       \
        random.cc                       \
        signalproxy.cc                  \
        signalproxy_connectionnode.cc   \
-       streamiochannel.cc              \
        stringutils.cc                  \
        timer.cc                        \
        timeval.cc                      \
@@ -69,7 +68,6 @@ glibmm_files_extra_h =                        \
        signalproxy.h                   \
        signalproxy_connectionnode.h    \
        slisthandle.h                   \
-       streamiochannel.h               \
        stringutils.h                   \
        timer.h                         \
        timeval.h                       \
diff --git a/glib/src/iochannel.ccg b/glib/src/iochannel.ccg
index 7577a84..93b5725 100644
--- a/glib/src/iochannel.ccg
+++ b/glib/src/iochannel.ccg
@@ -35,9 +35,7 @@ namespace
 // g_io_channel_new_file().  Neither is there a way to hook up a wrapper
 // object in an existing GIOChannel, nor exists any destroy notification.
 //
-// So that means:  If the IOChannel is implemented in C++ -- that is, our
-// GlibmmIOChannel backend is used -- we use the GIOChannel reference
-// counting mechanism.  If the IOChannel backend is unknown, then the
+// So that means: If the IOChannel backend is unknown (normal case), then the
 // wrapper instance holds always exactly one reference to the GIOChannel.
 // The wrapper object itself is then managed via our own refcounting
 // mechanism.  To do that a utility class ForeignIOChannel is introduced to
@@ -76,51 +74,8 @@ ForeignIOChannel::unreference() const
 namespace Glib
 {
 
-class GlibmmIOChannel
-{
-public:
-  GIOChannel base;
-  Glib::IOChannel* wrapper;
-
-  static const GIOFuncs vfunc_table;
-
-  static GIOStatus io_read(
-    GIOChannel* channel, char* buf, gsize count, gsize* bytes_read, GError** err);
-
-  static GIOStatus io_write(
-    GIOChannel* channel, const char* buf, gsize count, gsize* bytes_written, GError** err);
-
-  static GIOStatus io_seek(GIOChannel* channel, gint64 offset, GSeekType type, GError** err);
-  static GIOStatus io_close(GIOChannel* channel, GError** err);
-
-  static GSource* io_create_watch(GIOChannel* channel, GIOCondition condition);
-  static void io_free(GIOChannel* channel);
-
-  static GIOStatus io_set_flags(GIOChannel* channel, GIOFlags flags, GError** err);
-  static GIOFlags io_get_flags(GIOChannel* channel);
-};
-
-// static
-const GIOFuncs GlibmmIOChannel::vfunc_table = {
-  &GlibmmIOChannel::io_read, &GlibmmIOChannel::io_write, &GlibmmIOChannel::io_seek,
-  &GlibmmIOChannel::io_close, &GlibmmIOChannel::io_create_watch, &GlibmmIOChannel::io_free,
-  &GlibmmIOChannel::io_set_flags, &GlibmmIOChannel::io_get_flags,
-};
-
 /**** GLib::IOChannel ******************************************************/
 
-/* Construct a custom C++-implemented IOChannel.  GlibmmIOChannel is an
- * extended GIOChannel struct which allows us to hook up a pointer to this
- * persistent wrapper instance.
- */
-IOChannel::IOChannel() : gobject_(static_cast<GIOChannel*>(g_malloc(sizeof(GlibmmIOChannel))))
-{
-  g_io_channel_init(gobject_);
-  gobject_->funcs = const_cast<GIOFuncs*>(&GlibmmIOChannel::vfunc_table);
-
-  reinterpret_cast<GlibmmIOChannel*>(gobject_)->wrapper = this;
-}
-
 IOChannel::IOChannel(IOChannel&& other) noexcept : sigc::trackable(std::move(other)),
                                                    gobject_(std::move(other.gobject_))
 {
@@ -146,9 +101,7 @@ IOChannel::operator=(IOChannel&& other) noexcept
  */
 IOChannel::IOChannel(GIOChannel* gobject, bool take_copy) : gobject_(gobject)
 {
-  // This ctor should never be called for GlibmmIOChannel instances.
   g_assert(gobject != nullptr);
-  g_assert(gobject->funcs != &GlibmmIOChannel::vfunc_table);
 
   if (take_copy)
     g_io_channel_ref(gobject_);
@@ -159,19 +112,6 @@ IOChannel::release_gobject()
 {
   if (gobject_)
   {
-    // Check whether this IOChannel is implemented in C++, i.e. whether it
-    // uses our GlibmmIOChannel forwarding backend.  Normally, this will never
-    // be true because the wrapper should only be deleted in the io_free()
-    // callback, which clears gobject_ before deleting.  But in case the ctor
-    // of a derived class threw an exception the GIOChannel must be destroyed
-    // prematurely.
-    //
-    if (gobject_->funcs == &GlibmmIOChannel::vfunc_table)
-    {
-      // Disconnect the wrapper object so that it won't be deleted twice.
-      reinterpret_cast<GlibmmIOChannel*>(gobject_)->wrapper = nullptr;
-    }
-
     const auto tmp_gobject = gobject_;
     gobject_ = nullptr;
 
@@ -342,52 +282,6 @@ IOChannel::create_watch(IOCondition condition)
   return IOSource::create(Glib::RefPtr<IOChannel>(this), condition);
 }
 
-IOStatus
-IOChannel::read_vfunc(char*, gsize, gsize&)
-{
-  g_assert_not_reached();
-  return IO_STATUS_ERROR;
-}
-
-IOStatus
-IOChannel::write_vfunc(const char*, gsize, gsize&)
-{
-  g_assert_not_reached();
-  return IO_STATUS_ERROR;
-}
-
-IOStatus IOChannel::seek_vfunc(gint64, SeekType)
-{
-  g_assert_not_reached();
-  return IO_STATUS_ERROR;
-}
-
-IOStatus
-IOChannel::close_vfunc()
-{
-  g_assert_not_reached();
-  return IO_STATUS_ERROR;
-}
-
-Glib::RefPtr<Glib::Source> IOChannel::create_watch_vfunc(IOCondition)
-{
-  g_assert_not_reached();
-  return Glib::RefPtr<Glib::Source>();
-}
-
-IOStatus IOChannel::set_flags_vfunc(IOFlags)
-{
-  g_assert_not_reached();
-  return IO_STATUS_ERROR;
-}
-
-IOFlags
-IOChannel::get_flags_vfunc()
-{
-  g_assert_not_reached();
-  return IOFlags(0);
-}
-
 void
 IOChannel::reference() const
 {
@@ -407,180 +301,11 @@ wrap(GIOChannel* gobject, bool take_copy)
 
   if (gobject)
   {
-    if (gobject->funcs == &GlibmmIOChannel::vfunc_table)
-    {
-      cpp_object = reinterpret_cast<GlibmmIOChannel*>(gobject)->wrapper;
-
-      if (take_copy && cpp_object)
-        cpp_object->reference();
-    }
-    else
-    {
-      cpp_object = new ForeignIOChannel(gobject, take_copy);
-      cpp_object->reference(); // the refcount is initially 0
-    }
+    cpp_object = new ForeignIOChannel(gobject, take_copy);
+    cpp_object->reference(); // the refcount is initially 0
   }
 
   return Glib::RefPtr<IOChannel>(cpp_object);
 }
 
-/**** Glib::GlibmmIOChannel ************************************************/
-
-GIOStatus
-GlibmmIOChannel::io_read(
-  GIOChannel* channel, char* buf, gsize count, gsize* bytes_read, GError** err)
-{
-  const auto wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
-
-  try
-  {
-    return (GIOStatus)wrapper->read_vfunc(buf, count, *bytes_read);
-  }
-  catch (Glib::Error& error)
-  {
-    error.propagate(err);
-  }
-  catch (...)
-  {
-    Glib::exception_handlers_invoke();
-  }
-
-  return G_IO_STATUS_ERROR;
-}
-
-GIOStatus
-GlibmmIOChannel::io_write(
-  GIOChannel* channel, const char* buf, gsize count, gsize* bytes_written, GError** err)
-{
-  const auto wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
-
-  try
-  {
-    return (GIOStatus)wrapper->write_vfunc(buf, count, *bytes_written);
-  }
-  catch (Glib::Error& error)
-  {
-    error.propagate(err);
-  }
-  catch (...)
-  {
-    Glib::exception_handlers_invoke();
-  }
-
-  return G_IO_STATUS_ERROR;
-}
-
-GIOStatus
-GlibmmIOChannel::io_seek(GIOChannel* channel, gint64 offset, GSeekType type, GError** err)
-{
-  const auto wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
-
-  try
-  {
-    return (GIOStatus)wrapper->seek_vfunc(offset, (SeekType)type);
-  }
-  catch (Glib::Error& error)
-  {
-    error.propagate(err);
-  }
-  catch (...)
-  {
-    Glib::exception_handlers_invoke();
-  }
-
-  return G_IO_STATUS_ERROR;
-}
-
-GIOStatus
-GlibmmIOChannel::io_close(GIOChannel* channel, GError** err)
-{
-  const auto wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
-
-  try
-  {
-    return (GIOStatus)wrapper->close_vfunc();
-  }
-  catch (Glib::Error& error)
-  {
-    error.propagate(err);
-  }
-  catch (...)
-  {
-    Glib::exception_handlers_invoke();
-  }
-
-  return G_IO_STATUS_ERROR;
-}
-
-// static
-GSource*
-GlibmmIOChannel::io_create_watch(GIOChannel* channel, GIOCondition condition)
-{
-  const auto wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
-
-  try
-  {
-    const auto source = wrapper->create_watch_vfunc((IOCondition)condition);
-    return (source) ? source->gobj_copy() : nullptr;
-  }
-  catch (...)
-  {
-    Glib::exception_handlers_invoke();
-  }
-
-  return nullptr;
-}
-
-// static
-void
-GlibmmIOChannel::io_free(GIOChannel* channel)
-{
-  if (IOChannel* const wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper)
-  {
-    wrapper->gobject_ = nullptr;
-    delete wrapper;
-  }
-
-  g_free(channel);
-}
-
-GIOStatus
-GlibmmIOChannel::io_set_flags(GIOChannel* channel, GIOFlags flags, GError** err)
-{
-  const auto wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
-
-  try
-  {
-    return (GIOStatus)wrapper->set_flags_vfunc((IOFlags)flags);
-  }
-  catch (Glib::Error& error)
-  {
-    error.propagate(err);
-  }
-  catch (...)
-  {
-    Glib::exception_handlers_invoke();
-  }
-
-  return G_IO_STATUS_ERROR;
-}
-
-// static
-GIOFlags
-GlibmmIOChannel::io_get_flags(GIOChannel* channel)
-{
-  const auto wrapper = reinterpret_cast<GlibmmIOChannel*>(channel)->wrapper;
-
-  try
-  {
-    return (GIOFlags)wrapper->get_flags_vfunc();
-  }
-  catch (...)
-  {
-    Glib::exception_handlers_invoke();
-  }
-
-  return GIOFlags(0);
-}
-
 } // namespace Glib
diff --git a/glib/src/iochannel.hg b/glib/src/iochannel.hg
index 12b6b8d..b5c4eb9 100644
--- a/glib/src/iochannel.hg
+++ b/glib/src/iochannel.hg
@@ -419,61 +419,12 @@ public:
 protected:
   GIOChannel* gobject_;
 
-  /** Constructor that should be used by derived classes.
-   * Use this constructor if you want to inherit from IOChannel.
-   * It will set up a GIOChannel that will call the vfuncs of your
-   * class even if it is being used from C code, and it will keep
-   * a reference to the C++ code while the GIOChannel exists.
-   */
-  IOChannel();
   _IGNORE(g_io_channel_init)
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   IOChannel(GIOChannel* gobject, bool take_copy);
 #endif
 
-  //We don't put GLIBMM_DISABLE_DEPRECATED around these deprecated methods
-  //because they are virtual and that would make the ABI dependent on the ifdef.
-
-  /**
-   * @deprecated Custom Glib::IOChannel implementation was never really supported.
-   */
-  virtual IOStatus read_vfunc(char* buf, gsize count, gsize& bytes_read);
-
-  /**
-   * @deprecated Custom Glib::IOChannel implementation was never really supported.
-   */
-  virtual IOStatus write_vfunc(const char* buf, gsize count, gsize& bytes_written);
-
-  /**
-   * @deprecated Custom Glib::IOChannel implementation was never really supported.
-   */
-  virtual IOStatus seek_vfunc(gint64 offset, SeekType type);
-
-  /**
-   * @deprecated Custom Glib::IOChannel implementation was never really supported.
-   */
-  virtual IOStatus close_vfunc();
-
-  /**
-   * @deprecated Custom Glib::IOChannel implementation was never really supported.
-   */
-  virtual IOStatus set_flags_vfunc(IOFlags flags);
-
-  /**
-   * @deprecated Custom Glib::IOChannel implementation was never really supported.
-   */
-  virtual IOFlags  get_flags_vfunc();
-
-  /**
-   * @deprecated Custom Glib::IOChannel implementation was never really supported.
-   */
-  virtual Glib::RefPtr<Glib::Source> create_watch_vfunc(IOCondition cond);
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-  friend class Glib::GlibmmIOChannel;
-#endif
-
 private:
   void release_gobject();
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]