| 1 | 1 | $Tie::Watch::VERSION = '1.2'; | |||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | package Tie::Watch; | ||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | Tie::Watch - place watchpoints on Perl variables. | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | use Tie::Watch; | ||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | $watch = Tie::Watch->new( | ||||||||||||||||||
| 14 | -variable => \$frog, | ||||||||||||||||||
| 15 | -debug => 1, | ||||||||||||||||||
| 16 | -shadow => 0, | ||||||||||||||||||
| 17 | -fetch => [\&fetch, 'arg1', 'arg2', ..., 'argn'], | ||||||||||||||||||
| 18 | -store => \&store, | ||||||||||||||||||
| 19 | -destroy => sub {print "Final value=$frog.\n"}, | ||||||||||||||||||
| 20 | } | ||||||||||||||||||
| 21 | %vinfo = $watch->Info; | ||||||||||||||||||
| 22 | $args = $watch->Args(-fetch); | ||||||||||||||||||
| 23 | $val = $watch->Fetch; | ||||||||||||||||||
| 24 | print "val=", $watch->Say($val), ".\n"; | ||||||||||||||||||
| 25 | $watch->Store('Hello'); | ||||||||||||||||||
| 26 | $watch->Unwatch; | ||||||||||||||||||
| 27 | |||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||
| 29 | |||||||||||||||||||
| 30 | This class module binds one or more subroutines of your devising to a | ||||||||||||||||||
| 31 | Perl variable. All variables can have B<FETCH>, B<STORE> and | ||||||||||||||||||
| 32 | B<DESTROY> callbacks. Additionally, arrays can define B<CLEAR>, | ||||||||||||||||||
| 33 | B<DELETE>, B<EXISTS>, B<EXTEND>, B<FETCHSIZE>, B<POP>, B<PUSH>, | ||||||||||||||||||
| 34 | B<SHIFT>, B<SPLICE>, B<STORESIZE> and B<UNSHIFT> callbacks, and hashes | ||||||||||||||||||
| 35 | can define B<CLEAR>, B<DELETE>, B<EXISTS>, B<FIRSTKEY> and B<NEXTKEY> | ||||||||||||||||||
| 36 | callbacks. If these term are unfamiliar to you, I I<really> suggest | ||||||||||||||||||
| 37 | you read L<perltie>. | ||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | With Tie::Watch you can: | ||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | . alter a variable's value | ||||||||||||||||||
| 42 | . prevent a variable's value from being changed | ||||||||||||||||||
| 43 | . invoke a Perl/Tk callback when a variable changes | ||||||||||||||||||
| 44 | . trace references to a variable | ||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | Callback format is patterned after the Perl/Tk scheme: supply either a | ||||||||||||||||||
| 47 | code reference, or, supply an array reference and pass the callback | ||||||||||||||||||
| 48 | code reference in the first element of the array, followed by callback | ||||||||||||||||||
| 49 | arguments. (See examples in the Synopsis, above.) | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | Tie::Watch provides default callbacks for any that you fail to | ||||||||||||||||||
| 52 | specify. Other than negatively impacting performance, they perform | ||||||||||||||||||
| 53 | the standard action that you'd expect, so the variable behaves | ||||||||||||||||||
| 54 | "normally". Once you override a default callback, perhaps to insert | ||||||||||||||||||
| 55 | debug code like print statements, your callback normally finishes by | ||||||||||||||||||
| 56 | calling the underlying (overridden) method. But you don't have to! | ||||||||||||||||||
| 57 | |||||||||||||||||||
| 58 | To map a tied method name to a default callback name simply lowercase | ||||||||||||||||||
| 59 | the tied method name and uppercase its first character. So FETCH | ||||||||||||||||||
| 60 | becomes Fetch, NEXTKEY becomes Nextkey, etcetera. | ||||||||||||||||||
| 61 | |||||||||||||||||||
| 62 | Here are two callbacks for a scalar. The B<FETCH> (read) callback does | ||||||||||||||||||
| 63 | nothing other than illustrate the fact that it returns the value to | ||||||||||||||||||
| 64 | assign the variable. The B<STORE> (write) callback uppercases the | ||||||||||||||||||
| 65 | variable and returns it. In all cases the callback I<must> return the | ||||||||||||||||||
| 66 | correct read or write value - typically, it does this by invoking the | ||||||||||||||||||
| 67 | underlying method. | ||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | my $fetch_scalar = sub { | ||||||||||||||||||
| 70 | my($self) = @_; | ||||||||||||||||||
| 71 | $self->Fetch; | ||||||||||||||||||
| 72 | }; | ||||||||||||||||||
| 73 | |||||||||||||||||||
| 74 | my $store_scalar = sub { | ||||||||||||||||||
| 75 | my($self, $new_val) = @_; | ||||||||||||||||||
| 76 | $self->Store(uc $new_val); | ||||||||||||||||||
| 77 | }; | ||||||||||||||||||
| 78 | |||||||||||||||||||
| 79 | Here are B<FETCH> and B<STORE> callbacks for either an array or hash. | ||||||||||||||||||
| 80 | They do essentially the same thing as the scalar callbacks, but | ||||||||||||||||||
| 81 | provide a little more information. | ||||||||||||||||||
| 82 | |||||||||||||||||||
| 83 | my $fetch = sub { | ||||||||||||||||||
| 84 | my($self, $key) = @_; | ||||||||||||||||||
| 85 | my $val = $self->Fetch($key); | ||||||||||||||||||
| 86 | print "In fetch callback, key=$key, val=", $self->Say($val); | ||||||||||||||||||
| 87 | my $args = $self->Args(-fetch); | ||||||||||||||||||
| 88 | print ", args=('", join("', '", @$args), "')" if $args; | ||||||||||||||||||
| 89 | print ".\n"; | ||||||||||||||||||
| 90 | $val; | ||||||||||||||||||
| 91 | }; | ||||||||||||||||||
| 92 | |||||||||||||||||||
| 93 | my $store = sub { | ||||||||||||||||||
| 94 | my($self, $key, $new_val) = @_; | ||||||||||||||||||
| 95 | my $val = $self->Fetch($key); | ||||||||||||||||||
| 96 | $new_val = uc $new_val; | ||||||||||||||||||
| 97 | $self->Store($key, $new_val); | ||||||||||||||||||
| 98 | print "In store callback, key=$key, val=", $self->Say($val), | ||||||||||||||||||
| 99 | ", new_val=", $self->Say($new_val); | ||||||||||||||||||
| 100 | my $args = $self->Args(-store); | ||||||||||||||||||
| 101 | print ", args=('", join("', '", @$args), "')" if $args; | ||||||||||||||||||
| 102 | print ".\n"; | ||||||||||||||||||
| 103 | $new_val; | ||||||||||||||||||
| 104 | }; | ||||||||||||||||||
| 105 | |||||||||||||||||||
| 106 | In all cases, the first parameter is a reference to the Watch object, | ||||||||||||||||||
| 107 | used to invoke the following class methods. | ||||||||||||||||||
| 108 | |||||||||||||||||||
| 109 | =head1 METHODS | ||||||||||||||||||
| 110 | |||||||||||||||||||
| 111 | =over 4 | ||||||||||||||||||
| 112 | |||||||||||||||||||
| 113 | =item $watch = Tie::Watch->new(-options => values); | ||||||||||||||||||
| 114 | |||||||||||||||||||
| 115 | The watchpoint constructor method that accepts option/value pairs to | ||||||||||||||||||
| 116 | create and configure the Watch object. The only required option is | ||||||||||||||||||
| 117 | B<-variable>. | ||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | B<-variable> is a I<reference> to a scalar, array or hash variable. | ||||||||||||||||||
| 120 | |||||||||||||||||||
| 121 | B<-debug> (default 0) is 1 to activate debug print statements internal | ||||||||||||||||||
| 122 | to Tie::Watch. | ||||||||||||||||||
| 123 | |||||||||||||||||||
| 124 | B<-shadow> (default 1) is 0 to disable array and hash shadowing. To | ||||||||||||||||||
| 125 | prevent infinite recursion Tie::Watch maintains parallel variables for | ||||||||||||||||||
| 126 | arrays and hashes. When the watchpoint is created the parallel shadow | ||||||||||||||||||
| 127 | variable is initialized with the watched variable's contents, and when | ||||||||||||||||||
| 128 | the watchpoint is deleted the shadow variable is copied to the original | ||||||||||||||||||
| 129 | variable. Thus, changes made during the watch process are not lost. | ||||||||||||||||||
| 130 | Shadowing is on my default. If you disable shadowing any changes made | ||||||||||||||||||
| 131 | to an array or hash are lost when the watchpoint is deleted. | ||||||||||||||||||
| 132 | |||||||||||||||||||
| 133 | Specify any of the following relevant callback parameters, in the | ||||||||||||||||||
| 134 | format described above: B<-fetch>, B<-store>, B<-destroy>. | ||||||||||||||||||
| 135 | Additionally for arrays: B<-clear>, B<-extend>, B<-fetchsize>, | ||||||||||||||||||
| 136 | B<-pop>, B<-push>, B<-shift>, B<-splice>, B<-storesize> and | ||||||||||||||||||
| 137 | B<-unshift>. Additionally for hashes: B<-clear>, B<-delete>, | ||||||||||||||||||
| 138 | B<-exists>, B<-firstkey> and B<-nextkey>. | ||||||||||||||||||
| 139 | |||||||||||||||||||
| 140 | =item $args = $watch->Args(-fetch); | ||||||||||||||||||
| 141 | |||||||||||||||||||
| 142 | Returns a reference to a list of arguments for the specified callback, | ||||||||||||||||||
| 143 | or undefined if none. | ||||||||||||||||||
| 144 | |||||||||||||||||||
| 145 | =item $watch->Fetch(); $watch->Fetch($key); | ||||||||||||||||||
| 146 | |||||||||||||||||||
| 147 | Returns a variable's current value. $key is required for an array or | ||||||||||||||||||
| 148 | hash. | ||||||||||||||||||
| 149 | |||||||||||||||||||
| 150 | =item %vinfo = $watch->Info(); | ||||||||||||||||||
| 151 | |||||||||||||||||||
| 152 | Returns a hash detailing the internals of the Watch object, with these | ||||||||||||||||||
| 153 | keys: | ||||||||||||||||||
| 154 | |||||||||||||||||||
| 155 | %vinfo = { | ||||||||||||||||||
| 156 | -variable => SCALAR(0x200737f8) | ||||||||||||||||||
| 157 | -debug => '0' | ||||||||||||||||||
| 158 | -shadow => '1' | ||||||||||||||||||
| 159 | -value => 'HELLO SCALAR' | ||||||||||||||||||
| 160 | -destroy => ARRAY(0x200f86cc) | ||||||||||||||||||
| 161 | -fetch => ARRAY(0x200f8558) | ||||||||||||||||||
| 162 | -store => ARRAY(0x200f85a0) | ||||||||||||||||||
| 163 | -legible => above data formatted as a list of string, for printing | ||||||||||||||||||
| 164 | } | ||||||||||||||||||
| 165 | |||||||||||||||||||
| 166 | For array and hash Watch objects, the B<-value> key is replaced with a | ||||||||||||||||||
| 167 | B<-ptr> key which is a reference to the parallel array or hash. | ||||||||||||||||||
| 168 | Additionally, for an array or hash, there are key/value pairs for | ||||||||||||||||||
| 169 | all the variable specific callbacks. | ||||||||||||||||||
| 170 | |||||||||||||||||||
| 171 | =item $watch->Say($val); | ||||||||||||||||||
| 172 | |||||||||||||||||||
| 173 | Used mainly for debugging, it returns $val in quotes if required, or | ||||||||||||||||||
| 174 | the string "undefined" for undefined values. | ||||||||||||||||||
| 175 | |||||||||||||||||||
| 176 | =item $watch->Store($new_val); $watch->Store($key, $new_val); | ||||||||||||||||||
| 177 | |||||||||||||||||||
| 178 | Store a variable's new value. $key is required for an array or hash. | ||||||||||||||||||
| 179 | |||||||||||||||||||
| 180 | =item $watch->Unwatch(); | ||||||||||||||||||
| 181 | |||||||||||||||||||
| 182 | Stop watching the variable. | ||||||||||||||||||
| 183 | |||||||||||||||||||
| 184 | =back | ||||||||||||||||||
| 185 | |||||||||||||||||||
| 186 | =head1 EFFICIENCY CONSIDERATIONS | ||||||||||||||||||
| 187 | |||||||||||||||||||
| 188 | If you can live using the class methods provided, please do so. You | ||||||||||||||||||
| 189 | can meddle with the object hash directly and improved watch | ||||||||||||||||||
| 190 | performance, at the risk of your code breaking in the future. | ||||||||||||||||||
| 191 | |||||||||||||||||||
| 192 | =head1 AUTHOR | ||||||||||||||||||
| 193 | |||||||||||||||||||
| 194 | Stephen O. Lidie | ||||||||||||||||||
| 195 | |||||||||||||||||||
| 196 | =head1 HISTORY | ||||||||||||||||||
| 197 | |||||||||||||||||||
| 198 | lusol@Lehigh.EDU, LUCC, 96/05/30 | ||||||||||||||||||
| 199 | . Original version 0.92 release, based on the Trace module from Hans Mulder, | ||||||||||||||||||
| 200 | and ideas from Tim Bunce. | ||||||||||||||||||
| 201 | |||||||||||||||||||
| 202 | lusol@Lehigh.EDU, LUCC, 96/12/25 | ||||||||||||||||||
| 203 | . Version 0.96, release two inner references detected by Perl 5.004. | ||||||||||||||||||
| 204 | |||||||||||||||||||
| 205 | lusol@Lehigh.EDU, LUCC, 97/01/11 | ||||||||||||||||||
| 206 | . Version 0.97, fix Makefile.PL and MANIFEST (thanks Andreas Koenig). | ||||||||||||||||||
| 207 | Make sure test.pl doesn't fail if Tk isn't installed. | ||||||||||||||||||
| 208 | |||||||||||||||||||
| 209 | Stephen.O.Lidie@Lehigh.EDU, Lehigh University Computing Center, 97/10/03 | ||||||||||||||||||
| 210 | . Version 0.98, implement -shadow option for arrays and hashes. | ||||||||||||||||||
| 211 | |||||||||||||||||||
| 212 | Stephen.O.Lidie@Lehigh.EDU, Lehigh University Computing Center, 98/02/11 | ||||||||||||||||||
| 213 | . Version 0.99, finally, with Perl 5.004_57, we can completely watch arrays. | ||||||||||||||||||
| 214 | With tied array support this module is essentially complete, so its been | ||||||||||||||||||
| 215 | optimized for speed at the expense of clarity - sorry about that. The | ||||||||||||||||||
| 216 | Delete() method has been renamed Unwatch() because it conflicts with the | ||||||||||||||||||
| 217 | builtin delete(). | ||||||||||||||||||
| 218 | |||||||||||||||||||
| 219 | Stephen.O.Lidie@Lehigh.EDU, Lehigh University Computing Center, 99/04/04 | ||||||||||||||||||
| 220 | . Version 1.0, for Perl 5.005_03, update Makefile.PL for ActiveState, and | ||||||||||||||||||
| 221 | add two examples (one for Perl/Tk). | ||||||||||||||||||
| 222 | |||||||||||||||||||
| 223 | sol0@lehigh.edu, Lehigh University Computing Center, 2003/06/07 | ||||||||||||||||||
| 224 | . Version 1.1, for Perl 5.8, can trace a reference now, patch from Slaven | ||||||||||||||||||
| 225 | Rezic. | ||||||||||||||||||
| 226 | |||||||||||||||||||
| 227 | sol0@lehigh.edu, Lehigh University Computing Center, 2005/05/17 | ||||||||||||||||||
| 228 | . Version 1.2, for Perl 5.8, per Rob Seegel's suggestion, support array | ||||||||||||||||||
| 229 | DELETE and EXISTS. | ||||||||||||||||||
| 230 | |||||||||||||||||||
| 231 | =head1 COPYRIGHT | ||||||||||||||||||
| 232 | |||||||||||||||||||
| 233 | Copyright (C) 1996 - 2005 Stephen O. Lidie. All rights reserved. | ||||||||||||||||||
| 234 | |||||||||||||||||||
| 235 | This program is free software; you can redistribute it and/or modify it under | ||||||||||||||||||
| 236 | the same terms as Perl itself. | ||||||||||||||||||
| 237 | |||||||||||||||||||
| 238 | =cut | ||||||||||||||||||
| 239 | |||||||||||||||||||
| 240 | 1 | ▶ | use 5.004_57;; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 241 | 1 | ▶ | use Carp; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 242 | 1 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 243 | 1 | ▶ | use subs qw/normalize_callbacks/; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 244 | 1 | ▶ | use vars qw/@array_callbacks @hash_callbacks @scalar_callbacks/; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 245 | |||||||||||||||||||
| 246 | 1 | @array_callbacks = qw/-clear -delete -destroy -exists -extend -fetch | |||||||||||||||||
| 247 | -fetchsize -pop -push -shift -splice -store | ||||||||||||||||||
| 248 | -storesize -unshift/; | ||||||||||||||||||
| 249 | 1 | @hash_callbacks = qw/-clear -delete -destroy -exists -fetch -firstkey | |||||||||||||||||
| 250 | -nextkey -store/; | ||||||||||||||||||
| 251 | 1 | @scalar_callbacks = qw/-destroy -fetch -store/; | |||||||||||||||||
| 252 | |||||||||||||||||||
| 253 | 5 | ▶ | sub new { | ||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||
| 254 | |||||||||||||||||||
| 255 | # Watch constructor. The *real* constructor is Tie::Watch->base_watch(), | ||||||||||||||||||
| 256 | # invoked by methods in other Watch packages, depending upon the variable's | ||||||||||||||||||
| 257 | # type. Here we supply defaulted parameter values and then verify them, | ||||||||||||||||||
| 258 | # normalize all callbacks and bind the variable to the appropriate package. | ||||||||||||||||||
| 259 | |||||||||||||||||||
| 260 | 5 | my($class, %args) = @_; | |||||||||||||||||
| 261 | 5 | my $version = $Tie::Watch::VERSION; | |||||||||||||||||
| 262 | 5 | my (%arg_defaults) = (-debug => 0, -shadow => 1); | |||||||||||||||||
| 263 | 5 | my $variable = $args{-variable}; | |||||||||||||||||
| 264 | 5 | ▶ | croak "Tie::Watch::new(): -variable is required." if not defined $variable; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 265 | |||||||||||||||||||
| 266 | 5 | my($type, $watch_obj) = (ref $variable, undef); | |||||||||||||||||
| 267 | 5 | ▶ | if ($type =~ /(SCALAR|REF)/) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 268 | 1 | @arg_defaults{@scalar_callbacks} = ( | |||||||||||||||||
| 269 | [\&Tie::Watch::Scalar::Destroy], [\&Tie::Watch::Scalar::Fetch], | ||||||||||||||||||
| 270 | [\&Tie::Watch::Scalar::Store]); | ||||||||||||||||||
| 271 | } elsif ($type =~ /ARRAY/) { | ||||||||||||||||||
| 272 | 2 | @arg_defaults{@array_callbacks} = ( | |||||||||||||||||
| 273 | [\&Tie::Watch::Array::Clear], [\&Tie::Watch::Array::Delete], | ||||||||||||||||||
| 274 | [\&Tie::Watch::Array::Destroy], [\&Tie::Watch::Array::Exists], | ||||||||||||||||||
| 275 | [\&Tie::Watch::Array::Extend], [\&Tie::Watch::Array::Fetch], | ||||||||||||||||||
| 276 | [\&Tie::Watch::Array::Fetchsize], [\&Tie::Watch::Array::Pop], | ||||||||||||||||||
| 277 | [\&Tie::Watch::Array::Push], [\&Tie::Watch::Array::Shift], | ||||||||||||||||||
| 278 | [\&Tie::Watch::Array::Splice], [\&Tie::Watch::Array::Store], | ||||||||||||||||||
| 279 | [\&Tie::Watch::Array::Storesize], [\&Tie::Watch::Array::Unshift]); | ||||||||||||||||||
| 280 | } elsif ($type =~ /HASH/) { | ||||||||||||||||||
| 281 | 2 | @arg_defaults{@hash_callbacks} = ( | |||||||||||||||||
| 282 | [\&Tie::Watch::Hash::Clear], [\&Tie::Watch::Hash::Delete], | ||||||||||||||||||
| 283 | [\&Tie::Watch::Hash::Destroy], [\&Tie::Watch::Hash::Exists], | ||||||||||||||||||
| 284 | [\&Tie::Watch::Hash::Fetch], [\&Tie::Watch::Hash::Firstkey], | ||||||||||||||||||
| 285 | [\&Tie::Watch::Hash::Nextkey], [\&Tie::Watch::Hash::Store]); | ||||||||||||||||||
| 286 | } else { | ||||||||||||||||||
| 287 | 0 | croak "Tie::Watch::new() - not a variable reference."; | |||||||||||||||||
| 288 | } | ||||||||||||||||||
| 289 | 5 | my(@margs, %ahsh, $args, @args); | |||||||||||||||||
| 290 | 5 | @margs = grep ! defined $args{$_}, keys %arg_defaults; | |||||||||||||||||
| 291 | 5 | %ahsh = %args; # argument hash | |||||||||||||||||
| 292 | 5 | @ahsh{@margs} = @arg_defaults{@margs}; # fill in missing values | |||||||||||||||||
| 293 | 5 | normalize_callbacks \%ahsh; | |||||||||||||||||
| 294 | |||||||||||||||||||
| 295 | 5 | ▶ | if ($type =~ /(SCALAR|REF)/) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 296 | 1 | $watch_obj = tie $$variable, 'Tie::Watch::Scalar', %ahsh; | |||||||||||||||||
| 297 | } elsif ($type =~ /ARRAY/) { | ||||||||||||||||||
| 298 | 2 | $watch_obj = tie @$variable, 'Tie::Watch::Array', %ahsh; | |||||||||||||||||
| 299 | } elsif ($type =~ /HASH/) { | ||||||||||||||||||
| 300 | 2 | $watch_obj = tie %$variable, 'Tie::Watch::Hash', %ahsh; | |||||||||||||||||
| 301 | } | ||||||||||||||||||
| 302 | 5 | $watch_obj; | |||||||||||||||||
| 303 | |||||||||||||||||||
| 304 | } # end new, Watch constructor | ||||||||||||||||||
| 305 | |||||||||||||||||||
| 306 | 0 | ▶ | sub Args { | ||||||||||||||||
|
Subroutine
Args: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||
| 307 | |||||||||||||||||||
| 308 | # Return a reference to a list of callback arguments, or undef if none. | ||||||||||||||||||
| 309 | # | ||||||||||||||||||
| 310 | # $_[0] = self | ||||||||||||||||||
| 311 | # $_[1] = callback type | ||||||||||||||||||
| 312 | |||||||||||||||||||
| 313 | 0 | ▶ | defined $_[0]->{$_[1]}->[1] ? [@{$_[0]->{$_[1]}}[1 .. $#{$_[0]->{$_[1]}}]] | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 314 | : undef; | ||||||||||||||||||
| 315 | |||||||||||||||||||
| 316 | } # end Args | ||||||||||||||||||
| 317 | |||||||||||||||||||
| 318 | 0 | ▶ | sub Info { | ||||||||||||||||
|
Subroutine
Info: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 319 | |||||||||||||||||||
| 320 | # Info() method subclassed by other Watch modules. | ||||||||||||||||||
| 321 | # | ||||||||||||||||||
| 322 | # $_[0] = self | ||||||||||||||||||
| 323 | # @_[1 .. $#_] = optional callback types | ||||||||||||||||||
| 324 | |||||||||||||||||||
| 325 | 0 | my(%vinfo, @results); | |||||||||||||||||
| 326 | 0 | my(@info) = (qw/-variable -debug -shadow/); | |||||||||||||||||
| 327 | 0 | ▶ | push @info, @_[1 .. $#_] if scalar @_ >= 2; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 328 | 0 | foreach my $type (@info) { | |||||||||||||||||
| 329 | push @results, sprintf('%-10s: ', substr $type, 1) . | ||||||||||||||||||
| 330 | 0 | $_[0]->Say($_[0]->{$type}); | |||||||||||||||||
| 331 | 0 | $vinfo{$type} = $_[0]->{$type}; | |||||||||||||||||
| 332 | } | ||||||||||||||||||
| 333 | 0 | $vinfo{-legible} = [@results]; | |||||||||||||||||
| 334 | 0 | %vinfo; | |||||||||||||||||
| 335 | |||||||||||||||||||
| 336 | } # end Info | ||||||||||||||||||
| 337 | |||||||||||||||||||
| 338 | 0 | ▶ | sub Say { | ||||||||||||||||
|
Subroutine
Say: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 339 | |||||||||||||||||||
| 340 | # For debugging, mainly. | ||||||||||||||||||
| 341 | # | ||||||||||||||||||
| 342 | # $_[0] = self | ||||||||||||||||||
| 343 | # $_[1] = value | ||||||||||||||||||
| 344 | |||||||||||||||||||
| 345 | 0 | ▶ | defined $_[1] ? (ref($_[1]) ne '' ? $_[1] : "'$_[1]'") : "undefined"; | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 346 | |||||||||||||||||||
| 347 | } # end Say | ||||||||||||||||||
| 348 | |||||||||||||||||||
| 349 | 3 | ▶ | sub Unwatch { | ||||||||||||||||
|
Subroutine
Unwatch: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||||||
| 350 | |||||||||||||||||||
| 351 | # Stop watching a variable by releasing the last reference and untieing it. | ||||||||||||||||||
| 352 | # Update the original variable with its shadow, if appropriate. | ||||||||||||||||||
| 353 | # | ||||||||||||||||||
| 354 | # $_[0] = self | ||||||||||||||||||
| 355 | |||||||||||||||||||
| 356 | 3 | my $variable = $_[0]->{-variable}; | |||||||||||||||||
| 357 | 3 | my $type = ref $variable; | |||||||||||||||||
| 358 | 3 | ▶ | my $copy = $_[0]->{-ptr} if $type !~ /(SCALAR|REF)/; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 359 | 3 | my $shadow = $_[0]->{-shadow}; | |||||||||||||||||
| 360 | 3 | undef $_[0]; | |||||||||||||||||
| 361 | 3 | ▶ | if ($type =~ /(SCALAR|REF)/) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 362 | 1 | untie $$variable; | |||||||||||||||||
| 363 | } elsif ($type =~ /ARRAY/) { | ||||||||||||||||||
| 364 | 1 | untie @$variable; | |||||||||||||||||
| 365 | 1 | ▶ | @$variable = @$copy if $shadow; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 366 | } elsif ($type =~ /HASH/) { | ||||||||||||||||||
| 367 | 1 | untie %$variable; | |||||||||||||||||
| 368 | 1 | ▶ | %$variable = %$copy if $shadow; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 369 | } else { | ||||||||||||||||||
| 370 | 0 | croak "Tie::Watch::Delete() - not a variable reference."; | |||||||||||||||||
| 371 | } | ||||||||||||||||||
| 372 | |||||||||||||||||||
| 373 | } # end Unwatch | ||||||||||||||||||
| 374 | |||||||||||||||||||
| 375 | # Watch private methods. | ||||||||||||||||||
| 376 | |||||||||||||||||||
| 377 | 5 | ▶ | sub base_watch { | ||||||||||||||||
|
Subroutine
base_watch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 378 | |||||||||||||||||||
| 379 | # Watch base class constructor invoked by other Watch modules. | ||||||||||||||||||
| 380 | |||||||||||||||||||
| 381 | 5 | my($class, %args) = @_; | |||||||||||||||||
| 382 | 5 | my $watch_obj = {%args}; | |||||||||||||||||
| 383 | 5 | $watch_obj; | |||||||||||||||||
| 384 | |||||||||||||||||||
| 385 | } # end base_watch | ||||||||||||||||||
| 386 | |||||||||||||||||||
| 387 | 38 | ▶ | sub callback { | ||||||||||||||||
|
Subroutine
callback: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 388 | |||||||||||||||||||
| 389 | # Execute a Watch callback, either the default or user specified. | ||||||||||||||||||
| 390 | # Note that the arguments are those supplied by the tied method, | ||||||||||||||||||
| 391 | # not those (if any) specified by the user when the watch object | ||||||||||||||||||
| 392 | # was instantiated. This is for performance reasons, and why the | ||||||||||||||||||
| 393 | # Args() method exists. | ||||||||||||||||||
| 394 | # | ||||||||||||||||||
| 395 | # $_[0] = self | ||||||||||||||||||
| 396 | # $_[1] = callback type | ||||||||||||||||||
| 397 | # $_[2] through $#_ = tied arguments | ||||||||||||||||||
| 398 | |||||||||||||||||||
| 399 | 38 | &{$_[0]->{$_[1]}->[0]} ($_[0], @_[2 .. $#_]); | |||||||||||||||||
| 400 | |||||||||||||||||||
| 401 | } # end callback | ||||||||||||||||||
| 402 | |||||||||||||||||||
| 403 | 5 | ▶ | sub normalize_callbacks { | ||||||||||||||||
|
Subroutine
normalize_callbacks: called CC=5 SCAR=17.0
| |||||||||||||||||||
| 404 | |||||||||||||||||||
| 405 | # Ensure all callbacks are normalized in [\&code, @args] format. | ||||||||||||||||||
| 406 | |||||||||||||||||||
| 407 | 5 | my($args_ref) = @_; | |||||||||||||||||
| 408 | 5 | my($cb, $ref); | |||||||||||||||||
| 409 | 5 | foreach my $arg (keys %$args_ref) { | |||||||||||||||||
| 410 | 62 | ▶ | next if $arg =~ /variable|debug|shadow/; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 411 | 47 | $cb = $args_ref->{$arg}; | |||||||||||||||||
| 412 | 47 | $ref = ref $cb; | |||||||||||||||||
| 413 | 47 | ▶ | if ($ref =~ /CODE/) { | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 414 | 0 | $args_ref->{$arg} = [$cb]; | |||||||||||||||||
| 415 | } elsif ($ref !~ /ARRAY/) { | ||||||||||||||||||
| 416 | 0 | croak "Tie::Watch: malformed callback $arg=$cb."; | |||||||||||||||||
| 417 | } | ||||||||||||||||||
| 418 | } | ||||||||||||||||||
| 419 | |||||||||||||||||||
| 420 | } # end normalize_callbacks | ||||||||||||||||||
| 421 | |||||||||||||||||||
| 422 | ############################################################################### | ||||||||||||||||||
| 423 | |||||||||||||||||||
| 424 | package Tie::Watch::Scalar; | ||||||||||||||||||
| 425 | |||||||||||||||||||
| 426 | 1 | ▶ | use Carp; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 427 | 1 | @Tie::Watch::Scalar::ISA = qw/Tie::Watch/; | |||||||||||||||||
| 428 | |||||||||||||||||||
| 429 | 1 | ▶ | sub TIESCALAR { | ||||||||||||||||
|
Subroutine
TIESCALAR: called CC=2 SCAR=7.0
| |||||||||||||||||||
| 430 | |||||||||||||||||||
| 431 | 1 | my($class, %args) = @_; | |||||||||||||||||
| 432 | 1 | my $variable = $args{-variable}; | |||||||||||||||||
| 433 | 1 | my $watch_obj = Tie::Watch->base_watch(%args); | |||||||||||||||||
| 434 | 1 | $watch_obj->{-value} = $$variable; | |||||||||||||||||
| 435 | print "WatchScalar new: $variable created, \@_=", join(',', @_), "!\n" | ||||||||||||||||||
| 436 | 1 | ▶ | if $watch_obj->{-debug}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 437 | 1 | bless $watch_obj, $class; | |||||||||||||||||
| 438 | |||||||||||||||||||
| 439 | } # end TIESCALAR | ||||||||||||||||||
| 440 | |||||||||||||||||||
| 441 | 0 | ▶ | sub Info {$_[0]->SUPER::Info('-value', @Tie::Watch::scalar_callbacks)} | ||||||||||||||||
|
Subroutine
Info: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 442 | |||||||||||||||||||
| 443 | # Default scalar callbacks. | ||||||||||||||||||
| 444 | |||||||||||||||||||
| 445 | 1 | ▶ | sub Destroy {undef %{$_[0]}} | ||||||||||||||||
|
Subroutine
Destroy: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 446 | 1 | ▶ | sub Fetch {$_[0]->{-value}} | ||||||||||||||||
|
Subroutine
Fetch: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 447 | 1 | ▶ | sub Store {$_[0]->{-value} = $_[1]} | ||||||||||||||||
|
Subroutine
Store: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 448 | |||||||||||||||||||
| 449 | # Scalar access methods. | ||||||||||||||||||
| 450 | |||||||||||||||||||
| 451 | 1 | ▶ | sub DESTROY {$_[0]->callback('-destroy')} | ||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 452 | 1 | ▶ | sub FETCH {$_[0]->callback('-fetch')} | ||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 453 | 1 | ▶ | sub STORE {$_[0]->callback('-store', $_[1])} | ||||||||||||||||
|
Subroutine
STORE: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 454 | |||||||||||||||||||
| 455 | ############################################################################### | ||||||||||||||||||
| 456 | |||||||||||||||||||
| 457 | package Tie::Watch::Array; | ||||||||||||||||||
| 458 | |||||||||||||||||||
| 459 | 1 | ▶ | use Carp; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 460 | 1 | @Tie::Watch::Array::ISA = qw/Tie::Watch/; | |||||||||||||||||
| 461 | |||||||||||||||||||
| 462 | 2 | ▶ | sub TIEARRAY { | ||||||||||||||||
|
Subroutine
TIEARRAY: called CC=4 SCAR=14.3
| |||||||||||||||||||
| 463 | |||||||||||||||||||
| 464 | 2 | my($class, %args) = @_; | |||||||||||||||||
| 465 | 2 | my($variable, $shadow) = @args{-variable, -shadow}; | |||||||||||||||||
| 466 | 2 | ▶ | my @copy = @$variable if $shadow; # make a private copy of user's array | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 467 | 2 | ▶ | $args{-ptr} = $shadow ? \@copy : []; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 468 | 2 | my $watch_obj = Tie::Watch->base_watch(%args); | |||||||||||||||||
| 469 | print "WatchArray new: $variable created, \@_=", join(',', @_), "!\n" | ||||||||||||||||||
| 470 | 2 | ▶ | if $watch_obj->{-debug}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 471 | 2 | bless $watch_obj, $class; | |||||||||||||||||
| 472 | |||||||||||||||||||
| 473 | } # end TIEARRAY | ||||||||||||||||||
| 474 | |||||||||||||||||||
| 475 | 0 | ▶ | sub Info {$_[0]->SUPER::Info('-ptr', @Tie::Watch::array_callbacks)} | ||||||||||||||||
|
Subroutine
Info: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 476 | |||||||||||||||||||
| 477 | # Default array callbacks. | ||||||||||||||||||
| 478 | |||||||||||||||||||
| 479 | 0 | ▶ | sub Clear {$_[0]->{-ptr} = ()} | ||||||||||||||||
|
Subroutine
Clear: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 480 | 0 | ▶ | sub Delete {delete $_[0]->{-ptr}->[$_[1]]} | ||||||||||||||||
|
Subroutine
Delete: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 481 | 1 | ▶ | sub Destroy {undef %{$_[0]}} | ||||||||||||||||
|
Subroutine
Destroy: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 482 | 0 | ▶ | sub Exists {exists $_[0]->{-ptr}->[$_[1]]} | ||||||||||||||||
|
Subroutine
Exists: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 483 | 0 | ▶ | sub Extend {} | ||||||||||||||||
|
Subroutine
Extend: not called CC=1 SCAR=0.0
| |||||||||||||||||||
| 484 | 1 | ▶ | sub Fetch {$_[0]->{-ptr}->[$_[1]]} | ||||||||||||||||
|
Subroutine
Fetch: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 485 | 2 | ▶ | sub Fetchsize {scalar @{$_[0]->{-ptr}}} | ||||||||||||||||
|
Subroutine
Fetchsize: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 486 | 0 | ▶ | sub Pop {pop @{$_[0]->{-ptr}}} | ||||||||||||||||
|
Subroutine
Pop: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 487 | 1 | ▶ | sub Push {push @{$_[0]->{-ptr}}, @_[1 .. $#_]} | ||||||||||||||||
|
Subroutine
Push: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 488 | 0 | ▶ | sub Shift {shift @{$_[0]->{-ptr}}} | ||||||||||||||||
|
Subroutine
Shift: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 489 | 0 | ▶ | sub Splice { | ||||||||||||||||
|
Subroutine
Splice: not called CC=4 SCAR=30.0
| |||||||||||||||||||
| 490 | 0 | my $n = scalar @_; # splice() is wierd! | |||||||||||||||||
| 491 | 0 | ▶ | return splice @{$_[0]->{-ptr}}, $_[1] if $n == 2; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 492 | 0 | ▶ | return splice @{$_[0]->{-ptr}}, $_[1], $_[2] if $n == 3; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 493 | 0 | ▶ | return splice @{$_[0]->{-ptr}}, $_[1], $_[2], @_[3 .. $#_] if $n >= 4; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 494 | } | ||||||||||||||||||
| 495 | 1 | ▶ | sub Store {$_[0]->{-ptr}->[$_[1]] = $_[2]} | ||||||||||||||||
|
Subroutine
Store: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 496 | 1 | ▶ | sub Storesize {$#{@{$_[0]->{-ptr}}} = $_[1] - 1} | ||||||||||||||||
|
Subroutine
Storesize: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 497 | 0 | ▶ | sub Unshift {unshift @{$_[0]->{-ptr}}, @_[1 .. $#_]} | ||||||||||||||||
|
Subroutine
Unshift: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 498 | |||||||||||||||||||
| 499 | # Array access methods. | ||||||||||||||||||
| 500 | |||||||||||||||||||
| 501 | 0 | ▶ | sub CLEAR {$_[0]->callback('-clear')} | ||||||||||||||||
|
Subroutine
CLEAR: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 502 | 0 | ▶ | sub DELETE {$_[0]->callback('-delete', $_[1])} | ||||||||||||||||
|
Subroutine
DELETE: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 503 | 1 | ▶ | sub DESTROY {$_[0]->callback('-destroy')} | ||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 504 | 0 | ▶ | sub EXISTS {$_[0]->callback('-exists', $_[1])} | ||||||||||||||||
|
Subroutine
EXISTS: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 505 | 0 | ▶ | sub EXTEND {$_[0]->callback('-extend', $_[1])} | ||||||||||||||||
|
Subroutine
EXTEND: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 506 | 1 | ▶ | sub FETCH {$_[0]->callback('-fetch', $_[1])} | ||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 507 | 2 | ▶ | sub FETCHSIZE {$_[0]->callback('-fetchsize')} | ||||||||||||||||
|
Subroutine
FETCHSIZE: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 508 | 0 | ▶ | sub POP {$_[0]->callback('-pop')} | ||||||||||||||||
|
Subroutine
POP: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 509 | 1 | ▶ | sub PUSH {$_[0]->callback('-push', @_[1 .. $#_])} | ||||||||||||||||
|
Subroutine
PUSH: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 510 | 0 | ▶ | sub SHIFT {$_[0]->callback('-shift')} | ||||||||||||||||
|
Subroutine
SHIFT: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 511 | 0 | ▶ | sub SPLICE {$_[0]->callback('-splice', @_[1 .. $#_])} | ||||||||||||||||
|
Subroutine
SPLICE: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 512 | 1 | ▶ | sub STORE {$_[0]->callback('-store', $_[1], $_[2])} | ||||||||||||||||
|
Subroutine
STORE: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 513 | 1 | ▶ | sub STORESIZE {$_[0]->callback('-storesize', $_[1])} | ||||||||||||||||
|
Subroutine
STORESIZE: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 514 | 0 | ▶ | sub UNSHIFT {$_[0]->callback('-unshift', @_[1 .. $#_])} | ||||||||||||||||
|
Subroutine
UNSHIFT: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 515 | |||||||||||||||||||
| 516 | ############################################################################### | ||||||||||||||||||
| 517 | |||||||||||||||||||
| 518 | package Tie::Watch::Hash; | ||||||||||||||||||
| 519 | |||||||||||||||||||
| 520 | 1 | ▶ | use Carp; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 521 | 1 | @Tie::Watch::Hash::ISA = qw/Tie::Watch/; | |||||||||||||||||
| 522 | |||||||||||||||||||
| 523 | 2 | ▶ | sub TIEHASH { | ||||||||||||||||
|
Subroutine
TIEHASH: called CC=4 SCAR=14.3
| |||||||||||||||||||
| 524 | |||||||||||||||||||
| 525 | 2 | my($class, %args) = @_; | |||||||||||||||||
| 526 | 2 | my($variable, $shadow) = @args{-variable, -shadow}; | |||||||||||||||||
| 527 | 2 | ▶ | my %copy = %$variable if $shadow; # make a private copy of user's hash | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 528 | 2 | ▶ | $args{-ptr} = $shadow ? \%copy : {}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 529 | 2 | my $watch_obj = Tie::Watch->base_watch(%args); | |||||||||||||||||
| 530 | print "WatchHash new: $variable created, \@_=", join(',', @_), "!\n" | ||||||||||||||||||
| 531 | 2 | ▶ | if $watch_obj->{-debug}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 532 | 2 | bless $watch_obj, $class; | |||||||||||||||||
| 533 | |||||||||||||||||||
| 534 | } # end TIEHASH | ||||||||||||||||||
| 535 | |||||||||||||||||||
| 536 | 0 | ▶ | sub Info {$_[0]->SUPER::Info('-ptr', @Tie::Watch::hash_callbacks)} | ||||||||||||||||
|
Subroutine
Info: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 537 | |||||||||||||||||||
| 538 | # Default hash callbacks. | ||||||||||||||||||
| 539 | |||||||||||||||||||
| 540 | 0 | ▶ | sub Clear {$_[0]->{-ptr} = ()} | ||||||||||||||||
|
Subroutine
Clear: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 541 | 1 | ▶ | sub Delete {delete $_[0]->{-ptr}->{$_[1]}} | ||||||||||||||||
|
Subroutine
Delete: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 542 | 1 | ▶ | sub Destroy {undef %{$_[0]}} | ||||||||||||||||
|
Subroutine
Destroy: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 543 | 2 | ▶ | sub Exists {exists $_[0]->{-ptr}->{$_[1]}} | ||||||||||||||||
|
Subroutine
Exists: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 544 | 7 | ▶ | sub Fetch {$_[0]->{-ptr}->{$_[1]}} | ||||||||||||||||
|
Subroutine
Fetch: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 545 | 3 | ▶ | sub Firstkey {my $c = keys %{$_[0]->{-ptr}}; each %{$_[0]->{-ptr}}} | ||||||||||||||||
|
Subroutine
Firstkey: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 546 | 10 | ▶ | sub Nextkey {each %{$_[0]->{-ptr}}} | ||||||||||||||||
|
Subroutine
Nextkey: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 547 | 4 | ▶ | sub Store {$_[0]->{-ptr}->{$_[1]} = $_[2]} | ||||||||||||||||
|
Subroutine
Store: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 548 | |||||||||||||||||||
| 549 | # Hash access methods. | ||||||||||||||||||
| 550 | |||||||||||||||||||
| 551 | 0 | ▶ | sub CLEAR {$_[0]->callback('-clear')} | ||||||||||||||||
|
Subroutine
CLEAR: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 552 | 1 | ▶ | sub DELETE {$_[0]->callback('-delete', $_[1])} | ||||||||||||||||
|
Subroutine
DELETE: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 553 | 1 | ▶ | sub DESTROY {$_[0]->callback('-destroy')} | ||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 554 | 2 | ▶ | sub EXISTS {$_[0]->callback('-exists', $_[1])} | ||||||||||||||||
|
Subroutine
EXISTS: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 555 | 7 | ▶ | sub FETCH {$_[0]->callback('-fetch', $_[1])} | ||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 556 | 3 | ▶ | sub FIRSTKEY {$_[0]->callback('-firstkey')} | ||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 557 | 10 | ▶ | sub NEXTKEY {$_[0]->callback('-nextkey')} | ||||||||||||||||
|
Subroutine
NEXTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 558 | 4 | ▶ | sub STORE {$_[0]->callback('-store', $_[1], $_[2])} | ||||||||||||||||
|
Subroutine
STORE: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 559 | |||||||||||||||||||
| 560 | 1 | 1; | |||||||||||||||||