File Coverage

blib/lib/Wasm/Wasmtime/Table.pm
Criterion Covered Total %
statement 29 31 93.5
branch n/a
condition n/a
subroutine 10 11 90.9
pod 0 1 0.0
total 39 43 90.7


line stmt bran cond sub pod time code
1             package Wasm::Wasmtime::Table;
2              
3 16     16   243908 use strict;
  16         64  
  16         861  
4 16     16   93 use warnings;
  16         36  
  16         426  
5 16     16   289 use 5.008004;
  16         60  
6 16     16   106 use base qw( Wasm::Wasmtime::Extern );
  16         66  
  16         2133  
7 16     16   118 use Ref::Util qw( is_ref );
  16         41  
  16         827  
8 16     16   144 use Wasm::Wasmtime::FFI;
  16         60  
  16         1828  
9 16     16   115 use Wasm::Wasmtime::Store;
  16         43  
  16         482  
10 16     16   100 use Wasm::Wasmtime::TableType;
  16         36  
  16         601  
11 16     16   120 use constant is_table => 1;
  16         35  
  16         1046  
12 16     16   106 use constant kind => 'table';
  16         39  
  16         4187  
13              
14             # ABSTRACT: Wasmtime table class
15             our $VERSION = '0.22'; # VERSION
16              
17              
18             $ffi_prefix = 'wasm_table_';
19             $ffi->load_custom_type('::PtrObject' => 'wasm_table_t' => __PACKAGE__);
20              
21             sub new
22             {
23             # TODO: add wasm_table_new for standalone support
24             # TODO: add wasm_table_set
25             # TODO: add wasm_table_get
26             # TODO: add wasm_table_grow
27 0     0 0   my($class, $ptr, $owner) = @_;
28 0           bless {
29             ptr => $ptr,
30             owner => $owner,
31             }, $class;
32             }
33              
34              
35             $ffi->attach( type => ['wasm_table_t'] => 'wasm_tabletype_t' => sub {
36             my($xsub, $self) = @_;
37             my $type = $xsub->($self);
38             $type->{owner} = $self->{owner} || $self;
39             $type;
40             });
41              
42              
43             $ffi->attach( size => ['wasm_table_t'] => 'uint32' );
44              
45             __PACKAGE__->_cast(2);
46             _generate_destroy();
47              
48             1;
49              
50             __END__