annotate Lib/IMPL/Object/Disposable.pm @ 35:f25d021780b3

DOM::Navigator::Builder working version
author Sergey
date Tue, 17 Nov 2009 17:46:24 +0300
parents 0004faa276dc
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package IMPL::Object::Disposable;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4 our $Strict = 1;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 sub Dispose {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 my ($this) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9 bless $this, 'IMPL::Object::Disposed';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12 sub DESTROY {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 my ($this) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15 warn sprintf('The object %s were marked as disposable but isn\'t disposed properly', $this->can('ToString') ? $this->ToString() : (ref $this || $this) );
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 sub superDispose {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 my ($this) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21 my $package = caller;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23 no strict 'refs';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 ($_.'::Dispose')->($this) foreach @{$package.'::ISA'};
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 package IMPL::Object::Disposed;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 our $AUTOLOAD;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30 sub AUTOLOAD {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31 return if $AUTOLOAD eq __PACKAGE__.'::DESTROY';
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 die new IMPL::Exception('Object have been disposed',$AUTOLOAD);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33 }
33
0004faa276dc small fixes, some new tests
Sergey
parents: 0
diff changeset
34
0004faa276dc small fixes, some new tests
Sergey
parents: 0
diff changeset
35 sub isDisposed {
0004faa276dc small fixes, some new tests
Sergey
parents: 0
diff changeset
36 1;
0004faa276dc small fixes, some new tests
Sergey
parents: 0
diff changeset
37 }
0004faa276dc small fixes, some new tests
Sergey
parents: 0
diff changeset
38
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
39 1;