line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SPVM::BlessedObject::Class; |
2
|
|
|
|
|
|
|
|
3
|
278
|
|
|
278
|
|
1909
|
use strict; |
|
278
|
|
|
|
|
571
|
|
|
278
|
|
|
|
|
8635
|
|
4
|
278
|
|
|
278
|
|
1364
|
use warnings; |
|
278
|
|
|
|
|
532
|
|
|
278
|
|
|
|
|
6185
|
|
5
|
278
|
|
|
278
|
|
1314
|
use Carp; |
|
278
|
|
|
|
|
527
|
|
|
278
|
|
|
|
|
15389
|
|
6
|
|
|
|
|
|
|
|
7
|
278
|
|
|
278
|
|
2100
|
use base 'SPVM::BlessedObject'; |
|
278
|
|
|
|
|
755
|
|
|
278
|
|
|
|
|
28078
|
|
8
|
|
|
|
|
|
|
|
9
|
278
|
|
|
278
|
|
1962
|
use SPVM::ExchangeAPI; |
|
278
|
|
|
|
|
545
|
|
|
278
|
|
|
|
|
64337
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTOLOAD; |
12
|
|
|
|
|
|
|
sub AUTOLOAD { |
13
|
120991
|
|
|
120991
|
|
221166
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
120991
|
|
|
|
|
174000
|
my $method_name = $AUTOLOAD; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# If the class method is not found, AUTOLOAD is called. |
18
|
120991
|
100
|
|
|
|
237725
|
unless (ref $self) { |
19
|
2
|
|
|
|
|
5
|
my $basic_type_name = $self; |
20
|
2
|
|
|
|
|
12
|
$basic_type_name =~ s/^SPVM:://; |
21
|
2
|
|
|
|
|
13
|
$method_name =~ s/^.*:://; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
262
|
Carp::confess("The \"$method_name\" method in the \"$basic_type_name\" class is not found"); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# For a static instant method call |
27
|
120989
|
|
|
|
|
430816
|
$method_name =~ s/^SPVM:://; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# For an instance method call |
30
|
120989
|
|
|
|
|
307658
|
$method_name =~ s/^BlessedObject::Class:://; |
31
|
|
|
|
|
|
|
|
32
|
120989
|
|
|
|
|
275845
|
my $ret = $self->__api->call_method($self, $method_name, @_); |
33
|
|
|
|
|
|
|
|
34
|
120983
|
|
|
|
|
3420231
|
return $ret; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 Name |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
SPVM::BlessedObject::Class - SPVM Class |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 Description |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The object of the C class holds an instance of a SPVM class. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 Usage |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use SPVM 'Point'; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $point = SPVM::Point->new; |
52
|
|
|
|
|
|
|
$point->set_x(4); |
53
|
|
|
|
|
|
|
my $x = $point->x; |
54
|
|
|
|
|
|
|
$point->clear; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 Instance Methods |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 AUTOLOAD |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Instance method call |
61
|
|
|
|
|
|
|
my $ret = $blessed_object_class->foo(@args); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Static instance method call |
64
|
|
|
|
|
|
|
my $ret = $blessed_object_class->SPVM::MyClass::foo(@args); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Calls a SPVM instance method using L with the arguments, and returns the return value. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The static instance method call is allowed. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
If the class or the method is not found, an exception is thrown. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
If the invocant cannnot be assigned to the class of the static method call, an exception is thrown. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Examples: |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
use SPVM 'Point'; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Creates a SPVM::BlessedObject::Class object of the Point class. |
79
|
|
|
|
|
|
|
my $point = Point->new; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Calls instance methods in the Point class. |
82
|
|
|
|
|
|
|
$point->set_x(4); |
83
|
|
|
|
|
|
|
my $x = $point->x; |
84
|
|
|
|
|
|
|
$point->clear; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 Copyright & License |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Copyright (c) 2023 Yuki Kimoto |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
MIT License |