[gimp-perl] Use strict and warnings everywhere.
- From: Ed J <edj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Use strict and warnings everywhere.
- Date: Fri, 23 May 2014 23:18:50 +0000 (UTC)
commit 4aa50ef249f704843f748e96cb3fdfff1938ad13
Author: Ed J <edj src gnome org>
Date: Sat May 24 00:18:19 2014 +0100
Use strict and warnings everywhere.
Gimp.pm | 12 ++++++++++--
Gimp/Util.pm | 27 +++++++++++++--------------
2 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/Gimp.pm b/Gimp.pm
index ecc3d1a..db2a2d2 100644
--- a/Gimp.pm
+++ b/Gimp.pm
@@ -1,6 +1,7 @@
package Gimp;
-use strict 'vars';
+use strict;
+use warnings;
our (
$VERSION, @ISA, $AUTOLOAD, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, @EXPORT_FAIL,
$interface_pkg, $interface_type, @PREFIXES,
@@ -37,6 +38,7 @@ my @POLLUTE_CLASSES;
my $net_init;
sub import($;@) {
+ no strict 'refs';
my $pkg = shift;
warn "$$-$pkg->import(@_)" if $Gimp::verbose >= 2;
my $up = caller;
@@ -45,6 +47,7 @@ sub import($;@) {
# make sure we can call GIMP functions - start net conn if required
map { $net_init = $1 if /net_init=(\S+)/; } @_;
if ($interface_type eq "net" and not &Gimp::Net::initialized) {
+ no strict 'refs';
map { *{"Gimp::$_"} = \&{"Gimp::Constant::$_"} }
qw(RUN_INTERACTIVE RUN_NONINTERACTIVE);
Gimp::Net::gimp_init(grep {defined} $net_init);
@@ -218,6 +221,7 @@ sub on_run (&) { register_callback "run" , $_[0] }
sub on_quit (&) { register_callback "quit" , $_[0] }
sub main {
+ no strict 'refs';
&{"$interface_pkg\::gimp_main"};
}
@@ -238,6 +242,7 @@ warn "$$-Finished loading '$interface_pkg'" if $Gimp::verbose >= 2;
# create some common aliases
for(qw(gimp_procedural_db_proc_exists gimp_call_procedure initialized)) {
+ no strict 'refs';
*$_ = \&{"$interface_pkg\::$_"};
}
@@ -263,6 +268,8 @@ sub exception_strip {
$e;
}
sub AUTOLOAD {
+ no strict 'refs';
+ goto &$AUTOLOAD if defined &$AUTOLOAD; # happens if :auto, not if method call
my ($class,$name) = $AUTOLOAD =~ /^(.*)::(.*?)$/;
warn "$$-AUTOLOAD $AUTOLOAD(@_)" if $Gimp::verbose >= 2;
for(@{"$class\::PREFIXES"}) {
@@ -270,7 +277,7 @@ sub AUTOLOAD {
if (exists $ignore_function{$sub}) {
*{$AUTOLOAD} = sub { () };
goto &$AUTOLOAD;
- } elsif (UNIVERSAL::can(Gimp::Util,$sub)) {
+ } elsif (UNIVERSAL::can('Gimp::Util',$sub)) {
my $ref = \&{"Gimp::Util::$sub"};
*{$AUTOLOAD} = sub {
shift unless ref $_[0];
@@ -306,6 +313,7 @@ sub AUTOLOAD {
sub _pseudoclass {
my ($class, @prefixes)= @_;
unshift @prefixes,"";
+ no strict 'refs';
*{"Gimp::$class\::AUTOLOAD"} = \&AUTOLOAD;
push @{"Gimp::$class\::PREFIXES"}, @prefixes;
push @{"Gimp::$class\::ISA"}, 'Gimp::Base';
diff --git a/Gimp/Util.pm b/Gimp/Util.pm
index 777e28a..701474b 100644
--- a/Gimp/Util.pm
+++ b/Gimp/Util.pm
@@ -1,19 +1,18 @@
-package Gimp::Util;
+package Gimp::Util;
use Exporter 'import';
use strict;
+use warnings;
use File::Basename;
-our @EXPORT = qw(
- layer_create
- text_draw
- image_create_text
- layer_add_layer_as_mask
- );
-# EXPORT_OK = qw();
-
-import Gimp;
-# manual "import" to shut perl -cw up
-sub __ ($);
+Gimp->import;
+our @EXPORT_OK = qw(
+ layer_create
+ text_draw
+ image_create_text
+ layer_add_layer_as_mask
+);
+
+sub __ ($); # declare - defined in Gimp
our $VERSION = 2.3003;
@@ -170,7 +169,7 @@ sub gimp_image_set_visible {
my $image = shift;
my %layers; @layers{map $$_,@_}=(1) x @_;
for ($image->get_layers) {
- $_->set_visible ($layers{$$_});
+ $_->set_visible ($layers{$$_} // 0);
}
}
@@ -178,7 +177,7 @@ sub gimp_image_set_invisible {
my $image = shift;
my %layers; @layers{map $$_,@_}=(1) x @_;
for ($image->get_layers) {
- $_->set_visible (!$layers{$$_});
+ $_->set_visible (!$layers{$$_} // 0);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]