line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::ExportType; |
2
|
|
|
|
|
|
|
|
3
|
22
|
|
|
22
|
|
230855
|
use strict; |
|
22
|
|
|
|
|
75
|
|
|
22
|
|
|
|
|
669
|
|
4
|
22
|
|
|
22
|
|
127
|
use warnings; |
|
22
|
|
|
|
|
51
|
|
|
22
|
|
|
|
|
513
|
|
5
|
22
|
|
|
22
|
|
387
|
use 5.008004; |
|
22
|
|
|
|
|
77
|
|
6
|
22
|
|
|
22
|
|
141
|
use Ref::Util qw( is_blessed_ref ); |
|
22
|
|
|
|
|
56
|
|
|
22
|
|
|
|
|
1252
|
|
7
|
22
|
|
|
22
|
|
590
|
use Wasm::Wasmtime::FFI; |
|
22
|
|
|
|
|
44
|
|
|
22
|
|
|
|
|
2350
|
|
8
|
22
|
|
|
22
|
|
698
|
use Wasm::Wasmtime::ExternType; |
|
22
|
|
|
|
|
57
|
|
|
22
|
|
|
|
|
10076
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime export type class |
11
|
|
|
|
|
|
|
our $VERSION = '0.23'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_exporttype_'; |
15
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasm_exporttype_t' => __PACKAGE__); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$ffi->attach( new => ['wasm_byte_vec_t*', 'opaque'] => 'wasm_exporttype_t' => sub { |
19
|
|
|
|
|
|
|
my $xsub = shift; |
20
|
|
|
|
|
|
|
my $class = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# not sure this is actually useful... |
23
|
|
|
|
|
|
|
if(defined $_[1] && is_blessed_ref $_[1] && $_[1]->isa('Wasm::Wasmtime::ExternType')) |
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
my $name = Wasm::Wasmtime::ByteVec->new(shift); |
26
|
|
|
|
|
|
|
my $externtype = shift; |
27
|
|
|
|
|
|
|
my $self = $xsub->($name, $externtype->{ptr}); |
28
|
|
|
|
|
|
|
$name->delete; |
29
|
|
|
|
|
|
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
my ($ptr,$owner) = @_; |
34
|
|
|
|
|
|
|
return bless { |
35
|
|
|
|
|
|
|
ptr => $ptr, |
36
|
|
|
|
|
|
|
owner => $owner, |
37
|
|
|
|
|
|
|
}, $class; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
}); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$ffi->attach( name => ['wasm_exporttype_t'] => 'wasm_byte_vec_t*' => sub { |
43
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
44
|
|
|
|
|
|
|
my $name = $xsub->($self); |
45
|
|
|
|
|
|
|
$name->get; |
46
|
|
|
|
|
|
|
}); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$ffi->attach( type => ['wasm_exporttype_t'] => 'wasm_externtype_t' => sub { |
50
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
51
|
|
|
|
|
|
|
my $type = $xsub->($self); |
52
|
|
|
|
|
|
|
$type->{owner} = $self->{owner} || $self; |
53
|
|
|
|
|
|
|
$type; |
54
|
|
|
|
|
|
|
}); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub to_string |
58
|
|
|
|
|
|
|
{ |
59
|
3
|
|
|
3
|
1
|
288
|
my($self) = @_; |
60
|
3
|
|
|
|
|
13
|
my $kind = $self->type->kind; |
61
|
3
|
|
|
|
|
10
|
$kind =~ s/type$//; |
62
|
|
|
|
|
|
|
# TODO: escape strings ? |
63
|
3
|
|
|
|
|
15
|
sprintf '(%s (export "%s") %s)', $kind, $self->name, $self->type->to_string; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
_generate_destroy(); |
67
|
|
|
|
|
|
|
_generate_vec_class(); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |