mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
gio: more implementations of GFileDescriptorBased
Implement GFileDescriptorBased in GSocket{Input,Output}Stream and GUnix{Input,Output}Stream. https://bugzilla.gnome.org/show_bug.cgi?id=616852
This commit is contained in:
parent
f218353e04
commit
759c0e935d
@ -31,13 +31,20 @@
|
|||||||
#include "gcancellable.h"
|
#include "gcancellable.h"
|
||||||
#include "gpollableinputstream.h"
|
#include "gpollableinputstream.h"
|
||||||
#include "gioerror.h"
|
#include "gioerror.h"
|
||||||
|
#include "gfiledescriptorbased.h"
|
||||||
|
|
||||||
static void g_socket_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface);
|
static void g_socket_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface);
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
static void g_socket_input_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define g_socket_input_stream_get_type _g_socket_input_stream_get_type
|
#define g_socket_input_stream_get_type _g_socket_input_stream_get_type
|
||||||
G_DEFINE_TYPE_WITH_CODE (GSocketInputStream, g_socket_input_stream, G_TYPE_INPUT_STREAM,
|
G_DEFINE_TYPE_WITH_CODE (GSocketInputStream, g_socket_input_stream, G_TYPE_INPUT_STREAM,
|
||||||
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM, g_socket_input_stream_pollable_iface_init)
|
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM, g_socket_input_stream_pollable_iface_init)
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
|
||||||
|
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED, g_socket_input_stream_file_descriptor_based_iface_init)
|
||||||
|
#endif
|
||||||
)
|
)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -248,6 +255,16 @@ g_socket_input_stream_pollable_read_nonblocking (GPollableInputStream *pollable
|
|||||||
NULL, error);
|
NULL, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
static int
|
||||||
|
g_socket_input_stream_get_fd (GFileDescriptorBased *fd_based)
|
||||||
|
{
|
||||||
|
GSocketInputStream *input_stream = G_SOCKET_INPUT_STREAM (fd_based);
|
||||||
|
|
||||||
|
return g_socket_get_fd (input_stream->priv->socket);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_socket_input_stream_class_init (GSocketInputStreamClass *klass)
|
g_socket_input_stream_class_init (GSocketInputStreamClass *klass)
|
||||||
{
|
{
|
||||||
@ -272,6 +289,14 @@ g_socket_input_stream_class_init (GSocketInputStreamClass *klass)
|
|||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
static void
|
||||||
|
g_socket_input_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||||
|
{
|
||||||
|
iface->get_fd = g_socket_input_stream_get_fd;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_socket_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface)
|
g_socket_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface)
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "goutputstream.h"
|
#include "goutputstream.h"
|
||||||
#include "gsocketoutputstream.h"
|
#include "gsocketoutputstream.h"
|
||||||
#include "gsocket.h"
|
#include "gsocket.h"
|
||||||
|
#include "glibintl.h"
|
||||||
|
|
||||||
#include "gsimpleasyncresult.h"
|
#include "gsimpleasyncresult.h"
|
||||||
#include "gcancellable.h"
|
#include "gcancellable.h"
|
||||||
@ -34,14 +35,20 @@
|
|||||||
#include "gpollableoutputstream.h"
|
#include "gpollableoutputstream.h"
|
||||||
#include "gioerror.h"
|
#include "gioerror.h"
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
|
#include "gfiledescriptorbased.h"
|
||||||
|
|
||||||
static void g_socket_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface);
|
static void g_socket_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface);
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
static void g_socket_output_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define g_socket_output_stream_get_type _g_socket_output_stream_get_type
|
#define g_socket_output_stream_get_type _g_socket_output_stream_get_type
|
||||||
G_DEFINE_TYPE_WITH_CODE (GSocketOutputStream, g_socket_output_stream, G_TYPE_OUTPUT_STREAM,
|
G_DEFINE_TYPE_WITH_CODE (GSocketOutputStream, g_socket_output_stream, G_TYPE_OUTPUT_STREAM,
|
||||||
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_OUTPUT_STREAM, g_socket_output_stream_pollable_iface_init)
|
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_OUTPUT_STREAM, g_socket_output_stream_pollable_iface_init)
|
||||||
)
|
#ifdef G_OS_UNIX
|
||||||
|
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED, g_socket_output_stream_file_descriptor_based_iface_init)
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -251,6 +258,16 @@ g_socket_output_stream_pollable_write_nonblocking (GPollableOutputStream *polla
|
|||||||
NULL, error);
|
NULL, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
static int
|
||||||
|
g_socket_output_stream_get_fd (GFileDescriptorBased *fd_based)
|
||||||
|
{
|
||||||
|
GSocketOutputStream *output_stream = G_SOCKET_OUTPUT_STREAM (fd_based);
|
||||||
|
|
||||||
|
return g_socket_get_fd (output_stream->priv->socket);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_socket_output_stream_class_init (GSocketOutputStreamClass *klass)
|
g_socket_output_stream_class_init (GSocketOutputStreamClass *klass)
|
||||||
{
|
{
|
||||||
@ -275,6 +292,14 @@ g_socket_output_stream_class_init (GSocketOutputStreamClass *klass)
|
|||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
static void
|
||||||
|
g_socket_output_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||||
|
{
|
||||||
|
iface->get_fd = g_socket_output_stream_get_fd;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_socket_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface)
|
g_socket_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface)
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "gunixinputstream.h"
|
#include "gunixinputstream.h"
|
||||||
#include "gcancellable.h"
|
#include "gcancellable.h"
|
||||||
#include "gasynchelper.h"
|
#include "gasynchelper.h"
|
||||||
|
#include "gfiledescriptorbased.h"
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
|
|
||||||
|
|
||||||
@ -61,11 +62,14 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void g_unix_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface);
|
static void g_unix_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface);
|
||||||
|
static void g_unix_input_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GUnixInputStream, g_unix_input_stream, G_TYPE_INPUT_STREAM,
|
G_DEFINE_TYPE_WITH_CODE (GUnixInputStream, g_unix_input_stream, G_TYPE_INPUT_STREAM,
|
||||||
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
|
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_INPUT_STREAM,
|
||||||
g_unix_input_stream_pollable_iface_init)
|
g_unix_input_stream_pollable_iface_init)
|
||||||
);
|
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
|
||||||
|
g_unix_input_stream_file_descriptor_based_iface_init)
|
||||||
|
)
|
||||||
|
|
||||||
struct _GUnixInputStreamPrivate {
|
struct _GUnixInputStreamPrivate {
|
||||||
int fd;
|
int fd;
|
||||||
@ -189,6 +193,12 @@ g_unix_input_stream_pollable_iface_init (GPollableInputStreamInterface *iface)
|
|||||||
iface->create_source = g_unix_input_stream_pollable_create_source;
|
iface->create_source = g_unix_input_stream_pollable_create_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_unix_input_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||||
|
{
|
||||||
|
iface->get_fd = (int (*) (GFileDescriptorBased *))g_unix_input_stream_get_fd;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_unix_input_stream_set_property (GObject *object,
|
g_unix_input_stream_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "gcancellable.h"
|
#include "gcancellable.h"
|
||||||
#include "gsimpleasyncresult.h"
|
#include "gsimpleasyncresult.h"
|
||||||
#include "gasynchelper.h"
|
#include "gasynchelper.h"
|
||||||
|
#include "gfiledescriptorbased.h"
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
|
|
||||||
|
|
||||||
@ -61,11 +62,14 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void g_unix_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface);
|
static void g_unix_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface);
|
||||||
|
static void g_unix_output_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GUnixOutputStream, g_unix_output_stream, G_TYPE_OUTPUT_STREAM,
|
G_DEFINE_TYPE_WITH_CODE (GUnixOutputStream, g_unix_output_stream, G_TYPE_OUTPUT_STREAM,
|
||||||
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_OUTPUT_STREAM,
|
G_IMPLEMENT_INTERFACE (G_TYPE_POLLABLE_OUTPUT_STREAM,
|
||||||
g_unix_output_stream_pollable_iface_init)
|
g_unix_output_stream_pollable_iface_init)
|
||||||
);
|
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
|
||||||
|
g_unix_output_stream_file_descriptor_based_iface_init)
|
||||||
|
)
|
||||||
|
|
||||||
struct _GUnixOutputStreamPrivate {
|
struct _GUnixOutputStreamPrivate {
|
||||||
int fd;
|
int fd;
|
||||||
@ -174,6 +178,12 @@ g_unix_output_stream_pollable_iface_init (GPollableOutputStreamInterface *iface)
|
|||||||
iface->create_source = g_unix_output_stream_pollable_create_source;
|
iface->create_source = g_unix_output_stream_pollable_create_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_unix_output_stream_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||||
|
{
|
||||||
|
iface->get_fd = (int (*) (GFileDescriptorBased *))g_unix_output_stream_get_fd;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_unix_output_stream_set_property (GObject *object,
|
g_unix_output_stream_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user