Mercurial > pub > Impl
annotate Lib/IMPL/Object/Abstract.pm @ 89:3d1f584aea60
small fix in the activator and secure cookie
author | wizard |
---|---|
date | Wed, 21 Apr 2010 17:39:45 +0400 |
parents | 76b878ad6596 |
children | dc1da0389db7 |
rev | line source |
---|---|
49 | 1 package IMPL::Object::Abstract; |
2 use strict; | |
3 use warnings; | |
4 | |
5 use base qw(IMPL::Class::Meta); | |
6 | |
7 our $MemoryLeakProtection; | |
8 my $Cleanup = 0; | |
9 | |
10 my %cacheCTOR; | |
11 | |
12 my $t = 0; | |
13 sub cache_ctor { | |
14 my $class = shift; | |
15 | |
16 no strict 'refs'; | |
17 my @sequence; | |
18 | |
19 my $refCTORS = *{"${class}::CTOR"}{HASH}; | |
20 | |
21 foreach my $super ( @{"${class}::ISA"} ) { | |
22 my $superSequence = $cacheCTOR{$super} || cache_ctor($super); | |
23 | |
24 my $mapper = $refCTORS ? $refCTORS->{$super} : undef; | |
25 if (ref $mapper eq 'CODE') { | |
26 if ($mapper == *_pass_throgh_mapper{CODE}) { | |
27 push @sequence,@$superSequence; | |
28 } else { | |
29 push @sequence, sub { | |
30 my $this = shift; | |
31 $this->$_($mapper->(@_)) foreach @$superSequence; | |
32 }; | |
33 } | |
34 } else { | |
35 warn "Unsupported mapper type, in '$class' for the super class '$super'" if $mapper; | |
36 push @sequence, sub { | |
37 my $this = shift; | |
38 $this->$_() foreach @$superSequence; | |
39 }; | |
40 } | |
41 } | |
42 | |
43 push @sequence, *{"${class}::CTOR"}{CODE} if *{"${class}::CTOR"}{CODE}; | |
44 | |
45 $cacheCTOR{$class} = \@sequence; | |
46 return \@sequence; | |
47 } | |
48 | |
49 sub callCTOR { | |
50 my $self = shift; | |
51 my $class = ref $self; | |
52 | |
53 $self->$_(@_) foreach @{$cacheCTOR{$class} || cache_ctor($class)}; | |
54 } | |
55 | |
56 sub superCTOR { | |
57 my $this = shift; | |
58 | |
59 warn "The mehod is deprecated, at " . caller; | |
60 } | |
61 | |
62 sub toString { | |
63 my $self = shift; | |
64 | |
65 return (ref $self || $self); | |
66 } | |
67 | |
68 sub isDisposed { | |
69 0; | |
70 } | |
71 | |
72 #sub DESTROY { | |
73 # if ($MemoryLeakProtection and $Cleanup) { | |
74 # my $this = shift; | |
75 # warn sprintf("Object leaks: %s of type %s %s",$this->can('ToString') ? $this->ToString : $this,ref $this,UNIVERSAL::can($this,'_dump') ? $this->_dump : ''); | |
76 # } | |
77 #} | |
78 | |
79 sub END { | |
80 $Cleanup = 1; | |
81 } | |
82 | |
83 sub _pass_throgh_mapper { | |
84 @_; | |
85 } | |
86 | |
87 sub PassArgs { | |
88 \&_pass_throgh_mapper; | |
89 } | |
90 | |
91 sub PassThroughArgs { | |
92 my $class = shift; | |
93 $class = ref $class || $class; | |
94 no strict 'refs'; | |
95 no warnings 'once'; | |
96 ${"${class}::CTOR"}{$_} = \&_pass_throgh_mapper foreach @{"${class}::ISA"}; | |
97 } | |
98 | |
99 package self; | |
100 | |
101 our $AUTOLOAD; | |
102 sub AUTOLOAD { | |
103 goto &{caller(). substr $AUTOLOAD,4}; | |
104 } | |
105 | |
106 package supercall; | |
107 | |
108 our $AUTOLOAD; | |
109 sub AUTOLOAD { | |
110 my $sub; | |
111 my $methodName = substr $AUTOLOAD,11; | |
112 no strict 'refs'; | |
113 $sub = $_->can($methodName) and $sub->(@_) foreach @{caller().'::ISA'}; | |
114 } | |
115 | |
63
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
49
diff
changeset
|
116 1; |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
49
diff
changeset
|
117 |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
49
diff
changeset
|
118 __END__ |
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
49
diff
changeset
|
119 |
49 | 120 =pod |
63
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
49
diff
changeset
|
121 =head1 SYNOPSIS |
49 | 122 |
123 package MyBaseObject; | |
124 use base qw(IMPL::Object::Abstract); | |
125 | |
126 sub new { | |
127 # own implementation of the new opeator | |
128 } | |
129 | |
130 sub surrogate { | |
131 # own implementation of the surrogate operator | |
132 } | |
133 | |
63
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
49
diff
changeset
|
134 =head1 DESCRIPTION |
49 | 135 |
136 Реализация механизма вызова конструкторов и других вспомогательных вещей, кроме операторов | |
137 создания экземпляров. | |
138 =cut |