annotate Lib/IMPL/Object/Abstract.pm @ 183:2184fa28b49e

IMPL::Web::View::TTLoader tests
author cin
date Wed, 28 Mar 2012 17:28:51 +0400
parents d1676be8afcc
children 4d0e1962161c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
1 package IMPL::Object::Abstract;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
4
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 164
diff changeset
5 use parent qw(IMPL::Class::Meta);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
6
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
7 our $MemoryLeakProtection;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
8 my $Cleanup = 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
9
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
10 my %cacheCTOR;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
11
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
12 my $t = 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
13 sub cache_ctor {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
14 my $class = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
15
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
16 no strict 'refs';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
17 my @sequence;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
18
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
19 my $refCTORS = *{"${class}::CTOR"}{HASH};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
20
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
21 foreach my $super ( @{"${class}::ISA"} ) {
90
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
22 my $superSequence = $cacheCTOR{$super} || cache_ctor($super);
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
23
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
24 my $mapper = $refCTORS ? $refCTORS->{$super} : undef;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
25 if (ref $mapper eq 'CODE') {
174
d920d2b70230 minor changes
sergey
parents: 166
diff changeset
26 if ($mapper == *_pass_through_mapper{CODE}) {
90
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
27 push @sequence,@$superSequence;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
28 } else {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
29 push @sequence, sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
30 my $this = shift;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
31 $this->$_($mapper->(@_)) foreach @$superSequence;
144
b56ebc31bf18 Empty nodes no more created while transforming a post request to the DOM document
wizard
parents: 122
diff changeset
32 } if @$superSequence;
90
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
33 }
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
34 } else {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
35 warn "Unsupported mapper type, in '$class' for the super class '$super'" if $mapper;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
36 push @sequence, sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
37 my $this = shift;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
38 $this->$_() foreach @$superSequence;
144
b56ebc31bf18 Empty nodes no more created while transforming a post request to the DOM document
wizard
parents: 122
diff changeset
39 } if @$superSequence;
90
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
40 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
41 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
42
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
43 push @sequence, *{"${class}::CTOR"}{CODE} if *{"${class}::CTOR"}{CODE};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
44
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
45 $cacheCTOR{$class} = \@sequence;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
46 return \@sequence;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
47 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
48
90
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
49 sub dump_ctor {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
50 my ($self) = @_;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
51 $self = ref $self || $self;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
52
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
53 warn "dumping $self .ctor";
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
54 warn "$_" foreach @{$cacheCTOR{$self}||[]};
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
55 }
dc1da0389db7 Small improvements in the abstract object class
wizard
parents: 63
diff changeset
56
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
57 sub callCTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
58 my $self = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
59 my $class = ref $self;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
60
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
61 $self->$_(@_) foreach @{$cacheCTOR{$class} || cache_ctor($class)};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
62 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
63
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
64 sub toString {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
65 my $self = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
66
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
67 return (ref $self || $self);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
68 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
69
122
a7efb3117295 Fixed bug in IMPL::DOM::Navigator::selectNodes
wizard
parents: 108
diff changeset
70 sub typeof {
93
0667064553ef fixed _is_class in activator
wizard
parents: 90
diff changeset
71 ref $_[0] || $_[0];
0667064553ef fixed _is_class in activator
wizard
parents: 90
diff changeset
72 }
0667064553ef fixed _is_class in activator
wizard
parents: 90
diff changeset
73
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
74 sub isDisposed {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
75 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
76 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
77
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
78 #sub DESTROY {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
79 # if ($MemoryLeakProtection and $Cleanup) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
80 # my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
81 # warn sprintf("Object leaks: %s of type %s %s",$this->can('ToString') ? $this->ToString : $this,ref $this,UNIVERSAL::can($this,'_dump') ? $this->_dump : '');
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
82 # }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
83 #}
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
84
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
85 sub END {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
86 $Cleanup = 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
87 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
88
174
d920d2b70230 minor changes
sergey
parents: 166
diff changeset
89 sub _pass_through_mapper {
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
90 @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
91 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
92
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
93 sub PassArgs {
174
d920d2b70230 minor changes
sergey
parents: 166
diff changeset
94 \&_pass_through_mapper;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
95 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
96
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
97 sub PassThroughArgs {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
98 my $class = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
99 $class = ref $class || $class;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
100 no strict 'refs';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
101 no warnings 'once';
174
d920d2b70230 minor changes
sergey
parents: 166
diff changeset
102 ${"${class}::CTOR"}{$_} = \&_pass_through_mapper foreach @{"${class}::ISA"};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
103 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
104
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
105 package self;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
106
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
107 our $AUTOLOAD;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
108 sub AUTOLOAD {
108
c6fb6964de4c Removed absolute modules
wizard
parents: 93
diff changeset
109 goto &{caller(). substr $AUTOLOAD,6};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
110 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
111
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
112 package supercall;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
113
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
114 our $AUTOLOAD;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
115 sub AUTOLOAD {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
116 my $sub;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
117 my $methodName = substr $AUTOLOAD,11;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
118 no strict 'refs';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
119 $sub = $_->can($methodName) and $sub->(@_) foreach @{caller().'::ISA'};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
120 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
121
63
76b878ad6596 Added serialization support for the IMPL::Object::List
wizard
parents: 49
diff changeset
122 1;
76b878ad6596 Added serialization support for the IMPL::Object::List
wizard
parents: 49
diff changeset
123
76b878ad6596 Added serialization support for the IMPL::Object::List
wizard
parents: 49
diff changeset
124 __END__
76b878ad6596 Added serialization support for the IMPL::Object::List
wizard
parents: 49
diff changeset
125
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
126 =pod
63
76b878ad6596 Added serialization support for the IMPL::Object::List
wizard
parents: 49
diff changeset
127 =head1 SYNOPSIS
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
128
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
129 package MyBaseObject;
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 164
diff changeset
130 use parent qw(IMPL::Object::Abstract);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
131
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
132 sub new {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
133 # own implementation of the new opeator
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
134 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
135
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
136 sub surrogate {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
137 # own implementation of the surrogate operator
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
138 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
139
63
76b878ad6596 Added serialization support for the IMPL::Object::List
wizard
parents: 49
diff changeset
140 =head1 DESCRIPTION
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
141
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 174
diff changeset
142 Реализация механизма вызова конструкторов и других вспомогательных вещей, кроме операторов
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 174
diff changeset
143 создания экземпляров.
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 33
diff changeset
144 =cut