revise docs for source / target

This commit is contained in:
John Cupitt 2019-12-30 16:28:39 +00:00
parent 63d54e5df2
commit 96cdc5ef01
6 changed files with 35 additions and 15 deletions

View File

@ -61,7 +61,7 @@
<xi:include href="xml/object.xml"/> <xi:include href="xml/object.xml"/>
<xi:include href="xml/threadpool.xml"/> <xi:include href="xml/threadpool.xml"/>
<xi:include href="xml/buf.xml"/> <xi:include href="xml/buf.xml"/>
<xi:include href="xml/stream.xml"/> <xi:include href="xml/connection.xml"/>
<xi:include href="xml/bufis.xml"/> <xi:include href="xml/bufis.xml"/>
<xi:include href="xml/basic.xml"/> <xi:include href="xml/basic.xml"/>
</chapter> </chapter>

View File

@ -77,6 +77,7 @@
* @stability: Stable * @stability: Stable
* @see_also: <link linkend="libvips-image">image</link> * @see_also: <link linkend="libvips-image">image</link>
* @include: vips/vips.h * @include: vips/vips.h
* @title: VipsForeign
* *
* This set of operations load and save images in a variety of formats. * This set of operations load and save images in a variety of formats.
* *

View File

@ -86,8 +86,8 @@ typedef struct _VipsConnectionClass {
GType vips_connection_get_type( void ); GType vips_connection_get_type( void );
const char *vips_connection_filename( VipsConnection *stream ); const char *vips_connection_filename( VipsConnection *connection );
const char *vips_connection_nick( VipsConnection *stream ); const char *vips_connection_nick( VipsConnection *connection );
#define VIPS_TYPE_SOURCE (vips_source_get_type()) #define VIPS_TYPE_SOURCE (vips_source_get_type())
#define VIPS_SOURCE( obj ) \ #define VIPS_SOURCE( obj ) \
@ -107,7 +107,7 @@ const char *vips_connection_nick( VipsConnection *stream );
/* Read from something like a socket, file or memory area and present the data /* Read from something like a socket, file or memory area and present the data
* with a unified seek / read / map interface. * with a unified seek / read / map interface.
* *
* During the header phase, we save data from unseekable streams in a buffer * During the header phase, we save data from unseekable sources in a buffer
* so readers can rewind and read again. We don't buffer data during the * so readers can rewind and read again. We don't buffer data during the
* decode stage. * decode stage.
*/ */
@ -117,7 +117,7 @@ typedef struct _VipsSource {
/* We have two phases: /* We have two phases:
* *
* During the header phase, we save bytes read from the input (if this * During the header phase, we save bytes read from the input (if this
* is an unseekable stream) so that we can rewind and try again, if * is an unseekable source) so that we can rewind and try again, if
* necessary. * necessary.
* *
* Once we reach decode phase, we no longer support rewind and the * Once we reach decode phase, we no longer support rewind and the
@ -126,7 +126,7 @@ typedef struct _VipsSource {
gboolean decode; gboolean decode;
/* TRUE if this input is something like a pipe. These don't support /* TRUE if this input is something like a pipe. These don't support
* stream or map -- all you can do is read() bytes sequentially. * seek or map -- all you can do is read() bytes sequentially.
* *
* If you attempt to map or get the size of a pipe-style input, it'll * If you attempt to map or get the size of a pipe-style input, it'll
* get read entirely into memory. Seeks will cause read up to the seek * get read entirely into memory. Seeks will cause read up to the seek
@ -165,7 +165,7 @@ typedef struct _VipsSource {
*/ */
GByteArray *sniff; GByteArray *sniff;
/* For a memory stream, the blob we read from. /* For a memory source, the blob we read from.
*/ */
VipsBlob *blob; VipsBlob *blob;
@ -182,7 +182,7 @@ typedef struct _VipsSourceClass {
/* Subclasses can define these to implement other source methods. /* Subclasses can define these to implement other source methods.
*/ */
/* Read from the stream into the supplied buffer, args exactly as /* Read from the source into the supplied buffer, args exactly as
* read(2). Set errno on error. * read(2). Set errno on error.
* *
* We must return gint64, since ssize_t is often defined as unsigned * We must return gint64, since ssize_t is often defined as unsigned
@ -193,7 +193,7 @@ typedef struct _VipsSourceClass {
/* Seek to a certain position, args exactly as lseek(2). Set errno on /* Seek to a certain position, args exactly as lseek(2). Set errno on
* error. * error.
* *
* Unseekable streams should always return -1. VipsSource will then * Unseekable sources should always return -1. VipsSource will then
* seek by _read()ing bytes into memory as required. * seek by _read()ing bytes into memory as required.
* *
* We have to use int64 rather than off_t, since we must work on * We have to use int64 rather than off_t, since we must work on
@ -289,11 +289,11 @@ typedef struct _VipsTarget {
/*< private >*/ /*< private >*/
/* This stream should write to memory. /* This target should write to memory.
*/ */
gboolean memory; gboolean memory;
/* The stream has been finished and can no longer be written. /* The target has been finished and can no longer be written.
*/ */
gboolean finished; gboolean finished;
@ -324,7 +324,7 @@ typedef struct _VipsTargetClass {
gint64 (*write)( VipsTarget *, const void *, size_t ); gint64 (*write)( VipsTarget *, const void *, size_t );
/* Output has been generated, so do any clearing up, /* Output has been generated, so do any clearing up,
* eg. copy the bytes we saved in memory to the stream blob. * eg. copy the bytes we saved in memory to the target blob.
*/ */
void (*finish)( VipsTarget * ); void (*finish)( VipsTarget * );

View File

@ -62,12 +62,17 @@
* @stability: Stable * @stability: Stable
* @see_also: <link linkend="libvips-foreign">foreign</link> * @see_also: <link linkend="libvips-foreign">foreign</link>
* @include: vips/vips.h * @include: vips/vips.h
* @title: VipsConnection
* *
* A #VipsConnection is a source or sink of bytes for something like jpeg * A #VipsConnection is a source or sink of bytes for something like jpeg
* loading. It can be connected to a network socket, for example, or perhaps * loading, see for example vips_jpegload_source().
*
* It can be connected to a network socket, for example, or perhaps
* a node.js stream, or to an area of memory. * a node.js stream, or to an area of memory.
* *
* Subclass to add other input sources. * Subclass to add other input sources. Use #VipsSourceCustom and
* #VipsTargetCustom to make a source or target with action signals for
* ::read, ::write and ::seek.
*/ */
/** /**
@ -142,12 +147,25 @@ vips_connection_init( VipsConnection *connection )
connection->close_descriptor = -1; connection->close_descriptor = -1;
} }
/**
* vips_connection_filename:
* @connection: connection to operate on
*
* Returns: any filename associated with this connection, or NULL.
*/
const char * const char *
vips_connection_filename( VipsConnection *connection ) vips_connection_filename( VipsConnection *connection )
{ {
return( connection->filename ); return( connection->filename );
} }
/**
* vips_connection_nick:
* @connection: connection to operate on
*
* Returns: a string describing this connection which could be displayed to a
* user.
*/
const char * const char *
vips_connection_nick( VipsConnection *connection ) vips_connection_nick( VipsConnection *connection )
{ {

View File

@ -329,7 +329,7 @@ vips_source_class_init( VipsSourceClass *class )
VIPS_ARG_BOXED( class, "blob", 3, VIPS_ARG_BOXED( class, "blob", 3,
_( "Blob" ), _( "Blob" ),
_( "blob to load from" ), _( "Blob to load from" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsSource, blob ), G_STRUCT_OFFSET( VipsSource, blob ),
VIPS_TYPE_BLOB ); VIPS_TYPE_BLOB );

View File

@ -85,6 +85,7 @@
* @stability: Stable * @stability: Stable
* @see_also: <link linkend="libvips-generate">generate</link> * @see_also: <link linkend="libvips-generate">generate</link>
* @include: vips/vips.h * @include: vips/vips.h
* @title: VipsThreadpool
* *
* vips_threadpool_run() loops a set of threads over an image. Threads take it * vips_threadpool_run() loops a set of threads over an image. Threads take it
* in turns to allocate units of work (a unit might be a tile in an image), * in turns to allocate units of work (a unit might be a tile in an image),