line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#############################################################################
|
2
|
|
|
|
|
|
|
## Name: Map.pm
|
3
|
|
|
|
|
|
|
## Purpose: Thread::Isolate::Map
|
4
|
|
|
|
|
|
|
## Author: Graciliano M. P.
|
5
|
|
|
|
|
|
|
## Modified by:
|
6
|
|
|
|
|
|
|
## Created: 2005-01-29
|
7
|
|
|
|
|
|
|
## RCS-ID:
|
8
|
|
|
|
|
|
|
## Copyright: (c) 2005 Graciliano M. P.
|
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or
|
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself
|
11
|
|
|
|
|
|
|
#############################################################################
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Thread::Isolate::Map ;
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6540
|
use strict qw(vars) ;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
16
|
1
|
|
|
1
|
|
5
|
no warnings ;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
233
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#######
|
19
|
|
|
|
|
|
|
# NEW #
|
20
|
|
|
|
|
|
|
#######
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new {
|
23
|
0
|
|
|
0
|
|
|
my $this = shift ;
|
24
|
0
|
0
|
|
|
|
|
return( $this ) if ref($this) ;
|
25
|
0
|
|
0
|
|
|
|
my $class = $this || __PACKAGE__ ;
|
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $local_pack = shift ;
|
28
|
0
|
|
|
|
|
|
my ( $target_pack , $thi ) ;
|
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
$target_pack = !ref($_[0]) ? shift(@_) : $local_pack ;
|
31
|
0
|
|
|
|
|
|
$thi = shift ;
|
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
return if !ref($thi) ;
|
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $this = bless({} , $class) ;
|
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$this->{local_pack} = $local_pack ;
|
38
|
0
|
|
|
|
|
|
$this->{target_pack} = $target_pack ;
|
39
|
0
|
|
|
|
|
|
$this->{thi} = $thi ;
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$this->map ;
|
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $this ;
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#######
|
47
|
|
|
|
|
|
|
# MAP #
|
48
|
|
|
|
|
|
|
#######
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub map {
|
51
|
0
|
|
|
0
|
|
|
my $this = shift ;
|
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $thi_entries = $this->scan_pack_entries( $this->{thi} , $this->{target_pack} , 1 ) ;
|
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
7
|
no strict "refs" ;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
56
|
1
|
|
|
1
|
|
5
|
no warnings ;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
755
|
|
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
foreach my $entry ( sort @$thi_entries ) {
|
59
|
|
|
|
|
|
|
#print "> $entry\n" ;
|
60
|
0
|
|
|
|
|
|
eval {
|
61
|
0
|
0
|
|
|
|
|
if ( $entry =~ /^\$(.*)/ ) {
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
require Thread::Isolate::Map::Scalar ;
|
63
|
0
|
|
|
|
|
|
tie( ${$1} , 'Thread::Isolate::Map::Scalar' , $this->{thi} , $entry ) ;
|
|
0
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
}
|
65
|
|
|
|
|
|
|
elsif ( $entry =~ /^\@(.*)/ ) {
|
66
|
0
|
|
|
|
|
|
require Thread::Isolate::Map::Array ;
|
67
|
0
|
|
|
|
|
|
tie( @{$1} , 'Thread::Isolate::Map::Array' , $this->{thi} , $entry , $1 ) ;
|
|
0
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
elsif ( $entry =~ /^\%(.*)/ ) {
|
70
|
0
|
|
|
|
|
|
require Thread::Isolate::Map::Hash ;
|
71
|
0
|
|
|
|
|
|
tie( %{$1} , 'Thread::Isolate::Map::Hash' , $this->{thi} , $entry , $1 ) ;
|
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
elsif ( $entry =~ /^\*(.*)/ ) {
|
74
|
0
|
|
|
|
|
|
require Thread::Isolate::Map::Handle ;
|
75
|
0
|
|
|
|
|
|
tie( *{$1} , 'Thread::Isolate::Map::Handle' , $this->{thi} , $entry , $1 ) ;
|
|
0
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
elsif ( $entry =~ /^\&(.*)/ ) {
|
78
|
0
|
|
|
|
|
|
my $sub = $1 ;
|
79
|
0
|
|
|
|
|
|
my $thi = $this->{thi} ;
|
80
|
0
|
|
|
0
|
|
|
*$sub = sub { $thi->call($sub,@_) ;}
|
81
|
0
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
};
|
83
|
|
|
|
|
|
|
#print "$@\n" if $@ ;
|
84
|
|
|
|
|
|
|
}
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#####################
|
89
|
|
|
|
|
|
|
# SCAN_PACK_ENTRIES #
|
90
|
|
|
|
|
|
|
#####################
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub scan_pack_entries {
|
93
|
0
|
|
|
0
|
|
|
my $this = shift ;
|
94
|
0
|
0
|
|
|
|
|
my $thi = ref $_[0] ? shift(@_) : undef ;
|
95
|
0
|
|
|
|
|
|
my ( $packname , $recursive ) = @_ ;
|
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if ( $thi ) {
|
98
|
0
|
|
|
|
|
|
my $thi_entries = $thi->eval(q`
|
99
|
|
|
|
|
|
|
use Thread::Isolate::Map ;
|
100
|
|
|
|
|
|
|
return Thread::Isolate::Map->scan_pack_entries(@_) ;
|
101
|
|
|
|
|
|
|
` , $packname , $recursive ) ;
|
102
|
0
|
0
|
|
|
|
|
warn( $thi->err ) if $thi->err ;
|
103
|
0
|
|
|
|
|
|
return $thi_entries ;
|
104
|
|
|
|
|
|
|
}
|
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
$packname .= '::' if $packname !~ /::$/ ;
|
107
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
return if $packname =~ /^(?:main::)?(?:Thread::Isolate|threads|UNIVERSAL|Exporter|AutoLoader|CORE|Carp|Config|DynaLoader|Errno|Win32|XSLoader|attributes|overload|strict|utf8|vars|warnings|Storable|Fcntl|Internals|PerlIO|Symbol)(?:::|$)/ ;
|
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
1
|
|
7
|
no strict "refs" ;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
367
|
|
111
|
0
|
|
|
|
|
|
my $package = *{$packname}{HASH} ;
|
|
0
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
0
|
|
|
|
return if !defined %$package || $this->{scan_pack_entries}{$package} ;
|
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$this->{scan_pack_entries}{$package} = 1 ;
|
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my @entries ;
|
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
foreach my $symb ( keys %$package ) {
|
120
|
0
|
|
|
|
|
|
my $fullname = "$packname$symb" ;
|
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
0
|
|
|
|
next if $symb =~ /[^\w:]/ || $symb =~ /^[1-9\.]/ ;
|
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if ($symb =~ /::$/ ) {
|
125
|
0
|
|
|
|
|
|
push(@entries , $fullname) ;
|
126
|
0
|
0
|
|
|
|
|
push(@entries , @{$this->scan_pack_entries($fullname , $recursive)} ) if $recursive ;
|
|
0
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
}
|
128
|
|
|
|
|
|
|
else {
|
129
|
0
|
|
|
|
|
|
eval {
|
130
|
0
|
0
|
|
|
|
|
if (defined &$fullname) { push(@entries , "\&$fullname") ;}
|
|
0
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
0
|
|
|
|
if ( tied *{$fullname} || *{$fullname}{IO} ) { push(@entries , "\*$fullname") ;}
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
if (defined *{$fullname}{ARRAY}) { push(@entries , "\@$fullname") ;}
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
0
|
0
|
|
|
|
|
if (defined *{$fullname}{HASH}) { push(@entries , "\%$fullname") ;}
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
push(@entries , "\$$fullname") ;
|
139
|
|
|
|
|
|
|
};
|
140
|
|
|
|
|
|
|
}
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
delete $this->{scan_pack_entries}{$package} ;
|
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
return \@entries ;
|
147
|
|
|
|
|
|
|
}
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
########################
|
150
|
|
|
|
|
|
|
# LOAD THREAD::ISOLATE # Need to load here or the Mother Thread won't have the subs of this package:
|
151
|
|
|
|
|
|
|
########################
|
152
|
|
|
|
|
|
|
|
153
|
1
|
|
|
1
|
|
622
|
use Thread::Isolate ;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
#######
|
156
|
|
|
|
|
|
|
# END #
|
157
|
|
|
|
|
|
|
#######
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1;
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
__END__
|