File Coverage

blib/lib/Wasm/Wasmtime/Engine.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Wasm::Wasmtime::Engine;
2              
3 26     26   366892 use strict;
  26         62  
  26         761  
4 26     26   133 use warnings;
  26         53  
  26         584  
5 26     26   420 use 5.008004;
  26         87  
6 26     26   844 use Wasm::Wasmtime::FFI;
  26         120  
  26         3031  
7 26     26   10602 use Wasm::Wasmtime::Config;
  26         82  
  26         6202  
8              
9             # ABSTRACT: Wasmtime engine class
10             our $VERSION = '0.21'; # VERSION
11              
12              
13             $ffi_prefix = 'wasm_engine_';
14             $ffi->load_custom_type('::PtrObject' => 'wasm_engine_t' => __PACKAGE__ );
15              
16              
17             $ffi->attach( [ 'new_with_config' => 'new' ] => ['wasm_config_t'] => 'wasm_engine_t' => sub {
18             my($xsub, $class, $config) = @_;
19             $config ||= Wasm::Wasmtime::Config->new;
20             if(defined $ENV{PERL_WASM_WASMTIME_MEMORY})
21             {
22             my($static_memory_maximum_size, $static_memory_guard_size, $dynamic_memory_guard_size) = split /:/, $ENV{PERL_WASM_WASMTIME_MEMORY};
23             $config->static_memory_maximum_size($static_memory_maximum_size);
24             $config->static_memory_guard_size($static_memory_guard_size);
25             $config->dynamic_memory_guard_size($dynamic_memory_guard_size);
26             }
27             my $self = $xsub->($config),
28             delete $config->{ptr};
29             $self;
30             });
31              
32             _generate_destroy();
33              
34             1;
35              
36             __END__