rename function members

some function members were not named with a trailing _fn, causing
confusion
This commit is contained in:
John Cupitt 2011-11-02 09:22:30 +00:00
parent 8ec4dbcedc
commit f2d9001cce
7 changed files with 82 additions and 65 deletions

16
TODO
View File

@ -31,6 +31,22 @@ it's the 'stop' member of SinkThreadState
return( 0 );
}
argh we have ->stop (a bool) and ->stop (a function)
rename the function as stop_fn
sstate is the "state" member of VipsThread
which is created by the ->start member of the thread
which is set by vips_threadpool_run()
which is vips_thread_state_new(), see vips_sink_memory()
which creates a VipsThreadState
so .. move ->stop from SinkThreadState into the base class, VipsThreadState

View File

@ -44,11 +44,11 @@ typedef int (*VipsGenerateFn)( VipsRegion *out,
void *seq, void *a, void *b, gboolean *stop );
typedef int (*VipsStopFn)( void *seq, void *a, void *b );
int vips_sink( VipsImage *im,
VipsStartFn start, VipsGenerateFn generate, VipsStopFn stop,
VipsStartFn start_fn, VipsGenerateFn generate_fn, VipsStopFn stop_fn,
void *a, void *b );
int vips_sink_tile( VipsImage *im,
int tile_width, int tile_height,
VipsStartFn start, VipsGenerateFn generate, VipsStopFn stop,
VipsStartFn start_fn, VipsGenerateFn generate_fn, VipsStopFn stop_fn,
void *a, void *b );
typedef void (*VipsSinkNotify)( VipsImage *im, VipsRect *rect, void *a );
@ -69,7 +69,7 @@ VipsImage **vips_allocate_input_array( VipsImage *out, ... )
__attribute__((sentinel));
int vips_image_generate( VipsImage *im,
VipsStartFn start, VipsGenerateFn generate, VipsStopFn stop,
VipsStartFn start_fn, VipsGenerateFn generate_fn, VipsStopFn stop_fn,
void *a, void *b
);

View File

