[glib-networking/mcatanzaro/base-rebase: 21/40] gtlsoutputstream: Use G_DECLARE_FINAL_TYPE



commit 103f0f78b5ed7e59fe22d287d4625cef53a85b41
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Fri Apr 5 12:35:30 2019 -0500

    gtlsoutputstream: Use G_DECLARE_FINAL_TYPE

 tls/base/gtlsoutputstream.c | 33 ++++++++++++++++-----------------
 tls/base/gtlsoutputstream.h | 25 +++----------------------
 2 files changed, 19 insertions(+), 39 deletions(-)
---
diff --git a/tls/base/gtlsoutputstream.c b/tls/base/gtlsoutputstream.c
index aa93d69..6cf7316 100644
--- a/tls/base/gtlsoutputstream.c
+++ b/tls/base/gtlsoutputstream.c
@@ -27,23 +27,25 @@
 
 #include <glib/gi18n.h>
 
+struct _GTlsOutputStream
+{
+  GOutputStream parent_instance;
+
+  GWeakRef weak_conn;
+};
+
 static void g_tls_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (GTlsOutputStream, g_tls_output_stream, G_TYPE_OUTPUT_STREAM,
                          G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_OUTPUT_STREAM, 
g_tls_output_stream_pollable_iface_init)
                          )
 
-struct _GTlsOutputStreamPrivate
-{
-  GWeakRef weak_conn;
-};
-
 static void
 g_tls_output_stream_dispose (GObject *object)
 {
   GTlsOutputStream *stream = G_TLS_OUTPUT_STREAM (object);
 
-  g_weak_ref_set (&stream->priv->weak_conn, NULL);
+  g_weak_ref_set (&stream->weak_conn, NULL);
 
   G_OBJECT_CLASS (g_tls_output_stream_parent_class)->dispose (object);
 }
@@ -53,7 +55,7 @@ g_tls_output_stream_finalize (GObject *object)
 {
   GTlsOutputStream *stream = G_TLS_OUTPUT_STREAM (object);
 
-  g_weak_ref_clear (&stream->priv->weak_conn);
+  g_weak_ref_clear (&stream->weak_conn);
 
   G_OBJECT_CLASS (g_tls_output_stream_parent_class)->finalize (object);
 }
