comparison lib/IMPL/Object/AutoDispose.pm @ 407:c6e90e02dd17 ref20150831

renamed Lib->lib
author cin
date Fri, 04 Sep 2015 19:40:23 +0300
parents
children
comparison
equal deleted inserted replaced
406:f23fcb19d3c1 407:c6e90e02dd17
1 package IMPL::Object::AutoDispose;
2 use strict;
3
4 sub new {
5 my $self = shift;
6
7 if (ref $self) {
8 return ${$self}->new(@_);
9 } else {
10 my $obj = shift;
11 return bless \$obj, $self;
12 }
13 }
14
15 sub isa {
16 ${shift(@_)}->isa(@_);
17 }
18
19 sub can {
20 ${shift(@_)}->can(@_);
21 }
22
23 sub DESTROY {
24 ${shift(@_)}->Dispose();
25 }
26
27 sub AUTOLOAD {
28 our $AUTOLOAD;
29 my ($method) = ($AUTOLOAD =~ m/(\w+)$/);
30
31 no strict 'refs';
32
33 goto &{*{$AUTOLOAD} = sub {
34 ${shift(@_)}->$method(@_);
35 }};
36 }
37
38 1;