mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-12 17:09:28 -05:00
add SharedArrayBuffer deprecated constructor (#171)
needed temporarily for porting deno
This commit is contained in:
parent
e409030541
commit
5c9effbeb1
2 changed files with 36 additions and 0 deletions
|
@ -993,6 +993,14 @@ v8::SharedArrayBuffer* v8__SharedArrayBuffer__New(v8::Isolate* isolate,
|
|||
return local_to_ptr(v8::SharedArrayBuffer::New(isolate, byte_length));
|
||||
}
|
||||
|
||||
v8::SharedArrayBuffer* v8__SharedArrayBuffer__New__DEPRECATED(
|
||||
v8::Isolate* isolate, void* data_ptr, size_t data_length) {
|
||||
auto ab =
|
||||
v8::SharedArrayBuffer::New(isolate, data_ptr, data_length,
|
||||
v8::ArrayBufferCreationMode::kExternalized);
|
||||
return local_to_ptr(ab);
|
||||
}
|
||||
|
||||
size_t v8__SharedArrayBuffer__ByteLength(v8::SharedArrayBuffer& self) {
|
||||
return self.ByteLength();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,11 @@ extern "C" {
|
|||
isolate: *mut Isolate,
|
||||
byte_length: usize,
|
||||
) -> *mut SharedArrayBuffer;
|
||||
fn v8__SharedArrayBuffer__New__DEPRECATED(
|
||||
isolate: *mut Isolate,
|
||||
data_ptr: *mut std::ffi::c_void,
|
||||
data_length: usize,
|
||||
) -> *mut SharedArrayBuffer;
|
||||
fn v8__SharedArrayBuffer__ByteLength(
|
||||
self_: *const SharedArrayBuffer,
|
||||
) -> usize;
|
||||
|
@ -32,6 +37,29 @@ impl SharedArrayBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
/// DEPRECATED
|
||||
/// Use the version that takes a BackingStore.
|
||||
/// See http://crbug.com/v8/9908.
|
||||
///
|
||||
///
|
||||
/// Create a new SharedArrayBuffer over an existing memory block. The created
|
||||
/// array buffer is immediately in externalized state unless otherwise
|
||||
/// specified. The memory block will not be reclaimed when a created
|
||||
/// SharedArrayBuffer is garbage-collected.
|
||||
#[allow(non_snake_case)]
|
||||
pub unsafe fn new_DEPRECATED<'sc>(
|
||||
scope: &mut impl ToLocal<'sc>,
|
||||
data_ptr: *mut std::ffi::c_void,
|
||||
data_length: usize,
|
||||
) -> Local<'sc, SharedArrayBuffer> {
|
||||
Local::from_raw(v8__SharedArrayBuffer__New__DEPRECATED(
|
||||
scope.isolate(),
|
||||
data_ptr,
|
||||
data_length,
|
||||
))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// Data length in bytes.
|
||||
pub fn byte_length(&self) -> usize {
|
||||
unsafe { v8__SharedArrayBuffer__ByteLength(self) }
|
||||
|
|
Loading…
Reference in a new issue