annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
274
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
1 package IMPL::Object::AutoDispose;
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
2 use strict;
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
3
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
4 use IMPL::declare {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
5 base => [
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
6 'IMPL::Object::Abstract' => undef
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
7 ]
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
8 };
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
9
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
10 sub new {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
11 my $self = shift;
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
12
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
13 if (ref $self) {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
14 return ${$self}->new(@_);
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
15 } else {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
16 my $obj = shift;
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
17 return bless \$obj, $self;
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
18 }
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
19 }
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
20
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
21 sub isa {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
22 ${shift(@_)}->isa(@_);
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
23 }
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
24
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
25 sub can {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
26 ${shift(@_)}->can(@_);
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
27 }
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
28
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
29 sub DTOR {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
30 ${shift(@_)}->Dispose();
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
31 }
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
32
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
33 sub typeof {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
34 ${shift(@_)}->typeof(@_);
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
35 }
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
36
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
37 sub toString {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
38 ${shift(@_)}->toString(@_);
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
39 }
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
40
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
41 sub AUTOLOAD {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
42 our $AUTOLOAD;
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
43 my ($method) = ($AUTOLOAD =~ m/(\w+)$/);
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
44
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
45 no strict 'refs';
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
46
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
47 goto &{*{$AUTOLOAD} = sub {
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
48 ${shift(@_)}->$method(@_);
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
49 }};
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
50 }
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
51
8d36073411b1 +Added AutoDispose class
cin
parents:
diff changeset
52 1;