just the cache to fix now

This commit is contained in:
John Cupitt 2012-01-02 15:50:41 +00:00
parent 405b89b000
commit acd8ce277e
7 changed files with 72 additions and 14 deletions

18
TODO
View File

@ -1,9 +1,19 @@
- python/try.py
- Vips.cache_operation_build() is not very wrapper friendly
- have a ref leak
make it work like:
op2 = build(op1)
return NULL on error, returns a new op on success
always unref the old op
- grep for other vips_class_find() problems: do we use it for simple class
lookup anywhere else?
- try looping over operator props and looking up class and instance;
need to be able to get INPUT, OUTPUT, ASSIGNED etc

View File

@ -111,11 +111,11 @@ vips_measure_build( VipsObject *object )
/* left/top/width/height default to the size of the image.
*/
if( !vips_argument_get_assigned( object, "width" ) )
if( !vips_object_get_assigned( object, "width" ) )
g_object_set( object,
"width", vips_image_get_width( measure->in ),
NULL );
if( !vips_argument_get_assigned( object, "height" ) )
if( !vips_object_get_assigned( object, "height" ) )
g_object_set( object,
"height", vips_image_get_height( measure->in ),
NULL );

View File

@ -872,7 +872,7 @@ input_interpolate_init( im_object *obj, char *str )
{
GType type = g_type_from_name( "VipsInterpolate" );
VipsObjectClass *interpolate_class =
VIPS_INTERPOLATE_CLASS( g_type_class_ref( type ) );
VIPS_OBJECT_CLASS( g_type_class_ref( type ) );
VipsObject *object;
g_assert( interpolate_class );

View File

@ -93,14 +93,14 @@ vips_foreign_save_tiff_build( VipsObject *object )
/* Default xres/yres to the values from the image.
*/
if( !vips_argument_get_assigned( object, "xres" ) )
if( !vips_object_get_assigned( object, "xres" ) )
tiff->xres = save->ready->Xres * 10.0;
if( !vips_argument_get_assigned( object, "yres" ) )
if( !vips_object_get_assigned( object, "yres" ) )
tiff->yres = save->ready->Yres * 10.0;
/* resunit param overrides resunit metadata.
*/
if( !vips_argument_get_assigned( object, "resunit" ) &&
if( !vips_object_get_assigned( object, "resunit" ) &&
vips_image_get_typeof( save->ready,
VIPS_META_RESOLUTION_UNIT ) &&
!vips_image_get_string( save->ready,

View File

@ -293,7 +293,8 @@ int vips_object_get_argument( VipsObject *object, const char *name,
GParamSpec **pspec,
VipsArgumentClass **argument_class,
VipsArgumentInstance **argument_instance );
gboolean vips_argument_get_assigned( VipsObject *object, const char *name );
gboolean vips_object_get_assigned( VipsObject *object, const char *name );
VipsArgumentFlags vips_object_get_flags( VipsObject *object, const char *name );
/* We have to loop over an objects args in several places, and we can't always
* use vips_argument_map(), the preferred looper. Have the loop code as a

View File

@ -459,8 +459,15 @@ vips__argument_get_instance( VipsArgumentClass *argument_class,
/**
* vips_object_get_argument: (skip)
* @object: the object to fetch the args from
* @name: arg to fetch
* @pspec: (transfer none): the pspec for this arg
* @argument_class: (transfer none): the argument_class for this arg
* @argument_instance: (transfer none): the argument_instance for this arg
*
* Look up the three things you need to work with a vips argument.
*
* Returns: 0 on success, or -1 on error.
*/
int
vips_object_get_argument( VipsObject *object, const char *name,
@ -497,10 +504,17 @@ vips_object_get_argument( VipsObject *object, const char *name,
return( 0 );
}
/* Convenience: has an argument been assigned.
/**
* vips_object_get_assigned:
* @object: the object to fetch the args from
* @name: arg to fetch
*
* Convenience: has an argument been assigned.
*
* Returns: %TRUE if the arguent has been assigned.
*/
gboolean
vips_argument_get_assigned( VipsObject *object, const char *name )
vips_object_get_assigned( VipsObject *object, const char *name )
{
GParamSpec *pspec;
VipsArgumentClass *argument_class;
@ -513,6 +527,29 @@ vips_argument_get_assigned( VipsObject *object, const char *name )
return( argument_instance->assigned );
}
/**
* vips_object_get_flags:
* @object: the object to fetch the args from
* @name: arg to fetch
*
* Convenience: get the flags for an argument.
*
* Returns: The #VipsArgmentFlags for this argument.
*/
VipsArgumentFlags
vips_object_get_flags( VipsObject *object, const char *name )
{
GParamSpec *pspec;
VipsArgumentClass *argument_class;
VipsArgumentInstance *argument_instance;
if( vips_object_get_argument( object, name,
&pspec, &argument_class, &argument_instance ) )
return( 0 );
return( argument_class->flags );
}
static void
vips_object_clear_member( VipsObject *object, GParamSpec *pspec,
GObject **member )

View File

@ -30,13 +30,23 @@ print 'call operation:'
op = Vips.Operation.new("add")
for prop in op.props:
print 'prop =', prop
print 'prop.name =', prop.name
flags = op.get_flags(prop.name)
if flags & Vips.ArgumentFlags.OUTPUT:
print '\toutput'
if flags & Vips.ArgumentFlags.INPUT:
print '\tinput'
if flags & Vips.ArgumentFlags.REQUIRED:
print '\trequired'
print '\tassigned', op.get_assigned(prop.name)
op.props.left = a
op.props.right = a
if op.build() != 0:
print Vips.error_buffer()
sys.exit(-1)
out = op.props.out
op.unref_outputs()
print 'out.get_format() =', out.get_format()
print 'out.props.format =', out.props.format