diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/IMPL/Object/AutoDispose.pm	Wed Jan 30 03:30:28 2013 +0400
@@ -0,0 +1,52 @@
+package IMPL::Object::AutoDispose;
+use strict;
+
+use IMPL::declare {
+    base => [
+        'IMPL::Object::Abstract' => undef
+    ]
+};
+
+sub new {
+    my $self = shift;
+        
+    if (ref $self) {
+        return ${$self}->new(@_);
+    } else {
+        my $obj = shift;
+        return bless \$obj, $self;        
+    }    
+}
+
+sub isa {
+    ${shift(@_)}->isa(@_);
+}
+
+sub can {
+    ${shift(@_)}->can(@_);
+}
+
+sub DTOR {
+    ${shift(@_)}->Dispose();
+}
+
+sub typeof {
+    ${shift(@_)}->typeof(@_);
+}
+
+sub toString {
+    ${shift(@_)}->toString(@_);
+}
+
+sub AUTOLOAD {
+    our $AUTOLOAD;
+    my ($method) = ($AUTOLOAD =~ m/(\w+)$/);
+    
+    no strict 'refs';
+    
+    goto &{*{$AUTOLOAD} = sub {
+        ${shift(@_)}->$method(@_);
+    }};
+}
+
+1;
\ No newline at end of file