@ -297,9 +297,9 @@ typedef struct _VipsImage {
/* Partial image stuff. All these fields are initialised
* to NULL and ignored unless set by vips_image_generate() etc.
*/
void *(*start)(); /* user-supplied start function */
int (*generate)(); /* user-supplied generate function */
int (*stop)(); /* user-supplied stop function */
void *(*start_fn)(); /* user-supplied start function */
int (*generate_fn)(); /* user-supplied generate function */
int (*stop_fn)(); /* user-supplied stop function */
void *client1; /* user arguments */
void *client2;
GMutex *sslock; /* start-stop lock */

View File

@ -567,9 +567,9 @@ write_vips( VipsRegion *region, VipsRect *area, void *a, void *b )
/**
* vips_image_generate:
* @image: generate this image
* @start: start sequences with this function
* @generate: generate pixels with this function
* @stop: stop sequences with this function
* @start_fn: start sequences with this function
* @generate_fn: generate pixels with this function
* @stop_fn: stop sequences with this function
* @a: user data
* @b: user data
*
@ -591,14 +591,14 @@ write_vips( VipsRegion *region, VipsRect *area, void *a, void *b )
*/
int
vips_image_generate( VipsImage *image,
VipsStartFn start, VipsGenerateFn generate, VipsStopFn stop,
VipsStartFn start_fn, VipsGenerateFn generate_fn, VipsStopFn stop_fn,
void *a, void *b )
{
int res;
VIPS_DEBUG_MSG( "vips_image_generate: %p\n", image );
g_assert( generate );
g_assert( generate_fn );
g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) );
if( !image->hint_set ) {
@ -618,17 +618,17 @@ vips_image_generate( VipsImage *image,
case VIPS_IMAGE_PARTIAL:
/* Output to partial image. Just attach functions and return.
*/
if( image->generate ||
image->start ||
image->stop ) {
if( image->generate_fn ||
image->start_fn ||
image->stop_fn ) {
vips_error( "VipsImage",
"%s", _( "generate() called twice" ) );
return( -1 );
}
image->start = start;
image->generate = generate;
image->stop = stop;
image->start_fn = start_fn;
image->generate_fn = generate_fn;
image->stop_fn = stop_fn;
image->client1 = a;
image->client2 = b;
@ -643,9 +643,9 @@ vips_image_generate( VipsImage *image,
case VIPS_IMAGE_OPENOUT:
/* Eval now .. sanity check.
*/
if( image->generate ||
image->start ||
image->stop ) {
if( image->generate_fn ||
image->start_fn ||
image->stop_fn ) {
vips_error( "VipsImage",
"%s", _( "generate() called twice" ) );
return( -1 );
@ -653,9 +653,9 @@ vips_image_generate( VipsImage *image,
/* Attach callbacks.
*/
image->start = start;
image->generate = generate;
image->stop = stop;
image->start_fn = start_fn;
image->generate_fn = generate_fn;
image->stop_fn = stop_fn;
image->client1 = a;
image->client2 = b;

View File

@ -185,9 +185,9 @@ vips_image_finalize( GObject *gobject )
/* Junk generate functions.
*/
image->start = NULL;
image->generate = NULL;
image->stop = NULL;
image->start_fn = NULL;
image->generate_fn = NULL;
image->stop_fn = NULL;
image->client1 = NULL;
image->client2 = NULL;
@ -2095,7 +2095,7 @@ vips_image_wio_output( VipsImage *image )
case VIPS_IMAGE_PARTIAL:
/* Make sure nothing is attached.
*/
if( image->generate ) {
if( image->generate_fn ) {
vips_error( "vips_image_wio_output",
"%s", _( "image already written" ) );
return( -1 );
@ -2213,16 +2213,16 @@ vips_image_pio_input( VipsImage *image )
/* Should be no generate functions now.
*/
image->start = NULL;
image->generate = NULL;
image->stop = NULL;
image->start_fn = NULL;
image->generate_fn = NULL;
image->stop_fn = NULL;
break;
case VIPS_IMAGE_PARTIAL:
/* Should have had generate functions attached.
*/
if( !image->generate ) {
if( !image->generate_fn ) {
vips_error( "vips_image_pio_input",
"%s", _( "no image data" ) );
return( -1 );
@ -2284,7 +2284,7 @@ vips_image_pio_output( VipsImage *image )
break;
case VIPS_IMAGE_PARTIAL:
if( image->generate ) {
if( image->generate_fn ) {
vips_error( "im_poutcheck",
"%s", _( "image already written" ) );
return( -1 );

View File

@ -201,10 +201,10 @@ vips__region_start( VipsRegion *region )
{
VipsImage *image = region->im;
if( !region->seq && image->start ) {
if( !region->seq && image->start_fn ) {
g_mutex_lock( image->sslock );
region->seq =
image->start( image, image->client1, image->client2 );
region->seq = image->start_fn( image,
image->client1, image->client2 );
g_mutex_unlock( image->sslock );
if( !region->seq ) {
@ -225,11 +225,11 @@ vips__region_stop( VipsRegion *region )
{
IMAGE *image = region->im;
if( region->seq && image->stop ) {
if( region->seq && image->stop_fn ) {
int result;
g_mutex_lock( image->sslock );
result = image->stop( region->seq,
result = image->stop_fn( region->seq,
image->client1, image->client2 );
g_mutex_unlock( image->sslock );
@ -321,7 +321,7 @@ vips_region_sanity( VipsObject *object, VipsBuf *buf )
case VIPS_IMAGE_PARTIAL:
/* Start and stop can be NULL, but not generate.
*/
if( !region->im->generate )
if( !region->im->generate_fn )
vips_buf_appends( buf, "generate NULL in partial\n" );
break;
@ -796,7 +796,7 @@ int
vips_region_fill( VipsRegion *reg, VipsRect *r, VipsRegionFillFn fn, void *a )
{
g_assert( reg->im->dtype == VIPS_IMAGE_PARTIAL );
g_assert( reg->im->generate );
g_assert( reg->im->generate_fn );
/* Should have local memory.
*/
@ -986,7 +986,7 @@ vips_region_generate( VipsRegion *reg )
/* Ask for evaluation.
*/
if( im->generate( reg, reg->seq, im->client1, im->client2 ) )
if( im->generate_fn( reg, reg->seq, im->client1, im->client2 ) )
return( -1 );
return( 0 );
@ -1093,7 +1093,7 @@ vips_region_prepare_to_generate( VipsRegion *reg,
IMAGE *im = reg->im;
char *p;
if( !im->generate ) {
if( !im->generate_fn ) {
vips_error( "vips_region_prepare_to",
"%s", _( "incomplete header" ) );
return( -1 );
@ -1248,7 +1248,7 @@ vips_region_prepare_to( VipsRegion *reg,
/* Could be either input or output. If there is a generate
* function, we are outputting.
*/
if( im->generate ) {
if( im->generate_fn ) {
if( vips_region_prepare_to_generate( reg,
dest, &final, x, y ) )
return( -1 );

View File

@ -61,9 +61,9 @@ typedef struct _Sink {
/* Call params.
*/
VipsStartFn start;
VipsGenerateFn generate;
VipsStopFn stop;
VipsStartFn start_fn;
VipsGenerateFn generate_fn;
VipsStopFn stop_fn;
void *a;
void *b;
} Sink;
@ -99,10 +99,10 @@ G_DEFINE_TYPE( SinkThreadState, sink_thread_state, VIPS_TYPE_THREAD_STATE );
static int
sink_call_stop( Sink *sink, SinkThreadState *state )
{
if( state->seq && sink->stop ) {
if( state->seq && sink->stop_fn ) {
VIPS_DEBUG_MSG( "sink_call_stop: state = %p\n", state );
if( sink->stop( state->seq, sink->a, sink->b ) ) {
if( sink->stop_fn( state->seq, sink->a, sink->b ) ) {
SinkBase *sink_base = (SinkBase *) sink;
vips_error( "vips_sink",
@ -134,10 +134,10 @@ sink_thread_state_dispose( GObject *gobject )
static int
sink_call_start( Sink *sink, SinkThreadState *state )
{
if( !state->seq && sink->start ) {
if( !state->seq && sink->start_fn ) {
VIPS_DEBUG_MSG( "sink_call_start: state = %p\n", state );
state->seq = sink->start( sink->t, sink->a, sink->b );
state->seq = sink->start_fn( sink->t, sink->a, sink->b );
if( !state->seq ) {
SinkBase *sink_base = (SinkBase *) sink;
@ -221,17 +221,17 @@ vips_sink_base_init( SinkBase *sink_base, VipsImage *image )
static int
sink_init( Sink *sink,
VipsImage *image,
VipsStartFn start, VipsGenerateFn generate, VipsStopFn stop,
VipsStartFn start_fn, VipsGenerateFn generate_fn, VipsStopFn stop_fn,
void *a, void *b )
{
g_assert( generate );
g_assert( generate_fn );
vips_sink_base_init( &sink->sink_base, image );
sink->t = NULL;
sink->start = start;
sink->generate = generate;
sink->stop = stop;
sink->start_fn = start_fn;
sink->generate_fn = generate_fn;
sink->stop_fn = stop_fn;
sink->a = a;
sink->b = b;
@ -299,7 +299,7 @@ sink_work( VipsThreadState *state, void *a )
Sink *sink = (Sink *) a;
if( vips_region_prepare( sstate->reg, &state->pos ) ||
sink->generate( sstate->reg, sstate->seq,
sink->generate_fn( sstate->reg, sstate->seq,
sink->a, sink->b, &sstate->stop ) )
return( -1 );
@ -330,9 +330,9 @@ vips_sink_base_progress( void *a )
* @im: scan over this image
* @tile_width: tile width
* @tile_height: tile height
* @start: start sequences with this function
* @generate: generate pixels with this function
* @stop: stop sequences with this function
* @start_fn: start sequences with this function
* @generate_fn: generate pixels with this function
* @stop_fn: stop sequences with this function
* @a: user data
* @b: user data
*
@ -352,7 +352,7 @@ vips_sink_base_progress( void *a )
int
vips_sink_tile( VipsImage *im,
int tile_width, int tile_height,
VipsStartFn start, VipsGenerateFn generate, VipsStopFn stop,
VipsStartFn start_fn, VipsGenerateFn generate_fn, VipsStopFn stop_fn,
void *a, void *b )
{
Sink sink;
@ -365,7 +365,7 @@ vips_sink_tile( VipsImage *im,
*/
im->Bbits = vips_format_sizeof( im->BandFmt ) << 3;
if( sink_init( &sink, im, start, generate, stop, a, b ) )
if( sink_init( &sink, im, start_fn, generate_fn, stop_fn, a, b ) )
return( -1 );
if( tile_width > 0 ) {
@ -395,9 +395,9 @@ vips_sink_tile( VipsImage *im,
/**
* vips_sink:
* @im: scan over this image
* @start: start sequences with this function
* @generate: generate pixels with this function
* @stop: stop sequences with this function
* @start_fn: start sequences with this function
* @generate_fn: generate pixels with this function
* @stop_fn: stop sequences with this function
* @a: user data
* @b: user data
*
@ -414,8 +414,9 @@ vips_sink_tile( VipsImage *im,
*/
int
vips_sink( VipsImage *im,
VipsStartFn start, VipsGenerateFn generate, VipsStopFn stop,
VipsStartFn start_fn, VipsGenerateFn generate_fn, VipsStopFn stop_fn,
void *a, void *b )
{
return( vips_sink_tile( im, -1, -1, start, generate, stop, a, b ) );
return( vips_sink_tile( im, -1, -1,
start_fn, generate_fn, stop_fn, a, b ) );
}