blib/lib/Wasm/Wasmtime/WasiConfig.pm

filter: Statementstmt 100% 48 / 48 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 98.3% 58 / 59 CC 3 SCAR 3.1
CC
3
Cov
98%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.4
« blib/lib/Wasm/Wasmtime/Extern.pm ↑ Summary blib/lib/Wasm/Wasmtime/ExternType.pm »
1 package Wasm::Wasmtime::WasiConfig;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use Wasm::Wasmtime::FFI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: WASI Configuration
10 10 our $VERSION = '0.24'; # VERSION
11  
12  
13 10 $ffi_prefix = 'wasi_config_';
14 10 $ffi->load_custom_type('::PtrObject' => 'wasi_config_t' => __PACKAGE__);
15  
16  
17 sub _wrapper
18 16 ▶{
Subroutine _wrapper: called CC=1 SCAR=0.0
19 16 my $xsub = shift;
20 16 my $self = shift;
21 16 $xsub->($self, @_);
22 16 $self;
23 }
24  
25 10 $ffi->attach( new => [] => 'wasi_config_t' );
26 10 $ffi->attach( set_stdin_file => ['wasi_config_t','string'] => 'bool', \&_wrapper );
27 10 $ffi->attach( set_stdout_file => ['wasi_config_t','string'] => 'bool', \&_wrapper );
28 10 $ffi->attach( set_stderr_file => ['wasi_config_t','string'] => 'bool', \&_wrapper );
29 3 ▶$ffi->attach( preopen_dir => ['wasi_config_t','string','string','bool'] => 'bool' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
30 3 my $xsub = shift;
31 3 my $self = shift;
32 3 my($host, $guest, $fs_mutable) = @_;
33 3 ▶ $fs_mutable = 1 unless defined $fs_mutable;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fs_mutable 3 0 3
34 3 $xsub->($self, $host, $guest, $fs_mutable);
35 3 $self;
36 10 });
37  
38 10 foreach my $name (qw( argv env stdin stdout stderr ))
39 {
40 50 $ffi->attach( "inherit_$name" => ['wasi_config_t'] => 'void', \&_wrapper );
41 }
42  
43 3 ▶$ffi->attach( set_argv => ['wasi_config_t', 'size_t', 'string[]'] => 'bool' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
44 3 my($xsub, $self, @argv) = @_;
45 3 $xsub->($self, scalar(@argv), \@argv);
46 3 $self;
47 10 });
48  
49 1 ▶$ffi->attach( set_env => ['wasi_config_t','size_t','string[]','string[]'] => 'bool' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
50 1 my($xsub, $self, %env) = @_;
51 1 my @names;
52 my @values;
53 1 foreach my $name (keys %env)
54 {
55 2 push @names, $name;
56 2 push @values, $env{$name};
57 }
58 1 $xsub->($self, scalar(@names), \@names, \@values);
59 1 $self;
60 10 });
61  
62 10 _generate_destroy('wasi_config_delete');
63  
64 10 1;
65  
66 __END__
« blib/lib/Wasm/Wasmtime/Extern.pm ↑ Summary blib/lib/Wasm/Wasmtime/ExternType.pm »