[gimp-perl] Update to ITEM and VECTORS. Added test of changes. Patch by Ed J. Bug #725487
- From: Kevin Cozens <kcozens src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Update to ITEM and VECTORS. Added test of changes. Patch by Ed J. Bug #725487
- Date: Tue, 11 Mar 2014 00:49:31 +0000 (UTC)
commit 75ad6ce8b5224efc394f3fe0afd6fdfbea0a8e68
Author: Kevin Cozens <kevin ve3syb ca>
Date: Mon Mar 10 20:46:21 2014 -0400
Update to ITEM and VECTORS. Added test of changes. Patch by Ed J. Bug #725487
Gimp.pm | 3 +-
Gimp/Lib.xs | 70 ++++++++++++++++++++++++++++++++---------------------------
t/load.t | 6 -----
t/loadlib.t | 6 -----
t/run.t | 11 +++++----
5 files changed, 46 insertions(+), 50 deletions(-)
---
diff --git a/Gimp.pm b/Gimp.pm
index 85ad6d7..2e0ece5 100644
--- a/Gimp.pm
+++ b/Gimp.pm
@@ -614,6 +614,7 @@ _pseudoclass qw(Layer gimp_item_ gimp_layer_ gimp_floating_sel_ gimp_image_
gim
_pseudoclass qw(Image gimp_image_ gimp_item_ gimp_ plug_in_ perl_fu_);
_pseudoclass qw(Drawable gimp_item_ gimp_layer_ gimp_channel_ gimp_image_ gimp_ plug_in_ perl_fu_);
_pseudoclass qw(Selection gimp_selection_);
+_pseudoclass qw(Vectors gimp_vectors_);
_pseudoclass qw(Channel gimp_channel_ gimp_item_ gimp_selection_ gimp_image_ gimp_ plug_in_
perl_fu_);
_pseudoclass qw(Display gimp_display_ gimp_);
_pseudoclass qw(Plugin plug_in_);
@@ -625,7 +626,7 @@ _pseudoclass qw(Region );
_pseudoclass qw(GimpParasite );
push @Gimp::Drawable::ISA, qw(Gimp::Item);
-push @Gimp::Vector::ISA, qw(Gimp::Item);
+push @Gimp::Vectors::ISA, qw(Gimp::Item);
push @Gimp::Channel::ISA, qw(Gimp::Drawable);
push @Gimp::Layer::ISA, qw(Gimp::Drawable);
diff --git a/Gimp/Lib.xs b/Gimp/Lib.xs
index 12a5e0e..93c23eb 100644
--- a/Gimp/Lib.xs
+++ b/Gimp/Lib.xs
@@ -58,9 +58,6 @@
#define PKG_ANY ((char *)0)
-static char pkg_anyable[] = PKG_DRAWABLE ", " PKG_LAYER " or " PKG_CHANNEL;
-#define PKG_ANYABLE (pkg_anyable)
-
static int trace = TRACE_NONE;
#if HAVE_PDL
@@ -634,13 +631,29 @@ param_stash (GimpPDBArgType type)
{
static HV *bless_hv[GIMP_PDB_END]; /* initialized to zero */
static char *bless[GIMP_PDB_END] = {
- 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 0 , 0 , 0 ,
- PKG_COLOR , PKG_ITEM , PKG_DISPLAY , PKG_IMAGE, PKG_LAYER,
- PKG_CHANNEL , PKG_DRAWABLE, PKG_SELECTION, 0 , 0 ,
- PKG_PARASITE,
- 0
- };
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ PKG_COLOR,
+ PKG_ITEM,
+ PKG_DISPLAY,
+ PKG_IMAGE,
+ PKG_LAYER,
+ PKG_CHANNEL,
+ PKG_DRAWABLE,
+ PKG_SELECTION,
+ 0,
+ PKG_VECTORS,
+ PKG_PARASITE,
+ 0
+ };
if (bless [type] && !bless_hv [type])
bless_hv [type] = gv_stashpv (bless [type], 1);
@@ -669,11 +682,7 @@ static gint32
unbless (SV *sv, char *type, char *croak_str)
{
if (sv_isobject (sv))
- if (type == PKG_ANY
- || (type == PKG_ANYABLE && (sv_derived_from (sv, PKG_DRAWABLE)
- || sv_derived_from (sv, PKG_LAYER)
- || sv_derived_from (sv, PKG_CHANNEL)))
- || sv_derived_from (sv, type))
+ if (type == PKG_ANY || sv_derived_from (sv, type))
{
if (SvTYPE (SvRV (sv)) == SVt_PVMG)
return SvIV (SvRV (sv));
@@ -965,8 +974,8 @@ convert_sv2gimp (char *croak_str, GimpParam *arg, SV *sv)
case GIMP_PDB_ITEM:
case GIMP_PDB_DISPLAY:
- case GIMP_PDB_IMAGE:
- case GIMP_PDB_LAYER:
+ case GIMP_PDB_IMAGE:
+ case GIMP_PDB_LAYER:
case GIMP_PDB_CHANNEL:
case GIMP_PDB_DRAWABLE:
case GIMP_PDB_VECTORS:
@@ -976,24 +985,21 @@ convert_sv2gimp (char *croak_str, GimpParam *arg, SV *sv)
switch (arg->type) {
case GIMP_PDB_ITEM: arg->data.d_item = unbless(sv, PKG_ITEM , croak_str);
break;
case GIMP_PDB_DISPLAY: arg->data.d_display = unbless(sv, PKG_DISPLAY , croak_str);
break;
- case GIMP_PDB_LAYER: arg->data.d_layer = unbless(sv, PKG_ANYABLE , croak_str);
break;
- case GIMP_PDB_CHANNEL: arg->data.d_channel = unbless(sv, PKG_ANYABLE , croak_str);
break;
- case GIMP_PDB_DRAWABLE: arg->data.d_drawable = unbless(sv, PKG_ANYABLE , croak_str);
break;
- case GIMP_PDB_VECTORS: arg->data.d_vectors = unbless(sv, PKG_ANYABLE , croak_str);
break;
+ case GIMP_PDB_LAYER: arg->data.d_layer = unbless(sv, PKG_ITEM , croak_str); break;
+ case GIMP_PDB_CHANNEL: arg->data.d_channel = unbless(sv, PKG_ITEM , croak_str); break;
+ case GIMP_PDB_DRAWABLE: arg->data.d_drawable = unbless(sv, PKG_ITEM , croak_str); break;
+ case GIMP_PDB_VECTORS: arg->data.d_vectors = unbless(sv, PKG_ITEM , croak_str); break;
case GIMP_PDB_STATUS: arg->data.d_status = sv2gimp_extract_noref (SvIV, "STATUS");
case GIMP_PDB_IMAGE:
{
- if (sv_derived_from (sv, PKG_DRAWABLE))
- arg->data.d_image = gimp_drawable_get_image (unbless(sv, PKG_DRAWABLE, croak_str));
- else if (sv_derived_from (sv, PKG_LAYER ))
- arg->data.d_image = gimp_drawable_get_image (unbless(sv, PKG_LAYER , croak_str));
- else if (sv_derived_from (sv, PKG_CHANNEL ))
- arg->data.d_image = gimp_drawable_get_image (unbless(sv, PKG_CHANNEL , croak_str));
- else if (sv_derived_from (sv, PKG_IMAGE) || !SvROK (sv))
- {
- arg->data.d_image = unbless(sv, PKG_IMAGE , croak_str); break;
- }
- else
+ if (sv_derived_from (sv, PKG_ITEM))
+ arg->data.d_image = gimp_item_get_image(
+ unbless(sv, PKG_ITEM, croak_str)
+ );
+ else if (sv_derived_from (sv, PKG_IMAGE) || !SvROK (sv)) {
+ arg->data.d_image = unbless(sv, PKG_IMAGE, croak_str);
+ break;
+ } else
strcpy (croak_str, __("argument incompatible with type IMAGE"));
return 0;
diff --git a/t/load.t b/t/load.t
index 8e027a1..df66d91 100644
--- a/t/load.t
+++ b/t/load.t
@@ -5,9 +5,3 @@ use Gimp qw(:consts);
print "ok 1\n";
print "ok 2\n" if SHARPEN_CONVOLVE;
-
-
-
-
-
-
diff --git a/t/loadlib.t b/t/loadlib.t
index 17beccb..d123b63 100644
--- a/t/loadlib.t
+++ b/t/loadlib.t
@@ -6,9 +6,3 @@ BEGIN { @ARGV = '-gimp' }
use Gimp qw(:consts);
print "ok 1\n";
-
-
-
-
-
-
diff --git a/t/run.t b/t/run.t
index 82489ce..4fa8446 100644
--- a/t/run.t
+++ b/t/run.t
@@ -1,7 +1,7 @@
use Config;
use strict;
use File::Temp;
-use Test::More tests => 22;
+use Test::More tests => 23;
use IO::All;
BEGIN { use_ok('Gimp', qw(:auto)); }
@@ -48,7 +48,7 @@ ok(
ok(!$l->sharpen(10), 'call with maximum fu magic');
ok(!Gimp->plug_in_sharpen($i,$l,10), 'call plugin using default');
-# exercise COLORARRAY
+# exercise COLORARRAY - read only as can't find proc that takes as input
my @palettes = Gimp->palettes_get_list("Default");
my @colors = Gimp::Palette->get_colors($palettes[0]);
#require Data::Dumper;warn Data::Dumper::Dumper(scalar @colors), "\n";
@@ -58,8 +58,9 @@ cmp_ok(scalar(@{ $colors[0] }), '==', 4, 'colorarray 1st el is correct size');
# exercise VECTORS
my $tl = $i->text_layer_new("hi", "Arial", 8, 3);
$i->insert_layer($tl, 0, 0);
-my $vector = $tl->vectors_new_from_text_layer;
-my $vectorstring = $tl->vectors_export_to_string;
-ok($vectorstring =~ /^<\?xml/, 'vector string plausible');
+my $vectors = $tl->vectors_new_from_text_layer;
+cmp_ok(ref($vectors), 'eq', 'Gimp::Vectors', 'vectors object returned');
+my $vectorstring = $vectors->export_to_string; # takes VECTORS as input - QED
+like($vectorstring, qr/<path id="hi"/, 'vector string plausible');
ok(!$i->delete, 'remove image');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]