required C++ output params were broken

see https://github.com/jcupitt/libvips/pull/213

this now works:

        VImage rows;
	VImage cols = in.profile( &rows );
This commit is contained in:
John Cupitt 2015-01-06 11:51:53 +00:00
parent ca9cab48cc
commit 6440830315
9 changed files with 85 additions and 34 deletions

View File

@ -1,4 +1,5 @@
30/12/14 started 7.42.2
- C++ required output params were broken, thanks Lovell
- allow c++ set enum from string
- display param default and range in usage
- better docs

View File

@ -1,7 +1,7 @@
/*
* compile with:
*
* g++ -g -Wall avg.cc `pkg-config vips-cpp --cflags --libs`
* g++ -g -Wall avg.cpp `pkg-config vips-cpp --cflags --libs`
*
*/
@ -9,7 +9,7 @@
#include <vips/vips8>
using namespace vips8;
using namespace vips;
int
main( int argc, char **argv )

View File

@ -1,7 +1,7 @@
/*
* compile with:
*
* g++ -g -Wall embed.cc `pkg-config vips-cpp --cflags --libs`
* g++ -g -Wall embed.cpp `pkg-config vips-cpp --cflags --libs`
*
*/
@ -9,7 +9,7 @@
#include <vips/vips8>
using namespace vips8;
using namespace vips;
int
main( int argc, char **argv )

View File

@ -1,7 +1,7 @@
/*
* compile with:
*
* g++ -g -Wall invert.cc `pkg-config vips-cpp --cflags --libs`
* g++ -g -Wall invert.cpp `pkg-config vips-cpp --cflags --libs`
*
*/
@ -9,7 +9,7 @@
#include <vips/vips8>
using namespace vips8;
using namespace vips;
int
main( int argc, char **argv )

View File

@ -0,0 +1,53 @@
/*
* compile with:
*
* g++ -g -Wall profile.cpp `pkg-config vips-cpp --cflags --libs`
*
*/
#define DEBUG
#include <vips/vips8>
using namespace vips;
int
main( int argc, char **argv )
{
GOptionContext *context;
GOptionGroup *main_group;
GError *error = NULL;
if( vips_init( argv[0] ) )
vips_error_exit( NULL );
context = g_option_context_new( "" );
main_group = g_option_group_new( NULL, NULL, NULL, NULL, NULL );
g_option_context_set_main_group( context, main_group );
g_option_context_add_group( context, vips_get_option_group() );
if( !g_option_context_parse( context, &argc, &argv, &error ) ) {
if( error ) {
fprintf( stderr, "%s\n", error->message );
g_error_free( error );
}
vips_error_exit( NULL );
}
{
VImage in = VImage::new_from_file( argv[1] );
VImage rows;
VImage cols = in.profile( &rows );
rows.write_to_file( argv[2] );
cols.write_to_file( argv[3] );
}
vips_shutdown();
return( 0 );
}

View File

@ -104,7 +104,7 @@ def find_first_output(op, required):
def cppize(name):
return re.sub('-', '_', name)
def gen_arg_list(required):
def gen_arg_list(op, required):
first = True
for prop in required:
if not first:
@ -113,6 +113,12 @@ def gen_arg_list(required):
first = False
print get_ctype(prop),
# output params are passed by reference
flags = op.get_argument_flags(prop.name)
if flags & Vips.ArgumentFlags.OUTPUT:
print '*',
print cppize(prop.name),
if not first:
@ -142,7 +148,7 @@ def gen_operation(cls):
print 'VImage::%s(' % nickname,
gen_arg_list(required)
gen_arg_list(op, required)
print ')'
print ' throw( VError )'
@ -167,7 +173,7 @@ def gen_operation(cls):
else:
flags = op.get_argument_flags(prop.name)
arg = cppize(prop.name)
if flags & Vips.ArgumentFlags.OUTPUT:
if flags & Vips.ArgumentFlags.OUTPUT and prop == result:
arg = '&' + arg
print 'set( "%s", %s )' % (prop.name, arg),

View File

@ -94,7 +94,7 @@ def find_first_output(op, required):
def cppize(name):
return re.sub('-', '_', name)
def gen_arg_list(required):
def gen_arg_list(op, required):
first = True
for prop in required:
if not first:
@ -103,6 +103,12 @@ def gen_arg_list(required):
first = False
print get_ctype(prop),
# output params are passed by reference
flags = op.get_argument_flags(prop.name)
if flags & Vips.ArgumentFlags.OUTPUT:
print '*',
print cppize(prop.name),
if not first:
@ -136,7 +142,7 @@ def gen_operation(cls):
print '%s(' % nickname,
gen_arg_list(required)
gen_arg_list(op, required)
print ')'
print ' throw( VError );'

View File

@ -1,5 +1,5 @@
// headers for vips operations
// Thu Dec 18 11:24:18 GMT 2014
// Tue Jan 6 11:41:51 GMT 2015
// this file is generated automatically, do not edit!
static void system( char * cmd_format , VOption *options = 0 )
@ -70,9 +70,9 @@ VImage hough_line( VOption *options = 0 )
throw( VError );
VImage hough_circle( VOption *options = 0 )
throw( VError );
VImage project( VImage rows , VOption *options = 0 )
VImage project( VImage * rows , VOption *options = 0 )
throw( VError );
VImage profile( VImage rows , VOption *options = 0 )
VImage profile( VImage * rows , VOption *options = 0 )
throw( VError );
VImage measure( int h , int v , VOption *options = 0 )
throw( VError );
@ -80,8 +80,6 @@ std::vector<double> getpoint( int x , int y , VOption *options = 0 )
throw( VError );
VImage copy( VOption *options = 0 )
throw( VError );
VImage blockcache( VOption *options = 0 )
throw( VError );
VImage tilecache( VOption *options = 0 )
throw( VError );
VImage linecache( VOption *options = 0 )

View File

@ -1,5 +1,5 @@
// bodies for vips operations
// Thu Dec 18 11:24:06 GMT 2014
// Tue Jan 6 11:44:30 GMT 2015
// this file is generated automatically, do not edit!
void VImage::system( char * cmd_format , VOption *options )
@ -467,7 +467,7 @@ VImage VImage::hough_circle( VOption *options )
return( out );
}
VImage VImage::project( VImage rows , VOption *options )
VImage VImage::project( VImage * rows , VOption *options )
throw( VError )
{
VImage columns;
@ -476,12 +476,12 @@ VImage VImage::project( VImage rows , VOption *options )
(options ? options : VImage::option()) ->
set( "in", *this ) ->
set( "columns", &columns ) ->
set( "rows", &rows ) );
set( "rows", rows ) );
return( columns );
}
VImage VImage::profile( VImage rows , VOption *options )
VImage VImage::profile( VImage * rows , VOption *options )
throw( VError )
{
VImage columns;
@ -490,7 +490,7 @@ VImage VImage::profile( VImage rows , VOption *options )
(options ? options : VImage::option()) ->
set( "in", *this ) ->
set( "columns", &columns ) ->
set( "rows", &rows ) );
set( "rows", rows ) );
return( columns );
}
@ -538,19 +538,6 @@ VImage VImage::copy( VOption *options )
return( out );
}
VImage VImage::blockcache( VOption *options )
throw( VError )
{
VImage out;
call( "blockcache" ,
(options ? options : VImage::option()) ->
set( "out", &out ) ->
set( "in", *this ) );
return( out );
}
VImage VImage::tilecache( VOption *options )
throw( VError )
{