| 1 | package Wasm::Wasmtime::Caller; | ||||||||||||
| 2 | |||||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 10 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 10 | ▶ | use 5.008004; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 10 | ▶ | use FFI::Platypus::Buffer (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 10 | ▶ | use Wasm::Wasmtime::FFI; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 10 | ▶ | use Wasm::Wasmtime::Extern; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 10 | ▶ | use base qw( Exporter ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 10 | our @EXPORT = qw( wasmtime_caller ); | |||||||||||
| 12 | |||||||||||||
| 13 | 10 | $ffi_prefix = 'wasmtime_caller_'; | |||||||||||
| 14 | |||||||||||||
| 15 | # ABSTRACT: Wasmtime caller interface | ||||||||||||
| 16 | 10 | our $VERSION = '0.24'; # VERSION | |||||||||||
| 17 | |||||||||||||
| 18 | |||||||||||||
| 19 | 10 | our @callers; | |||||||||||
| 20 | |||||||||||||
| 21 | sub wasmtime_caller (;$) | ||||||||||||
| 22 | 4 | ▶ | { | ||||||||||
|
Subroutine
wasmtime_caller: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 23 | 4 | ▶ | $callers[$_[0]||0] | ||||||||||
|
Condition50%1/2
$_[0] || 0
MC/DC0%0/1
$_[0] || 0
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | |||||||||||||
| 27 | sub new | ||||||||||||
| 28 | 11 | ▶ | { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 29 | 11 | my($class, $ptr, $store) = @_; | |||||||||||
| 30 | 11 | bless { | |||||||||||
| 31 | ptr => $ptr, | ||||||||||||
| 32 | store => $store, | ||||||||||||
| 33 | }, $class; | ||||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | |||||||||||||
| 37 | 0 | ▶ | sub store { shift->{store} } | ||||||||||
|
Subroutine
store: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 38 | |||||||||||||
| 39 | 3 | ▶ | $ffi->attach( export_get => ['opaque','opaque','size_t','wasmtime_extern_t'] => 'bool' => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||
| 40 | 3 | my $xsub = shift; | |||||||||||
| 41 | 3 | my $self = shift; | |||||||||||
| 42 | 3 | ▶ | return undef unless $self->{ptr}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 2 | my $name = shift; | |||||||||||
| 44 | 2 | ▶ | $name = defined $name ? "$name" : ""; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | 2 | my($nptr, $nlen) = FFI::Platypus::Buffer::scalar_to_buffer($name); | |||||||||||
| 46 | 2 | my $extern = Wasm::Wasmtime::ExternData->new; | |||||||||||
| 47 | 2 | ▶ | return undef unless $xsub->($self->{ptr}, $nptr, $nlen, $extern); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 48 | 2 | my $obj = Wasm::Wasmtime::Extern->from_extern($extern, $self->{store}); | |||||||||||
| 49 | 2 | $extern->free; | |||||||||||
| 50 | 2 | $obj; | |||||||||||
| 51 | 10 | }); | |||||||||||
| 52 | |||||||||||||
| 53 | 10 | 1; | |||||||||||
| 54 | |||||||||||||
| 55 | __END__ | ||||||||||||