blib/lib/SPVM/ExchangeAPI.pm

filter: Statementstmt 20.5% 103 / 501 Branchbran 8.7% 16 / 184 Conditioncond 8.3% 2 / 24 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 33.7% 25 / 74 Podpod 92.4% 61 / 66 totaltotal 23.9% 207 / 865 CC 104 SCAR 25.1
CC
104
Cov
17%
new_options
42.0
new_options
42.0
new_muldim_array
30.0
CRAP 12.3
« blib/lib/SPVM/Builder/LinkInfo.pm ↑ Summary blib/lib/SPVM/Builder/DependencyAnalyzer.pm »
1 package SPVM::ExchangeAPI;
2  
3 279 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 279 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 279 ▶use SPVM::ExchangeAPI::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 279 ▶use SPVM::ExchangeAPI::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 279 ▶use Carp 'confess';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 279 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Fields
12 270 ▶sub env {
Subroutine env: called CC=2 SCAR=8.4
Pod documented
13 270 ▶ my $self = shift;
Subroutine env: called CC=2 SCAR=8.4
Pod documented
14 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 270 270
if (@_) { } 0 769 769
15 0 $self->{env} = $_[0];
16 0 return $self;
17 }
18 else {
19 270 return $self->{env};
20 }
21 }
22  
23 83 ▶sub stack {
Subroutine stack: called CC=2 SCAR=8.4
Pod documented
24 83 ▶ my $self = shift;
Subroutine stack: called CC=2 SCAR=8.4
Pod documented
25 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 83 83
if (@_) { } 0 274 274
26 0 $self->{stack} = $_[0];
27 0 return $self;
28 }
29 else {
30 83 return $self->{stack};
31 }
32 }
33  
34 # Class Methods
35 167 ▶sub new {
Subroutine new: called CC=2 SCAR=7.4
Pod undocumented
36 167 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.4
Pod undocumented
37
38 167 my $self = {
39 @_
40 };
41
42 167 ▶ bless $self, ref $class || $class;
Condition33%2/6
ref $class || $class
l!l&&r!l&&!r
01670
ref $class || $class
l!l&&r!l&&!r
04630
MC/DC0%0/2
ref $class || $class
ref $class $class
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
43
44 167 return $self;
45 }
46  
47 # Instance Methods
48  
49 0 ▶sub _parse_type_name {
Subroutine _parse_type_name: not called CC=3 SCAR=14.8
50 0 ▶ my ($self, $type_name) = @_;
Subroutine _parse_type_name: called CC=3 SCAR=14.8
51
52 0 my $basic_type_name;
53 0 my $type_dimension = 0;
54 0 ▶ if ($type_name =~ /^([a-zA-Z_0-9:]+)((\[\])*)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type_name =~ /^([a-zA-Z_0-9:]+)((\[\])*)$/) 0 0 0
if ($type_name =~ /^([a-zA-Z_0-9:]+)((\[\])*)$/) 201 0 201
55 0 $basic_type_name = $1;
56 0 my $type_dimension_part = $2;
57
58 0 ▶ while ($type_dimension_part =~ /\[/g) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type_dimension_part =~ /\[/g) 0 0 0
if ($type_dimension_part =~ /\[/g) 201 201 402
59 0 $type_dimension++;
60 }
61 }
62
63 0 return ($basic_type_name, $type_dimension);
64 }
65  
66 0 ▶sub new_object_array {
Subroutine new_object_array: not called CC=4 SCAR=22.4
Pod documented
67 0 ▶ my ($self, $type_name, $array) = @_;
Subroutine new_object_array: called CC=4 SCAR=22.4
Pod documented
68
69 0 my ($basic_type_name, $type_dimension) = $self->_parse_type_name($type_name);
70
71 0 ▶ unless (defined $basic_type_name) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $basic_type_name) 0 0 0
unless (defined $basic_type_name) 0 201 201
72 0 confess("The type name \$type_name was parsed, but the class name could not be extracted");
73 }
74
75 0 ▶ unless ($type_dimension == 1) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($type_dimension == 1) 0 0 0
unless ($type_dimension == 1) 0 201 201
76 0 confess("The dimension of the type \$type_name must be 1");
77 }
78
79 0 my $ret;
80 0 eval { $ret = $self->_xs_new_object_array($basic_type_name, $array) };
81 0 ▶ if ($@) { confess($@) }
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 201 201
82
83 0 return $ret;
84 }
85  
86 0 ▶sub new_object_array_len {
Subroutine new_object_array_len: not called CC=4 SCAR=29.3
Pod documented
87 0 ▶ my ($self, $type_name, $length) = @_;
Subroutine new_object_array_len: not called CC=4 SCAR=29.3
Pod documented
88
89 0 my ($basic_type_name, $type_dimension) = $self->_parse_type_name($type_name);
90
91 0 ▶ unless (defined $basic_type_name) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $basic_type_name) 0 0 0
unless (defined $basic_type_name) 0 0 0
92 0 confess("The type name \$type_name was parsed, but the class name could not be extracted");
93 }
94
95 0 ▶ unless ($type_dimension == 1) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($type_dimension == 1) 0 0 0
unless ($type_dimension == 1) 0 0 0
96 0 confess("The dimension of the type \$type_name must be 1");
97 }
98
99 0 my $ret;
100 0 eval { $ret = $self->_xs_new_object_array_len($basic_type_name, $length) };
101 0 ▶ if ($@) { confess($@) }
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
102
103 0 return $ret;
104 }
105  
106 0 ▶sub new_any_object_array {
Subroutine new_any_object_array: not called CC=1 SCAR=2.6
Pod documented
107 0 ▶ my ($self, $array) = @_;
Subroutine new_any_object_array: called CC=1 SCAR=2.6
Pod documented
108
109 0 my $type_name = 'object[]';
110
111 0 return $self->new_object_array($type_name, $array);
112 }
113  
114 0 ▶sub new_any_object_array_len {
Subroutine new_any_object_array_len: not called CC=1 SCAR=6.9
Pod documented
115 0 ▶ my ($self, $length) = @_;
Subroutine new_any_object_array_len: not called CC=1 SCAR=6.9
Pod documented
116
117 0 my $type_name = 'object[]';
118
119 0 my $array = $self->new_object_array_len($type_name, $length);
120
121 0 return $array;
122 }
123  
124 0 ▶sub new_options {
Subroutine new_options: not called CC=6 SCAR=37.4
Pod documented
125 0 ▶ my ($self, $options) = @_;
Subroutine new_options: not called CC=6 SCAR=37.4
Pod documented
126
127 0 ▶ unless (ref $options eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
unless (ref $options eq "HASH") 0 0 0
unless (ref $options eq "HASH") 0 0 0
128 0 confess("The options \$options must be a hash reference");
129 }
130
131 0 my $array_ref = [];
132 0 for my $name (keys %$options) {
133 0 my $obj_name = $self->new_string($name);
134 0 my $value = $options->{$name};
135 0 ▶ if (defined $value) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $value) 0 0 0
if (defined $value) 0 0 0
136 0 ▶ unless (blessed $value && $value->isa('SPVM::BlessedObject')) {
Branch: 2 branches
BranchTrueFalseTotal
unless (builtin::blessed($value) and $value->isa("SPVM::BlessedObject")) 0 0 0
unless (builtin::blessed($value) and $value->isa("SPVM::BlessedObject")) 0 0 0
Condition0%0/6
builtin::blessed($value) and $value->isa("SPVM::BlessedObject")
!ll&&!rl&&r
000
builtin::blessed($value) and $value->isa("SPVM::BlessedObject")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("SPVM::BlessedObject")
builtin::blessed($value) $value->isa("SPVM::BlessedObject")
MC/DC0%0/2
builtin::blessed($value) and $value->isa("SPVM::BlessedObject")
builtin::blessed($value) $value->isa("SPVM::BlessedObject")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("SPVM::BlessedObject")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("SPVM::BlessedObject")
ABresult
0X0
100
111
137 0 confess("The value of \$options must be an SPVM::BlessedObject object");
138 }
139 }
140 0 push @$array_ref, $obj_name, $value;
141 }
142
143 0 my $array = $self->new_any_object_array($array_ref);
144
145 0 return $array;
146 }
147  
148 0 ▶sub new_mulnum_array {
Subroutine new_mulnum_array: not called CC=4 SCAR=30.0
Pod documented
149 0 ▶ my ($self, $type_name, $array) = @_;
Subroutine new_mulnum_array: not called CC=4 SCAR=30.0
Pod documented
150
151 0 my ($basic_type_name, $type_dimension) = $self->_parse_type_name($type_name);
152
153 0 ▶ unless (defined $basic_type_name) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $basic_type_name) 0 0 0
unless (defined $basic_type_name) 0 0 0
154 0 confess("The type name \$type_name was parsed, but the class name could not be extracted");
155 }
156
157 0 ▶ unless ($type_dimension == 1) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($type_dimension == 1) 0 0 0
unless ($type_dimension == 1) 0 0 0
158 0 confess("The dimension of the type \$type_name must be 1");
159 }
160
161 0 my $ret;
162 0 eval { $ret = $self->_xs_new_mulnum_array($basic_type_name, $array) };
163 0 ▶ if ($@) { confess($@) }
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
164
165 0 return $ret;
166 }
167  
168 11 ▶sub new_mulnum_array_len {
Subroutine new_mulnum_array_len: called CC=4 SCAR=30.0
Pod documented
169 0 ▶ my ($self, $type_name, $length) = @_;
Subroutine new_mulnum_array_len: not called CC=4 SCAR=30.0
Pod documented
170
171 0 my ($basic_type_name, $type_dimension) = $self->_parse_type_name($type_name);
172
173 0 ▶ unless (defined $basic_type_name) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $basic_type_name) 0 0 0
unless (defined $basic_type_name) 0 0 0
174 0 confess("The type name \$type_name was parsed, but the class name could not be extracted");
175 }
176
177 0 ▶ unless ($type_dimension == 1) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($type_dimension == 1) 0 0 0
unless ($type_dimension == 1) 0 0 0
178 0 confess("The dimension of the type \$type_name must be 1");
179 }
180
181 0 my $ret;
182 0 eval { $ret = $self->_xs_new_mulnum_array_len($basic_type_name, $length) };
183 0 ▶ if ($@) { confess($@) }
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
184
185 0 return $ret;
186 }
187  
188 0 ▶sub new_mulnum_array_from_bin {
Subroutine new_mulnum_array_from_bin: not called CC=4 SCAR=30.0
Pod documented
189 0 ▶ my ($self, $type_name, $binary) = @_;
Subroutine new_mulnum_array_from_bin: not called CC=4 SCAR=30.0
Pod documented
190
191 0 my ($basic_type_name, $type_dimension) = $self->_parse_type_name($type_name);
192
193 0 ▶ unless (defined $basic_type_name) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $basic_type_name) 0 0 0
unless (defined $basic_type_name) 0 0 0
194 0 confess("The type name \$type_name was parsed, but the class name could not be extracted");
195 }
196
197 0 ▶ unless ($type_dimension == 1) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($type_dimension == 1) 0 0 0
unless ($type_dimension == 1) 0 0 0
198 0 confess("The dimension of the type \$type_name must be 1");
199 }
200 0 my $ret;
201 0 eval { $ret = $self->_xs_new_mulnum_array_from_bin($basic_type_name, $binary) };
202 0 ▶ if ($@) { confess($@) }
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
203
204 0 return $ret;
205 }
206  
207 0 ▶sub new_muldim_array {
Subroutine new_muldim_array: not called CC=5 SCAR=34.0
Pod documented
208 0 ▶ my ($self, $type_name, $array) = @_;
Subroutine new_muldim_array: not called CC=5 SCAR=34.0
Pod documented
209
210 0 my ($basic_type_name, $type_dimension) = $self->_parse_type_name($type_name);
211
212 0 ▶ unless (defined $basic_type_name) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $basic_type_name) 0 0 0
unless (defined $basic_type_name) 0 0 0
213 0 confess("The type name \$type_name was parsed, but the class name could not be extracted");
214 }
215
216 0 ▶ unless ($type_dimension >= 2 && $type_dimension <= 255) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($type_dimension >= 2 and $type_dimension <= 255) 0 0 0
unless ($type_dimension >= 2 and $type_dimension <= 255) 0 0 0
Condition0%0/6
$type_dimension >= 2 and $type_dimension <= 255
!ll&&!rl&&r
000
$type_dimension >= 2 and $type_dimension <= 255
!ll&&!rl&&r
000
MC/DC0%0/2
$type_dimension >= 2 and $type_dimension <= 255
$type_dimension >= 2 $type_dimension <= 255
MC/DC0%0/2
$type_dimension >= 2 and $type_dimension <= 255
$type_dimension >= 2 $type_dimension <= 255
Truth table0%0/3
A and B
A= $type_dimension >= 2B= $type_dimension <= 255
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $type_dimension >= 2B= $type_dimension <= 255
ABresult
0X0
100
111
217 0 confess("The dimension of the type \$type_name must be greater than or equal to 2 and less than or equal to 255");
218 }
219
220 0 my $ret;
221 0 eval { $ret = $self->_xs_new_muldim_array($basic_type_name, $type_dimension, $array) };
222 0 ▶ if ($@) { confess($@) }
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
223
224 0 return $ret;
225 }
226  
227 0 ▶sub new_muldim_array_len {
Subroutine new_muldim_array_len: not called CC=5 SCAR=31.0
Pod documented
228 0 ▶ my ($self, $type_name, $length) = @_;
Subroutine new_muldim_array_len: not called CC=5 SCAR=31.0
Pod documented
229
230 0 my ($basic_type_name, $type_dimension) = $self->_parse_type_name($type_name);
231
232 0 ▶ unless (defined $basic_type_name) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $basic_type_name) 0 0 0
unless (defined $basic_type_name) 0 0 0
233 0 confess("The type name \$type_name was parsed, but the class name could not be extracted");
234 }
235
236 0 ▶ unless ($type_dimension >= 2 && $type_dimension <= 255) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($type_dimension >= 2 and $type_dimension <= 255) 0 0 0
unless ($type_dimension >= 2 and $type_dimension <= 255) 0 0 0
Condition0%0/6
$type_dimension >= 2 and $type_dimension <= 255
!ll&&!rl&&r
000
$type_dimension >= 2 and $type_dimension <= 255
!ll&&!rl&&r
000
MC/DC0%0/2
$type_dimension >= 2 and $type_dimension <= 255
$type_dimension >= 2 $type_dimension <= 255
MC/DC0%0/2
$type_dimension >= 2 and $type_dimension <= 255
$type_dimension >= 2 $type_dimension <= 255
Truth table0%0/3
A and B
A= $type_dimension >= 2B= $type_dimension <= 255
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $type_dimension >= 2B= $type_dimension <= 255
ABresult
0X0
100
111
237 0 confess("The dimension of the type \$type_name must be greater than or equal to 2 and less than or equal to 255");
238 }
239
240 0 my $ret;
241 0 eval { $ret = $self->_xs_new_muldim_array_len($basic_type_name, $type_dimension, $length) };
242 0 ▶ if ($@) { confess($@) }
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
243
244 0 return $ret;
245 }
246  
247 0 ▶sub class {
Subroutine class: not called CC=1 SCAR=6.9
Pod documented
248 0 ▶ my ($self, $basic_type_name) = @_;
Subroutine class: not called CC=1 SCAR=6.9
Pod documented
249
250 0 my $class = SPVM::ExchangeAPI::Class->__new(__name => $basic_type_name, __api => $self);
251
252 0 return $class;
253 }
254  
255 0 ▶sub new_error {
Subroutine new_error: not called CC=1 SCAR=6.9
Pod undocumented
256 0 ▶ my ($self) = @_;
Subroutine new_error: not called CC=1 SCAR=6.9
Pod undocumented
257
258 0 my $error = SPVM::ExchangeAPI::Error->new(id => 0);
259
260 0 return $error;
261 }
262  
263 # other functions is implemented in SPVM.xs
264  
265 0 ▶sub new_string { my $ret; eval { $ret = &_xs_new_string(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_string: not called CC=2 SCAR=15.4
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 11 11
266 0 ▶sub new_address_object { my $ret; eval { $ret = &_xs_new_address_object(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_address_object: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
267 0 ▶sub new_byte_array { my $ret; eval { $ret = &_xs_new_byte_array(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_byte_array: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
268 0 ▶sub new_byte_array_unsigned { my $ret; eval { $ret = &_xs_new_byte_array_unsigned(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_byte_array_unsigned: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
269 0 ▶sub new_byte_array_len { my $ret; eval { $ret = &_xs_new_byte_array_len(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_byte_array_len: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
270 0 ▶sub new_byte_array_from_bin { my $ret; eval { $ret = &_xs_new_byte_array_from_bin(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_byte_array_from_bin: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
271 0 ▶sub new_short_array { my $ret; eval { $ret = &_xs_new_short_array(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_short_array: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
272 0 ▶sub new_short_array_unsigned { my $ret; eval { $ret = &_xs_new_short_array_unsigned(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_short_array_unsigned: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
273 0 ▶sub new_short_array_len { my $ret; eval { $ret = &_xs_new_short_array_len(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_short_array_len: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
274 0 ▶sub new_short_array_from_bin { my $ret; eval { $ret = &_xs_new_short_array_from_bin(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_short_array_from_bin: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
275 0 ▶sub new_int_array { my $ret; eval { $ret = &_xs_new_int_array(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_int_array: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
276 0 ▶sub new_int_array_unsigned { my $ret; eval { $ret = &_xs_new_int_array_unsigned(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_int_array_unsigned: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
277 0 ▶sub new_int_array_len { my $ret; eval { $ret = &_xs_new_int_array_len(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_int_array_len: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
278 0 ▶sub new_int_array_from_bin { my $ret; eval { $ret = &_xs_new_int_array_from_bin(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_int_array_from_bin: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
279 0 ▶sub new_long_array { my $ret; eval { $ret = &_xs_new_long_array(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_long_array: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
280 0 ▶sub new_long_array_unsigned { my $ret; eval { $ret = &_xs_new_long_array_unsigned(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_long_array_unsigned: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
281 0 ▶sub new_long_array_len { my $ret; eval { $ret = &_xs_new_long_array_len(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_long_array_len: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
282 0 ▶sub new_long_array_from_bin { my $ret; eval { $ret = &_xs_new_long_array_from_bin(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_long_array_from_bin: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
283 0 ▶sub new_double_array { my $ret; eval { $ret = &_xs_new_double_array(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_double_array: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
284 0 ▶sub new_double_array_len { my $ret; eval { $ret = &_xs_new_double_array_len(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_double_array_len: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
285 0 ▶sub new_double_array_from_bin { my $ret; eval { $ret = &_xs_new_double_array_from_bin(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_double_array_from_bin: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
286 0 ▶sub new_float_array { my $ret; eval { $ret = &_xs_new_float_array(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_float_array: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
287 0 ▶sub new_float_array_len { my $ret; eval { $ret = &_xs_new_float_array_len(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_float_array_len: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
288 0 ▶sub new_float_array_from_bin { my $ret; eval { $ret = &_xs_new_float_array_from_bin(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_float_array_from_bin: called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
289 0 ▶sub new_string_array { my $ret; eval { $ret = &_xs_new_string_array(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_string_array: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
290 0 ▶sub new_string_array_len { my $ret; eval { $ret = &_xs_new_string_array_len(@_) }; if ($@) { confess($@) } $ret}
Subroutine new_string_array_len: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
291 0 ▶sub dump { my $ret; eval { $ret = &_xs_dump(@_) }; if ($@) { confess($@) } $ret}
Subroutine dump: not called CC=2 SCAR=7.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
292 0 ▶sub get_exception { my $ret; eval { $ret = &_xs_get_exception(@_) }; if ($@) { confess($@) } $ret}
Subroutine get_exception: called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
293 0 ▶sub set_exception { my $ret; eval { $ret = &_xs_set_exception(@_) }; if ($@) { confess($@) } $ret}
Subroutine set_exception: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
294 0 ▶sub get_memory_blocks_count { my $ret; eval { $ret = &_xs_get_memory_blocks_count(@_) }; if ($@) { confess($@) } $ret}
Subroutine get_memory_blocks_count: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 457 457
295 0 ▶sub enable_record_object { my $ret; eval { $ret = &_xs_enable_record_object(@_) }; if ($@) { confess($@) } $ret}
Subroutine enable_record_object: called CC=2 SCAR=7.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
296 0 ▶sub disable_record_object { my $ret; eval { $ret = &_xs_disable_record_object(@_) }; if ($@) { confess($@) } $ret}
Subroutine disable_record_object: called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
297 5769 ▶sub dump_recorded_objects { my $ret; eval { $ret = &_xs_dump_recorded_objects(@_) }; if ($@) { confess($@) } $ret}
Subroutine dump_recorded_objects: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
298 1010 ▶sub destroy_runtime_permanent_vars { my $ret; eval { $ret = &_xs_destroy_runtime_permanent_vars(@_) }; if ($@) { confess($@) } $ret}
Subroutine destroy_runtime_permanent_vars: called CC=2 SCAR=7.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 212 212
299 507 ▶sub get_version_string { my $ret; eval { $ret = &_xs_get_version_string(@_) }; if ($@) { confess($@) } $ret}
Subroutine get_version_string: called CC=2 SCAR=7.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 10 10
300 530 ▶sub call_method {
Subroutine call_method: called CC=2 SCAR=6.9
Pod documented
301 530 ▶ my $ret; eval { $ret = &_xs_call_method(@_) }; if ($@) { confess($@) } $ret;
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 11 5791 5802
302 }
303  
304 1048 1;
305  
306 =encoding utf8
307  
308 =head1 Name
309  
310 SPVM::ExchangeAPI - SPVM Exchange API
311  
312 =head1 Description
313  
314 C<SPVM::ExchangeAPI> is APIs to convert Perl data structures to/from SPVM data structures, and to call SPVM methods from Perl.
315  
316 =head1 Usage
317
318 use SPVM;
319
320 my $api = SPVM::api();
321 my $spvm_int_array = $api->new_int_array([1, 2, 3]);
322 my $perl_array_ref = $spvm_int_array->to_array;
323
324 my $spvm_string = $api->new_string("abc");
325 my $perl_string = $spvm_string->to_string;
326
327 use SPVM 'Int';
328 my $int_object = Int->new(4);
329 my $value = $int_object->value;
330  
331 =head1 Loading SPVM Class
332
333 # Load an SPVM class
334 use SPVM 'SomeClass';
335
336 # Load only SPVM module
337 use SPVM;
338  
339 The C<use> statement loads a L<SPVM> class.
340  
341 An SPVM class is loaded and is bound to a Perl module.
342  
343 The bound Perl class name is prefixed with C<SPVM::>.
344  
345 Exceptions:
346  
347 If the SPVM module cannot be loaded, an exception is thrown.
348  
349 Examples:
350  
351 use SPVM 'Int';
352
353 my $int_object = SPVM::Int->new(3);
354 my $value = $int_object->value.
355  
356 =head1 SPVM Functions
357  
358 =head2 api
359  
360 my $api = SPVM::api();
361  
362 Gets the global L<SPVM::ExchangeAPI> object for this Perl interpreter.
363  
364 =head1 Fields
365  
366 =head2 env
367  
368 my $env = $api->env;
369  
370 Gets the current execution environment.
371  
372 =head2 stack
373  
374 my $stack = $api->stack;
375  
376 Gets the current call stack.
377  
378 =head1 Class Methods
379  
380 my $api = SPVM::ExchangeAPI->new(env => $env, stack => $stack);
381  
382 Creates a new L<SPVM::ExchangeAPI> object.
383  
384 Options:
385  
386 =over 2
387  
388 =item C<env>
389  
390 An execution environment.
391  
392 C<env> must be a L<SPVM::Bulder::Env> or L<SPVM::BlessedObject::Class> object of L<Native::Env|SPVM::Native::Env> class.
393
394 =item C<stack>
395  
396 An call stack.
397  
398 C<stack> must be a L<SPVM::Bulder::Stack> or L<SPVM::BlessedObject::Class> object of L<Native::Stack|SPVM::Native::Stack> class.
399  
400 =back
401  
402 =head2 new_string
403  
404 my $spvm_string = $api->new_string($string);
405  
406 Converts the Perl scalar $string to an SPVM string using perlapi L<SvPV|https://perldoc.perl.org/perlapi#SvPV>, and returns the object that converts it to a L<SPVM::BlessedObject::String> object.
407  
408 If $string is undef, returns undef.
409  
410 If $string is a L<SPVM::BlessedObject::String> object, returns itself.
411  
412 Exceptions:
413  
414 $string must be a non-reference scalar or an SPVM::BlessedObject::String object or undef. Otherwise an exception is thrown.
415  
416 Examples:
417  
418 my $spvm_string = $api->new_string("abc");
419
420 my $spvm_string = $api->new_string("あいう");
421  
422 =head2 new_byte_array
423
424 my $spvm_array = $api->new_byte_array($array);
425  
426 Converts the Perl array reference $array to an SPVM byte array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
427  
428 Each element is converted by the conversion of L</"byte Type Argument">.
429  
430 If $array is undef, returns undef.
431  
432 If $array is a L<SPVM::BlessedObject::Array> object, returns itself.
433  
434 Exceptions:
435  
436 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
437  
438 $array: If it is an SPVM::BlessedObject::Array object, the type must be the byte[] type. Otherwise an exception is thrown.
439  
440 Examples:
441  
442 my $spvm_array = $api->new_byte_array([1, 2, 3]);
443  
444 =head2 new_byte_array_unsigned
445
446 my $spvm_array = $api->new_byte_array_unsigned($array);
447  
448 The same as L</"new_byte_array"> method, but each element is converted by L<SvUV|https://perldoc.perl.org/perlapi#SvUV> perlapi and a type cast to C<uint8_t> in the C language.
449  
450 (int8_t)(uint8_t)SvUV(perl_scalar);
451  
452 =head2 new_byte_array_len
453  
454 my $spvm_array= $api->new_byte_array_len($length);
455  
456 Creates an SPVM byte array with the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
457  
458 Exceptions:
459  
460 $length must be greater than or equal to 0. Otherwise an exception is thrown.
461  
462 Examples:
463
464 my $length = 10;
465 my $spvm_array = $api->new_byte_array_len($length);
466  
467 =head2 new_byte_array_from_bin
468  
469 my $spvm_array = $api->new_byte_array_from_bin($binary);
470  
471 Converts the binary date $binary to an SPVM byte array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
472  
473 $binary is copied to an SPVM byte array by the C<memcpy> function in the C laugnage. The length of the array is calcurated from $binary.
474  
475 Exceptions:
476  
477 $binary must be a defined non-reference scalar. Otherwise an exception is thrown.
478  
479 Examples:
480  
481 my $binary = pack('c*', 97, 98, 99);
482 my $spvm_array = $api->new_byte_array_from_bin($binary);
483  
484 my $string = "abc";
485 my $spvm_array = $api->new_byte_array_from_bin($string);
486
487 my $string = "あいう";
488 my $spvm_array = $api->new_byte_array_from_bin($string);
489  
490 =head2 new_short_array
491
492 my $spvm_array = $api->new_short_array($array);
493  
494 Converts the Perl array reference $array to an SPVM short array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
495  
496 Each element is converted by the conversion of L</"short Type Argument">.
497  
498 If $array is undef, returns undef.
499  
500 If $array is a L<SPVM::BlessedObject::Array> object, returns itself.
501  
502 Exceptions:
503  
504 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
505  
506 $array: If it is an SPVM::BlessedObject::Array object, the type must be the short[] type. Otherwise an exception is thrown.
507  
508 Examples:
509  
510 my $spvm_array = $api->new_short_array([1, 2, 3]);
511  
512 =head2 new_short_array_unsigned
513
514 my $spvm_array = $api->new_short_array_unsigned($array);
515  
516 The same as L</"new_short_array"> method, but each element is converted by L<SvUV|https://perldoc.perl.org/perlapi#SvUV> perlapi and a type cast to C<uint16_t> in the C language.
517  
518 (int16_t)(uint16_t)SvUV(perl_scalar);
519  
520 =head2 new_short_array_len
521  
522 my $spvm_array = $api->new_short_array_len($length);
523  
524 Creates an SPVM short array with the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
525  
526 Exceptions:
527  
528 $length must be greater than or equal to 0. Otherwise an exception is thrown.
529  
530 Examples:
531
532 my $length = 10;
533 my $spvm_array = $api->new_short_array_len($length);
534  
535 =head2 new_short_array_from_bin
536  
537 my $spvm_array = $api->new_short_array_from_bin($binary);
538  
539 Converts the binary date $binary to an SPVM short array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
540  
541 $binary is copied to an SPVM short array by the C<memcpy> function in the C laugnage. The length of the array is calcurated from $binary.
542  
543 Exceptions:
544  
545 $binary must be a defined non-reference scalar. Otherwise an exception is thrown.
546  
547 The length of $binary must be divisible by 2. Otherwise an exception is thrown.
548  
549 Examples:
550  
551 my $binary = pack('s*', 97, 98, 99);
552 my $spvm_array = $api->new_short_array_from_bin($binary);
553  
554 =head2 new_int_array
555
556 my $spvm_array = $api->new_int_array($array);
557  
558 Converts the Perl array reference $array to an SPVM int array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
559  
560 Each element is converted by the conversion of L</"int Type Argument">.
561  
562 If $array is undef, returns undef.
563  
564 If $array is a L<SPVM::BlessedObject::Array> object, returns itself.
565  
566 Exceptions:
567  
568 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
569  
570 $array: If it is an SPVM::BlessedObject::Array object, the type must be the int[] type. Otherwise an exception is thrown.
571  
572 Examples:
573  
574 my $spvm_array = $api->new_int_array([1, 2, 3]);
575  
576 =head2 new_int_array_unsigned
577
578 my $spvm_array = $api->new_int_array_unsigned($array);
579  
580 The same as L</"new_int_array"> method, but each element is converted by L<SvUV|https://perldoc.perl.org/perlapi#SvUV> perlapi and a type cast to C<uint32_t> in the C language.
581  
582 (int32_t)(uint32_t)SvUV(perl_scalar);
583  
584 =head2 new_int_array_len
585  
586 my $spvm_array = $api->new_int_array_len($length);
587  
588 Creates an SPVM int array with the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
589  
590 Exceptions:
591  
592 $length must be greater than or equal to 0. Otherwise an exception is thrown.
593  
594 Examples:
595
596 my $length = 10;
597 my $spvm_array = $api->new_int_array_len($length);
598  
599 =head2 new_int_array_from_bin
600  
601 my $spvm_array = $api->new_int_array_from_bin($binary);
602  
603 Converts the binary date $binary to an SPVM int array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
604  
605 $binary is copied to an SPVM int array by the C<memcpy> function in the C laugnage. The length of the array is calcurated from $binary.
606  
607 Exceptions:
608  
609 $binary must be defined. Otherwise an exception is thrown.
610  
611 The length of $binary must be divisible by 4. Otherwise an exception is thrown.
612  
613 Examples:
614  
615 my $binary = pack('l*', 97, 98, 99);
616 my $spvm_array = $api->new_int_array_from_bin($binary);
617  
618 =head2 new_long_array
619
620 my $spvm_array = $api->new_long_array($array);
621  
622 Converts the Perl array reference $array to an SPVM long array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object. Each element is converted by the conversion of L</"long Type Argument">.
623  
624 If $array is undef, returns undef.
625  
626 Exceptions:
627  
628 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
629  
630 $array: If it is an SPVM::BlessedObject::Array object, the type must be the long[] type. Otherwise an exception is thrown.
631  
632 Examples:
633  
634 my $spvm_array = $api->new_long_array([1, 2, 3]);
635  
636 =head2 new_long_array_unsigned
637
638 my $spvm_array = $api->new_long_array_unsigned($array);
639  
640 The same as L</"new_long_array"> method, but each element is converted by L<SvUV|https://perldoc.perl.org/perlapi#SvUV> perlapi and a type cast to C<uint64_t> in the C language.
641  
642 (int64_t)(uint64_t)SvUV(perl_scalar);
643  
644 =head2 new_long_array_len
645  
646 my $spvm_array = $api->new_long_array_len($length);
647  
648 Creates an SPVM long array with the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
649  
650 Exceptions:
651  
652 $length must be greater than or equal to 0. Otherwise an exception is thrown.
653  
654 Examples:
655
656 my $length = 10;
657 my $spvm_array = $api->new_long_array_len($length);
658  
659 =head2 new_long_array_from_bin
660  
661 my $spvm_array = $api->new_long_array_from_bin($binary);
662  
663 Converts the binary date $binary to an SPVM long array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
664  
665 $binary is copied to an SPVM long array by the C<memcpy> function in the C laugnage. The length of the array is calcurated from $binary.
666  
667 Exceptions:
668  
669 $binary must be defined. Otherwise an exception is thrown.
670  
671 The length of $binary must be divisible by 8. Otherwise an exception is thrown.
672  
673 Examples:
674  
675 my $binary = pack('q*', 97, 98, 99);
676 my $spvm_array = $api->new_long_array_from_bin($binary);
677  
678 =head2 new_float_array
679
680 my $spvm_array = $api->new_float_array($array);
681  
682 Converts the Perl array reference $array to an SPVM float array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
683  
684 Each element is converted by the conversion of L</"float Type Argument">.
685  
686 If $array is undef, returns undef.
687  
688 If $array is a L<SPVM::BlessedObject::Array> object, returns itself.
689  
690 Exceptions:
691  
692 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
693  
694 $array: If it is an SPVM::BlessedObject::Array object, the type must be the float[] type. Otherwise an exception is thrown.
695  
696 Examples:
697  
698 my $spvm_array = $api->new_float_array([1, 2, 3]);
699  
700 =head2 new_float_array_len
701  
702 my $spvm_array = $api->new_float_array_len($length);
703  
704 Creates an SPVM float array with the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
705  
706 Exceptions:
707  
708 $length must be greater than or equal to 0. Otherwise an exception is thrown.
709  
710 Examples:
711
712 my $length = 10;
713 my $spvm_array = $api->new_float_array_len($length);
714  
715 =head2 new_float_array_from_bin
716  
717 my $spvm_array = $api->new_float_array_from_bin($binary);
718  
719 Converts the binary date $binary to an SPVM float array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
720  
721 $binary is copied to an SPVM float array by the C<memcpy> function in the C laugnage. The length of the array is calcurated from $binary.
722  
723 Exceptions:
724  
725 $binary must be defined. Otherwise an exception is thrown.
726  
727 The length of $binary must be divisible by 4. Otherwise an exception is thrown.
728  
729 Examples:
730  
731 my $binary = pack('f*', 97.1, 98.2, 99.3);
732 my $spvm_array = $api->new_float_array_from_bin($binary);
733  
734 =head2 new_double_array
735
736 my $spvm_array = $api->new_double_array($array);
737  
738 Converts the Perl array reference $array to an SPVM double array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
739  
740 Each element is converted by the conversion of L</"double Type Argument">.
741  
742 Exceptions:
743  
744 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
745  
746 $array: If it is an SPVM::BlessedObject::Array object, the type must be the double[] type. Otherwise an exception is thrown.
747  
748 Examples:
749  
750 my $spvm_array = $api->new_double_array([1, 2, 3]);
751  
752 =head2 new_double_array_len
753  
754 my $spvm_array = $api->new_double_array_len($length);
755  
756 Creates an SPVM double array with the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
757  
758 Exceptions:
759  
760 $length must be greater than or equal to 0. Otherwise an exception is thrown.
761  
762 Examples:
763
764 my $length = 10;
765 my $spvm_array = $api->new_double_array_len($length);
766  
767 =head2 new_double_array_from_bin
768  
769 my $spvm_array = $api->new_double_array_from_bin($binary);
770  
771 Converts the binary date $binary to an SPVM double array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
772  
773 $binary is copied to an SPVM double array by the C<memcpy> function in the C laugnage. The length of the array is calcurated from $binary.
774  
775 Exceptions:
776  
777 $binary must be defined. Otherwise an exception is thrown.
778  
779 The length of $binary must be divisible by 8. Otherwise an exception is thrown.
780  
781 Examples:
782  
783 my $binary = pack('d*', 97.1, 98.2, 99.3);
784 my $spvm_array = $api->new_double_array_from_bin($binary);
785  
786 =head2 new_string_array
787
788 my $spvm_array = $api->new_string_array($array);
789  
790 Converts the Perl array reference $array to an SPVM string array, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object. Each element is converted by L</"new_string"> method.
791  
792 If $array is undef, returns undef.
793  
794 If $array is a L<SPVM::BlessedObject::Array> object, returns itself.
795  
796 Exceptions:
797  
798 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
799  
800 $array: If it is an SPVM::BlessedObject::Array object, the type must be the string[] type. Otherwise an exception is thrown.
801  
802 Examples:
803  
804 my $spvm_array = $api->new_string_array(["foo", "bar", "baz"]);
805
806 my $spvm_array = $api->new_string_array(["あい", "うえ", "お"]);
807  
808 =head2 new_string_array_len
809  
810 my $spvm_array = $api->new_string_array_len($length);
811  
812 Creates an SPVM string array with the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
813  
814 Exceptions:
815  
816 $length must be greater than or equal to 0. Otherwise an exception is thrown.
817  
818 Examples:
819
820 my $length = 10;
821 my $spvm_array = $api->new_string_array_len($length);
822  
823 =head2 new_object_array
824  
825 my $spvm_object_array = $api->new_object_array($type_name, $array);
826  
827 Converts the Perl array reference $array to a value of the SPVM object array(1-dimensional) type $type_name, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object of $type_name type.
828  
829 If $array is undef, it is converted to SPVM undef.
830  
831 If $array is a L<SPVM::BlessedObject::Array> object, returns itself.
832  
833 Exceptions:
834  
835 If the type name $type_name was parsed, but the class name could not be extracted, an exception is thrown.
836  
837 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
838  
839 $array: If it is an SPVM::BlessedObject::Array object, the type must satisfy type requirement. Otherwise an exception is thrown.
840  
841 If the bacic type of the type $type_name is not found, an exception is thrown.
842  
843 The dimension of the type $type_name must be 1. Otherwise an exception is thrown.
844  
845 $type_name must be an object array type. Otherwise an exception is thrown.
846  
847 Examples:
848
849 my $point1 = SPVM::Point->new;
850 my $point2 = SPVM::Point->new;
851 my $spvm_array = $api->new_object_array("Point[]", [$point1, $point2]);
852  
853 =head2 new_object_array_len
854  
855 my $spvm_array = $api->new_object_array_len($type_name, $length);
856  
857 Creates an SPVM object array(1-dimensional) with the type name $type_name and the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object of $type_name type.
858  
859 Exceptions:
860  
861 If the type name $type_name was parsed, but the class name could not be extracted, an exception is thrown.
862  
863 $length must be greater than or equal to 0. Otherwise an exception is thrown.
864  
865 If the bacic type of the type $type_name is not found, an exception is thrown.
866  
867 The dimension of the type $type_name must be 1. Otherwise an exception is thrown.
868  
869 $type_name must be an object array type. Otherwise an exception is thrown.
870  
871 Examples:
872
873 my $length = 10;
874 my $spvm_array = $api->new_object_array("Point[]", $length);
875  
876 =head2 new_any_object_array
877  
878 my $byte_array = $api->new_any_object_array(
879 [SPVM::Byte->new(1), SPVM::Byte>new(2), SPVM::Byte->new(3)]
880 );
881  
882 The alias for the following code using L</"new_object_array"> method.
883  
884 my $spvm_array = $api->new_object_array('object[]', $array);
885  
886 =head2 new_any_object_array_len
887  
888 my $spvm_array = $api->new_any_object_array_len($length);
889  
890 Creates an SPVM object array with the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object of $type_name.
891  
892 Exceptions:
893  
894 $length must be greater than or equal to 0. Otherwise an exception is thrown.
895  
896 Examples:
897
898 my $length = 10;
899 my $spvm_array = $api->new_any_object_array("Point[]", $length);
900  
901 =head2 new_options
902  
903 my $spvm_any_object_array = $api->new_options($options);
904  
905 Converts the Perl hash reference $options to a value of the SPVM C<object[]> type, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
906  
907 Each key of $options is converted to a L<SPVM::BlessedObject::String> object using L</"new_string"> method.
908  
909 Exceptions:
910  
911 The value of $options must be a L<SPVM::BlessedObject> object. Otherwise an exception is thrown.
912  
913 $options must be a hash reference. Otherwise an exception is thrown.
914  
915 Examples:
916  
917 my $options = $api->new_options({
918 x => SPVM::Int->new(1),
919 y => SPVM::Int->new(2)
920 });
921  
922 =head2 new_mulnum_array
923  
924 my $spvm_mulnum_array = $api->new_mulnum_array($type_name, $array);
925  
926 Converts the Perl array reference of a hash references $array to the SPVM multi-numeric array type $type_name, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
927  
928 Each value of the hash reference is coverted by the conversion of L</"byte Type Argument">, L</"short Type Argument">, L</"int Type Argument">, L</"long Type Argument">, L</"float Type Argument">, L</"double Type Argument"> corresponding to the numeric type of the the element of $type.
929  
930 Exceptions:
931  
932 If the type name $type_name was parsed, but the class name could not be extracted, an exception is thrown.
933  
934 All fields of the element type of $type_name must be defined. Otherwise an exception is thrown.
935  
936 If the bacic type of the type $type_name is not found, an exception is thrown.
937  
938 The dimension of the type $type_name must be 1. Otherwise an exception is thrown.
939  
940 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
941  
942 $array: If it is an SPVM::BlessedObject::Array object, the type must satisfy type requirement. Otherwise an exception is thrown.
943  
944 Examples:
945  
946 my $values = [
947 {x => 0, y => 1, z => 2},
948 {x => 3, y => 4, z => 5},
949 {x => 6, y => 7, z => 8},
950 ];
951 my $spvm_mulnum_array = $api->new_mulnum_array("TestCase::Point_3i[]", $values);
952  
953 =head2 new_mulnum_array_len
954  
955 my $spvm_array = $api->new_mulnum_array_len($type_name, $length);
956  
957 Creates an SPVM object array with the type name $type_name and the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object of $type_name.
958  
959 Exceptions:
960  
961 $length must be greater than or equal to 0. Otherwise an exception is thrown.
962  
963 If the bacic type of the type $type_name is not found, an exception is thrown.
964  
965 The dimension of $type_name must be 1. Otherwise an exception is thrown.
966  
967 Examples:
968
969 my $length = 10;
970 my $spvm_array = $api->new_mulnum_array("Complex_2d[]", $length);
971  
972 =head2 new_mulnum_array_from_bin
973  
974 my $spvm_mulnum_array = $api->new_mulnum_array_from_bin($type_name, $binary);
975  
976 Converts the binary data $binary to an SPVM multi-numeric array type $type_name, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
977  
978 $binary is copied to an SPVM multi-numeric array by the C<memcpy> function in the C laugnage. The length of the array is calcurated from $binary.
979  
980 Exceptions:
981  
982 If the bacic type of the type $type_name is not found, an exception is thrown.
983  
984 The dimension of the type $type_name must be 1. Otherwise an exception is thrown.
985  
986 $binary must be an array reference. Otherwise an exception is thrown.
987  
988 The length of $binary must be divisible by the length of fields * the byte size of the element type. Otherwise an exception is thrown.
989  
990 Examples:
991
992 # new_mulnum_array_from_bin - byte
993 {
994 my $binary = pack('c9', (0, 1, 2), (3, 4, 5), (6, 7, 8));
995 my $spvm_mulnum_array = $api->new_mulnum_array_from_bin("TestCase::Point_3b[]", $binary);
996 }
997  
998 # new_mulnum_array_from_bin - short
999 {
1000 my $binary = pack('s9', (0, 1, 2), (3, 4, 5), (6, 7, 8));
1001 my $spvm_mulnum_array = $api->new_mulnum_array_from_bin("TestCase::Point_3s[]", $binary);
1002 }
1003  
1004 # new_mulnum_array_from_bin - int
1005 {
1006 my $binary = pack('l9', (0, 1, 2), (3, 4, 5), (6, 7, 8));
1007 my $spvm_mulnum_array = $api->new_mulnum_array_from_bin("TestCase::Point_3i[]", $binary);
1008 }
1009  
1010 # new_mulnum_array_from_bin - long
1011 {
1012 my $binary = pack('q9', (0, 1, 2), (3, 4, 5), (6, 7, 8));
1013 my $spvm_mulnum_array = $api->new_mulnum_array_from_bin("TestCase::Point_3l[]", $binary);
1014 }
1015  
1016 # new_mulnum_array_from_bin - float
1017 {
1018 my $binary = pack('f9', (0, 1, 2), (3, 4, 5), (6, 7, 8));
1019 my $spvm_mulnum_array = $api->new_mulnum_array_from_bin("TestCase::Point_3f[]", $binary);
1020 }
1021  
1022 # new_mulnum_array_from_bin - double
1023 {
1024 my $binary = pack('d9', (0, 1, 2), (3, 4, 5), (6, 7, 8));
1025 my $spvm_mulnum_array = $api->new_mulnum_array_from_bin("TestCase::Point_3d[]", $binary);
1026 }
1027  
1028 =head2 new_muldim_array
1029  
1030 my $spvm_object_array = $api->new_muldim_array($type_name, $array);
1031  
1032 Converts the Perl array reference $array to a value of the SPVM multi-dimensional array type $type_name, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object.
1033  
1034 If $array is undef, it is converted to SPVM undef.
1035  
1036 If $array is a L<SPVM::BlessedObject::Array> object, returns itself.
1037  
1038 Exceptions:
1039  
1040 If $array is a reference other than the array reference, an exception is thrown.
1041  
1042 $array: If it is a reference, it must be an array reference. Otherwise an exception is thrown.
1043  
1044 $array: If it is an SPVM::BlessedObject::Array object, the type must satisfy type requirement. Otherwise an exception is thrown.
1045  
1046 If the bacic type of the type $type_name is not found, an exception is thrown.
1047  
1048 The dimension of $type_name must be greater than or equal to 2 and less than or equal to 255. Otherwise an exception is thrown.
1049  
1050 The assignment requirement of the element to the element type of $type_name is checked. If it is not satisfied, an exception is thrown.
1051  
1052 Examples:
1053  
1054 my $object1 = $api->new_int_array([1, 2, 3]);
1055 my $object2 = $api->new_int_array([4, 5, 6]);
1056 my $objects = $api->new_muldim_array("int[][]", [$object1, $object2]);
1057  
1058 =head2 new_muldim_array_len
1059  
1060 my $spvm_array = $api->new_muldim_array_len($type_name, $length);
1061  
1062 Creates an SPVM multi-dimensional array with the type name $type_name and the length $length, and returns the object that converts it to a L<SPVM::BlessedObject::Array> object of $type_name.
1063  
1064 Exceptions:
1065  
1066 $length must be greater than or equal to 0. Otherwise an exception is thrown.
1067  
1068 If the bacic type of the type $type_name is not found, an exception is thrown.
1069  
1070 The dimension of $type_name must be greater than or equal to 2 and less than or equal to 255. Otherwise an exception is thrown.
1071  
1072 Examples:
1073
1074 my $length = 10;
1075 my $spvm_array = $api->new_muldim_array("int[][]", $length);
1076  
1077 =head2 get_exception
1078  
1079 my $message = $api->get_exception();
1080  
1081 Returns the exception of the current thread variables as a L<SPVM::BlessedObject::String> object.
1082  
1083 If the exception is not set, undef is returned.
1084  
1085 =head2 set_exception
1086  
1087 $api->set_exception($message);
1088  
1089 Sets a message given by $message to the exception of the current thread variables.
1090  
1091 $message is converted to the SPVM string using L</"new_string"> method.
1092  
1093 Exceptions:
1094  
1095 Exceptions thrown by L</"new_string"> method are thrown.
1096  
1097 Examples:
1098  
1099 $api->set_exception("Error");
1100 $api->set_exception(undef);
1101  
1102 =head2 get_memory_blocks_count
1103  
1104 my $count = $api->get_memory_blocks_count;
1105  
1106 Returns the count of memory blocks the current runtime allocates.
1107  
1108 Examples:
1109  
1110 # First Memory Blocks Count
1111 my $start_memory_blocks_count = $api->get_memory_blocks_count;
1112  
1113 # Processing
1114 # ...
1115  
1116 # Last Memory Blocks Count
1117 my $end_memory_blocks_count = $api->get_memory_blocks_count;
1118  
1119 unless ($end_memory_blocks_count == $start_memory_blocks_count) {
1120 die"Memroy leak";
1121 }
1122  
1123 =head2 class
1124  
1125 my $class = $api->class($basic_type_name);
1126  
1127 Creates a new L<SPVM::ExchangeAPI::Class> object with the class name $basic_type_name, and returns it.
1128  
1129 Examples:
1130
1131 my $class = $api->class('Int');
1132 my $spvm_object = $class->new(1);
1133  
1134 =head2 dump
1135  
1136 my $dump = $api->dump($object);
1137  
1138 Converts the SPVM object $object to a dumped string using L<dump|SPVM::Document::Language/"dump Operator"> operator, and returns it.
1139  
1140 Exceptions:
1141  
1142 $object must be an SPVM::BlessedObject object. Otherwise an exception is thrown.
1143  
1144 =head2 error
1145  
1146 my $error = $api->new_error;
1147  
1148 Creates a new L<SPVM::ExchangeAPI::Error> object, and returns it.
1149  
1150 The error id is set to 0.
1151  
1152 =head2 call_method
1153
1154 my $ret = $api->call_method($invocant, $method_name, @args);
1155
1156 my $ret = $api->call_method($invocant, $method_name, @args, $error);
1157
1158 my $ret = $api->call_method($invocant, $method_name, @args, $options);
1159  
1160 Calls a class method or an instance method. If the invocant $invocant is a string, a class method is called. If the invocant $invocant is a L<SPVM::BlessedObject::Class>, an instance method is called.
1161  
1162 Each of the arguments @args are converted by the rule of L</"Argument Conversion">.
1163  
1164 The method name $method_name allows a static method name such as C<Foo::bar>.
1165  
1166 The return value is converted by the rule of L</"Return Value Conversion">.
1167  
1168 If a L<SPVM::ExchangeAPI::Error> object is passed to the last of the arguments, and if an exception is thrown from an SPVM method, the error code is set to the C<code> field of the object.
1169  
1170 Exceptions:
1171  
1172 If $invocant is an SPVM::BlessedObject, $invocant must be an SPVM::BlessedObject::Class object. Otherwise an exception is thrown.
1173  
1174 The static method call must be valid. Otherwise an exception is thrown.
1175  
1176 If the M method in the C class is not found, an exception is thrown.
1177  
1178 If too few arguments are passed to the M method in the C class, an exception is thrown.
1179  
1180 If too many arguments are passed to the M method in the C class, an exception is thrown.
1181  
1182 If L<argument conversion|/"Argument Conversion"> fails, an exception is thrown.
1183  
1184 If the calling method throws an exception, the exception is thrown.
1185  
1186 Examples:
1187  
1188 # Class method call
1189 my $obj_int = $api->call_method("Int", "new", 1);
1190
1191 # Instance method call
1192 $api->call_method($obj_int, "set_value", 5);
1193 my $value = $api->call_method($obj_int, "value");
1194
1195 # Call static instance method
1196 $api->call_method($object, "Foo::value");
1197  
1198 Easy Ways:
1199  
1200 Calling class methods can be made easier using L<SPVM class loading|SPVM/"Loading Class"> feature.
1201  
1202 use SPVM 'Int';
1203 my $int_object = Int->new(4);
1204  
1205 Instance method calls can be made easier using L<SPVM::BlessedObject::Class>.
1206  
1207 my $value = $int_object->value;
1208  
1209 =head2 destroy_runtime_permanent_vars
1210  
1211 $api->destroy_runtime_permanent_vars;
1212
1213 Same as L<Fn#destroy_runtime_permanent_vars|SPVM::Fn/"destroy_runtime_permanent_vars"> method.
1214  
1215 =head2 get_version_string
1216  
1217 my $version_string = $api->get_version_string("MyClass");
1218  
1219 Same as L<Fn#get_version_string|SPVM::Fn/"get_version_string"> method.
1220  
1221 =head2 get_version_string
1222  
1223 my $version_string = $api->get_version_string("MyClass");
1224  
1225 Same as L<Fn#get_version_string|SPVM::Fn/"get_version_string"> method.
1226  
1227 =head2 enable_record_object
1228  
1229 $api->enable_record_object;
1230  
1231 Same as L<Fn#enable_record_object|SPVM::Fn/"enable_record_object"> method.
1232  
1233 =head2 disable_record_object
1234  
1235 $api->disable_record_object;
1236  
1237 Same as L<Fn#disable_record_object|SPVM::Fn/"disable_record_object"> method.
1238  
1239 =head2 dump_recorded_objects
1240  
1241 my $dump = $api->dump_recorded_objects;
1242  
1243 Same as L<Fn#dump_recorded_objects|SPVM::Fn/"dump_recorded_objects"> method.
1244  
1245 =head1 Argument Conversion
1246  
1247 Each argument passed to L</"call_method"> method are converted to an SPVM value according to the SPVM type before it passed to an SPVM method.
1248  
1249 =head2 byte Type Argument
1250  
1251 A Perl scalar is converted to a value of the SPVM C<byte> type by L<SvIV|https://perldoc.perl.org/perlapi#SvIV> perlapi and a type cast to C<int8_t> in the C language.
1252  
1253 (int8_t)SvIV(perl_scalar)
1254  
1255 Exceptions:
1256  
1257 The argument must be a non-reference scalar. Otherwise an exception is thrown.
1258  
1259 =head2 short Type Argument
1260  
1261 A Perl scalar is converted to a value of the SPVM C<short> type by L<SvIV|https://perldoc.perl.org/perlapi#SvIV> perlapi and a type cast to C<int16_t> in the C language.
1262
1263 (int16_t)SvIV(perl_scalar)
1264  
1265 Exceptions:
1266  
1267 The argument must be a non-reference scalar. Otherwise an exception is thrown.
1268  
1269 =head2 int Type Argument
1270  
1271 A Perl scalar is converted to a value of the SPVM C<int> type by L<SvIV|https://perldoc.perl.org/perlapi#SvIV> perlapi and a type cast to C<int32_t> in the C language.
1272  
1273 (int32_t)SvIV(perl_scalar)
1274  
1275 Exceptions:
1276  
1277 The argument must be a non-reference scalar. Otherwise an exception is thrown.
1278  
1279 Examples:
1280  
1281 my $int_object = SPVM::Int->new(10);
1282  
1283 =head2 long Type Argument
1284  
1285 A Perl scalar is converted to a value of the SPVM C<long> type by L<SvIV|https://perldoc.perl.org/perlapi#SvIV> perlapi and a type cast to C<int64_t> in the C language.
1286  
1287 (int64_t)SvIV(perl_scalar)
1288  
1289 Exceptions:
1290  
1291 The argument must be a non-reference scalar. Otherwise an exception is thrown.
1292  
1293 Examples:
1294  
1295 my $long_object = SPVM::Long->new(10);
1296  
1297 =head2 float Type Argument
1298  
1299 A Perl scalar is converted to a value of the SPVM C<float> type by L<SvNV|https://perldoc.perl.org/perlapi#SvNV> perlapi and a type cast to C<float> in the C language.
1300  
1301 (float)SvNV(perl_scalar)
1302  
1303 Exceptions:
1304  
1305 The argument must be a non-reference scalar. Otherwise an exception is thrown.
1306  
1307 Examples:
1308  
1309 my $float_object = SPVM::Float->new(10.5);
1310  
1311 =head2 double Type Argument
1312  
1313 A Perl scalar is converted to a value of the SPVM C<double> type by L<SvNV|https://perldoc.perl.org/perlapi#SvNV> perlapi and a type cast to C<double> in the C language.
1314  
1315 (double)SvNV(perl_scalar)
1316  
1317 Exceptions:
1318  
1319 The argument must be a non-reference scalar. Otherwise an exception is thrown.
1320  
1321 Examples:
1322  
1323 my $double_object = SPVM::Double->new(10.5);
1324  
1325 =head2 string Type Argument
1326  
1327 A Perl scalar is converted to a value of the SPVM C<string> type by L</"new_string"> method.
1328  
1329 Exceptions:
1330  
1331 Exceptions thrown by L</"new_string"> method are thrown.
1332  
1333 Examples:
1334
1335 my $substr = SPVM::Fn->substr("abcde", 0, 3);
1336  
1337 =head2 Any Object Type Argument
1338  
1339 No conversion is performed.
1340  
1341 Exceptions:
1342  
1343 The argument must be an SPVM::BlessedObject object or undef. Otherwise an exception is thrown.
1344  
1345 =head2 Class Type Argument
1346  
1347 No conversion is performed.
1348  
1349 Exceptions:
1350  
1351 The argument must be an SPVM::BlessedObject::Class object that can be assigned to Z type, or undef. Otherwise an exception is thrown.
1352  
1353 =head2 Interaface Type Argument
1354  
1355 No conversion is performed.
1356  
1357 Exceptions:
1358  
1359 The argument must be an SPVM::BlessedObject::Class object that can be assigned to Z type, or undef. Otherwise an exception is thrown.
1360  
1361 =head2 Multi-Numeric Type Argument
1362  
1363 =head3 Multi-Numeric byte
1364  
1365 Converts a hash reference containing field names and its values of the multi-numeric byte type to a value of the multi-numeric byte type.
1366  
1367 Each field value is coverted by the conversion of L</"byte Type Argument">.
1368  
1369 Exceptions:
1370  
1371 The argument must be a hash reference. Otherwise an exception is thrown.
1372  
1373 If a field is not found, an exception is thrown.
1374  
1375 Examples:
1376  
1377 # Converts a Perl hash reference to MyClassPoint_2b type
1378 SPVM::MyClass->foo({x => 1, y => 2});
1379  
1380 =head3 Multi-Numeric short Type Argument
1381  
1382 Converts a hash reference containing field names and its values of the multi-numeric short type to a value of the multi-numeric short type.
1383  
1384 Each field value is coverted by the conversion of L</"short Type Argument">.
1385  
1386 Exceptions:
1387  
1388 The argument must be a hash reference. Otherwise an exception is thrown.
1389  
1390 If a field is not found, an exception is thrown.
1391  
1392 Examples:
1393  
1394 # Converts a Perl hash reference to MyClassPoint_2s type
1395 SPVM::MyClass->foo({x => 1, y => 2});
1396  
1397 =head3 Multi-Numeric int Type Argument
1398  
1399 Converts a hash reference containing field names and its values of the multi-numeric int type to a value of the multi-numeric int type.
1400  
1401 Each field value is coverted by the conversion of L</"int Type Argument">.
1402  
1403 Exceptions:
1404  
1405 The argument must be a hash reference. Otherwise an exception is thrown.
1406  
1407 If a field is not found, an exception is thrown.
1408  
1409 Examples:
1410  
1411 # Converts a Perl hash reference to MyClassPoint_2i type
1412 SPVM::MyClass->foo({x => 1, y => 2});
1413  
1414 =head3 Multi-Numeric long Type Argument
1415  
1416 Converts a hash reference containing field names and its values of the multi-numeric long type to a value of the multi-numeric long type.
1417  
1418 Each field value is coverted by the conversion of L</"long Type Argument">.
1419  
1420 Exceptions:
1421  
1422 The argument must be a hash reference. Otherwise an exception is thrown.
1423  
1424 If a field is not found, an exception is thrown.
1425  
1426 Examples:
1427  
1428 # Converts a Perl hash reference to MyClassPoint_2l type
1429 SPVM::MyClass->foo({x => 1, y => 2});
1430  
1431 =head3 Multi-Numeric float Type Argument
1432  
1433 Converts a hash reference containing field names and its values of the multi-numeric float type to a value of the multi-numeric float type.
1434  
1435 Each field value is coverted by the conversion of L</"float Type Argument">.
1436  
1437 Exceptions:
1438  
1439 The argument must be a hash reference. Otherwise an exception is thrown.
1440  
1441 If a field is not found, an exception is thrown.
1442  
1443 Examples:
1444  
1445 # Converts a Perl hash reference to MyClassPoint_2f type
1446 SPVM::MyClass->foo({x => 1.2, y => 2.3});
1447  
1448 =head3 Multi-Numeric double Type Argument
1449  
1450 Converts a hash reference containing field names and its values of the multi-numeric double type to a value of the multi-numeric double type.
1451  
1452 Each field value is coverted by the conversion of L</"double Type Argument">.
1453  
1454 Exceptions:
1455  
1456 The argument must be a hash reference. Otherwise an exception is thrown.
1457  
1458 If a field is not found, an exception is thrown.
1459  
1460 Examples:
1461  
1462 # Converts a Perl hash reference to MyClassPoint_2d type
1463 SPVM::MyClass->foo({x => 1.2, y => 2.3});
1464  
1465 =head2 Numeric Reference Type Argument
1466  
1467 =head3 byte Reference Type Argument
1468  
1469 A Perl reference is converted to a value of the SPVM byte reference type.
1470  
1471 The referenced value is converted to a value of the SPVM C<byte> type by the conversion of L</"byte Type Argument">.
1472  
1473 After returning from the SPVM method, the referenced value is converted to a Perl scalar by the conversion of L</"byte Type Return Value">
1474  
1475 Exceptions:
1476  
1477 The argument must be a scalar reference. Otherwise an exception is thrown.
1478  
1479 Examples:
1480  
1481 # Converts a Perl scalar reference to byte* type
1482 my $value = 23;
1483 SPVM::MyClass->foo(\$value);
1484  
1485 =head3 short Reference Type Argument
1486  
1487 A Perl reference is converted to a value of the SPVM short reference type.
1488  
1489 The referenced value is converted to a value of the SPVM C<short> type by the conversion of L</"short Type Argument">.
1490  
1491 After returning from the SPVM method, the referenced value is converted to a Perl scalar by the conversion of L</"short Type Return Value">
1492  
1493 Exceptions:
1494  
1495 The argument must be a scalar reference. Otherwise an exception is thrown.
1496  
1497 Examples:
1498  
1499 # Converts a Perl scalar reference to short* type
1500 my $value = 23;
1501 SPVM::MyClass->foo(\$value);
1502  
1503 =head3 int Reference Type Argument
1504  
1505 A Perl reference is converted to a value of the SPVM int reference type.
1506  
1507 The referenced value is converted to a value of the SPVM C<int> type by the conversion of L</"int Type Argument">.
1508  
1509 After returning from the SPVM method, the referenced value is converted to a Perl scalar by the conversion of L</"int Type Return Value">
1510  
1511 Exceptions:
1512  
1513 The argument must be a scalar reference. Otherwise an exception is thrown.
1514  
1515 Examples:
1516  
1517 # Converts a Perl scalar reference to int* type
1518 my $value = 23;
1519 SPVM::MyClass->foo(\$value);
1520  
1521 =head3 long Reference Type Argument
1522  
1523 A Perl reference is converted to a value of the SPVM long reference type.
1524  
1525 The referenced value is converted to a value of the SPVM C<long> type by the conversion of L</"long Type Argument">.
1526  
1527 After returning from the SPVM method, the referenced value is converted to a Perl scalar by the conversion of L</"long Type Return Value">
1528  
1529 Exceptions:
1530  
1531 The argument must be a scalar reference. Otherwise an exception is thrown.
1532  
1533 Examples:
1534  
1535 # Converts a Perl scalar reference to long* type
1536 my $value = 23;
1537 SPVM::MyClass->foo(\$value);
1538  
1539 =head3 float Reference Type Argument
1540  
1541 A Perl reference is converted to a value of the SPVM float reference type.
1542  
1543 The referenced value is converted to a value of the SPVM C<float> type by the conversion of L</"float Type Argument">.
1544  
1545 After returning from the SPVM method, the referenced value is converted to a Perl scalar by the conversion of L</"float Type Return Value">
1546  
1547 Exceptions:
1548  
1549 The argument must be a scalar reference. Otherwise an exception is thrown.
1550  
1551 Examples:
1552  
1553 # Converts a Perl scalar reference to float* type
1554 my $value = 23.5;
1555 SPVM::MyClass->foo(\$value);
1556  
1557 =head3 double Reference Type Argument
1558  
1559 A Perl reference is converted to a value of the SPVM double reference type.
1560  
1561 The referenced value is converted to a value of the SPVM C<double> type by the conversion of L</"double Type Argument">.
1562  
1563 After returning from the SPVM method, the referenced value is converted to a Perl scalar by the conversion of L</"double Type Return Value">
1564  
1565 Exceptions:
1566  
1567 The argument must be a scalar reference. Otherwise an exception is thrown.
1568  
1569 Examples:
1570  
1571 # Converts a Perl scalar reference to double* type
1572 my $value = 23.5;
1573 SPVM::MyClass->foo(\$value);
1574  
1575 =head2 Multi-Numeric Reference Type Argument
1576  
1577 =head3 Multi-Numeric byte Reference Type Argument
1578  
1579 A Perl reference is converted to an SPVM multi-numeric C<byte> reference type.
1580  
1581 Each field is converted to a value of the SPVM C<byte> type by the conversion of L</"byte Type Argument">.
1582  
1583 After returning from the SPVM method, each field value is converted to a Perl scalar by the conversion of L</"byte Type Return Value">.
1584  
1585 Exceptions:
1586  
1587 The reference must be a scalar reference to a hash reference. Otherwise an exception is thrown.
1588  
1589 If a field is not found, an exception is thrown.
1590  
1591 Examples:
1592  
1593 # Converts a Perl scalar reference to a hash reference to the MyClassPoint_2b* type
1594 my $value = {x => 1, y => 2};
1595 SPVM::MyClass->foo(\$value);
1596  
1597 =head3 Multi-Numeric short Reference Type Argument
1598  
1599 A Perl reference is converted to an SPVM multi-numeric C<short> reference type.
1600  
1601 Each field is converted to a value of the SPVM C<short> type by the conversion of L</"short Type Argument">.
1602  
1603 After returning from the SPVM method, each field value is converted to a Perl scalar by the conversion of L</"short Type Return Value">.
1604  
1605 Exceptions:
1606  
1607 The reference must be a scalar reference to a hash reference. Otherwise an exception is thrown.
1608  
1609 If a field is not found, an exception is thrown.
1610  
1611 Examples:
1612  
1613 # Converts a Perl scalar reference to a hash reference to the MyClassPoint_2s* type
1614 my $value = {x => 1, y => 2};
1615 SPVM::MyClass->foo(\$value);
1616  
1617 =head3 Multi-Numeric int Reference Type Argument
1618  
1619 A Perl reference is converted to an SPVM multi-numeric C<int> reference type.
1620  
1621 Each field is converted to a value of the SPVM C<int> type by the conversion of L</"int Type Argument">.
1622  
1623 After returning from the SPVM method, each field value is converted to a Perl scalar by the conversion of L</"int Type Return Value">.
1624  
1625 Exceptions:
1626  
1627 The reference must be a scalar reference to a hash reference. Otherwise an exception is thrown.
1628  
1629 If a field is not found, an exception is thrown.
1630  
1631 Examples:
1632  
1633 # Converts a Perl scalar reference to a hash reference to the SPVM MyClassPoint_2i* type
1634 my $value = {x => 1, y => 2};
1635 SPVM::MyClass->foo(\$value);
1636  
1637 =head3 Multi-Numeric long Reference Type Argument
1638  
1639 A Perl reference is converted to an SPVM multi-numeric C<long> reference type.
1640  
1641 Each field is converted to a value of the SPVM C<long> type by the conversion of L</"long Type Argument">.
1642  
1643 After returning from the SPVM method, each field value is converted to a Perl scalar by the conversion of L</"long Type Return Value">.
1644  
1645 Exceptions:
1646  
1647 The reference must be a scalar reference to a hash reference. Otherwise an exception is thrown.
1648  
1649 If a field is not found, an exception is thrown.
1650  
1651 Examples:
1652  
1653 # Converts a Perl scalar reference to a hash reference to the SPVM MyClassPoint_2l* type
1654 my $value = {x => 1, y => 2};
1655 SPVM::MyClass->foo(\$value);
1656  
1657 =head3 Multi-Numeric float Reference Type Argument
1658  
1659 A Perl reference is converted to an SPVM multi-numeric C<float> reference type.
1660  
1661 Each field is converted to a value of the SPVM C<float> type by the conversion of L</"float Type Argument">.
1662  
1663 After returning from the SPVM method, each field value is converted to a Perl scalar by the conversion of L</"float Type Return Value">.
1664  
1665 Exceptions:
1666  
1667 The reference must be a scalar reference to a hash reference. Otherwise an exception is thrown.
1668  
1669 If a field is not found, an exception is thrown.
1670  
1671 Examples:
1672  
1673 # Converts a Perl scalar reference to a hash reference to the SPVM MyClassPoint_2f* type
1674 my $value = {x => 1,2, y => 2.3};
1675 SPVM::MyClass->foo(\$value);
1676  
1677 =head3 Multi-Numeric double Reference Type Argument
1678  
1679 A Perl reference is converted to an SPVM multi-numeric C<double> reference type.
1680  
1681 Each field is converted to a value of the SPVM C<double> type by the conversion of L</"double Type Argument">.
1682  
1683 After returning from the SPVM method, each field value is converted to a Perl scalar by the conversion of L</"double Type Return Value">.
1684  
1685 Exceptions:
1686  
1687 The reference must be a scalar reference to a hash reference. Otherwise an exception is thrown.
1688  
1689 If a field is not found, an exception is thrown.
1690  
1691 Examples:
1692  
1693 # Converts a Perl scalar reference to a hash reference to the SPVM MyClassPoint_2d* type
1694 my $value = {x => 1.2, y => 2.3};
1695 SPVM::MyClass->foo(\$value);
1696  
1697 =head2 Array Type Argument
1698  
1699 =head3 byte[] Type Argument
1700  
1701 A Perl array reference(or undef) is converted to a value of the C<byte[]> type by L</"new_byte_array"> method.
1702  
1703 Exceptions:
1704  
1705 Exceptions thrown by L</"new_byte_array"> method are thrown.
1706  
1707 Examples:
1708  
1709 # Converts a Perl array reference to the byte[] type
1710 SPVM::MyClass->foo([1, 2, 3]);
1711  
1712 =head3 short[] Type Argument
1713  
1714 A Perl array reference(or undef) is converted to a value of the C<short[]> type by L</"new_short_array"> method.
1715  
1716 Exceptions:
1717  
1718 Exceptions thrown by L</"new_short_array"> method are thrown.
1719  
1720 Examples:
1721  
1722 # Converts a Perl array reference to the short[] type
1723 SPVM::MyClass->foo([1, 2, 3]);
1724  
1725 =head3 int[] Type Argument
1726  
1727 A Perl array reference(or undef) is converted to a value of the C<int[]> type by L</"new_int_array"> method.
1728  
1729 Exceptions:
1730  
1731 Exceptions thrown by L</"new_int_array"> method are thrown.
1732  
1733 Examples:
1734  
1735 # Converts a Perl array reference to the int[] type
1736 SPVM::MyClass->foo([1, 2, 3]);
1737  
1738 =head3 long[] Type Argument
1739  
1740 A Perl array reference(or undef) is converted to a value of the C<long[]> type by L</"new_long_array"> method.
1741  
1742 Exceptions:
1743  
1744 Exceptions thrown by L</"new_long_array"> method are thrown.
1745  
1746 Examples:
1747  
1748 # Converts a Perl array reference to the long[] type
1749 SPVM::MyClass->foo([1, 2, 3]);
1750  
1751 =head3 float[] Type Argument
1752  
1753 A Perl array reference(or undef) is converted to a value of the C<float[]> type by L</"new_float_array"> method.
1754  
1755 Exceptions:
1756  
1757 Exceptions thrown by L</"new_float_array"> method are thrown.
1758  
1759 Examples:
1760  
1761 # Converts a Perl array reference to float[] type
1762 SPVM::MyClass->foo([1.2, 2.3, 3.4]);
1763  
1764 =head3 double[] Type Argument
1765  
1766 A Perl array reference(or undef) is converted to a value of the C<double[]> type by L</"new_double_array"> method.
1767  
1768 Exceptions:
1769  
1770 Exceptions thrown by L</"new_double_array"> method are thrown.
1771  
1772 Examples:
1773  
1774 # Converts a Perl array reference to the double[] type
1775 SPVM::MyClass->foo([1.2, 2.3, 3.4]);
1776  
1777 =head3 string[] Type Argument
1778  
1779 A Perl array reference(or undef) is converted to a value of the C<string[]> type by L</"new_string_array"> method.
1780  
1781 Exceptions:
1782  
1783 Exceptions thrown by L</"new_string_array"> method are thrown.
1784  
1785 Examples:
1786  
1787 # Converts a Perl array reference to the string[] type
1788 SPVM::MyClass->foo(["あい", "うえ", "お"]);
1789  
1790 =head3 Any Object Array Type Argument
1791  
1792 A Perl array reference(or undef) is converted to a value of the C<object[]> type by L</"new_object_array"> method.
1793  
1794 Exceptions:
1795  
1796 Exceptions thrown by L</"new_object_array"> method are thrown.
1797  
1798 =head3 Class Array Type Argument
1799  
1800 A Perl array reference(or undef) is converted to a value of the class type by L</"new_object_array"> method.
1801  
1802 Exceptions:
1803  
1804 Exceptions thrown by L</"new_object_array"> method are thrown.
1805  
1806 =head3 Interface Array Type Argument
1807  
1808 A Perl array reference(or undef) is converted to a value of the interface type by L</"new_object_array"> method.
1809  
1810 Exceptions:
1811  
1812 Exceptions thrown by L</"new_object_array"> method are thrown.
1813  
1814 =head3 Multi-Numeric Array Type Argument
1815  
1816 A Perl array reference(or undef) is converted to a value of the multi-numeric array type by L</"new_mulnum_array"> method.
1817  
1818 Exceptions:
1819  
1820 Exceptions thrown by L</"new_mulnum_array"> method are thrown.
1821  
1822 Examples:
1823  
1824 # Converts a Perl array reference of a hash reference to the Complex_2d[] type
1825 SPVM::MyClass->foo([{re => 1.2, im => 2.3}, {re => 3.4, im => 4.5}]);
1826  
1827 =head3 Multi-Dimensional Array Type Argument
1828  
1829 A Perl array reference(or undef) is converted to a value of the multi-dimensional array type by L</"new_muldim_array"> method.
1830  
1831 Exceptions:
1832  
1833 Exceptions thrown by L</"new_muldim_array"> method are thrown.
1834  
1835 =head1 Return Value Conversion
1836  
1837 An SPVM return value is converted to a Perl value according to the SPVM type.
1838  
1839 =head2 void Type Return Value
1840  
1841 The SPVM void return value is converted to Perl undef.
1842  
1843 =head2 byte Type Return Value
1844  
1845 A value of the SPVM byte type is converted to a Perl scalar using L<newSViv|https://perldoc.perl.org/perlapi#newSViv> perlapi.
1846  
1847 =head2 short Type Return Value
1848  
1849 A value of the SPVM short type is converted to a Perl scalar using L<newSViv|https://perldoc.perl.org/perlapi#newSViv> perlapi.
1850  
1851 =head2 int Type Return Value
1852  
1853 A value of the SPVM float type is converted to a Perl scalar using L<newSViv|https://perldoc.perl.org/perlapi#newSViv> perlapi.
1854  
1855 =head2 long Type Return Value
1856  
1857 A value of the SPVM float type is converted to a Perl scalar using L<newSViv|https://perldoc.perl.org/perlapi#newSViv> perlapi.
1858  
1859 =head2 float Type Return Value
1860  
1861 A value of the SPVM float type is converted to a Perl scalar using L<newSVnv|https://perldoc.perl.org/perlapi#newSVnv> perlapi.
1862  
1863 =head2 double Type Return Value
1864  
1865 A value of the SPVM double type is converted to a Perl scalar using L<newSVnv|https://perldoc.perl.org/perlapi#newSVnv> perlapi.
1866  
1867 =head2 string Type Return Value
1868  
1869 If the SPVM return value is undef, it is converted to Perl undef.
1870  
1871 Otherwise it is converted to a L<SPVM::BlessedObject::String> object.
1872  
1873 =head2 Multi-Numeric Type Return Value
1874  
1875 The value of the SPVM multi-numeric type is converted to a Perl hash reference that has the field names of the multi-numeric type as the keys.
1876  
1877 Each field value is converted by the conversion of L</"byte Type Return Value">, L</"short Type Return Value">, L</"int Type Return Value">, L</"long Type Return Value">, L</"float Type Return Value">, L</"double Type Return Value"> according to the multi-numeric type.
1878  
1879 =head2 Any Object Type Return Value
1880  
1881 If the SPVM return value is undef, it is converted to Perl undef.
1882  
1883 If the type of the return value is an array type, it is converted to a L<SPVM::BlessedObject::Array> object.
1884  
1885 If the type of the return value is an string type, it is converted to a L<SPVM::BlessedObject::String> object.
1886  
1887 Otherwise it is converted to a L<SPVM::BlessedObject::Class> object.
1888  
1889 =head2 Class Type Return Value
1890  
1891 If the SPVM return value is undef, it is converted to Perl undef.
1892  
1893 Otherwise it is converted to a L<SPVM::BlessedObject::Class> object.
1894  
1895 =head2 Interface Type Return Value
1896  
1897 If the SPVM return value is undef, it is converted to Perl undef.
1898  
1899 Otherwise it is converted to a L<SPVM::BlessedObject::Class> object.
1900  
1901 =head2 Array Type Return Value
1902  
1903 If the SPVM return value is undef, it is converted to Perl undef.
1904  
1905 Otherwise it is converted to a L<SPVM::BlessedObject::Array> object.
1906  
1907 =head1 Copyright & License
1908  
1909 Copyright (c) 2023 Yuki Kimoto
1910  
1911 MIT License
« blib/lib/SPVM/Builder/LinkInfo.pm ↑ Summary blib/lib/SPVM/Builder/DependencyAnalyzer.pm »