line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JavaScript::QuickJS::Function; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2197
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
128
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
298
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=encoding utf-8 |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
JavaScript::QuickJS::Function |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $func = JavaScript::QuickJS->new()->eval("() => 123"); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
print $func->(); # prints “123”; note overloading :) |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class represents a JavaScript |
21
|
|
|
|
|
|
|
L |
22
|
|
|
|
|
|
|
instance in Perl. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This class is not instantiated directly. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 OVERLOADING |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
For convenience, instances of this class are callable as Perl code references. |
29
|
|
|
|
|
|
|
This is equivalent to a C with $this_sv (see below) set to undef. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
See the L above for an example. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 INVOCATION METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 $ret = I->call( $this_sv, @arguments ) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Like JavaScript’s method of the same name. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 ACCESSOR METHODS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
The following methods return their corresponding JS property: |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item * C |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * C |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _as_coderef; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use overload ( |
58
|
4
|
|
|
|
|
34
|
'&{}' => \&_as_coderef, |
59
|
|
|
|
|
|
|
nomethod => \&_give_self, # xsub |
60
|
4
|
|
|
4
|
|
26
|
); |
|
4
|
|
|
|
|
10
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _as_coderef { |
63
|
9
|
|
|
9
|
|
28221
|
my ($self) = @_; |
64
|
|
|
|
|
|
|
|
65
|
9
|
|
|
9
|
|
74
|
return sub { $self->call(undef, @_) }; |
|
9
|
|
|
|
|
169
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |