Merge pull request #1294 from kleisauke/cpp-const-char

Change 'char *' to 'const char *' in the C++ binding
This commit is contained in:
John Cupitt 2019-04-24 15:27:05 +01:00 committed by GitHub
commit b5b7e75b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 222 additions and 129 deletions

View File

@ -25,7 +25,7 @@
import argparse
from pyvips import Image, Operation, GValue, Error, \
from pyvips import Operation, GValue, Error, \
ffi, gobject_lib, type_map, type_from_name, nickname_find, type_name
# turn a GType into a C++ type
@ -33,7 +33,7 @@ gtype_to_cpp = {
GValue.gbool_type: 'bool',
GValue.gint_type: 'int',
GValue.gdouble_type: 'double',
GValue.gstr_type: 'char *',
GValue.gstr_type: 'const char *',
GValue.refstr_type: 'char *',
GValue.gflags_type: 'int',
GValue.image_type: 'VImage',

View File

@ -1,5 +1,5 @@
// headers for vips operations
// Sun 3 Feb 13:10:05 GMT 2019
// Wed Apr 24 15:50:21 CEST 2019
// this file is generated automatically, do not edit!
/**
@ -164,7 +164,7 @@ VImage affine( std::vector<double> matrix, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage analyzeload( char *filename, VOption *options = 0 );
static VImage analyzeload( const char *filename, VOption *options = 0 );
/**
* Join an array of images.
@ -451,14 +451,14 @@ VImage crop( int left, int top, int width, int height, VOption *options = 0 ) co
* @param options Optional options.
* @return Output image.
*/
static VImage csvload( char *filename, VOption *options = 0 );
static VImage csvload( const char *filename, VOption *options = 0 );
/**
* Save image to csv file.
* @param filename Filename to save to.
* @param options Optional options.
*/
void csvsave( char *filename, VOption *options = 0 ) const;
void csvsave( const char *filename, VOption *options = 0 ) const;
/**
* Calculate de00.
@ -574,7 +574,7 @@ void draw_smudge( int left, int top, int width, int height, VOption *options = 0
* @param filename Filename to save to.
* @param options Optional options.
*/
void dzsave( char *filename, VOption *options = 0 ) const;
void dzsave( const char *filename, VOption *options = 0 ) const;
/**
* Save image to dz buffer.
@ -660,14 +660,14 @@ int find_trim( int *top, int *width, int *height, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage fitsload( char *filename, VOption *options = 0 );
static VImage fitsload( const char *filename, VOption *options = 0 );
/**
* Save image to fits file.
* @param filename Filename to save to.
* @param options Optional options.
*/
void fitssave( char *filename, VOption *options = 0 ) const;
void fitssave( const char *filename, VOption *options = 0 ) const;
/**
* Flatten alpha out of an image.
@ -764,7 +764,7 @@ std::vector<double> getpoint( int x, int y, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage gifload( char *filename, VOption *options = 0 );
static VImage gifload( const char *filename, VOption *options = 0 );
/**
* Load gif with giflib.
@ -810,6 +810,36 @@ static VImage grey( int width, int height, VOption *options = 0 );
*/
VImage grid( int tile_height, int across, int down, VOption *options = 0 ) const;
/**
* Load a heif image.
* @param filename Filename to load from.
* @param options Optional options.
* @return Output image.
*/
static VImage heifload( const char *filename, VOption *options = 0 );
/**
* Load a heif image.
* @param buffer Buffer to load from.
* @param options Optional options.
* @return Output image.
*/
static VImage heifload_buffer( VipsBlob *buffer, VOption *options = 0 );
/**
* Save image in heif format.
* @param filename Filename to load from.
* @param options Optional options.
*/
void heifsave( const char *filename, VOption *options = 0 ) const;
/**
* Save image in heif format.
* @param options Optional options.
* @return Buffer to save to.
*/
VipsBlob *heifsave_buffer( VOption *options = 0 ) const;
/**
* Form cumulative histogram.
* @param options Optional options.
@ -925,7 +955,7 @@ VImage icc_import( VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
VImage icc_transform( char *output_profile, VOption *options = 0 ) const;
VImage icc_transform( const char *output_profile, VOption *options = 0 ) const;
/**
* Make a 1d image where pixel values are indexes.
@ -989,7 +1019,7 @@ VImage join( VImage in2, VipsDirection direction, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage jpegload( char *filename, VOption *options = 0 );
static VImage jpegload( const char *filename, VOption *options = 0 );
/**
* Load jpeg from buffer.
@ -1004,7 +1034,7 @@ static VImage jpegload_buffer( VipsBlob *buffer, VOption *options = 0 );
* @param filename Filename to save to.
* @param options Optional options.
*/
void jpegsave( char *filename, VOption *options = 0 ) const;
void jpegsave( const char *filename, VOption *options = 0 ) const;
/**
* Save image to jpeg buffer.
@ -1057,7 +1087,7 @@ static VImage logmat( double sigma, double min_ampl, VOption *options = 0 );
* @param options Optional options.
* @return Output image.
*/
static VImage magickload( char *filename, VOption *options = 0 );
static VImage magickload( const char *filename, VOption *options = 0 );
/**
* Load buffer with imagemagick.
@ -1072,7 +1102,7 @@ static VImage magickload_buffer( VipsBlob *buffer, VOption *options = 0 );
* @param filename Filename to save to.
* @param options Optional options.
*/
void magicksave( char *filename, VOption *options = 0 ) const;
void magicksave( const char *filename, VOption *options = 0 ) const;
/**
* Save image to magick buffer.
@ -1263,7 +1293,7 @@ VImage math2_const( VipsOperationMath2 math2, std::vector<double> c, VOption *op
* @param options Optional options.
* @return Output image.
*/
static VImage matload( char *filename, VOption *options = 0 );
static VImage matload( const char *filename, VOption *options = 0 );
/**
* Load matrix from file.
@ -1271,7 +1301,7 @@ static VImage matload( char *filename, VOption *options = 0 );
* @param options Optional options.
* @return Output image.
*/
static VImage matrixload( char *filename, VOption *options = 0 );
static VImage matrixload( const char *filename, VOption *options = 0 );
/**
* Print matrix.
@ -1284,7 +1314,7 @@ void matrixprint( VOption *options = 0 ) const;
* @param filename Filename to save to.
* @param options Optional options.
*/
void matrixsave( char *filename, VOption *options = 0 ) const;
void matrixsave( const char *filename, VOption *options = 0 ) const;
/**
* Find image maximum.
@ -1380,14 +1410,14 @@ VImage multiply( VImage right, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage niftiload( char *filename, VOption *options = 0 );
static VImage niftiload( const char *filename, VOption *options = 0 );
/**
* Save image to nifti file.
* @param filename Filename to save to.
* @param options Optional options.
*/
void niftisave( char *filename, VOption *options = 0 ) const;
void niftisave( const char *filename, VOption *options = 0 ) const;
/**
* Load an openexr image.
@ -1395,7 +1425,7 @@ void niftisave( char *filename, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage openexrload( char *filename, VOption *options = 0 );
static VImage openexrload( const char *filename, VOption *options = 0 );
/**
* Load file with openslide.
@ -1403,7 +1433,7 @@ static VImage openexrload( char *filename, VOption *options = 0 );
* @param options Optional options.
* @return Output image.
*/
static VImage openslideload( char *filename, VOption *options = 0 );
static VImage openslideload( const char *filename, VOption *options = 0 );
/**
* Load pdf with libpoppler.
@ -1411,7 +1441,7 @@ static VImage openslideload( char *filename, VOption *options = 0 );
* @param options Optional options.
* @return Output image.
*/
static VImage pdfload( char *filename, VOption *options = 0 );
static VImage pdfload( const char *filename, VOption *options = 0 );
/**
* Load pdf with libpoppler.
@ -1452,7 +1482,7 @@ VImage phasecor( VImage in2, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage pngload( char *filename, VOption *options = 0 );
static VImage pngload( const char *filename, VOption *options = 0 );
/**
* Load png from buffer.
@ -1467,7 +1497,7 @@ static VImage pngload_buffer( VipsBlob *buffer, VOption *options = 0 );
* @param filename Filename to save to.
* @param options Optional options.
*/
void pngsave( char *filename, VOption *options = 0 ) const;
void pngsave( const char *filename, VOption *options = 0 ) const;
/**
* Save image to png buffer.
@ -1482,14 +1512,14 @@ VipsBlob *pngsave_buffer( VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage ppmload( char *filename, VOption *options = 0 );
static VImage ppmload( const char *filename, VOption *options = 0 );
/**
* Save image to ppm file.
* @param filename Filename to save to.
* @param options Optional options.
*/
void ppmsave( char *filename, VOption *options = 0 ) const;
void ppmsave( const char *filename, VOption *options = 0 ) const;
/**
* Premultiply image alpha.
@ -1512,7 +1542,7 @@ VImage profile( VImage *rows, VOption *options = 0 ) const;
* @param options Optional options.
* @return Loaded profile.
*/
static VipsBlob *profile_load( char *name, VOption *options = 0 );
static VipsBlob *profile_load( const char *name, VOption *options = 0 );
/**
* Find image projections.
@ -1543,14 +1573,14 @@ VImage rad2float( VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage radload( char *filename, VOption *options = 0 );
static VImage radload( const char *filename, VOption *options = 0 );
/**
* Save image to radiance file.
* @param filename Filename to save to.
* @param options Optional options.
*/
void radsave( char *filename, VOption *options = 0 ) const;
void radsave( const char *filename, VOption *options = 0 ) const;
/**
* Save image to radiance buffer.
@ -1578,14 +1608,14 @@ VImage rank( int width, int height, int index, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage rawload( char *filename, int width, int height, int bands, VOption *options = 0 );
static VImage rawload( const char *filename, int width, int height, int bands, VOption *options = 0 );
/**
* Save image to raw file.
* @param filename Filename to save to.
* @param options Optional options.
*/
void rawsave( char *filename, VOption *options = 0 ) const;
void rawsave( const char *filename, VOption *options = 0 ) const;
/**
* Write raw image to file descriptor.
@ -1891,7 +1921,7 @@ static VImage sum( std::vector<VImage> in, VOption *options = 0 );
* @param options Optional options.
* @return Output image.
*/
static VImage svgload( char *filename, VOption *options = 0 );
static VImage svgload( const char *filename, VOption *options = 0 );
/**
* Load svg with rsvg.
@ -1906,7 +1936,7 @@ static VImage svgload_buffer( VipsBlob *buffer, VOption *options = 0 );
* @param cmd_format Command to run.
* @param options Optional options.
*/
static void system( char *cmd_format, VOption *options = 0 );
static void system( const char *cmd_format, VOption *options = 0 );
/**
* Make a text image.
@ -1914,7 +1944,7 @@ static void system( char *cmd_format, VOption *options = 0 );
* @param options Optional options.
* @return Output image.
*/
static VImage text( char *text, VOption *options = 0 );
static VImage text( const char *text, VOption *options = 0 );
/**
* Generate thumbnail from file.
@ -1923,7 +1953,7 @@ static VImage text( char *text, VOption *options = 0 );
* @param options Optional options.
* @return Output image.
*/
static VImage thumbnail( char *filename, int width, VOption *options = 0 );
static VImage thumbnail( const char *filename, int width, VOption *options = 0 );
/**
* Generate thumbnail from buffer.
@ -1948,7 +1978,7 @@ VImage thumbnail_image( int width, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage tiffload( char *filename, VOption *options = 0 );
static VImage tiffload( const char *filename, VOption *options = 0 );
/**
* Load tiff from buffer.
@ -1963,7 +1993,7 @@ static VImage tiffload_buffer( VipsBlob *buffer, VOption *options = 0 );
* @param filename Filename to save to.
* @param options Optional options.
*/
void tiffsave( char *filename, VOption *options = 0 ) const;
void tiffsave( const char *filename, VOption *options = 0 ) const;
/**
* Save image to tiff buffer.
@ -2006,14 +2036,14 @@ VImage unpremultiply( VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage vipsload( char *filename, VOption *options = 0 );
static VImage vipsload( const char *filename, VOption *options = 0 );
/**
* Save image to vips file.
* @param filename Filename to save to.
* @param options Optional options.
*/
void vipssave( char *filename, VOption *options = 0 ) const;
void vipssave( const char *filename, VOption *options = 0 ) const;
/**
* Load webp from file.
@ -2021,7 +2051,7 @@ void vipssave( char *filename, VOption *options = 0 ) const;
* @param options Optional options.
* @return Output image.
*/
static VImage webpload( char *filename, VOption *options = 0 );
static VImage webpload( const char *filename, VOption *options = 0 );
/**
* Load webp from buffer.
@ -2036,7 +2066,7 @@ static VImage webpload_buffer( VipsBlob *buffer, VOption *options = 0 );
* @param filename Filename to save to.
* @param options Optional options.
*/
void webpsave( char *filename, VOption *options = 0 ) const;
void webpsave( const char *filename, VOption *options = 0 ) const;
/**
* Save image to webp buffer.

View File

@ -1,5 +1,5 @@
// bodies for vips operations
// Sun 3 Feb 13:09:56 GMT 2019
// Wed Apr 24 15:50:21 CEST 2019
// this file is generated automatically, do not edit!
VImage VImage::CMC2LCh( VOption *options ) const
@ -268,7 +268,7 @@ VImage VImage::affine( std::vector<double> matrix, VOption *options ) const
return( out );
}
VImage VImage::analyzeload( char *filename, VOption *options )
VImage VImage::analyzeload( const char *filename, VOption *options )
{
VImage out;
@ -729,7 +729,7 @@ VImage VImage::crop( int left, int top, int width, int height, VOption *options
return( out );
}
VImage VImage::csvload( char *filename, VOption *options )
VImage VImage::csvload( const char *filename, VOption *options )
{
VImage out;
@ -741,7 +741,7 @@ VImage VImage::csvload( char *filename, VOption *options )
return( out );
}
void VImage::csvsave( char *filename, VOption *options ) const
void VImage::csvsave( const char *filename, VOption *options ) const
{
call( "csvsave",
(options ? options : VImage::option())->
@ -890,7 +890,7 @@ void VImage::draw_smudge( int left, int top, int width, int height, VOption *opt
set( "height", height ) );
}
void VImage::dzsave( char *filename, VOption *options ) const
void VImage::dzsave( const char *filename, VOption *options ) const
{
call( "dzsave",
(options ? options : VImage::option())->
@ -1020,7 +1020,7 @@ int VImage::find_trim( int *top, int *width, int *height, VOption *options ) con
return( left );
}
VImage VImage::fitsload( char *filename, VOption *options )
VImage VImage::fitsload( const char *filename, VOption *options )
{
VImage out;
@ -1032,7 +1032,7 @@ VImage VImage::fitsload( char *filename, VOption *options )
return( out );
}
void VImage::fitssave( char *filename, VOption *options ) const
void VImage::fitssave( const char *filename, VOption *options ) const
{
call( "fitssave",
(options ? options : VImage::option())->
@ -1181,7 +1181,7 @@ std::vector<double> VImage::getpoint( int x, int y, VOption *options ) const
return( out_array );
}
VImage VImage::gifload( char *filename, VOption *options )
VImage VImage::gifload( const char *filename, VOption *options )
{
VImage out;
@ -1260,6 +1260,50 @@ VImage VImage::grid( int tile_height, int across, int down, VOption *options ) c
return( out );
}
VImage VImage::heifload( const char *filename, VOption *options )
{
VImage out;
call( "heifload",
(options ? options : VImage::option())->
set( "out", &out )->
set( "filename", filename ) );
return( out );
}
VImage VImage::heifload_buffer( VipsBlob *buffer, VOption *options )
{
VImage out;
call( "heifload_buffer",
(options ? options : VImage::option())->
set( "out", &out )->
set( "buffer", buffer ) );
return( out );
}
void VImage::heifsave( const char *filename, VOption *options ) const
{
call( "heifsave",
(options ? options : VImage::option())->
set( "in", *this )->
set( "filename", filename ) );
}
VipsBlob *VImage::heifsave_buffer( VOption *options ) const
{
VipsBlob *buffer;
call( "heifsave_buffer",
(options ? options : VImage::option())->
set( "in", *this )->
set( "buffer", &buffer ) );
return( buffer );
}
VImage VImage::hist_cum( VOption *options ) const
{
VImage out;
@ -1444,7 +1488,7 @@ VImage VImage::icc_import( VOption *options ) const
return( out );
}
VImage VImage::icc_transform( char *output_profile, VOption *options ) const
VImage VImage::icc_transform( const char *output_profile, VOption *options ) const
{
VImage out;
@ -1547,7 +1591,7 @@ VImage VImage::join( VImage in2, VipsDirection direction, VOption *options ) con
return( out );
}
VImage VImage::jpegload( char *filename, VOption *options )
VImage VImage::jpegload( const char *filename, VOption *options )
{
VImage out;
@ -1571,7 +1615,7 @@ VImage VImage::jpegload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
void VImage::jpegsave( char *filename, VOption *options ) const
void VImage::jpegsave( const char *filename, VOption *options ) const
{
call( "jpegsave",
(options ? options : VImage::option())->
@ -1649,7 +1693,7 @@ VImage VImage::logmat( double sigma, double min_ampl, VOption *options )
return( out );
}
VImage VImage::magickload( char *filename, VOption *options )
VImage VImage::magickload( const char *filename, VOption *options )
{
VImage out;
@ -1673,7 +1717,7 @@ VImage VImage::magickload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
void VImage::magicksave( char *filename, VOption *options ) const
void VImage::magicksave( const char *filename, VOption *options ) const
{
call( "magicksave",
(options ? options : VImage::option())->
@ -1939,7 +1983,7 @@ VImage VImage::math2_const( VipsOperationMath2 math2, std::vector<double> c, VOp
return( out );
}
VImage VImage::matload( char *filename, VOption *options )
VImage VImage::matload( const char *filename, VOption *options )
{
VImage out;
@ -1951,7 +1995,7 @@ VImage VImage::matload( char *filename, VOption *options )
return( out );
}
VImage VImage::matrixload( char *filename, VOption *options )
VImage VImage::matrixload( const char *filename, VOption *options )
{
VImage out;
@ -1970,7 +2014,7 @@ void VImage::matrixprint( VOption *options ) const
set( "in", *this ) );
}
void VImage::matrixsave( char *filename, VOption *options ) const
void VImage::matrixsave( const char *filename, VOption *options ) const
{
call( "matrixsave",
(options ? options : VImage::option())->
@ -2111,7 +2155,7 @@ VImage VImage::multiply( VImage right, VOption *options ) const
return( out );
}
VImage VImage::niftiload( char *filename, VOption *options )
VImage VImage::niftiload( const char *filename, VOption *options )
{
VImage out;
@ -2123,7 +2167,7 @@ VImage VImage::niftiload( char *filename, VOption *options )
return( out );
}
void VImage::niftisave( char *filename, VOption *options ) const
void VImage::niftisave( const char *filename, VOption *options ) const
{
call( "niftisave",
(options ? options : VImage::option())->
@ -2131,7 +2175,7 @@ void VImage::niftisave( char *filename, VOption *options ) const
set( "filename", filename ) );
}
VImage VImage::openexrload( char *filename, VOption *options )
VImage VImage::openexrload( const char *filename, VOption *options )
{
VImage out;
@ -2143,7 +2187,7 @@ VImage VImage::openexrload( char *filename, VOption *options )
return( out );
}
VImage VImage::openslideload( char *filename, VOption *options )
VImage VImage::openslideload( const char *filename, VOption *options )
{
VImage out;
@ -2155,7 +2199,7 @@ VImage VImage::openslideload( char *filename, VOption *options )
return( out );
}
VImage VImage::pdfload( char *filename, VOption *options )
VImage VImage::pdfload( const char *filename, VOption *options )
{
VImage out;
@ -2218,7 +2262,7 @@ VImage VImage::phasecor( VImage in2, VOption *options ) const
return( out );
}
VImage VImage::pngload( char *filename, VOption *options )
VImage VImage::pngload( const char *filename, VOption *options )
{
VImage out;
@ -2242,7 +2286,7 @@ VImage VImage::pngload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
void VImage::pngsave( char *filename, VOption *options ) const
void VImage::pngsave( const char *filename, VOption *options ) const
{
call( "pngsave",
(options ? options : VImage::option())->
@ -2262,7 +2306,7 @@ VipsBlob *VImage::pngsave_buffer( VOption *options ) const
return( buffer );
}
VImage VImage::ppmload( char *filename, VOption *options )
VImage VImage::ppmload( const char *filename, VOption *options )
{
VImage out;
@ -2274,7 +2318,7 @@ VImage VImage::ppmload( char *filename, VOption *options )
return( out );
}
void VImage::ppmsave( char *filename, VOption *options ) const
void VImage::ppmsave( const char *filename, VOption *options ) const
{
call( "ppmsave",
(options ? options : VImage::option())->
@ -2307,7 +2351,7 @@ VImage VImage::profile( VImage *rows, VOption *options ) const
return( columns );
}
VipsBlob *VImage::profile_load( char *name, VOption *options )
VipsBlob *VImage::profile_load( const char *name, VOption *options )
{
VipsBlob *profile;
@ -2357,7 +2401,7 @@ VImage VImage::rad2float( VOption *options ) const
return( out );
}
VImage VImage::radload( char *filename, VOption *options )
VImage VImage::radload( const char *filename, VOption *options )
{
VImage out;
@ -2369,7 +2413,7 @@ VImage VImage::radload( char *filename, VOption *options )
return( out );
}
void VImage::radsave( char *filename, VOption *options ) const
void VImage::radsave( const char *filename, VOption *options ) const
{
call( "radsave",
(options ? options : VImage::option())->
@ -2404,7 +2448,7 @@ VImage VImage::rank( int width, int height, int index, VOption *options ) const
return( out );
}
VImage VImage::rawload( char *filename, int width, int height, int bands, VOption *options )
VImage VImage::rawload( const char *filename, int width, int height, int bands, VOption *options )
{
VImage out;
@ -2419,7 +2463,7 @@ VImage VImage::rawload( char *filename, int width, int height, int bands, VOptio
return( out );
}
void VImage::rawsave( char *filename, VOption *options ) const
void VImage::rawsave( const char *filename, VOption *options ) const
{
call( "rawsave",
(options ? options : VImage::option())->
@ -2909,7 +2953,7 @@ VImage VImage::sum( std::vector<VImage> in, VOption *options )
return( out );
}
VImage VImage::svgload( char *filename, VOption *options )
VImage VImage::svgload( const char *filename, VOption *options )
{
VImage out;
@ -2933,14 +2977,14 @@ VImage VImage::svgload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
void VImage::system( char *cmd_format, VOption *options )
void VImage::system( const char *cmd_format, VOption *options )
{
call( "system",
(options ? options : VImage::option())->
set( "cmd_format", cmd_format ) );
}
VImage VImage::text( char *text, VOption *options )
VImage VImage::text( const char *text, VOption *options )
{
VImage out;
@ -2952,7 +2996,7 @@ VImage VImage::text( char *text, VOption *options )
return( out );
}
VImage VImage::thumbnail( char *filename, int width, VOption *options )
VImage VImage::thumbnail( const char *filename, int width, VOption *options )
{
VImage out;
@ -2991,7 +3035,7 @@ VImage VImage::thumbnail_image( int width, VOption *options ) const
return( out );
}
VImage VImage::tiffload( char *filename, VOption *options )
VImage VImage::tiffload( const char *filename, VOption *options )
{
VImage out;
@ -3015,7 +3059,7 @@ VImage VImage::tiffload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
void VImage::tiffsave( char *filename, VOption *options ) const
void VImage::tiffsave( const char *filename, VOption *options ) const
{
call( "tiffsave",
(options ? options : VImage::option())->
@ -3082,7 +3126,7 @@ VImage VImage::unpremultiply( VOption *options ) const
return( out );
}
VImage VImage::vipsload( char *filename, VOption *options )
VImage VImage::vipsload( const char *filename, VOption *options )
{
VImage out;
@ -3094,7 +3138,7 @@ VImage VImage::vipsload( char *filename, VOption *options )
return( out );
}
void VImage::vipssave( char *filename, VOption *options ) const
void VImage::vipssave( const char *filename, VOption *options ) const
{
call( "vipssave",
(options ? options : VImage::option())->
@ -3102,7 +3146,7 @@ void VImage::vipssave( char *filename, VOption *options ) const
set( "filename", filename ) );
}
VImage VImage::webpload( char *filename, VOption *options )
VImage VImage::webpload( const char *filename, VOption *options )
{
VImage out;
@ -3126,7 +3170,7 @@ VImage VImage::webpload_buffer( VipsBlob *buffer, VOption *options )
return( out );
}
void VImage::webpsave( char *filename, VOption *options ) const
void VImage::webpsave( const char *filename, VOption *options ) const
{
call( "webpsave",
(options ? options : VImage::option())->

View File

@ -1,48 +1,68 @@
#!/usr/bin/python
#!/usr/bin/env python
# walk vips and generate a list of all operators and their descriptions
# walk vips and generate a list of all operators and their descriptions
# for docs
# this needs pyvips
#
# pip install --user pyvips
# sample output:
# <row>
# <entry>gamma</entry>
# <entry>gamma an image</entry>
# <entry>Gamma an image</entry>
# <entry>vips_gamma()</entry>
# </row>
import gi
gi.require_version('Vips', '8.0')
from gi.repository import Vips, GObject
from pyvips import Operation, Error, \
ffi, type_map, type_from_name, nickname_find
vips_type_operation = GObject.GType.from_name("VipsOperation")
# for VipsOperationFlags
_OPERATION_DEPRECATED = 8
def gen_function(cls):
op = Vips.Operation.new(cls.name)
gtype = Vips.type_find("VipsOperation", cls.name)
nickname = Vips.nickname_find(gtype)
print '<row>'
print ' <entry>%s</entry>' % nickname
print ' <entry>%s</entry>' % op.get_description()
print ' <entry>vips_%s()</entry>' % nickname
print '</row>'
def gen_function(operation_name):
op = Operation.new_from_name(operation_name)
# we have a few synonyms ... don't generate twice
generated = {}
print('<row>')
print(' <entry>{}</entry>'.format(operation_name))
print(' <entry>{}</entry>'.format(op.get_description().capitalize()))
print(' <entry>vips_{}()</entry>'.format(operation_name))
print('</row>')
def gen_function_list(cls):
if not cls.is_abstract():
gtype = Vips.type_find("VipsOperation", cls.name)
nickname = Vips.nickname_find(gtype)
if not nickname in generated:
gen_function(cls)
generated[nickname] = True
if len(cls.children) > 0:
for child in cls.children:
gen_function_list(child)
def gen_function_list():
all_nicknames = []
def add_nickname(gtype, a, b):
nickname = nickname_find(gtype)
try:
# can fail for abstract types
op = Operation.new_from_name(nickname)
# we are only interested in non-deprecated operations
if (op.get_flags() & _OPERATION_DEPRECATED) == 0:
all_nicknames.append(nickname)
except Error:
pass
type_map(gtype, add_nickname)
return ffi.NULL
type_map(type_from_name('VipsOperation'), add_nickname)
# add 'missing' synonyms by hand
all_nicknames.append('crop')
# make list unique and sort
all_nicknames = list(set(all_nicknames))
all_nicknames.sort()
for nickname in all_nicknames:
gen_function(nickname)
if __name__ == '__main__':
gen_function_list(vips_type_operation)
gen_function_list()

View File

@ -181,7 +181,7 @@ int vips_add( VipsImage *left, VipsImage *right, VipsImage **out, ... );
appears in C++ as:
<programlisting language="cpp">
VImage VImage::add( VImage right, VOption *options = 0 );
VImage VImage::add( VImage right, VOption *options ) const
</programlisting>
</para>
@ -312,7 +312,7 @@ int vips_sin( VipsImage *in, VipsImage **out, ... );
and a C++ member function VImage::sin():
<programlisting language="cpp">
VImage VImage::sin( VOption *options = 0 );
VImage VImage::sin( VOption *options = 0 ) const
</programlisting>
</para>
@ -354,8 +354,8 @@ void VImage::set( const char *field, const char *value );
<programlisting language="cpp">
VImage im = VImage::new_from_file( "x.jpg" )
int orientation = atoi( im.get_string( "exif-ifd0-Orientation" ) );
im.set( "exif-ifd0-Orientation", "2" );
int orientation = im.get_int( VIPS_META_ORIENTATION );
im.set( VIPS_META_ORIENTATION, 2 );
im.write_to_file( "y.jpg" );
</programlisting>
</para>
@ -372,11 +372,10 @@ im.write_to_file( "y.jpg" );
</para>
<para>
The member function for each operation, for example VImage::add(), is
generated by a small Python program called <code>gen-operators.py</code>,
and its companion, <code>gen-operators-h.py</code> to generate the
headers. If you write a new VIPS operator, you'll need to rerun these
programs to make the new member function.
The member definition and declaration for each operation, for example
VImage::add(), is generated by a small Python program called
<code>gen-operators.py</code>. If you write a new VIPS operator, you'll
need to rerun this program to make it visible in the C++ interface.
</para>
<para>
@ -384,17 +383,17 @@ im.write_to_file( "y.jpg" );
The one for VImage::add() looks like this:
<programlisting language="cpp">
VImage VImage::add(VImage right, VOption *options)
VImage VImage::add( VImage right, VOption *options ) const
{
VImage out;
VImage out;
call("add" ,
(options ? options : VImage::option()) ->
set("out", &amp;out) ->
set("left", *this) ->
set("right", right));
call("add",
(options ? options : VImage::option())->
set("out", &amp;out)->
set("left", *this)->
set("right", right));
return out;
return out;
}
</programlisting>