From: Wolfram Schneider Date: Wed, 14 Apr 2010 09:35:38 +0000 (+0000) Subject: import Scalar::Util to test weaken references of perl objects X-Git-Tag: CPAN-v1.02~148^2~7 X-Git-Url: http://git.indexdata.com/?p=irspy-moved-to-github.git;a=commitdiff_plain;h=1d9e1ab49a01c412515e93b36f92a41590d8ab56 import Scalar::Util to test weaken references of perl objects --- diff --git a/lib/ZOOM/IRSpy/Node.pm b/lib/ZOOM/IRSpy/Node.pm index f912b94..9d2f5c7 100644 --- a/lib/ZOOM/IRSpy/Node.pm +++ b/lib/ZOOM/IRSpy/Node.pm @@ -6,6 +6,7 @@ use 5.008; use strict; use warnings; +use Scalar::Util; =head1 NAME @@ -57,13 +58,15 @@ changed. sub new { my $class = shift(); my($name, @subnodes) = @_; - return bless { + my $this = bless { name => $name, subnodes => \@subnodes, address => undef, # filled in by resolve() previous => undef, # filled in by resolve() next => undef, # filled in by resolve() }, $class; + + return $this; } =head2 name() diff --git a/lib/ZOOM/IRSpy/Record.pm b/lib/ZOOM/IRSpy/Record.pm index 7444d70..e80fe12 100644 --- a/lib/ZOOM/IRSpy/Record.pm +++ b/lib/ZOOM/IRSpy/Record.pm @@ -8,6 +8,7 @@ use 5.008; use strict; use warnings; +use Scalar::Util; use XML::LibXML; use XML::LibXML::XPathContext; use ZOOM::IRSpy::Utils qw(xml_encode isodate irspy_xpath_context); @@ -36,12 +37,17 @@ sub new { ### Parser should be in the IRSpy object my $parser = new XML::LibXML(); - return bless { + my $this = bless { irspy => $irspy, target => $target, parser => $parser, zeerex => $parser->parse_string($zeerex)->documentElement(), }, $class; + + #Scalar::Util::weaken($this->{irspy}); + #Scalar::Util::weaken($this->{parser}); + + return $this; } diff --git a/lib/ZOOM/IRSpy/Stats.pm b/lib/ZOOM/IRSpy/Stats.pm index af667dc..f701740 100644 --- a/lib/ZOOM/IRSpy/Stats.pm +++ b/lib/ZOOM/IRSpy/Stats.pm @@ -5,6 +5,8 @@ package ZOOM::IRSpy::Stats; use 5.008; use strict; use warnings; + +use Scalar::Util; use ZOOM::IRSpy::Utils qw(irspy_xpath_context); =head1 NAME diff --git a/lib/ZOOM/IRSpy/Task.pm b/lib/ZOOM/IRSpy/Task.pm index 8e3f251..4340198 100644 --- a/lib/ZOOM/IRSpy/Task.pm +++ b/lib/ZOOM/IRSpy/Task.pm @@ -6,6 +6,8 @@ use 5.008; use strict; use warnings; +use Scalar::Util; + =head1 NAME ZOOM::IRSpy::Task - base class for tasks in IRSpy @@ -34,7 +36,7 @@ sub new { my $class = shift(); my($conn, $udata, $options, %cb) = @_; - return bless { + my $this = bless { irspy => $conn->{irspy}, conn => $conn, udata => $udata, @@ -42,6 +44,11 @@ sub new { cb => \%cb, timeRegistered => time(), }, $class; + + #Scalar::Util::weaken($this->{irspy}); + #Scalar::Util::weaken($this->{udata}); + + return $this; } diff --git a/lib/ZOOM/IRSpy/Test.pm b/lib/ZOOM/IRSpy/Test.pm index e73061a..765cd4f 100644 --- a/lib/ZOOM/IRSpy/Test.pm +++ b/lib/ZOOM/IRSpy/Test.pm @@ -6,6 +6,8 @@ use 5.008; use strict; use warnings; +use Scalar::Util; + =head1 NAME ZOOM::IRSpy::Test - base class for tests in IRSpy diff --git a/lib/ZOOM/IRSpy/Utils.pm b/lib/ZOOM/IRSpy/Utils.pm index 0b1f646..b1d2331 100644 --- a/lib/ZOOM/IRSpy/Utils.pm +++ b/lib/ZOOM/IRSpy/Utils.pm @@ -6,6 +6,8 @@ use 5.008; use strict; use warnings; +use Scalar::Util; + use Exporter 'import'; our @EXPORT_OK = qw(utf8param isodate