line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::WasiConfig; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
187955
|
use strict; |
|
11
|
|
|
|
|
29
|
|
|
11
|
|
|
|
|
322
|
|
4
|
11
|
|
|
11
|
|
51
|
use warnings; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
343
|
|
5
|
11
|
|
|
11
|
|
188
|
use 5.008004; |
|
11
|
|
|
|
|
40
|
|
6
|
11
|
|
|
11
|
|
413
|
use Wasm::Wasmtime::FFI; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
5140
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: WASI Configuration |
9
|
|
|
|
|
|
|
our $VERSION = '0.21'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$ffi_prefix = 'wasi_config_'; |
13
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasi_config_t' => __PACKAGE__); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _wrapper |
17
|
|
|
|
|
|
|
{ |
18
|
19
|
|
|
19
|
|
3491
|
my $xsub = shift; |
19
|
19
|
|
|
|
|
30
|
my $self = shift; |
20
|
19
|
|
|
|
|
57
|
$xsub->($self, @_); |
21
|
19
|
|
|
|
|
390
|
$self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$ffi->attach( new => [] => 'wasi_config_t' ); |
25
|
|
|
|
|
|
|
$ffi->attach( set_stdin_file => ['wasi_config_t','string'] => 'void', \&_wrapper ); |
26
|
|
|
|
|
|
|
$ffi->attach( set_stdout_file => ['wasi_config_t','string'] => 'void', \&_wrapper ); |
27
|
|
|
|
|
|
|
$ffi->attach( set_stderr_file => ['wasi_config_t','string'] => 'void', \&_wrapper ); |
28
|
|
|
|
|
|
|
$ffi->attach( preopen_dir => ['wasi_config_t','string','string'] => 'void', \&_wrapper ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
foreach my $name (qw( argv env stdin stdout stderr )) |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
$ffi->attach( "inherit_$name" => ['wasi_config_t'], \&_wrapper ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$ffi->attach( set_argv => ['wasi_config_t', 'int', 'string[]'] => sub { |
36
|
|
|
|
|
|
|
my($xsub, $self, @argv) = @_; |
37
|
|
|
|
|
|
|
$xsub->($self, scalar(@argv), \@argv); |
38
|
|
|
|
|
|
|
$self; |
39
|
|
|
|
|
|
|
}); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$ffi->attach( set_env => ['wasi_config_t','int','string[]','string[]'] => sub { |
42
|
|
|
|
|
|
|
my($xsub, $self, %env) = @_; |
43
|
|
|
|
|
|
|
my @names; |
44
|
|
|
|
|
|
|
my @values; |
45
|
|
|
|
|
|
|
foreach my $name (keys %env) |
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
push @names, $name; |
48
|
|
|
|
|
|
|
push @values, $env{$name}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
$xsub->($self, scalar(@names), \@names, \@values); |
51
|
|
|
|
|
|
|
$self; |
52
|
|
|
|
|
|
|
}); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
_generate_destroy(); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |