many more const decls

ruby gobject-introspection is quite fussy about needing a lot of const
declarations ... these changes help vips_image_matrix_from_array()
appear in Ruby
This commit is contained in:
John Cupitt 2015-10-23 11:45:11 +01:00
parent 649c30018e
commit 2b46b7e889
17 changed files with 91 additions and 63 deletions

View File

@ -1,6 +1,7 @@
7/10/15 started 8.2.0
- added im_bufmagick2vips(), a vips7 wrapper for magick load from buffer
- fetch unset property now returns default value rather than warning
- many more const declarations to help gobject-introspection
7/5/15 started 8.1.1
- oop, vips-8.0 should be vips-8.1, thanks Danilo

View File

@ -553,7 +553,7 @@ vips_foreign_load( const char *name, VipsImage **out, ... )
*/
static void *
vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class,
void **buf, size_t *len )
const void **buf, size_t *len )
{
if( load_class->is_a_buffer &&
load_class->is_a_buffer( *buf, *len ) )
@ -576,7 +576,7 @@ vips_foreign_find_load_buffer_sub( VipsForeignLoadClass *load_class,
* error.
*/
const char *
vips_foreign_find_load_buffer( void *data, size_t size )
vips_foreign_find_load_buffer( const void *data, size_t size )
{
VipsForeignLoadClass *load_class;
@ -630,7 +630,7 @@ vips_foreign_is_a( const char *loader, const char *filename )
* Returns: %TRUE if @data can be loaded by @loader.
*/
gboolean
vips_foreign_is_a_buffer( const char *loader, void *data, size_t size )
vips_foreign_is_a_buffer( const char *loader, const void *data, size_t size )
{
VipsObjectClass *class;
VipsForeignLoadClass *load_class;

View File

@ -1157,7 +1157,7 @@ typedef struct {
/* Private stuff during read.
*/
gboolean start_of_file; /* have we gotten any data yet? */
JOCTET *buf;
const JOCTET *buf;
size_t len;
} InputBuffer;
@ -1288,7 +1288,7 @@ term_source (j_decompress_ptr cinfo)
*/
static void
readjpeg_buffer (ReadJpeg *jpeg, void *buf, size_t len)
readjpeg_buffer (ReadJpeg *jpeg, const void *buf, size_t len)
{
j_decompress_ptr cinfo = &jpeg->cinfo;
InputBuffer *src;
@ -1320,7 +1320,7 @@ readjpeg_buffer (ReadJpeg *jpeg, void *buf, size_t len)
}
int
vips__jpeg_read_buffer( void *buf, size_t len, VipsImage *out,
vips__jpeg_read_buffer( const void *buf, size_t len, VipsImage *out,
gboolean header_only, int shrink, int fail, gboolean readbehind,
gboolean autorotate )
{
@ -1344,9 +1344,9 @@ vips__jpeg_read_buffer( void *buf, size_t len, VipsImage *out,
}
int
vips__isjpeg_buffer( void *buf, size_t len )
vips__isjpeg_buffer( const void *buf, size_t len )
{
guchar *str = (guchar *) buf;
const guchar *str = (const guchar *) buf;
if( len >= 2 &&
str[0] == 0xff &&

View File

@ -302,7 +302,7 @@ vips_foreign_load_jpeg_buffer_load( VipsForeignLoad *load )
}
static gboolean
vips_foreign_load_jpeg_buffer_is_a( void *buf, size_t len )
vips_foreign_load_jpeg_buffer_is_a( const void *buf, size_t len )
{
return( vips__isjpeg_buffer( buf, len ) );
}

View File

@ -219,7 +219,7 @@ G_DEFINE_TYPE( VipsForeignLoadMagickBuffer, vips_foreign_load_magick_buffer,
vips_foreign_load_magick_get_type() );
static gboolean
vips_foreign_load_magick_buffer_is_a_buffer ( void* buf, size_t len )
vips_foreign_load_magick_buffer_is_a_buffer( const void *buf, size_t len )
{
VipsImage *t;
int result;

View File

@ -55,12 +55,12 @@ int vips__tiff_read_header( const char *filename, VipsImage *out, int page );
int vips__tiff_read( const char *filename, VipsImage *out,
int page, gboolean readbehind );
gboolean vips__istifftiled( const char *filename );
gboolean vips__istiff_buffer( void *buf, size_t len );
gboolean vips__istiff_buffer( const void *buf, size_t len );
gboolean vips__istiff( const char *filename );
int vips__tiff_read_header_buffer( void *buf, size_t len, VipsImage *out,
int vips__tiff_read_header_buffer( const void *buf, size_t len, VipsImage *out,
int page );
int vips__tiff_read_buffer( void *buf, size_t len, VipsImage *out,
int vips__tiff_read_buffer( const void *buf, size_t len, VipsImage *out,
int page, gboolean readbehind );
#ifdef __cplusplus

View File

@ -224,7 +224,7 @@ typedef struct _ReadTiff {
/* Parameters.
*/
char *filename;
void *buf;
const void *buf;
size_t len;
VipsImage *out;
int page;
@ -1870,7 +1870,7 @@ my_tiff_unmap( thandle_t st, tdata_t start, toff_t len )
}
static ReadTiff *
readtiff_new_buffer( void *buf, size_t len, VipsImage *out, int page,
readtiff_new_buffer( const void *buf, size_t len, VipsImage *out, int page,
gboolean readbehind )
{
ReadTiff *rtiff;
@ -1991,7 +1991,7 @@ vips__istifftiled( const char *filename )
}
gboolean
vips__istiff_buffer( void *buf, size_t len )
vips__istiff_buffer( const void *buf, size_t len )
{
char *str = (char *) buf;
@ -2018,7 +2018,8 @@ vips__istiff( const char *filename )
}
int
vips__tiff_read_header_buffer( void *buf, size_t len, VipsImage *out, int page )
vips__tiff_read_header_buffer( const void *buf, size_t len,
VipsImage *out, int page )
{
ReadTiff *rtiff;
@ -2034,8 +2035,8 @@ vips__tiff_read_header_buffer( void *buf, size_t len, VipsImage *out, int page )
}
int
vips__tiff_read_buffer( void *buf, size_t len, VipsImage *out,
int page, gboolean readbehind )
vips__tiff_read_buffer( const void *buf, size_t len,
VipsImage *out, int page, gboolean readbehind )
{
ReadTiff *rtiff;

View File

@ -48,12 +48,12 @@ int vips__jpeg_write_buffer( VipsImage *in,
gboolean no_subsample, gboolean trellis_quant,
gboolean overshoot_deringing, gboolean optimize_scans );
int vips__isjpeg_buffer( void *buf, size_t len );
int vips__isjpeg_buffer( const void *buf, size_t len );
int vips__isjpeg( const char *filename );
int vips__jpeg_read_file( const char *name, VipsImage *out,
gboolean header_only, int shrink, gboolean fail, gboolean readbehind,
gboolean autorotate );
int vips__jpeg_read_buffer( void *buf, size_t len, VipsImage *out,
int vips__jpeg_read_buffer( const void *buf, size_t len, VipsImage *out,
gboolean header_only, int shrink, int fail, gboolean readbehind,
gboolean autorotate );

View File

@ -147,7 +147,7 @@ typedef struct {
/* For memory input.
*/
char *buffer;
const void *buffer;
size_t length;
size_t read_pos;
@ -614,8 +614,8 @@ vips__png_read( const char *filename, VipsImage *out, gboolean readbehind )
return( 0 );
}
int
vips__png_ispng_buffer( void *buf, size_t len )
gboolean
vips__png_ispng_buffer( const void *buf, size_t len )
{
if( len >= 8 &&
!png_sig_cmp( (png_bytep) buf, 0, 8 ) )
@ -650,7 +650,7 @@ vips_png_read_buffer( png_structp pPng, png_bytep data, png_size_t length )
}
static Read *
read_new_buffer( VipsImage *out, char *buffer, size_t length,
read_new_buffer( VipsImage *out, const void *buffer, size_t length,
gboolean readbehind )
{
Read *read;
@ -677,7 +677,7 @@ read_new_buffer( VipsImage *out, char *buffer, size_t length,
}
int
vips__png_header_buffer( char *buffer, size_t length, VipsImage *out )
vips__png_header_buffer( const void *buffer, size_t length, VipsImage *out )
{
Read *read;
@ -689,7 +689,7 @@ vips__png_header_buffer( char *buffer, size_t length, VipsImage *out )
}
int
vips__png_read_buffer( char *buffer, size_t length, VipsImage *out,
vips__png_read_buffer( const void *buffer, size_t length, VipsImage *out,
gboolean readbehind )
{
Read *read;

View File

@ -37,13 +37,14 @@ extern "C" {
int vips__png_header( const char *name, VipsImage *out );
int vips__png_read( const char *name, VipsImage *out, gboolean readbehind );
int vips__png_ispng_buffer( void *buf, size_t len );
gboolean vips__png_ispng_buffer( const void *buf, size_t len );
int vips__png_ispng( const char *filename );
gboolean vips__png_isinterlaced( const char *filename );
extern const char *vips__png_suffs[];
int vips__png_read_buffer( char *buffer, size_t length, VipsImage *out,
gboolean readbehind );
int vips__png_header_buffer( char *buffer, size_t length, VipsImage *out );
int vips__png_read_buffer( const void *buffer, size_t length,
VipsImage *out, gboolean readbehind );
int vips__png_header_buffer( const void *buffer, size_t length,
VipsImage *out );
int vips__png_write( VipsImage *in, const char *filename,
int compress, int interlace, const char *profile,

View File

@ -37,14 +37,16 @@ extern "C" {
extern const char *vips__webp_suffs[];
int vips__iswebp_buffer( void *buf, size_t len );
int vips__iswebp_buffer( const void *buf, size_t len );
int vips__iswebp( const char *filename );
int vips__webp_read_file_header( const char *name, VipsImage *out );
int vips__webp_read_file( const char *name, VipsImage *out );
int vips__webp_read_buffer_header( void *buf, size_t len, VipsImage *out );
int vips__webp_read_buffer( void *buf, size_t len, VipsImage *out );
int vips__webp_read_buffer_header( const void *buf, size_t len,
VipsImage *out );
int vips__webp_read_buffer( const void *buf, size_t len,
VipsImage *out );
int vips__webp_write_file( VipsImage *out, const char *filename,
int Q, gboolean lossless );

View File

@ -69,10 +69,10 @@ typedef struct {
*/
char *filename;
/* Memory source. We se gint64 rather than size_t since we use
/* Memory source. We use gint64 rather than size_t since we use
* vips_file_length() and vips__mmap() for file sources.
*/
void *data;
const void *data;
gint64 length;
/* If we are opening a file object, the fd.
@ -89,7 +89,7 @@ typedef struct {
} Read;
int
vips__iswebp_buffer( void *buf, size_t len )
vips__iswebp_buffer( const void *buf, size_t len )
{
if( len >= MINIMAL_HEADER &&
WebPGetInfo( buf, MINIMAL_HEADER, NULL, NULL ) )
@ -132,7 +132,7 @@ read_free( Read *read )
}
static Read *
read_new( const char *filename, void *data, size_t length )
read_new( const char *filename, const void *data, size_t length )
{
Read *read;
@ -266,7 +266,7 @@ vips__webp_read_file( const char *filename, VipsImage *out )
}
int
vips__webp_read_buffer_header( void *buf, size_t len, VipsImage *out )
vips__webp_read_buffer_header( const void *buf, size_t len, VipsImage *out )
{
Read *read;
@ -285,7 +285,7 @@ vips__webp_read_buffer_header( void *buf, size_t len, VipsImage *out )
}
int
vips__webp_read_buffer( void *buf, size_t len, VipsImage *out )
vips__webp_read_buffer( const void *buf, size_t len, VipsImage *out )
{
Read *read;

View File

@ -166,7 +166,7 @@ typedef struct _VipsForeignLoadClass {
* This function should return %TRUE if the buffer contains an image of
* this type.
*/
gboolean (*is_a_buffer)( void *data, size_t size );
gboolean (*is_a_buffer)( const void *data, size_t size );
/* Get the flags from a filename.
*
@ -214,11 +214,12 @@ typedef struct _VipsForeignLoadClass {
GType vips_foreign_load_get_type( void );
const char *vips_foreign_find_load( const char *filename );
const char *vips_foreign_find_load_buffer( void *data, size_t size );
const char *vips_foreign_find_load_buffer( const void *data, size_t size );
VipsForeignFlags vips_foreign_flags( const char *loader, const char *filename );
gboolean vips_foreign_is_a( const char *loader, const char *filename );
gboolean vips_foreign_is_a_buffer( const char *loader, void *data, size_t size );
gboolean vips_foreign_is_a_buffer( const char *loader,
const void *data, size_t size );
#define VIPS_TYPE_FOREIGN_SAVE (vips_foreign_save_get_type())
#define VIPS_FOREIGN_SAVE( obj ) \

View File

@ -427,15 +427,17 @@ VipsImage *vips_image_new_from_file( const char *name, ... )
VipsImage *vips_image_new_from_file_RW( const char *filename );
VipsImage *vips_image_new_from_file_raw( const char *filename,
int xsize, int ysize, int bands, guint64 offset );
VipsImage *vips_image_new_from_memory( void *data, size_t size,
VipsImage *vips_image_new_from_memory( const void *data, size_t size,
int width, int height, int bands, VipsBandFormat format );
VipsImage *vips_image_new_from_buffer( void *buf, size_t len,
VipsImage *vips_image_new_from_buffer( const void *buf, size_t len,
const char *option_string, ... )
__attribute__((sentinel));
VipsImage *vips_image_new_matrix( int width, int height );
VipsImage *vips_image_new_matrixv( int width, int height, ... );
VipsImage *vips_image_new_matrix_from_array( int width, int height,
double *array, int size );
const double *array, int size );
VipsImage *vips_image_matrix_from_array( int width, int height,
const double *array, int size );
void vips_image_set_delete_on_close( VipsImage *image,
gboolean delete_on_close );
guint64 vips_get_disc_threshold( void );

View File

@ -127,7 +127,7 @@ char *vips__b64_encode( const unsigned char *data, size_t data_length );
unsigned char *vips__b64_decode( const char *buffer, size_t *data_length );
void *vips__mmap( int fd, int writeable, size_t length, gint64 offset );
int vips__munmap( void *start, size_t length );
int vips__munmap( const void *start, size_t length );
int vips_mapfile( VipsImage * );
int vips_mapfilerw( VipsImage * );
int vips_remapfilerw( VipsImage * );

View File

@ -1873,7 +1873,7 @@ vips_filename_get_options( const char *vips_filename )
* See also: vips_foreign_find_load(), vips_foreign_is_a(),
* vips_image_write_to_file().
*
* Returns: the new #VipsImage, or %NULL on error.
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
*/
VipsImage *
vips_image_new_from_file( const char *name, ... )
@ -1910,7 +1910,7 @@ vips_image_new_from_file( const char *name, ... )
*
* See also: vips_draw_circle().
*
* Returns: the new #VipsImage, or %NULL on error.
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
*/
VipsImage *
vips_image_new_from_file_RW( const char *filename )
@ -1934,7 +1934,7 @@ vips_image_new_from_file_RW( const char *filename )
*
* See also: vips_copy(), vips_rawload(), vips_image_new_from_file().
*
* Returns: the new #VipsImage, or %NULL on error.
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
*/
VipsImage *
vips_image_new_from_file_raw( const char *filename,
@ -1963,7 +1963,7 @@ vips_image_new_from_file_raw( const char *filename,
/**
* vips_image_new_from_memory:
* @data: (array length=size) (element-type guint8) (transfer full): start of memory area
* @data: (array length=size) (element-type guint8) (transfer none): start of memory area
* @size: length of memory area
* @width: image width
* @height: image height
@ -1983,10 +1983,10 @@ vips_image_new_from_file_raw( const char *filename,
*
* See also: vips_image_new(), vips_image_write_to_memory().
*
* Returns: the new #VipsImage, or %NULL on error.
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
*/
VipsImage *
vips_image_new_from_memory( void *data, size_t size,
vips_image_new_from_memory( const void *data, size_t size,
int width, int height, int bands, VipsBandFormat format )
{
VipsImage *image;
@ -2026,7 +2026,7 @@ vips_image_new_from_memory( void *data, size_t size,
/**
* vips_image_new_from_buffer:
* @buf: start of memory buffer
* @buf: (array length=len) (element-type guint8) (transfer none): image data
* @len: length of memory buffer
* @option_string: set of extra options as a string
* @...: %NULL-terminated list of optional named arguments
@ -2046,10 +2046,10 @@ vips_image_new_from_memory( void *data, size_t size,
*
* See also: vips_image_write_to_buffer().
*
* Returns: 0 on success, -1 on error
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
*/
VipsImage *
vips_image_new_from_buffer( void *buf, size_t len,
vips_image_new_from_buffer( const void *buf, size_t len,
const char *option_string, ... )
{
const char *operation_name;
@ -2094,7 +2094,7 @@ vips_image_new_from_buffer( void *buf, size_t len,
*
* See also: vips_image_new_matrixv()
*
* Returns: the new #VipsImage, or %NULL on error.
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
*/
VipsImage *
vips_image_new_matrix( int width, int height )
@ -2138,7 +2138,7 @@ vips_image_new_matrix( int width, int height )
*
* See also: vips_image_new_matrix()
*
* Returns: the new #VipsImage, or %NULL on error.
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
*/
VipsImage *
vips_image_new_matrixv( int width, int height, ... )
@ -2169,11 +2169,11 @@ vips_image_new_matrixv( int width, int height, ... )
*
* A binding-friendly version of vips_image_new_matrixv().
*
* Returns: the new #VipsImage, or %NULL on error.
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
*/
VipsImage *
vips_image_new_matrix_from_array( int width, int height,
double *array, int size )
const double *array, int size )
{
VipsImage *matrix;
int x, y;
@ -2198,6 +2198,26 @@ vips_image_new_matrix_from_array( int width, int height,
return( matrix );
}
/**
* vips_image_matrix_from_array:
* @width: image width
* @height: image height
* @array: (array length=size) (transfer none): array of elements
* @size: number of elements
*
* A renamed vips_image_new_matrix_from_array(). Some gobject bindings do not
* like more than one _new method.
*
* Returns: (transfer full): the new #VipsImage, or %NULL on error.
*/
VipsImage *
vips_image_matrix_from_array( int width, int height,
const double *array, int size )
{
return( vips_image_new_matrix_from_array( width, height,
array, size ) );
}
/**
* vips_image_set_delete_on_close:
* @image: image to set

View File

@ -189,16 +189,16 @@ vips__mmap( int fd, int writeable, size_t length, gint64 offset )
}
int
vips__munmap( void *start, size_t length )
vips__munmap( const void *start, size_t length )
{
#ifdef OS_WIN32
if( !UnmapViewOfFile( start ) ) {
if( !UnmapViewOfFile( (void *) start ) ) {
vips_error_system( GetLastError(), "vips_mapfile",
"%s", _( "unable to UnmapViewOfFile" ) );
return( -1 );
}
#else /*!OS_WIN32*/
if( munmap( start, length ) < 0 ) {
if( munmap( (void *) start, length ) < 0 ) {
vips_error_system( errno, "vips_mapfile",
"%s", _( "unable to munmap file" ) );
return( -1 );