line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SWISH::API::Remote::FunctionGenerator; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################ |
4
|
|
|
|
|
|
|
# makeaccessors( 'packagename', 'fieldname', ['fieldname'...]) |
5
|
|
|
|
|
|
|
# makes functions called fieldname() and fieldname2() in the package 'packagename' |
6
|
|
|
|
|
|
|
# which will create functions to get/set, ie, |
7
|
|
|
|
|
|
|
# $self->fieldname() and $self->fieldname( "value" ) |
8
|
|
|
|
|
|
|
# returns nothing useful |
9
|
|
|
|
|
|
|
sub makeaccessors { |
10
|
6
|
|
|
6
|
0
|
27
|
my ($package, @list) = @_; |
11
|
6
|
|
|
|
|
18
|
for my $f (@list) { |
12
|
15
|
50
|
|
|
|
91
|
die "not a valid function name: $f" unless $f =~ /^[a-zA-Z][a-zA-Z0-9]*$/; |
13
|
15
|
|
|
|
|
75
|
(my $fu = $f) =~ s/^([a-z])/uc($1)/e; |
|
15
|
|
|
|
|
56
|
|
14
|
15
|
|
|
|
|
76
|
my $acc = "package $package; sub $fu { "; |
15
|
15
|
|
|
|
|
43
|
$acc .= "my \$self = shift; return \$self->{$f} unless (\@_); \$self->{$f} = shift; }; "; |
16
|
|
|
|
|
|
|
#warn "\n$acc\n"; |
17
|
|
|
|
|
|
|
|
18
|
15
|
0
|
|
0
|
0
|
1451
|
eval $acc; |
|
0
|
0
|
|
0
|
0
|
|
|
|
0
|
0
|
|
0
|
0
|
|
|
|
0
|
0
|
|
0
|
0
|
|
|
|
0
|
0
|
|
0
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
15
|
50
|
|
|
|
77
|
die "Failed to create function $package::$f: $@" if $@; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |