[glibmm] Wrap some constructors and methods in giomm streams



commit 2857a6fb98191e7e402435b8b4c023369a2cb2ad
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Jun 2 09:30:48 2016 +0200

    Wrap some constructors and methods in giomm streams
    
    Also, add TODO comments about adding vfuncs at ABI break.
    * gio/src/bufferedinputstream.hg: TODO: Add fill_vfunc().
    * gio/src/filterinputstream.[hg|ccg]: Add ctor.
    * gio/src/filteroutputstream.[hg|ccg]: Add ctor.
    * gio/src/inputstream.hg: Add ctor, is_closed(), has_pending(),
    set_pending(), clear_pending(). TODO: Add read_vfunc(), skip_vfunc(),
    close_vfunc().
    * gio/src/memoryoutputstream.[hg|ccg]: Add ctor and create().
    * gio/src/outputstream.hg: Add ctor, is_closed(), is_closing(), has_pending(),
    set_pending(), clear_pending(). TODO: Add write_vfunc(), splice_vfunc(),
    flush_vfunc(), close_vfunc().
    An updated version of a patch by Krzysztof KosiƄski <tweenk pl gmail com>
    Bug #572471

 gio/src/bufferedinputstream.hg |    6 ++----
 gio/src/filterinputstream.ccg  |   11 +++++++++--
 gio/src/filterinputstream.hg   |    7 +++++--
 gio/src/filteroutputstream.ccg |   11 +++++++++--
 gio/src/filteroutputstream.hg  |    7 +++++--
 gio/src/inputstream.hg         |   17 +++++++++++++++--
 gio/src/memoryoutputstream.ccg |   14 ++++++++++++--
 gio/src/memoryoutputstream.hg  |    7 +++++++
 gio/src/outputstream.hg        |   22 +++++++++++++++++++---
 9 files changed, 83 insertions(+), 19 deletions(-)
---
diff --git a/gio/src/bufferedinputstream.hg b/gio/src/bufferedinputstream.hg
index d940f43..9661d1e 100644
--- a/gio/src/bufferedinputstream.hg
+++ b/gio/src/bufferedinputstream.hg
@@ -1,5 +1,3 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-
 /* Copyright (C) 2008 The gtkmm Development Team
  *
  * This library is free software; you can redistribute it and/or
@@ -109,9 +107,9 @@ public:
   _WRAP_PROPERTY("buffer-size", guint)
 
 protected:
+  //TODO: When we can break ABI, add vfunc. See https://bugzilla.gnome.org/show_bug.cgi?id=572471
 #m4 _CONVERSION(`GCancellable*', `const Glib::RefPtr<Cancellable>&', `Glib::wrap($3, true)')
-  //_WRAP_VFUNC(gssize fill(gssize count, const Glib::RefPtr<Cancellable>& cancellable, GError** error), 
"fill")
-
+  //_WRAP_VFUNC(gssize fill(gssize count, const Glib::RefPtr<Cancellable>& cancellable), fill, errthrow, 
err_return_value -1)
 };
 
 } // namespace Gio
diff --git a/gio/src/filterinputstream.ccg b/gio/src/filterinputstream.ccg
index 40517b7..f69b83d 100644
--- a/gio/src/filterinputstream.ccg
+++ b/gio/src/filterinputstream.ccg
@@ -1,5 +1,3 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-
 /* Copyright (C) 2008 The gtkmm Development Team
  *
  * This library is free software; you can redistribute it and/or
@@ -18,3 +16,12 @@
  */
 
 #include <gio/gio.h>
+
+namespace Gio {
+
+FilterInputStream::FilterInputStream(const Glib::RefPtr<InputStream>& base_stream)
+: _CONSTRUCT("base_stream", const_cast<GInputStream*>(Glib::unwrap(base_stream)))
+{
+}
+
+} // namespace Gio
diff --git a/gio/src/filterinputstream.hg b/gio/src/filterinputstream.hg
index 6d09e4d..bd35f73 100644
--- a/gio/src/filterinputstream.hg
+++ b/gio/src/filterinputstream.hg
@@ -1,5 +1,3 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-
 /* Copyright (C) 2008 The gtkmm Development Team
  *
  * This library is free software; you can redistribute it and/or
@@ -37,6 +35,11 @@ namespace Gio
 class FilterInputStream : public Gio::InputStream
 {
   _CLASS_GOBJECT(FilterInputStream, GFilterInputStream, G_FILTER_INPUT_STREAM, Gio::InputStream, 
GInputStream)
+
+protected:
+  // This needs to be hand-coded because there is no public GFilterInputStream constructor.
+  explicit FilterInputStream(const Glib::RefPtr<InputStream>& base_stream);
+
 public:
   _WRAP_METHOD(Glib::RefPtr<InputStream> get_base_stream(),
                g_filter_input_stream_get_base_stream,
diff --git a/gio/src/filteroutputstream.ccg b/gio/src/filteroutputstream.ccg
index 40517b7..49d0402 100644
--- a/gio/src/filteroutputstream.ccg
+++ b/gio/src/filteroutputstream.ccg
@@ -1,5 +1,3 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-
 /* Copyright (C) 2008 The gtkmm Development Team
  *
  * This library is free software; you can redistribute it and/or
@@ -18,3 +16,12 @@
  */
 
 #include <gio/gio.h>
