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   468909 use strict;
  26         101  
  26         827  
4 26     26   152 use warnings;
  26         71  
  26         706  
5 26     26   460 use 5.008004;
  26         101  
6 26     26   1110 use Wasm::Wasmtime::FFI;
  26         109  
  26         2881  
7 26     26   11534 use Wasm::Wasmtime::Config;
  26         92  
  26         7215  
8              
9             # ABSTRACT: Wasmtime engine class
10             our $VERSION = '0.22'; # 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__