|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Wasm::Wasmtime::ExternType;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
 
 | 
243061
 | 
 use strict;  | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
66
 | 
    | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
753
 | 
    | 
| 
4
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
 
 | 
171
 | 
 use warnings;  | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
75
 | 
    | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
588
 | 
    | 
| 
5
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
 
 | 
480
 | 
 use 5.008004;  | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
94
 | 
    | 
| 
6
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
 
 | 
2719
 | 
 use Wasm::Wasmtime::FFI;  | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
123
 | 
    | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5213
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 require Wasm::Wasmtime::FuncType;  | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 require Wasm::Wasmtime::GlobalType;  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 require Wasm::Wasmtime::TableType;  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 require Wasm::Wasmtime::MemoryType;  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ABSTRACT: Wasmtime extern type class  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '0.22'; # VERSION  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
  
0
  
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
0
 | 
 sub kind { die "internal error" };  | 
| 
18
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
 
 | 
223
 | 
 use constant is_functype   => 0;  | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
    | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1944
 | 
    | 
| 
19
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
 
 | 
181
 | 
 use constant is_globaltype => 0;  | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
88
 | 
    | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1483
 | 
    | 
| 
20
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
 
 | 
205
 | 
 use constant is_tabletype  => 0;  | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
96
 | 
    | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1461
 | 
    | 
| 
21
 | 
26
 | 
 
 | 
 
 | 
  
26
  
 | 
 
 | 
183
 | 
 use constant is_memorytype => 0;  | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
64
 | 
    | 
| 
 
 | 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8976
 | 
    | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $ffi_prefix = 'wasm_externtype_';  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $ffi->attach( [ kind => '_kind' ] => ['opaque'] => 'uint8' );  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my @cast;  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _cast  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 {  | 
| 
31
 | 
104
 | 
 
 | 
 
 | 
  
104
  
 | 
 
 | 
259
 | 
   my(undef, $index) = @_;  | 
| 
32
 | 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
270
 | 
   my $caller = caller;  | 
| 
33
 | 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
682
 | 
   my($name) = map { lc $_ } $caller =~ /::([a-z]+Type)$/i;  | 
| 
 
 | 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
370
 | 
    | 
| 
34
 | 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
562
 | 
   $cast[$index] = $ffi->function( "wasm_externtype_as_$name" => ['opaque'] => "wasm_${name}_t" )->sub_ref;  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $ffi->custom_type('wasm_externtype_t' => {  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   native_type => 'opaque',  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   native_to_perl => sub {  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $externtype = shift;  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     Carp::croak("externtype error") unless defined $externtype;  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $kind = _kind($externtype);  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $cast[$kind]->($externtype);  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   },  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 });  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub to_string  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 {  | 
| 
50
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
 
 | 
   die "internal error";  # pure virtual ish  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |