1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use std::os::raw::c_void;
use raw::{HandleScope, EscapableHandleScope, InheritedHandleScope, Local, Isolate};
pub trait Root {
unsafe fn allocate() -> Self;
unsafe fn enter(&mut self, *mut Isolate);
unsafe fn exit(&mut self);
}
impl Root for HandleScope {
unsafe fn allocate() -> Self { HandleScope::new() }
unsafe fn enter(&mut self, isolate: *mut Isolate) {
enter(self, isolate)
}
unsafe fn exit(&mut self) {
exit(self)
}
}
impl Root for EscapableHandleScope {
unsafe fn allocate() -> Self { EscapableHandleScope::new() }
unsafe fn enter(&mut self, isolate: *mut Isolate) {
enter_escapable(self, isolate)
}
unsafe fn exit(&mut self) {
exit_escapable(self)
}
}
impl Root for InheritedHandleScope {
unsafe fn allocate() -> Self { InheritedHandleScope }
unsafe fn enter(&mut self, _: *mut Isolate) { }
unsafe fn exit(&mut self) { }
}
extern "C" {
#[link_name = "Neon_Scope_Escape"]
pub fn escape(out: &mut Local, scope: *mut EscapableHandleScope, value: Local);
#[link_name = "Neon_Scope_Chained"]
pub fn chained(out: *mut c_void, closure: *mut c_void, callback: extern fn(&mut c_void, *mut c_void, *mut c_void, *mut c_void), parent_scope: *mut c_void);
#[link_name = "Neon_Scope_Nested"]
pub fn nested(out: *mut c_void, closure: *mut c_void, callback: extern fn(&mut c_void, *mut c_void, *mut c_void), realm: *mut c_void);
#[link_name = "Neon_Scope_Enter"]
pub fn enter(scope: &mut HandleScope, isolate: *mut c_void);
#[link_name = "Neon_Scope_Exit"]
pub fn exit(scope: &mut HandleScope);
#[link_name = "Neon_Scope_Enter_Escapable"]
pub fn enter_escapable(scope: &mut EscapableHandleScope, isolate: *mut c_void);
#[link_name = "Neon_Scope_Exit_Escapable"]
pub fn exit_escapable(scope: &mut EscapableHandleScope);
#[link_name = "Neon_Scope_Sizeof"]
pub fn size() -> usize;
#[link_name = "Neon_Scope_Alignof"]
pub fn alignment() -> usize;
#[link_name = "Neon_Scope_SizeofEscapable"]
pub fn escapable_size() -> usize;
#[link_name = "Neon_Scope_AlignofEscapable"]
pub fn escapable_alignment() -> usize;
#[link_name = "Neon_Scope_GetGlobal"]
pub fn get_global(isolate: *mut c_void, out: &mut Local);
}