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   232578 use strict;
  16         55  
  16         518  
4 16     16   84 use warnings;
  16         33  
  16         419  
5 16     16   273 use 5.008004;
  16         64  
6 16     16   102 use base qw( Wasm::Wasmtime::Extern );
  16         31  
  16         2097  
7 16     16   136 use Ref::Util qw( is_ref );
  16         40  
  16         823  
8 16     16   123 use Wasm::Wasmtime::FFI;
  16         96  
  16         1645  
9 16     16   112 use Wasm::Wasmtime::Store;
  16         55  
  16         500  
10 16     16   113 use Wasm::Wasmtime::TableType;
  16         51  
  16         594  
11 16     16   165 use constant is_table => 1;
  16         37  
  16         1068  
12 16     16   163 use constant kind => 'table';
  16         39  
  16         3986  
13              
14             # ABSTRACT: Wasmtime table class
15             our $VERSION = '0.23'; # 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__