diff --git a/ChangeLog b/ChangeLog index 139d40ce..98ba7bd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -65,6 +65,7 @@ vips_image_new_from_file() etc. - VipsFormat is deprecated - remove outchecks from documented API +- support gobject-introspection 12/10/11 started 7.26.6 - NOCACHE was not being set correctly on OS X causing performance diff --git a/TODO b/TODO index 9500e6c0..b4962d0c 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,10 @@ -- revisit gio test prog and try to make a nice binding +- python/try.py + + - have a ref leak + + - try looping over operator props and looking up class and instance; + need to be able to get INPUT, OUTPUT, ASSIGNED etc + @@ -10,7 +16,8 @@ - foreign docs come up as "VipsForeignSave", annoying, why? -- we can no longer have round brackets in filenames, argh +- we can no longer have round brackets in filenames, argh, maybe only allow + []{} to enclose args - add something to parse option sets backwards, so only trailing {}()[] are seen diff --git a/libvips/include/vips/object.h b/libvips/include/vips/object.h index 0b0e2de5..93ea17ee 100644 --- a/libvips/include/vips/object.h +++ b/libvips/include/vips/object.h @@ -50,6 +50,7 @@ typedef struct _VipsObjectClass VipsObjectClass; * @VIPS_ARGUMENT_REQUIRED: must be set in the constructor * @VIPS_ARGUMENT_CONSTRUCT: can only be set in the constructor * @VIPS_ARGUMENT_SET_ONCE: can only be set once + * @VIPS_ARGUMENT_SET_ALWAYS: don't do use-before-set checks * @VIPS_ARGUMENT_INPUT: is an input argument (one we depend on) * @VIPS_ARGUMENT_OUTPUT: is an output argument (depends on us) * @@ -59,14 +60,20 @@ typedef struct _VipsObjectClass VipsObjectClass; * * Input gobjects are automatically reffed, output gobjects automatically ref * us. We also automatically watch for "destroy" and unlink. + * + * @VIPS_ARGUMENT_SET_ALWAYS is handy for arguments which are set from C. For + * example, VipsImage::width is a property that gives access to the Xsize + * member of struct _VipsImage. We default its 'assigned' to TRUE + * since the field is always set directly by C. */ typedef enum { VIPS_ARGUMENT_NONE = 0, VIPS_ARGUMENT_REQUIRED = 1, VIPS_ARGUMENT_CONSTRUCT = 2, VIPS_ARGUMENT_SET_ONCE = 4, - VIPS_ARGUMENT_INPUT = 8, - VIPS_ARGUMENT_OUTPUT = 16 + VIPS_ARGUMENT_SET_ALWAYS = 8, + VIPS_ARGUMENT_INPUT = 16, + VIPS_ARGUMENT_OUTPUT = 32 } VipsArgumentFlags; /* Useful flag combinations. User-visible ones are: diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 665085c2..b9086cf2 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -480,6 +480,7 @@ vips_argument_flags_get_type( void ) {VIPS_ARGUMENT_REQUIRED, "VIPS_ARGUMENT_REQUIRED", "required"}, {VIPS_ARGUMENT_CONSTRUCT, "VIPS_ARGUMENT_CONSTRUCT", "construct"}, {VIPS_ARGUMENT_SET_ONCE, "VIPS_ARGUMENT_SET_ONCE", "set-once"}, + {VIPS_ARGUMENT_SET_ALWAYS, "VIPS_ARGUMENT_SET_ALWAYS", "set-always"}, {VIPS_ARGUMENT_INPUT, "VIPS_ARGUMENT_INPUT", "input"}, {VIPS_ARGUMENT_OUTPUT, "VIPS_ARGUMENT_OUTPUT", "output"}, {0, NULL, NULL} diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index da75ecb1..84a8de35 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -838,70 +838,70 @@ vips_image_class_init( VipsImageClass *class ) VIPS_ARG_INT( class, "width", 2, _( "Width" ), _( "Image width in pixels" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, Xsize ), 0, 1000000, 0 ); VIPS_ARG_INT( class, "height", 3, _( "Height" ), _( "Image height in pixels" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, Ysize ), 0, 1000000, 0 ); VIPS_ARG_INT( class, "bands", 4, _( "Bands" ), _( "Number of bands in image" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, Bands ), 0, 1000000, 0 ); VIPS_ARG_ENUM( class, "format", 5, _( "Format" ), _( "Pixel format in image" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, BandFmt ), VIPS_TYPE_BAND_FORMAT, VIPS_FORMAT_UCHAR ); VIPS_ARG_ENUM( class, "coding", 6, _( "Coding" ), _( "Pixel coding" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, Coding ), VIPS_TYPE_CODING, VIPS_CODING_NONE ); VIPS_ARG_ENUM( class, "interpretation", 7, _( "Interpretation" ), _( "Pixel interpretation" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, Type ), VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_MULTIBAND ); VIPS_ARG_DOUBLE( class, "xres", 8, _( "Xres" ), _( "Horizontal resolution in pixels/mm" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, Xres ), 0, 1000000, 0 ); VIPS_ARG_DOUBLE( class, "yres", 9, _( "Yres" ), _( "Vertical resolution in pixels/mm" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, Yres ), 0, 1000000, 0 ); VIPS_ARG_INT( class, "xoffset", 10, _( "Xoffset" ), _( "Horizontal offset of origin" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, Xoffset ), -1000000, 1000000, 0 ); VIPS_ARG_INT( class, "yoffset", 11, _( "Yoffset" ), _( "Vertical offset of origin" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, Yoffset ), -1000000, 1000000, 0 ); @@ -922,7 +922,7 @@ vips_image_class_init( VipsImageClass *class ) VIPS_ARG_BOOL( class, "kill", 14, _( "Kill" ), _( "Block evaluation on this image" ), - VIPS_ARGUMENT_NONE, + VIPS_ARGUMENT_SET_ALWAYS, G_STRUCT_OFFSET( VipsImage, kill ), FALSE ); diff --git a/libvips/iofuncs/object.c b/libvips/iofuncs/object.c index 77cf6573..7993e643 100644 --- a/libvips/iofuncs/object.c +++ b/libvips/iofuncs/object.c @@ -426,7 +426,11 @@ vips_argument_init( VipsObject *object ) ((VipsArgument *) argument_instance)->pspec = pspec; argument_instance->argument_class = argument_class; argument_instance->object = object; - argument_instance->assigned = FALSE; + /* SET_ALWAYS args default to assigned. + */ + argument_instance->assigned = + argument_class->flags & + VIPS_ARGUMENT_SET_ALWAYS; argument_instance->close_id = 0; vips_argument_table_replace( object->argument_table, @@ -486,8 +490,7 @@ vips_object_get_argument( VipsObject *object, const char *name, !(*argument_instance = vips__argument_get_instance( *argument_class, object )) ) { vips_error( VIPS_OBJECT_CLASS( class )->nickname, - _( "vips argument `%s' has no instance" ), - G_OBJECT_TYPE_NAME( object ), name ); + _( "vips argument `%s' has no instance" ), name ); return( -1 ); } @@ -943,9 +946,10 @@ vips_object_set_property( GObject *gobject, *member = g_value_dup_boxed( value ); } else { - g_warning( "%s: %s unimplemented property type %s", + g_warning( "%s: %s.%s unimplemented property type %s", G_STRLOC, G_OBJECT_TYPE_NAME( gobject ), + g_param_spec_get_name( pspec ), g_type_name( G_PARAM_SPEC_VALUE_TYPE( pspec ) ) ); } @@ -976,9 +980,10 @@ vips_object_get_property( GObject *gobject, g_assert( ((VipsArgument *) argument_class)->pspec == pspec ); if( !argument_instance->assigned ) { - g_warning( "%s: %s attempt to read unset property %s", + g_warning( "%s: %s.%s attempt to read unset %s property", G_STRLOC, G_OBJECT_TYPE_NAME( gobject ), + g_param_spec_get_name( pspec ), g_type_name( G_PARAM_SPEC_VALUE_TYPE( pspec ) ) ); return; } @@ -1041,9 +1046,10 @@ vips_object_get_property( GObject *gobject, g_value_set_boxed( value, *member ); } else { - g_warning( "%s: %s unimplemented property type %s", + g_warning( "%s: %s.%s unimplemented property type %s", G_STRLOC, G_OBJECT_TYPE_NAME( gobject ), + g_param_spec_get_name( pspec ), g_type_name( G_PARAM_SPEC_VALUE_TYPE( pspec ) ) ); } } diff --git a/python/README b/python/old/README similarity index 100% rename from python/README rename to python/old/README diff --git a/python/finalizable.py b/python/old/finalizable.py similarity index 100% rename from python/finalizable.py rename to python/old/finalizable.py diff --git a/python/test.py b/python/old/test.py similarity index 100% rename from python/test.py rename to python/old/test.py diff --git a/python/vipsimage.py b/python/old/vipsimage.py similarity index 100% rename from python/vipsimage.py rename to python/old/vipsimage.py diff --git a/python/vipsobject.py b/python/old/vipsobject.py similarity index 100% rename from python/vipsobject.py rename to python/old/vipsobject.py diff --git a/python/vipsoperation.py b/python/old/vipsoperation.py similarity index 100% rename from python/vipsoperation.py rename to python/old/vipsoperation.py diff --git a/python/test_gobject.py b/python/try.py similarity index 50% rename from python/test_gobject.py rename to python/try.py index 885f2256..1255bd37 100755 --- a/python/test_gobject.py +++ b/python/try.py @@ -7,6 +7,8 @@ import sys # export GI_TYPELIB_PATH=$VIPSHOME/lib/girepository-1.0 from gi.repository import Vips +print 'long way around:' + a = Vips.Image() a.props.filename = sys.argv[1] a.props.mode = 'r' @@ -17,8 +19,35 @@ if a.build() != 0: print 'a.get_width() =', a.get_width() print 'a.props.width =', a.props.width +print 'direct call:' + +a = Vips.Image.new_from_file(sys.argv[1]) + +print 'a.get_width() =', a.get_width() +print 'a.props.width =', a.props.width + +print 'call operation:' + +op = Vips.Operation.new("add") +for prop in op.props: + print 'prop =', prop +op.props.left = a +op.props.right = a +if op.build() != 0: + print Vips.error_buffer() + sys.exit(-1) +out = op.props.out + +print 'out.get_format() =', out.get_format() +print 'out.props.format =', out.props.format + +out.write_to_file("x.v") + print 'starting shutdown ...' del a +del op +del out + # sometimes have to do several GCs to get them all, not sure why for i in range(10): gc.collect ()