comparison Lib/IMPL/Object/AutoDispose.pm @ 274:8d36073411b1

+Added AutoDispose class *code cleanups
author cin
date Wed, 30 Jan 2013 03:30:28 +0400
parents
children 6253872024a4
comparison
equal deleted inserted replaced
273:ad93c9f4dd93 274:8d36073411b1
1 package IMPL::Object::AutoDispose;
2 use strict;
3
4 use IMPL::declare {
5 base => [
6 'IMPL::Object::Abstract' => undef
7 ]
8 };
9
10 sub new {
11 my $self = shift;
12
13 if (ref $self) {
14 return ${$self}->new(@_);
15 } else {
16 my $obj = shift;
17 return bless \$obj, $self;
18 }
19 }
20
21 sub isa {
22 ${shift(@_)}->isa(@_);
23 }
24
25 sub can {
26 ${shift(@_)}->can(@_);
27 }
28
29 sub DTOR {
30 ${shift(@_)}->Dispose();
31 }
32
33 sub typeof {
34 ${shift(@_)}->typeof(@_);
35 }
36
37 sub toString {
38 ${shift(@_)}->toString(@_);
39 }
40
41 sub AUTOLOAD {
42 our $AUTOLOAD;
43 my ($method) = ($AUTOLOAD =~ m/(\w+)$/);
44
45 no strict 'refs';
46
47 goto &{*{$AUTOLOAD} = sub {
48 ${shift(@_)}->$method(@_);
49 }};
50 }
51
52 1;