+
+namespace Gio {
+
+FilterOutputStream::FilterOutputStream(const Glib::RefPtr<OutputStream>& base_stream)
+: _CONSTRUCT("base_stream", const_cast<GOutputStream*>(Glib::unwrap(base_stream)))
+{
+}
+
+} // namespace Gio
diff --git a/gio/src/filteroutputstream.hg b/gio/src/filteroutputstream.hg
index 47b5e01..0ac953a 100644
--- a/gio/src/filteroutputstream.hg
+++ b/gio/src/filteroutputstream.hg
@@ -1,5 +1,3 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-
 /* Copyright (C) 2008 The gtkmm Development Team
  *
  * This library is free software; you can redistribute it and/or
@@ -38,6 +36,11 @@ namespace Gio
 class FilterOutputStream : public Gio::OutputStream
 {
   _CLASS_GOBJECT(FilterOutputStream, GFilterOutputStream, G_FILTER_OUTPUT_STREAM, Gio::OutputStream, 
GOutputStream)
+
+protected:
+  // This needs to be hand-coded because there is no public GFilterOutputStream constructor.
+  explicit FilterOutputStream(const Glib::RefPtr<OutputStream>& base_stream);
+
 public:
   _WRAP_METHOD(Glib::RefPtr<OutputStream> get_base_stream(),
                g_filter_output_stream_get_base_stream,
diff --git a/gio/src/inputstream.hg b/gio/src/inputstream.hg
index 745c11d..0283a48 100644
--- a/gio/src/inputstream.hg
+++ b/gio/src/inputstream.hg
@@ -40,6 +40,9 @@ class InputStream : public Glib::Object
 {
   _CLASS_GOBJECT(InputStream, GInputStream, G_INPUT_STREAM, Glib::Object, GObject)
 
+protected:
+  _CTOR_DEFAULT
+
 public:
   _WRAP_METHOD(gssize read(void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable{?}),
                g_input_stream_read,
@@ -380,8 +383,18 @@ public:
                g_input_stream_close_finish,
                errthrow)
 
-  // These are private inside the module (for implementations)
-  _IGNORE(g_input_stream_has_pending, g_input_stream_is_closed, g_input_stream_set_pending, 
g_input_stream_clear_pending)
+  _WRAP_METHOD(bool is_closed(), g_input_stream_is_closed, newin "2,50")
+  _WRAP_METHOD(bool has_pending(), g_input_stream_has_pending, newin "2,50")
+
+protected:
+  _WRAP_METHOD(bool set_pending(), g_input_stream_set_pending, errthrow, newin "2,50")
+  _WRAP_METHOD(void clear_pending(), g_input_stream_clear_pending, newin "2,50")
+
+  //TODO: When we can break ABI, add vfuncs. See https://bugzilla.gnome.org/show_bug.cgi?id=572471
+#m4 _CONVERSION(`GCancellable*', `const Glib::RefPtr<Cancellable>&', `Glib::wrap($3, true)')
+  //_WRAP_VFUNC(gssize read(void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable), 
read_fn, errthrow, err_return_value -1)
+  //_WRAP_VFUNC(gssize skip(gsize count, const Glib::RefPtr<Cancellable>& cancellable), skip, errthrow, 
err_return_value -1)
+  //_WRAP_VFUNC(bool close(const Glib::RefPtr<Cancellable>& cancellable), close_fn, errthrow)
 };
 
 } // namespace Gio
diff --git a/gio/src/memoryoutputstream.ccg b/gio/src/memoryoutputstream.ccg
index 028f74e..45f52e0 100644
--- a/gio/src/memoryoutputstream.ccg
+++ b/gio/src/memoryoutputstream.ccg
@@ -1,5 +1,3 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-
 /* Copyright (C) 2008 The gtkmm Development Team
  *
  * This library is free software; you can redistribute it and/or
@@ -19,3 +17,15 @@
 
 #include <gio/gio.h>
 #include <glibmm/bytes.h>
+
+namespace Gio
+{
+
+// Equivalent to g_memory_output_stream_new_resizable().
+MemoryOutputStream::MemoryOutputStream()
+: _CONSTRUCT("data", nullptr, "size", 0, "realloc-function", g_realloc,
+             "destroy-function", g_free)
+{
+}
+
+} // namespace Gio
diff --git a/gio/src/memoryoutputstream.hg b/gio/src/memoryoutputstream.hg
index 8f08c03..4b1048b 100644
--- a/gio/src/memoryoutputstream.hg
+++ b/gio/src/memoryoutputstream.hg
@@ -49,11 +49,18 @@ class MemoryOutputStream :
 {
   _CLASS_GOBJECT(MemoryOutputStream, GMemoryOutputStream, G_MEMORY_OUTPUT_STREAM, Gio::OutputStream, 
GOutputStream)
   _IMPLEMENTS_INTERFACE(Seekable)
+
 protected:
+  // Hand-coded because it's equivalent to g_memory_output_stream_new_resizable(),
+  // which sets some properties to non-default values.
+  /** Creates a resizable stream.
+   */
+  MemoryOutputStream();
   // TODO: more C++-like interface using sigc++
   _WRAP_CTOR(MemoryOutputStream(void* data, gsize size, GReallocFunc realloc_function, GDestroyNotify 
destroy_function), g_memory_output_stream_new)
 
 public:
