| 1 | package Wasm::Wasmtime::MemoryType; | ||||||||||
| 2 | |||||||||||
| 3 | 26 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 26 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 26 | ▶ | use 5.008004; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 26 | ▶ | use base qw( Wasm::Wasmtime::ExternType ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 26 | ▶ | use Ref::Util qw( is_ref is_plain_arrayref ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 26 | ▶ | use Wasm::Wasmtime::FFI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 26 | ▶ | use constant is_memorytype => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 26 | ▶ | use constant kind => 'memorytype'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | # ABSTRACT: Wasmtime memory type class | ||||||||||
| 13 | 26 | our $VERSION = '0.24'; # VERSION | |||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | 26 | $ffi_prefix = 'wasm_memorytype_'; | |||||||||
| 17 | 26 | $ffi->load_custom_type('::PtrObject' => 'wasm_memorytype_t' => __PACKAGE__); | |||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | 4 | ▶ | $ffi->attach( new => ['uint32[2]'] => 'wasm_memorytype_t' => sub { | ||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.8
| |||||||||||
| 21 | 4 | my $xsub = shift; | |||||||||
| 22 | 4 | my $class = shift; | |||||||||
| 23 | 4 | ▶ | if(is_ref $_[0]) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | { | ||||||||||
| 25 | 4 | my $limit = shift; | |||||||||
| 26 | 4 | ▶ | Carp::croak("bad limits") unless is_plain_arrayref($limit); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 4 | ▶ | Carp::croak("no minumum in limit") unless defined $limit->[0]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 4 | ▶ | $limit->[1] = 0xffffffff unless defined $limit->[1]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 4 | return $xsub->($limit); | |||||||||
| 30 | } | ||||||||||
| 31 | else | ||||||||||
| 32 | { | ||||||||||
| 33 | 0 | my ($ptr, $owner) = @_; | |||||||||
| 34 | 0 | return bless { | |||||||||
| 35 | ptr => $ptr, | ||||||||||
| 36 | owner => $owner, | ||||||||||
| 37 | }, $class; | ||||||||||
| 38 | } | ||||||||||
| 39 | 26 | }); | |||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | 8 | ▶ | $ffi->attach( limits => ['wasm_memorytype_t'] => 'uint32[2]' => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 43 | 8 | my($xsub, $self) = @_; | |||||||||
| 44 | 8 | my $limits = $xsub->($self); | |||||||||
| 45 | 8 | $limits; | |||||||||
| 46 | 26 | }); | |||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | sub to_string | ||||||||||
| 50 | 3 | ▶ | { | ||||||||
|
Subroutine
to_string: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 51 | 3 | my($self) = @_; | |||||||||
| 52 | 3 | my($min, $max) = @{ $self->limits }; | |||||||||
| 53 | 3 | my $string = "$min"; | |||||||||
| 54 | 3 | ▶ | $string .= " $max" if $max != 0xffffffff; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 3 | return $string; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 26 | __PACKAGE__->_cast(3); | |||||||||
| 59 | 26 | _generate_destroy(); | |||||||||
| 60 | |||||||||||
| 61 | 26 | 1; | |||||||||
| 62 | |||||||||||
| 63 | __END__ | ||||||||||