Mercurial > pub > Impl
annotate Lib/IMPL/Object/Disposable.pm @ 329:50ff1595bd62
fixed bug when transforming list properties
| author | sergey |
|---|---|
| date | Mon, 03 Jun 2013 18:03:54 +0400 |
| parents | 63709a4e6da0 |
| children |
| rev | line source |
|---|---|
| 49 | 1 package IMPL::Object::Disposable; |
| 2 use strict; | |
| 328 | 3 require IMPL::Object::AutoDispose; |
| 49 | 4 |
| 5 our $Strict = 1; | |
| 6 | |
| 7 sub Dispose { | |
| 8 my ($this) = @_; | |
| 9 | |
| 10 bless $this, 'IMPL::Object::Disposed'; | |
| 11 } | |
| 12 | |
|
273
ad93c9f4dd93
+Added support for destructors, (special method named DTOR)
sergey
parents:
49
diff
changeset
|
13 sub DTOR { |
| 49 | 14 my ($this) = @_; |
| 15 | |
| 16 warn sprintf('The object %s were marked as disposable but isn\'t disposed properly', $this->can('ToString') ? $this->ToString() : (ref $this || $this) ); | |
| 17 } | |
| 18 | |
| 328 | 19 sub AutoPtr { |
| 20 IMPL::Object::AutoDispose->new(shift); | |
| 49 | 21 } |
| 22 | |
| 23 package IMPL::Object::Disposed; | |
| 24 our $AUTOLOAD; | |
| 25 sub AUTOLOAD { | |
| 26 return if $AUTOLOAD eq __PACKAGE__.'::DESTROY'; | |
| 27 die new IMPL::Exception('Object have been disposed',$AUTOLOAD); | |
| 28 } | |
| 29 | |
| 30 sub isDisposed { | |
| 31 1; | |
| 32 } | |
| 33 | |
| 34 1; |
