mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-14 01:50:24 -05:00
feat: Add v8::CreateParams::has_set_array_buffer_allocator (#1232)
This commit is contained in:
parent
c68038bc7d
commit
367be04178
2 changed files with 13 additions and 4 deletions
|
@ -58,6 +58,13 @@ impl CreateParams {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if `array_buffer_allocator` has already been called. Useful to some
|
||||||
|
/// embedders that might want to set an allocator but not overwrite if one
|
||||||
|
/// was already set by a user.
|
||||||
|
pub fn has_set_array_buffer_allocator(&self) -> bool {
|
||||||
|
!self.raw.array_buffer_allocator_shared.is_null()
|
||||||
|
}
|
||||||
|
|
||||||
/// Specifies an optional nullptr-terminated array of raw addresses in the
|
/// Specifies an optional nullptr-terminated array of raw addresses in the
|
||||||
/// embedder that V8 can match against during serialization and use for
|
/// embedder that V8 can match against during serialization and use for
|
||||||
/// deserialization. This array and its content must stay valid for the
|
/// deserialization. This array and its content must stay valid for the
|
||||||
|
|
|
@ -7342,10 +7342,12 @@ fn run_with_rust_allocator() {
|
||||||
let count = Arc::new(AtomicUsize::new(0));
|
let count = Arc::new(AtomicUsize::new(0));
|
||||||
|
|
||||||
let _setup_guard = setup::parallel_test();
|
let _setup_guard = setup::parallel_test();
|
||||||
let create_params =
|
let create_params = v8::CreateParams::default();
|
||||||
v8::CreateParams::default().array_buffer_allocator(unsafe {
|
assert!(!create_params.has_set_array_buffer_allocator());
|
||||||
v8::new_rust_allocator(Arc::into_raw(count.clone()), vtable)
|
let create_params = create_params.array_buffer_allocator(unsafe {
|
||||||
});
|
v8::new_rust_allocator(Arc::into_raw(count.clone()), vtable)
|
||||||
|
});
|
||||||
|
assert!(create_params.has_set_array_buffer_allocator());
|
||||||
let isolate = &mut v8::Isolate::new(create_params);
|
let isolate = &mut v8::Isolate::new(create_params);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue