blib/lib/Wasm/Wasmtime/ExportType.pm

filter: Statementstmt 89.3% 42 / 47 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 77.0% 57 / 74 CC 5 SCAR 10.3
CC
5
Cov
79%
__ANON__
6.7
__ANON__
2.1
BEGIN
1.0
CRAP 2.8
« blib/lib/Wasm/Wasmtime/Store.pm ↑ Summary blib/lib/Wasm/Wasmtime/Module.pm »
1 package Wasm::Wasmtime::ExportType;
2  
3 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 22 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 22 ▶use Ref::Util qw( is_blessed_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 22 ▶use Wasm::Wasmtime::FFI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 22 ▶use Wasm::Wasmtime::ExternType;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # ABSTRACT: Wasmtime export type class
11 22 our $VERSION = '0.24'; # VERSION
12  
13  
14 22 $ffi_prefix = 'wasm_exporttype_';
15 22 $ffi->load_custom_type('::PtrObject' => 'wasm_exporttype_t' => __PACKAGE__);
16  
17  
18 180 ▶$ffi->attach( new => ['wasm_byte_vec_t*', 'opaque'] => 'wasm_exporttype_t' => sub {
Subroutine __ANON__: called CC=4 SCAR=19.1
19 180 my $xsub = shift;
20 180 my $class = shift;
21  
22 # not sure this is actually useful...
23 180 ▶ if(defined $_[1] && is_blessed_ref $_[1] && $_[1]->isa('Wasm::Wasmtime::ExternType'))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1] and is_blessed_ref($_[1]) and $_[1]->isa('Wasm::Wasmtime::ExternType')) { } 0 180 180
Condition33%2/6
defined $_[1] and is_blessed_ref($_[1]) and $_[1]->isa("Wasm::Wasmtime::ExternType")
!ll&&!rl&&r
01800
defined $_[1] and is_blessed_ref($_[1])
!ll&&!rl&&r
00180
MC/DC0%0/3
defined $_[1] and is_blessed_ref($_[1]) and $_[1]->isa("Wasm::Wasmtime::ExternType")
defined $_[1] is_blessed_ref($_[1]) $_[1]->isa("Wasm::Wasmtime::ExternType")
Truth table25%1/4
A and B and C
A= defined $_[1]B= is_blessed_ref($_[1])C= $_[1]->isa("Wasm::Wasmtime::ExternType")
ABCresult
0XX0
10X0
1100
1111
24 {
25 0 my $name = Wasm::Wasmtime::ByteVec->new(shift);
26 0 my $externtype = shift;
27 0 my $self = $xsub->($name, $externtype->{ptr});
28 0 $name->delete;
29 0 return $self;
30 }
31 else
32 {
33 180 my ($ptr,$owner) = @_;
34 180 return bless {
35 ptr => $ptr,
36 owner => $owner,
37 }, $class;
38 }
39 22 });
40  
41  
42 179 ▶$ffi->attach( name => ['wasm_exporttype_t'] => 'wasm_byte_vec_t*' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
43 179 my($xsub, $self) = @_;
44 179 my $name = $xsub->($self);
45 179 $name->get;
46 22 });
47  
48  
49 123 ▶$ffi->attach( type => ['wasm_exporttype_t'] => 'wasm_externtype_t' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.4
50 123 my($xsub, $self) = @_;
51 123 my $type = $xsub->($self);
52 123 ▶ $type->{owner} = $self->{owner} || $self;
Condition33%1/3
$self->{'owner'} || $self
l!l&&r!l&&!r
12300
MC/DC0%0/2
$self->{'owner'} || $self
$self->{'owner'} $self
Truth table33%1/3
A || B
A= $self->{'owner'}B= $self
ABresult
1X1
011
000
53 123 $type;
54 22 });
55  
56  
57 sub to_string
58 3 ▶{
Subroutine to_string: called CC=1 SCAR=0.0
Pod documented
59 3 my($self) = @_;
60 3 my $kind = $self->type->kind;
61 3 $kind =~ s/type$//;
62 # TODO: escape strings ?
63 3 sprintf '(%s (export "%s") %s)', $kind, $self->name, $self->type->to_string;
64 }
65  
66 22 _generate_destroy();
67 22 _generate_vec_class();
68  
69 22 1;
70  
71 __END__
« blib/lib/Wasm/Wasmtime/Store.pm ↑ Summary blib/lib/Wasm/Wasmtime/Module.pm »