@@ -69,7 +71,7 @@ g_tls_output_stream_write (GOutputStream  *stream,
   GTlsConnectionBase *conn;
   gssize ret;
 
-  conn = g_weak_ref_get (&tls_stream->priv->weak_conn);
+  conn = g_weak_ref_get (&tls_stream->weak_conn);
   if (conn == NULL)
     {
       g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
@@ -90,7 +92,7 @@ g_tls_output_stream_pollable_is_writable (GPollableOutputStream *pollable)
   GTlsConnectionBase *conn;
   gboolean ret;
 
-  conn = g_weak_ref_get (&tls_stream->priv->weak_conn);
+  conn = g_weak_ref_get (&tls_stream->weak_conn);
   g_return_val_if_fail (conn != NULL, FALSE);
 
   ret = g_tls_connection_base_check (conn, G_IO_OUT);
@@ -108,7 +110,7 @@ g_tls_output_stream_pollable_create_source (GPollableOutputStream *pollable,
   GTlsConnectionBase *conn;
   GSource *ret;
 
-  conn = g_weak_ref_get (&tls_stream->priv->weak_conn);
+  conn = g_weak_ref_get (&tls_stream->weak_conn);
   g_return_val_if_fail (conn != NULL, NULL);
 
   ret = g_tls_connection_base_create_source (conn,
@@ -128,7 +130,7 @@ g_tls_output_stream_pollable_write_nonblocking (GPollableOutputStream  *pollable
   GTlsConnectionBase *conn;
   gssize ret;
 
-  conn = g_weak_ref_get (&tls_stream->priv->weak_conn);
+  conn = g_weak_ref_get (&tls_stream->weak_conn);
   g_return_val_if_fail (conn != NULL, -1);
 
   ret = g_tls_connection_base_write (conn, buffer, size,
@@ -147,7 +149,7 @@ g_tls_output_stream_close (GOutputStream            *stream,
   GIOStream *conn;
   gboolean ret;
 
-  conn = g_weak_ref_get (&tls_stream->priv->weak_conn);
+  conn = g_weak_ref_get (&tls_stream->weak_conn);
 
   /* Special case here because this is called by the finalize
    * of the main GTlsConnection object.
@@ -177,7 +179,7 @@ close_thread (GTask        *task,
   GError *error = NULL;
   GIOStream *conn;
 
-  conn = g_weak_ref_get (&tls_stream->priv->weak_conn);
+  conn = g_weak_ref_get (&tls_stream->weak_conn);
 
   if (conn && !g_tls_connection_base_close_internal (conn,
                                                      G_TLS_DIRECTION_WRITE,
@@ -225,8 +227,6 @@ g_tls_output_stream_class_init (GTlsOutputStreamClass *klass)
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   GOutputStreamClass *output_stream_class = G_OUTPUT_STREAM_CLASS (klass);
 
-  g_type_class_add_private (klass, sizeof (GTlsOutputStreamPrivate));
-
   gobject_class->dispose = g_tls_output_stream_dispose;
   gobject_class->finalize = g_tls_output_stream_finalize;
 
@@ -247,7 +247,6 @@ g_tls_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface)
 static void
 g_tls_output_stream_init (GTlsOutputStream *stream)
 {
-  stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream, G_TYPE_TLS_OUTPUT_STREAM, GTlsOutputStreamPrivate);
 }
 
 GOutputStream *
@@ -256,7 +255,7 @@ g_tls_output_stream_new (GTlsConnectionBase *conn)
   GTlsOutputStream *tls_stream;
 
   tls_stream = g_object_new (G_TYPE_TLS_OUTPUT_STREAM, NULL);
-  g_weak_ref_init (&tls_stream->priv->weak_conn, conn);
+  g_weak_ref_init (&tls_stream->weak_conn, conn);
 
   return G_OUTPUT_STREAM (tls_stream);
 }
diff --git a/tls/base/gtlsoutputstream.h b/tls/base/gtlsoutputstream.h
index 3b410d7..1e5448d 100644
--- a/tls/base/gtlsoutputstream.h
+++ b/tls/base/gtlsoutputstream.h
@@ -31,28 +31,9 @@
 G_BEGIN_DECLS
 
 #define G_TYPE_TLS_OUTPUT_STREAM            (g_tls_output_stream_get_type ())
-#define G_TLS_OUTPUT_STREAM(inst)           (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_OUTPUT_STREAM, 
GTlsOutputStream))
-#define G_TLS_OUTPUT_STREAM_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_OUTPUT_STREAM, 
GTlsOutputStreamClass))
-#define G_IS_TLS_OUTPUT_STREAM(inst)        (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_OUTPUT_STREAM))
-#define G_IS_TLS_OUTPUT_STREAM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_OUTPUT_STREAM))
-#define G_TLS_OUTPUT_STREAM_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_OUTPUT_STREAM, 
GTlsOutputStreamClass))
-
-typedef struct _GTlsOutputStreamPrivate GTlsOutputStreamPrivate;
-typedef struct _GTlsOutputStreamClass   GTlsOutputStreamClass;
-typedef struct _GTlsOutputStream        GTlsOutputStream;
-
-struct _GTlsOutputStreamClass
-{
-  GOutputStreamClass parent_class;
-};
-
-struct _GTlsOutputStream
-{
-  GOutputStream parent_instance;
-  GTlsOutputStreamPrivate *priv;
-};
-
-GType          g_tls_output_stream_get_type (void) G_GNUC_CONST;
+
+G_DECLARE_FINAL_TYPE (GTlsOutputStream, g_tls_output_stream, G, TLS_OUTPUT_STREAM, GOutputStream)
+
 GOutputStream *g_tls_output_stream_new      (GTlsConnectionBase *conn);
 
 G_END_DECLS


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