line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::WasiConfig; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
225563
|
use strict; |
|
11
|
|
|
|
|
29
|
|
|
11
|
|
|
|
|
306
|
|
4
|
11
|
|
|
11
|
|
70
|
use warnings; |
|
11
|
|
|
|
|
35
|
|
|
11
|
|
|
|
|
313
|
|
5
|
11
|
|
|
11
|
|
194
|
use 5.008004; |
|
11
|
|
|
|
|
42
|
|
6
|
11
|
|
|
11
|
|
479
|
use Wasm::Wasmtime::FFI; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
5243
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: WASI Configuration |
9
|
|
|
|
|
|
|
our $VERSION = '0.23'; # 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
|
|
4379
|
my $xsub = shift; |
19
|
19
|
|
|
|
|
33
|
my $self = shift; |
20
|
19
|
|
|
|
|
68
|
$xsub->($self, @_); |
21
|
19
|
|
|
|
|
503
|
$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__ |