blib/lib/Wasm/Wasmtime/WasiConfig.pm

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