diff --git a/ChangeLog b/ChangeLog index cdfc7394..0f85862b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/cplusplus/examples/avg.cpp b/cplusplus/examples/avg.cpp index 3cd7cae7..c88fa141 100644 --- a/cplusplus/examples/avg.cpp +++ b/cplusplus/examples/avg.cpp @@ -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 -using namespace vips8; +using namespace vips; int main( int argc, char **argv ) diff --git a/cplusplus/examples/embed.cpp b/cplusplus/examples/embed.cpp index 7ca724ab..088f188a 100644 --- a/cplusplus/examples/embed.cpp +++ b/cplusplus/examples/embed.cpp @@ -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 -using namespace vips8; +using namespace vips; int main( int argc, char **argv ) diff --git a/cplusplus/examples/invert.cpp b/cplusplus/examples/invert.cpp index 361abf1b..f8751618 100644 --- a/cplusplus/examples/invert.cpp +++ b/cplusplus/examples/invert.cpp @@ -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 -using namespace vips8; +using namespace vips; int main( int argc, char **argv ) diff --git a/cplusplus/examples/profile.cpp b/cplusplus/examples/profile.cpp new file mode 100644 index 00000000..3c9383ef --- /dev/null +++ b/cplusplus/examples/profile.cpp @@ -0,0 +1,53 @@ +/* + * compile with: + * + * g++ -g -Wall profile.cpp `pkg-config vips-cpp --cflags --libs` + * + */ + +#define DEBUG + +#include + +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 ); +} diff --git a/cplusplus/gen-operators.py b/cplusplus/gen-operators.py index b4a8e6d8..09c31eba 100755 --- a/cplusplus/gen-operators.py +++ b/cplusplus/gen-operators.py @@ -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), diff --git a/cplusplus/include/vips/gen-operators-h.py b/cplusplus/include/vips/gen-operators-h.py index ab69bc0c..44c4fcc3 100755 --- a/cplusplus/include/vips/gen-operators-h.py +++ b/cplusplus/include/vips/gen-operators-h.py @@ -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 );' diff --git a/cplusplus/include/vips/vips-operators.h b/cplusplus/include/vips/vips-operators.h index b1e9538a..301a444f 100644 --- a/cplusplus/include/vips/vips-operators.h +++ b/cplusplus/include/vips/vips-operators.h @@ -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 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 ) diff --git a/cplusplus/vips-operators.cpp b/cplusplus/vips-operators.cpp index 42dddf9e..e8a0687b 100644 --- a/cplusplus/vips-operators.cpp +++ b/cplusplus/vips-operators.cpp @@ -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 ) {