+  _WRAP_CREATE()
   // TODO: more C++-like interface using sigc++
   _WRAP_CREATE(void* data, gsize size, GReallocFunc realloc_function, GDestroyNotify destroy_function)
 
diff --git a/gio/src/outputstream.hg b/gio/src/outputstream.hg
index afbf1e8..428da3d 100644
--- a/gio/src/outputstream.hg
+++ b/gio/src/outputstream.hg
@@ -22,6 +22,7 @@
 
 _DEFS(giomm,gio)
 _PINCLUDE(glibmm/private/object_p.h)
+_PINCLUDE(gio/gio.h) // for GOutputStreamSpliceFlags
 
 namespace Gio
 {
@@ -38,6 +39,9 @@ class OutputStream : public Glib::Object
 {
   _CLASS_GOBJECT(OutputStream, GOutputStream, G_OUTPUT_STREAM, Glib::Object, GObject)
 
+protected:
+  _CTOR_DEFAULT
+
 public:
 
   _WRAP_METHOD(gssize write(const void* buffer, gsize count, const Glib::RefPtr<Cancellable>& 
cancellable{?}),
@@ -491,9 +495,21 @@ public:
                g_output_stream_close_finish,
                errthrow)
 
-  // These are private inside the module (for implementations)
-  _IGNORE(g_output_stream_has_pending, g_output_stream_is_closed, g_output_stream_is_closing, 
g_output_stream_set_pending, g_output_stream_clear_pending)
-
+  _WRAP_METHOD(bool is_closed(), g_output_stream_is_closed, newin "2,50")
+  _WRAP_METHOD(bool is_closing(), g_output_stream_is_closing, newin "2,50")
+  _WRAP_METHOD(bool has_pending(), g_output_stream_has_pending, newin "2,50")
+
+protected:
+  _WRAP_METHOD(bool set_pending(), g_output_stream_set_pending, errthrow, newin "2,50")
+  _WRAP_METHOD(void clear_pending(), g_output_stream_clear_pending, newin "2,50")
+
+  //TODO: When we can break ABI, add vfuncs. See https://bugzilla.gnome.org/show_bug.cgi?id=572471
+#m4 _CONVERSION(`GCancellable*', `const Glib::RefPtr<Cancellable>&', `Glib::wrap($3, true)')
+#m4 _CONVERSION(`GInputStream*', `const Glib::RefPtr<InputStream>&', `Glib::wrap($3, true)')
+  //_WRAP_VFUNC(gssize write(const void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable), 
write_fn, errthrow, err_return_value -1)
+  //_WRAP_VFUNC(gssize splice(const Glib::RefPtr<InputStream>& source, const Glib::RefPtr<Cancellable>& 
cancellable{.}, OutputStreamSpliceFlags flags{.}), splice, errthrow, err_return_value -1)
+  //_WRAP_VFUNC(bool flush(const Glib::RefPtr<Cancellable>& cancellable), flush, errthrow)
+  //_WRAP_VFUNC(bool close(const Glib::RefPtr<Cancellable>& cancellable), close_fn, errthrow)
 };
 
 } // namespace Gio


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