TYPEMAP
Vips::Image                    T_VIPS_OBJECT
Vips::Source                   T_VIPS_OBJECT
Vips::Target                   T_VIPS_OBJECT

INPUT
T_VIPS_OBJECT
    if (SvROK($arg) && sv_derived_from($arg, \"$ntype\"))
        $var = INT2PTR($type, SvIV((SV *) SvRV($arg)));
    else
        vp_croak_error(aTHX_ NULL, \"Argument '%s' of '%s' must be a %s\",
            \"$var\", GvNAME(CvGV(cv)), \"$ntype\");

OUTPUT
T_VIPS_OBJECT
    sv_setref_pv($arg, \"$ntype\", (void *) $var);
