0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-26 00:59:28 -05:00

feat: V8 12.8 (#1539)

This commit is contained in:
snek 2024-07-23 12:43:32 -07:00 committed by GitHub
parent 979f3d87d1
commit 1e4b691905
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 353 additions and 275 deletions

4
.gn
View file

@ -55,6 +55,10 @@ default_args = {
# fixed addresses.
v8_typed_array_max_size_in_heap = 0
# Historically these always had 2 slots. Keep for compat.
v8_array_buffer_internal_field_count = 2
v8_array_buffer_view_internal_field_count = 2
# Enabling the shared read-only heap comes with a restriction that all
# isolates running at the same time must be created from the same snapshot.
# This is problematic for Deno, which has separate "runtime" and "typescript

View file

@ -1,6 +1,6 @@
# Rusty V8 Binding
V8 Version: 12.7.224.13
V8 Version: 12.8.374.1
[![ci](https://github.com/denoland/rusty_v8/workflows/ci/badge.svg?branch=main)](https://github.com/denoland/rusty_v8/actions)
[![crates](https://img.shields.io/crates/v/v8.svg)](https://crates.io/crates/v8)

View file

@ -70,9 +70,6 @@ static_assert(
static_assert(sizeof(v8::FunctionCallbackInfo<v8::Value>) == sizeof(size_t) * 3,
"FunctionCallbackInfo size mismatch");
static_assert(sizeof(v8::PropertyCallbackInfo<v8::Value>) == sizeof(size_t) * 1,
"PropertyCallbackInfo size mismatch");
static_assert(sizeof(v8::ReturnValue<v8::Value>) == sizeof(size_t) * 1,
"ReturnValue size mismatch");
@ -2289,55 +2286,81 @@ const extern int v8__FunctionCallbackInfo__kArgsLength = 6;
// NOTE(bartlomieju): V8 made this field private in 11.4
// v8::FunctionCallbackInfo<v8::Value>::kArgsLength;
const extern int v8__PropertyCallbackInfo__kArgsLength = 7;
// NOTE(bartlomieju): V8 made this field private in 11.4
// v8::PropertyCallbackInfo<v8::Value>::kArgsLength;
const v8::Value* v8__FunctionCallbackInfo__Data(
const v8::FunctionCallbackInfo<v8::Value>& self) {
return local_to_ptr(self.Data());
}
v8::Isolate* v8__PropertyCallbackInfo__GetIsolate(
const v8::PropertyCallbackInfo<v8::Value>& self) {
return self.GetIsolate();
}
const v8::Value* v8__PropertyCallbackInfo__Data(
const v8::PropertyCallbackInfo<v8::Value>& self) {
return local_to_ptr(self.Data());
}
const v8::Object* v8__PropertyCallbackInfo__This(
const v8::PropertyCallbackInfo<v8::Value>& self) {
return local_to_ptr(self.This());
}
const v8::Object* v8__PropertyCallbackInfo__Holder(
const v8::PropertyCallbackInfo<v8::Value>& self) {
return local_to_ptr(self.HolderV2());
}
v8::internal::Address* v8__PropertyCallbackInfo__GetReturnValue(
const v8::PropertyCallbackInfo<v8::Value>& self) {
v8::ReturnValue<v8::Value> rv = self.GetReturnValue();
return *reinterpret_cast<v8::internal::Address**>(&rv);
}
bool v8__PropertyCallbackInfo__ShouldThrowOnError(
const v8::PropertyCallbackInfo<v8::Value>& self) {
return self.ShouldThrowOnError();
}
void v8__ReturnValue__Set(v8::ReturnValue<v8::Value>* self,
const v8::Value& value) {
void v8__ReturnValue__Value__Set(v8::ReturnValue<v8::Value>* self,
const v8::Value& value) {
self->Set(ptr_to_local(&value));
}
void v8__ReturnValue__Set__Bool(v8::ReturnValue<v8::Value>* self, bool i) {
void v8__ReturnValue__Value__Set__Bool(v8::ReturnValue<v8::Value>* self,
bool i) {
self->Set(i);
}
void v8__ReturnValue__Set__Int32(v8::ReturnValue<v8::Value>* self, int32_t i) {
void v8__ReturnValue__Value__Set__Int32(v8::ReturnValue<v8::Value>* self,
int32_t i) {
self->Set(i);
}
void v8__ReturnValue__Set__Uint32(v8::ReturnValue<v8::Value>* self,
uint32_t i) {
void v8__ReturnValue__Value__Set__Uint32(v8::ReturnValue<v8::Value>* self,
uint32_t i) {
self->Set(i);
}
void v8__ReturnValue__Set__Double(v8::ReturnValue<v8::Value>* self, double i) {
void v8__ReturnValue__Value__Set__Double(v8::ReturnValue<v8::Value>* self,
double i) {
self->Set(i);
}
void v8__ReturnValue__SetNull(v8::ReturnValue<v8::Value>* self) {
void v8__ReturnValue__Value__SetNull(v8::ReturnValue<v8::Value>* self) {
self->SetNull();
}
void v8__ReturnValue__SetUndefined(v8::ReturnValue<v8::Value>* self) {
void v8__ReturnValue__Value__SetUndefined(v8::ReturnValue<v8::Value>* self) {
self->SetUndefined();
}
void v8__ReturnValue__SetEmptyString(v8::ReturnValue<v8::Value>* self) {
void v8__ReturnValue__Value__SetEmptyString(v8::ReturnValue<v8::Value>* self) {
self->SetEmptyString();
}
const v8::Value* v8__ReturnValue__Get(const v8::ReturnValue<v8::Value>& self) {
const v8::Value* v8__ReturnValue__Value__Get(
const v8::ReturnValue<v8::Value>& self) {
return local_to_ptr(self.Get());
}

View file

@ -3,10 +3,12 @@
use crate::support::intptr_t;
use crate::FunctionCallback;
use crate::IndexedDefinerCallback;
use crate::IndexedDeleterCallback;
use crate::IndexedGetterCallback;
use crate::IndexedSetterCallback;
use crate::MessageCallback;
use crate::NamedDefinerCallback;
use crate::NamedDeleterCallback;
use crate::NamedGetterCallback;
use crate::NamedSetterCallback;
use crate::PropertyEnumeratorCallback;
@ -19,9 +21,11 @@ pub union ExternalReference<'s> {
pub named_getter: NamedGetterCallback<'s>,
pub named_setter: NamedSetterCallback<'s>,
pub named_definer: NamedDefinerCallback<'s>,
pub named_deleter: NamedDeleterCallback<'s>,
pub indexed_getter: IndexedGetterCallback<'s>,
pub indexed_setter: IndexedSetterCallback<'s>,
pub indexed_definer: IndexedDefinerCallback<'s>,
pub indexed_deleter: IndexedDeleterCallback<'s>,
pub enumerator: PropertyEnumeratorCallback<'s>,
pub message: MessageCallback,
pub pointer: *mut c_void,

View file

@ -1,4 +1,5 @@
use crate::support::Opaque;
use crate::Isolate;
use crate::Local;
use crate::Value;
use std::{
@ -205,6 +206,7 @@ pub union FastApiCallbackData<'a> {
/// ```
#[repr(C)]
pub struct FastApiCallbackOptions<'a> {
pub isolate: *mut Isolate,
/// If the callback wants to signal an error condition or to perform an
/// allocation, it must set options.fallback to true and do an early return
/// from the fast method. Then V8 checks the value of options.fallback and if

View file

@ -11,6 +11,8 @@ use crate::support::ToCFn;
use crate::support::UnitType;
use crate::support::{int, Opaque};
use crate::template::Intercepted;
use crate::Array;
use crate::Boolean;
use crate::Context;
use crate::Function;
use crate::HandleScope;
@ -62,26 +64,41 @@ extern "C" {
static v8__FunctionCallbackInfo__kArgsLength: int;
static v8__PropertyCallbackInfo__kArgsLength: int;
fn v8__FunctionCallbackInfo__Data(
this: *const FunctionCallbackInfo,
) -> *const Value;
fn v8__PropertyCallbackInfo__GetIsolate(
this: *const RawPropertyCallbackInfo,
) -> *mut Isolate;
fn v8__PropertyCallbackInfo__Data(
this: *const RawPropertyCallbackInfo,
) -> *const Value;
fn v8__PropertyCallbackInfo__This(
this: *const RawPropertyCallbackInfo,
) -> *const Object;
fn v8__PropertyCallbackInfo__Holder(
this: *const RawPropertyCallbackInfo,
) -> *const Object;
fn v8__PropertyCallbackInfo__GetReturnValue(
this: *const RawPropertyCallbackInfo,
) -> usize;
fn v8__PropertyCallbackInfo__ShouldThrowOnError(
this: *const PropertyCallbackInfo,
this: *const RawPropertyCallbackInfo,
) -> bool;
fn v8__ReturnValue__Set(this: *mut ReturnValue, value: *const Value);
fn v8__ReturnValue__Set__Bool(this: *mut ReturnValue, value: bool);
fn v8__ReturnValue__Set__Int32(this: *mut ReturnValue, value: i32);
fn v8__ReturnValue__Set__Uint32(this: *mut ReturnValue, value: u32);
fn v8__ReturnValue__Set__Double(this: *mut ReturnValue, value: f64);
fn v8__ReturnValue__SetNull(this: *mut ReturnValue);
fn v8__ReturnValue__SetUndefined(this: *mut ReturnValue);
fn v8__ReturnValue__SetEmptyString(this: *mut ReturnValue);
fn v8__ReturnValue__Get(this: *const ReturnValue) -> *const Value;
fn v8__ReturnValue__Value__Set(
this: *mut RawReturnValue,
value: *const Value,
);
fn v8__ReturnValue__Value__Set__Bool(this: *mut RawReturnValue, value: bool);
fn v8__ReturnValue__Value__Set__Int32(this: *mut RawReturnValue, value: i32);
fn v8__ReturnValue__Value__Set__Uint32(this: *mut RawReturnValue, value: u32);
fn v8__ReturnValue__Value__Set__Double(this: *mut RawReturnValue, value: f64);
fn v8__ReturnValue__Value__SetNull(this: *mut RawReturnValue);
fn v8__ReturnValue__Value__SetUndefined(this: *mut RawReturnValue);
fn v8__ReturnValue__Value__SetEmptyString(this: *mut RawReturnValue);
fn v8__ReturnValue__Value__Get(this: *const RawReturnValue) -> *const Value;
}
// Ad-libbed - V8 does not document ConstructorBehavior.
@ -112,68 +129,87 @@ pub enum SideEffectType {
HasSideEffectToReceiver,
}
#[repr(C)]
#[derive(Debug)]
struct RawReturnValue(usize);
// Note: the 'cb lifetime is required because the ReturnValue object must not
// outlive the FunctionCallbackInfo/PropertyCallbackInfo object from which it
// is derived.
#[repr(C)]
#[derive(Debug)]
pub struct ReturnValue<'cb>(NonNull<Value>, PhantomData<&'cb ()>);
pub struct ReturnValue<'cb, T = Value>(RawReturnValue, PhantomData<&'cb T>);
/// In V8 ReturnValue<> has a type parameter, but
/// it turns out that in most of the APIs it's ReturnValue<Value>
/// and for our purposes we currently don't need
/// other types. So for now it's a simplified version.
impl<'cb> ReturnValue<'cb> {
impl<'cb, T> ReturnValue<'cb, T> {
#[inline(always)]
pub fn from_property_callback_info(
info: &'cb PropertyCallbackInfo<T>,
) -> Self {
Self(
unsafe {
RawReturnValue(v8__PropertyCallbackInfo__GetReturnValue(&info.0))
},
PhantomData,
)
}
}
impl<'cb> ReturnValue<'cb, Value> {
#[inline(always)]
pub fn from_function_callback_info(info: &'cb FunctionCallbackInfo) -> Self {
let nn = info.get_return_value_non_null();
Self(nn, PhantomData)
Self(RawReturnValue(nn.as_ptr() as _), PhantomData)
}
}
impl<'cb> ReturnValue<'cb, ()> {
#[inline(always)]
pub fn from_property_callback_info(info: &'cb PropertyCallbackInfo) -> Self {
let nn = info.get_return_value_non_null();
Self(nn, PhantomData)
pub fn set_bool(&mut self, value: bool) {
unsafe { v8__ReturnValue__Value__Set__Bool(&mut self.0, value) }
}
}
impl<'cb, T> ReturnValue<'cb, T>
where
for<'s> Local<'s, T>: Into<Local<'s, Value>>,
{
#[inline(always)]
pub fn set(&mut self, value: Local<Value>) {
unsafe { v8__ReturnValue__Set(&mut *self, &*value) }
pub fn set(&mut self, value: Local<T>) {
unsafe { v8__ReturnValue__Value__Set(&mut self.0, &*value.into()) }
}
#[inline(always)]
pub fn set_bool(&mut self, value: bool) {
unsafe { v8__ReturnValue__Set__Bool(&mut *self, value) }
unsafe { v8__ReturnValue__Value__Set__Bool(&mut self.0, value) }
}
#[inline(always)]
pub fn set_int32(&mut self, value: i32) {
unsafe { v8__ReturnValue__Set__Int32(&mut *self, value) }
unsafe { v8__ReturnValue__Value__Set__Int32(&mut self.0, value) }
}
#[inline(always)]
pub fn set_uint32(&mut self, value: u32) {
unsafe { v8__ReturnValue__Set__Uint32(&mut *self, value) }
unsafe { v8__ReturnValue__Value__Set__Uint32(&mut self.0, value) }
}
#[inline(always)]
pub fn set_double(&mut self, value: f64) {
unsafe { v8__ReturnValue__Set__Double(&mut *self, value) }
unsafe { v8__ReturnValue__Value__Set__Double(&mut self.0, value) }
}
#[inline(always)]
pub fn set_null(&mut self) {
unsafe { v8__ReturnValue__SetNull(&mut *self) }
unsafe { v8__ReturnValue__Value__SetNull(&mut self.0) }
}
#[inline(always)]
pub fn set_undefined(&mut self) {
unsafe { v8__ReturnValue__SetUndefined(&mut *self) }
unsafe { v8__ReturnValue__Value__SetUndefined(&mut self.0) }
}
#[inline(always)]
pub fn set_empty_string(&mut self) {
unsafe { v8__ReturnValue__SetEmptyString(&mut *self) }
unsafe { v8__ReturnValue__Value__SetEmptyString(&mut self.0) }
}
/// Getter. Creates a new Local<> so it comes with a certain performance
@ -181,7 +217,8 @@ impl<'cb> ReturnValue<'cb> {
/// value.
#[inline(always)]
pub fn get<'s>(&self, scope: &mut HandleScope<'s>) -> Local<'s, Value> {
unsafe { scope.cast_local(|_| v8__ReturnValue__Get(self)) }.unwrap()
unsafe { scope.cast_local(|_| v8__ReturnValue__Value__Get(&self.0)) }
.unwrap()
}
}
@ -301,86 +338,20 @@ impl FunctionCallbackInfo {
}
}
#[repr(C)]
#[derive(Debug)]
struct RawPropertyCallbackInfo(Opaque);
/// The information passed to a property callback about the context
/// of the property access.
#[repr(C)]
#[derive(Debug)]
pub struct PropertyCallbackInfo {
// The layout of this struct must match that of `class PropertyCallbackInfo`
// as defined in v8.h.
args: *mut *const Opaque,
}
pub struct PropertyCallbackInfo<T>(RawPropertyCallbackInfo, PhantomData<T>);
// These constants must match those defined on `class PropertyCallbackInfo` in
// v8-function-callback.h.
#[allow(dead_code, non_upper_case_globals)]
impl PropertyCallbackInfo {
const kShouldThrowOnErrorIndex: i32 = 0;
const kHolderIndex: i32 = 1;
const kIsolateIndex: i32 = 2;
const kReturnValueDefaultValueIndex: i32 = 3;
const kReturnValueIndex: i32 = 4;
const kDataIndex: i32 = 5;
const kThisIndex: i32 = 6;
const kArgsLength: i32 = 7;
}
impl PropertyCallbackInfo {
impl<T> PropertyCallbackInfo<T> {
#[inline(always)]
pub(crate) fn get_isolate_ptr(&self) -> *mut Isolate {
let arg_nn = self.get_arg_non_null::<*mut Isolate>(Self::kIsolateIndex);
*unsafe { arg_nn.as_ref() }
}
#[inline(always)]
pub(crate) fn get_return_value_non_null(&self) -> NonNull<Value> {
self.get_arg_non_null::<Value>(Self::kReturnValueIndex)
}
#[inline(always)]
pub(crate) fn holder(&self) -> Local<Object> {
unsafe { self.get_arg_local(Self::kHolderIndex) }
}
#[inline(always)]
pub(crate) fn this(&self) -> Local<Object> {
unsafe { self.get_arg_local(Self::kThisIndex) }
}
#[inline(always)]
pub(crate) fn data(&self) -> Local<Value> {
unsafe { self.get_arg_local(Self::kDataIndex) }
}
#[inline(always)]
pub(crate) fn should_throw_on_error(&self) -> bool {
unsafe { v8__PropertyCallbackInfo__ShouldThrowOnError(self) }
}
#[inline(always)]
fn get_arg_non_null<T>(&self, index: i32) -> NonNull<T> {
// In debug builds, verify that `PropertyCallbackInfo::kArgsLength` matches
// the C++ definition. Unfortunately we can't check the other constants
// because they are declared protected in the C++ header.
debug_assert_eq!(
unsafe { v8__PropertyCallbackInfo__kArgsLength },
Self::kArgsLength
);
// Assert that `index` is in bounds.
assert!(index >= 0);
assert!(index < Self::kArgsLength);
// Compute the address of the implicit argument and cast to `NonNull<T>`.
let ptr = unsafe { self.args.offset(index as isize) as *mut T };
debug_assert!(!ptr.is_null());
unsafe { NonNull::new_unchecked(ptr) }
}
// SAFETY: caller must guarantee that the implicit argument at `index`
// contains a valid V8 handle.
#[inline(always)]
unsafe fn get_arg_local<T>(&self, index: i32) -> Local<T> {
let nn = self.get_arg_non_null::<T>(index);
Local::from_non_null(nn)
unsafe { v8__PropertyCallbackInfo__GetIsolate(&self.0) }
}
}
@ -448,26 +419,27 @@ impl<'s> FunctionCallbackArguments<'s> {
}
#[derive(Debug)]
pub struct PropertyCallbackArguments<'s>(&'s PropertyCallbackInfo);
pub struct PropertyCallbackArguments<'s>(&'s RawPropertyCallbackInfo);
impl<'s> PropertyCallbackArguments<'s> {
#[inline(always)]
pub(crate) fn from_property_callback_info(
info: &'s PropertyCallbackInfo,
pub(crate) fn from_property_callback_info<T>(
info: &'s PropertyCallbackInfo<T>,
) -> Self {
Self(info)
Self(&info.0)
}
/// Returns he object in the prototype chain of the receiver that has the
/// interceptor. Suppose you have `x` and its prototype is `y`, and `y` has an
/// interceptor. Then `info.this()` is `x` and `info.holder()` is `y`. The
/// `holder()` could be a hidden object (the global object, rather than the
/// global proxy).
///
/// For security reasons, do not pass the object back into the runtime.
/// Returns the object in the prototype chain of the receiver that has the
/// interceptor. Suppose you have `x` and its prototype is `y`, and `y`
/// has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`.
/// In case the property is installed on the global object the Holder()
/// would return the global proxy.
#[inline(always)]
pub fn holder(&self) -> Local<'s, Object> {
self.0.holder()
unsafe {
Local::from_raw(v8__PropertyCallbackInfo__Holder(self.0))
.unwrap_unchecked()
}
}
/// Returns the receiver. In many cases, this is the object on which the
@ -511,7 +483,9 @@ impl<'s> PropertyCallbackArguments<'s> {
/// ```
#[inline(always)]
pub fn this(&self) -> Local<'s, Object> {
self.0.this()
unsafe {
Local::from_raw(v8__PropertyCallbackInfo__This(self.0)).unwrap_unchecked()
}
}
/// Returns the data set in the configuration, i.e., in
@ -519,7 +493,9 @@ impl<'s> PropertyCallbackArguments<'s> {
/// `IndexedPropertyHandlerConfiguration.`
#[inline(always)]
pub fn data(&self) -> Local<'s, Value> {
self.0.data()
unsafe {
Local::from_raw(v8__PropertyCallbackInfo__Data(self.0)).unwrap_unchecked()
}
}
/// Returns `true` if the intercepted function should throw if an error
@ -529,7 +505,7 @@ impl<'s> PropertyCallbackArguments<'s> {
/// language mode.
#[inline(always)]
pub fn should_throw_on_error(&self) -> bool {
self.0.should_throw_on_error()
unsafe { v8__PropertyCallbackInfo__ShouldThrowOnError(self.0) }
}
}
@ -538,7 +514,11 @@ pub type FunctionCallback = extern "C" fn(*const FunctionCallbackInfo);
impl<F> MapFnFrom<F> for FunctionCallback
where
F: UnitType
+ for<'s> Fn(&mut HandleScope<'s>, FunctionCallbackArguments<'s>, ReturnValue),
+ for<'s> Fn(
&mut HandleScope<'s>,
FunctionCallbackArguments<'s>,
ReturnValue<Value>,
),
{
fn mapping() -> Self {
let f = |info: *const FunctionCallbackInfo| {
@ -553,7 +533,7 @@ where
}
pub(crate) type NamedGetterCallbackForAccessor<'s> =
extern "C" fn(Local<'s, Name>, *const PropertyCallbackInfo);
extern "C" fn(Local<'s, Name>, *const PropertyCallbackInfo<Value>);
impl<F> MapFnFrom<F> for NamedGetterCallbackForAccessor<'_>
where
@ -562,11 +542,11 @@ where
&mut HandleScope<'s>,
Local<'s, Name>,
PropertyCallbackArguments<'s>,
ReturnValue,
ReturnValue<Value>,
),
{
fn mapping() -> Self {
let f = |key: Local<Name>, info: *const PropertyCallbackInfo| {
let f = |key: Local<Name>, info: *const PropertyCallbackInfo<Value>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
@ -577,8 +557,10 @@ where
}
}
pub(crate) type NamedGetterCallback<'s> =
extern "C" fn(Local<'s, Name>, *const PropertyCallbackInfo) -> Intercepted;
pub(crate) type NamedGetterCallback<'s> = extern "C" fn(
Local<'s, Name>,
*const PropertyCallbackInfo<Value>,
) -> Intercepted;
impl<F> MapFnFrom<F> for NamedGetterCallback<'_>
where
@ -587,11 +569,11 @@ where
&mut HandleScope<'s>,
Local<'s, Name>,
PropertyCallbackArguments<'s>,
ReturnValue,
ReturnValue<Value>,
) -> Intercepted,
{
fn mapping() -> Self {
let f = |key: Local<Name>, info: *const PropertyCallbackInfo| {
let f = |key: Local<Name>, info: *const PropertyCallbackInfo<Value>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
@ -602,8 +584,11 @@ where
}
}
pub(crate) type NamedSetterCallbackForAccessor<'s> =
extern "C" fn(Local<'s, Name>, Local<'s, Value>, *const PropertyCallbackInfo);
pub(crate) type NamedSetterCallbackForAccessor<'s> = extern "C" fn(
Local<'s, Name>,
Local<'s, Value>,
*const PropertyCallbackInfo<()>,
);
impl<F> MapFnFrom<F> for NamedSetterCallbackForAccessor<'_>
where
@ -613,13 +598,13 @@ where
Local<'s, Name>,
Local<'s, Value>,
PropertyCallbackArguments<'s>,
ReturnValue,
ReturnValue<()>,
),
{
fn mapping() -> Self {
let f = |key: Local<Name>,
value: Local<Value>,
info: *const PropertyCallbackInfo| {
info: *const PropertyCallbackInfo<()>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
@ -633,7 +618,7 @@ where
pub(crate) type NamedSetterCallback<'s> = extern "C" fn(
Local<'s, Name>,
Local<'s, Value>,
*const PropertyCallbackInfo,
*const PropertyCallbackInfo<()>,
) -> Intercepted;
impl<F> MapFnFrom<F> for NamedSetterCallback<'_>
@ -644,13 +629,13 @@ where
Local<'s, Name>,
Local<'s, Value>,
PropertyCallbackArguments<'s>,
ReturnValue,
ReturnValue<()>,
) -> Intercepted,
{
fn mapping() -> Self {
let f = |key: Local<Name>,
value: Local<Value>,
info: *const PropertyCallbackInfo| {
info: *const PropertyCallbackInfo<()>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
@ -663,15 +648,19 @@ where
// Should return an Array in Return Value
pub(crate) type PropertyEnumeratorCallback<'s> =
extern "C" fn(*const PropertyCallbackInfo);
extern "C" fn(*const PropertyCallbackInfo<Array>);
impl<F> MapFnFrom<F> for PropertyEnumeratorCallback<'_>
where
F: UnitType
+ for<'s> Fn(&mut HandleScope<'s>, PropertyCallbackArguments<'s>, ReturnValue),
+ for<'s> Fn(
&mut HandleScope<'s>,
PropertyCallbackArguments<'s>,
ReturnValue<Array>,
),
{
fn mapping() -> Self {
let f = |info: *const PropertyCallbackInfo| {
let f = |info: *const PropertyCallbackInfo<Array>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
@ -685,7 +674,7 @@ where
pub(crate) type NamedDefinerCallback<'s> = extern "C" fn(
Local<'s, Name>,
*const PropertyDescriptor,
*const PropertyCallbackInfo,
*const PropertyCallbackInfo<()>,
) -> Intercepted;
impl<F> MapFnFrom<F> for NamedDefinerCallback<'_>
@ -696,13 +685,13 @@ where
Local<'s, Name>,
&PropertyDescriptor,
PropertyCallbackArguments<'s>,
ReturnValue,
ReturnValue<()>,
) -> Intercepted,
{
fn mapping() -> Self {
let f = |key: Local<Name>,
desc: *const PropertyDescriptor,
info: *const PropertyCallbackInfo| {
info: *const PropertyCallbackInfo<()>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
@ -714,8 +703,35 @@ where
}
}
pub(crate) type NamedDeleterCallback<'s> = extern "C" fn(
Local<'s, Name>,
*const PropertyCallbackInfo<Boolean>,
) -> Intercepted;
impl<F> MapFnFrom<F> for NamedDeleterCallback<'_>
where
F: UnitType
+ for<'s> Fn(
&mut HandleScope<'s>,
Local<'s, Name>,
PropertyCallbackArguments<'s>,
ReturnValue<Boolean>,
) -> Intercepted,
{
fn mapping() -> Self {
let f = |key: Local<Name>, info: *const PropertyCallbackInfo<Boolean>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
let rv = ReturnValue::from_property_callback_info(info);
(F::get())(scope, key, args, rv)
};
f.to_c_fn()
}
}
pub(crate) type IndexedGetterCallback<'s> =
extern "C" fn(u32, *const PropertyCallbackInfo) -> Intercepted;
extern "C" fn(u32, *const PropertyCallbackInfo<Value>) -> Intercepted;
impl<F> MapFnFrom<F> for IndexedGetterCallback<'_>
where
@ -724,11 +740,11 @@ where
&mut HandleScope<'s>,
u32,
PropertyCallbackArguments<'s>,
ReturnValue,
ReturnValue<Value>,
) -> Intercepted,
{
fn mapping() -> Self {
let f = |index: u32, info: *const PropertyCallbackInfo| {
let f = |index: u32, info: *const PropertyCallbackInfo<Value>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
@ -742,7 +758,7 @@ where
pub(crate) type IndexedSetterCallback<'s> = extern "C" fn(
u32,
Local<'s, Value>,
*const PropertyCallbackInfo,
*const PropertyCallbackInfo<()>,
) -> Intercepted;
impl<F> MapFnFrom<F> for IndexedSetterCallback<'_>
@ -753,18 +769,19 @@ where
u32,
Local<'s, Value>,
PropertyCallbackArguments<'s>,
ReturnValue,
ReturnValue<()>,
) -> Intercepted,
{
fn mapping() -> Self {
let f =
|index: u32, value: Local<Value>, info: *const PropertyCallbackInfo| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
let rv = ReturnValue::from_property_callback_info(info);
(F::get())(scope, index, value, args, rv)
};
let f = |index: u32,
value: Local<Value>,
info: *const PropertyCallbackInfo<()>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
let rv = ReturnValue::from_property_callback_info(info);
(F::get())(scope, index, value, args, rv)
};
f.to_c_fn()
}
}
@ -772,7 +789,7 @@ where
pub(crate) type IndexedDefinerCallback<'s> = extern "C" fn(
u32,
*const PropertyDescriptor,
*const PropertyCallbackInfo,
*const PropertyCallbackInfo<()>,
) -> Intercepted;
impl<F> MapFnFrom<F> for IndexedDefinerCallback<'_>
@ -783,13 +800,13 @@ where
u32,
&PropertyDescriptor,
PropertyCallbackArguments<'s>,
ReturnValue,
ReturnValue<()>,
) -> Intercepted,
{
fn mapping() -> Self {
let f = |index: u32,
desc: *const PropertyDescriptor,
info: *const PropertyCallbackInfo| {
info: *const PropertyCallbackInfo<()>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
@ -801,6 +818,31 @@ where
}
}
pub(crate) type IndexedDeleterCallback<'s> =
extern "C" fn(u32, *const PropertyCallbackInfo<Boolean>) -> Intercepted;
impl<F> MapFnFrom<F> for IndexedDeleterCallback<'_>
where
F: UnitType
+ for<'s> Fn(
&mut HandleScope<'s>,
u32,
PropertyCallbackArguments<'s>,
ReturnValue<Boolean>,
) -> Intercepted,
{
fn mapping() -> Self {
let f = |index: u32, info: *const PropertyCallbackInfo<Boolean>| {
let info = unsafe { &*info };
let scope = &mut unsafe { CallbackScope::new(info) };
let args = PropertyCallbackArguments::from_property_callback_info(info);
let rv = ReturnValue::from_property_callback_info(info);
(F::get())(scope, index, args, rv)
};
f.to_c_fn()
}
}
/// A builder to construct the properties of a Function or FunctionTemplate.
pub struct FunctionBuilder<'s, T> {
pub(crate) callback: FunctionCallback,

View file

@ -159,10 +159,10 @@ impl<'s, T> Local<'s, T> {
///
/// # Examples
///
/// ```
/// ```ignore
/// let value: Local<'_, Value> = get_v8_value();
///
/// if let Ok(func) = value.try_cast::<Function<() {
/// if let Ok(func) = value.try_cast::<Function> {
/// //
/// }
/// ```
@ -181,7 +181,7 @@ impl<'s, T> Local<'s, T> {
///
/// # Example
///
/// ```
/// ```ignore
/// let value: Local<'_, Value> = get_v8_value();
///
/// let func = value.cast::<Function>();

View file

@ -1167,7 +1167,7 @@ mod param {
type NewScope = CallbackScope<'s>;
}
impl<'s> NewCallbackScope<'s> for &'s PropertyCallbackInfo {
impl<'s, T> NewCallbackScope<'s> for &'s PropertyCallbackInfo<T> {
type NewScope = CallbackScope<'s>;
}
@ -1222,7 +1222,7 @@ mod getter {
}
}
impl<'s> GetIsolate<'s> for &'s PropertyCallbackInfo {
impl<'s, T> GetIsolate<'s> for &'s PropertyCallbackInfo<T> {
unsafe fn get_isolate_mut(self) -> &'s mut Isolate {
&mut *self.get_isolate_ptr()
}

View file

@ -16,10 +16,12 @@ use crate::FunctionBuilder;
use crate::FunctionCallback;
use crate::HandleScope;
use crate::IndexedDefinerCallback;
use crate::IndexedDeleterCallback;
use crate::IndexedGetterCallback;
use crate::IndexedSetterCallback;
use crate::Local;
use crate::NamedDefinerCallback;
use crate::NamedDeleterCallback;
use crate::NamedGetterCallback;
use crate::NamedGetterCallbackForAccessor;
use crate::NamedSetterCallback;
@ -210,7 +212,7 @@ pub type NamedPropertyQueryCallback<'s> = NamedGetterCallback<'s>;
/// in strict mode.
///
/// See also [ObjectTemplate::set_named_property_handler].
pub type NamedPropertyDeleterCallback<'s> = NamedGetterCallback<'s>;
pub type NamedPropertyDeleterCallback<'s> = NamedDeleterCallback<'s>;
/// Returns an array containing the names of the properties the named property getter intercepts.
///
@ -254,7 +256,7 @@ pub type IndexedPropertySetterCallback<'s> = IndexedSetterCallback<'s>;
pub type IndexedPropertyQueryCallback<'s> = IndexedGetterCallback<'s>;
/// See [GenericNamedPropertyDeleterCallback].
pub type IndexedPropertyDeleterCallback<'s> = IndexedGetterCallback<'s>;
pub type IndexedPropertyDeleterCallback<'s> = IndexedDeleterCallback<'s>;
/// See [GenericNamedPropertyEnumeratorCallback].
pub type IndexedPropertyEnumeratorCallback<'s> = PropertyEnumeratorCallback<'s>;

View file

@ -611,7 +611,7 @@ fn microtasks() {
scope,
|_: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
_: v8::ReturnValue| {
_: v8::ReturnValue<v8::Value>| {
CALL_COUNT.fetch_add(1, Ordering::SeqCst);
},
)
@ -1577,7 +1577,7 @@ fn create_message_argument_lifetimes() {
scope,
|scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let message = v8::Exception::create_message(scope, args.get(0));
let message_str = message.get(scope);
rv.set(message_str.into())
@ -1921,7 +1921,7 @@ fn instance_template_with_internal_field() {
pub fn constructor_callback(
scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut retval: v8::ReturnValue,
mut retval: v8::ReturnValue<v8::Value>,
) {
let this = args.this();
@ -1963,7 +1963,7 @@ fn object_template_set_accessor() {
let getter = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -1985,7 +1985,7 @@ fn object_template_set_accessor() {
key: v8::Local<v8::Name>,
value: v8::Local<v8::Value>,
args: v8::PropertyCallbackArguments,
_rv: v8::ReturnValue| {
_rv: v8::ReturnValue<()>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -2003,7 +2003,7 @@ fn object_template_set_accessor() {
|scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -2022,24 +2022,25 @@ fn object_template_set_accessor() {
rv.set(internal_field);
};
let setter_with_data = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
value: v8::Local<v8::Value>,
args: v8::PropertyCallbackArguments,
_rv: v8::ReturnValue| {
let this = args.this();
let setter_with_data =
|scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
value: v8::Local<v8::Value>,
args: v8::PropertyCallbackArguments,
_rv: v8::ReturnValue<()>| {
let this = args.this();
assert_eq!(args.holder(), this);
assert!(args.data().is_string());
assert!(!args.should_throw_on_error());
assert_eq!(args.data().to_rust_string_lossy(scope), "data");
assert_eq!(args.holder(), this);
assert!(args.data().is_string());
assert!(!args.should_throw_on_error());
assert_eq!(args.data().to_rust_string_lossy(scope), "data");
let expected_key = v8::String::new(scope, "key").unwrap();
assert!(key.strict_equals(expected_key.into()));
let expected_key = v8::String::new(scope, "key").unwrap();
assert!(key.strict_equals(expected_key.into()));
assert!(value.is_int32());
assert!(this.set_internal_field(0, value.into()));
};
assert!(value.is_int32());
assert!(this.set_internal_field(0, value.into()));
};
let key = v8::String::new(scope, "key").unwrap();
let name = v8::String::new(scope, "obj").unwrap();
@ -2117,7 +2118,7 @@ fn object_template_set_accessor() {
fn property_setter(
scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
_: v8::ReturnValue,
_: v8::ReturnValue<v8::Value>,
) {
let this = args.this();
@ -2178,7 +2179,7 @@ fn object_template_set_named_property_handler() {
let getter = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let fallthrough_key = v8::String::new(scope, "fallthrough").unwrap();
if key.strict_equals(fallthrough_key.into()) {
return v8::Intercepted::No;
@ -2206,7 +2207,7 @@ fn object_template_set_named_property_handler() {
key: v8::Local<v8::Name>,
value: v8::Local<v8::Value>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<()>| {
let fallthrough_key = v8::String::new(scope, "fallthrough").unwrap();
if key.strict_equals(fallthrough_key.into()) {
return v8::Intercepted::No;
@ -2229,14 +2230,14 @@ fn object_template_set_named_property_handler() {
assert!(value.is_int32());
assert!(this.set_internal_field(0, value.into()));
rv.set_undefined();
rv.set_bool(true);
v8::Intercepted::Yes
};
let query = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let fallthrough_key = v8::String::new(scope, "fallthrough").unwrap();
if key.strict_equals(fallthrough_key.into()) {
return v8::Intercepted::No;
@ -2270,7 +2271,7 @@ fn object_template_set_named_property_handler() {
let deleter = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Boolean>| {
let fallthrough_key = v8::String::new(scope, "fallthrough").unwrap();
if key.strict_equals(fallthrough_key.into()) {
return v8::Intercepted::No;
@ -2289,7 +2290,7 @@ fn object_template_set_named_property_handler() {
let enumerator = |scope: &mut v8::HandleScope,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Array>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -2308,14 +2309,14 @@ fn object_template_set_named_property_handler() {
let key: v8::Local<v8::Name> =
v8::String::new(scope, "key").unwrap().into();
let result = v8::Array::new_with_elements(scope, &[key.into()]);
rv.set(result.into());
rv.set(result);
};
let definer = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
desc: &v8::PropertyDescriptor,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<()>| {
let fallthrough_key = v8::String::new(scope, "fallthrough").unwrap();
if key.strict_equals(fallthrough_key.into()) {
return v8::Intercepted::No;
@ -2342,14 +2343,14 @@ fn object_template_set_named_property_handler() {
assert!(value.is_int32());
assert!(this.set_internal_field(0, value.into()));
rv.set_undefined();
rv.set_bool(true);
v8::Intercepted::Yes
};
let descriptor = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let fallthrough_key = v8::String::new(scope, "fallthrough").unwrap();
if key.strict_equals(fallthrough_key.into()) {
return v8::Intercepted::No;
@ -2648,7 +2649,7 @@ fn object_template_set_indexed_property_handler() {
let getter = |scope: &mut v8::HandleScope,
index: u32,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -2670,7 +2671,7 @@ fn object_template_set_indexed_property_handler() {
index: u32,
value: v8::Local<v8::Value>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<()>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -2682,14 +2683,14 @@ fn object_template_set_indexed_property_handler() {
assert!(value.is_int32());
assert!(this.set_internal_field(0, value.into()));
rv.set_undefined();
rv.set_bool(true);
v8::Intercepted::Yes
};
let query = |_scope: &mut v8::HandleScope,
index: u32,
_args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
if index == 12 {
return v8::Intercepted::No;
}
@ -2704,7 +2705,7 @@ fn object_template_set_indexed_property_handler() {
let deleter = |_scope: &mut v8::HandleScope,
index: u32,
_args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Boolean>| {
assert_eq!(index, 37);
rv.set_bool(false);
@ -2713,7 +2714,7 @@ fn object_template_set_indexed_property_handler() {
let enumerator = |scope: &mut v8::HandleScope,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Array>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -2731,14 +2732,14 @@ fn object_template_set_indexed_property_handler() {
let key = v8::Integer::new(scope, 37);
let result = v8::Array::new_with_elements(scope, &[key.into()]);
rv.set(result.into());
rv.set(result);
};
let definer = |_scope: &mut v8::HandleScope,
index: u32,
desc: &v8::PropertyDescriptor,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<()>| {
let this = args.this();
assert_eq!(index, 37);
@ -2753,14 +2754,14 @@ fn object_template_set_indexed_property_handler() {
let value = desc.value();
this.set_internal_field(0, value.into());
rv.set_undefined();
rv.set_bool(true);
v8::Intercepted::Yes
};
let descriptor = |scope: &mut v8::HandleScope,
index: u32,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let this = args.this();
assert_eq!(index, 37);
@ -3182,7 +3183,7 @@ fn object_set_accessor() {
let getter = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -3240,7 +3241,7 @@ fn object_set_accessor_with_setter() {
let getter = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -3266,7 +3267,7 @@ fn object_set_accessor_with_setter() {
key: v8::Local<v8::Name>,
value: v8::Local<v8::Value>,
args: v8::PropertyCallbackArguments,
_rv: v8::ReturnValue| {
_rv: v8::ReturnValue<()>| {
println!("setter called");
let this = args.this();
@ -3342,7 +3343,7 @@ fn object_set_accessor_with_setter_with_property() {
let getter = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -3368,7 +3369,7 @@ fn object_set_accessor_with_setter_with_property() {
key: v8::Local<v8::Name>,
value: v8::Local<v8::Value>,
args: v8::PropertyCallbackArguments,
_rv: v8::ReturnValue| {
_rv: v8::ReturnValue<()>| {
println!("setter called");
let this = args.this();
@ -3445,7 +3446,7 @@ fn object_set_accessor_with_data() {
let getter = |scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let this = args.this();
assert_eq!(args.holder(), this);
@ -3474,7 +3475,7 @@ fn object_set_accessor_with_data() {
key: v8::Local<v8::Name>,
value: v8::Local<v8::Value>,
args: v8::PropertyCallbackArguments,
_rv: v8::ReturnValue| {
_rv: v8::ReturnValue<()>| {
println!("setter called");
let this = args.this();
@ -3622,7 +3623,7 @@ fn proxy() {
fn fn_callback_external(
scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
assert_eq!(args.length(), 0);
let data = args.data();
@ -3638,7 +3639,7 @@ fn fn_callback_external(
fn fn_callback(
scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
assert_eq!(args.length(), 0);
let s = v8::String::new(scope, "Hello callback!").unwrap();
@ -3649,7 +3650,7 @@ fn fn_callback(
fn fn_callback_new(
scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
assert_eq!(args.length(), 0);
assert!(args.new_target().is_object());
@ -3664,7 +3665,7 @@ fn fn_callback_new(
fn fn_callback2(
scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
assert_eq!(args.length(), 2);
let arg1_val = v8::String::new(scope, "arg1").unwrap();
@ -3685,7 +3686,7 @@ fn fn_callback2(
fn fortytwo_callback(
_: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
rv.set_int32(42);
}
@ -3693,7 +3694,7 @@ fn fortytwo_callback(
fn data_is_true_callback(
_scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
_rv: v8::ReturnValue,
_rv: v8::ReturnValue<v8::Value>,
) {
let data = args.data();
assert!(data.is_true());
@ -3702,13 +3703,13 @@ fn data_is_true_callback(
fn nested_builder<'a>(
scope: &mut v8::HandleScope<'a>,
args: v8::FunctionCallbackArguments<'a>,
_: v8::ReturnValue,
_: v8::ReturnValue<v8::Value>,
) {
let arg0 = args.get(0);
v8::Function::builder(
|_: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
_: v8::ReturnValue| {},
_: v8::ReturnValue<v8::Value>| {},
)
.data(arg0)
.build(scope);
@ -3766,7 +3767,7 @@ fn return_value() {
scope,
|scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
assert_eq!(args.length(), 0);
assert!(rv.get(scope).is_undefined());
rv.set_bool(false);
@ -3789,7 +3790,7 @@ fn return_value() {
scope,
|scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
assert_eq!(args.length(), 0);
assert!(rv.get(scope).is_undefined());
rv.set_int32(69);
@ -3812,7 +3813,7 @@ fn return_value() {
scope,
|scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
assert_eq!(args.length(), 0);
assert!(rv.get(scope).is_undefined());
rv.set_uint32(69);
@ -3835,7 +3836,7 @@ fn return_value() {
scope,
|scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
assert_eq!(args.length(), 0);
assert!(rv.get(scope).is_undefined());
rv.set_null();
@ -3857,7 +3858,7 @@ fn return_value() {
scope,
|scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
assert_eq!(args.length(), 0);
assert!(rv.get(scope).is_undefined());
rv.set_undefined();
@ -3879,7 +3880,7 @@ fn return_value() {
scope,
|scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
assert_eq!(args.length(), 0);
assert!(rv.get(scope).is_undefined());
rv.set_double(69.420);
@ -3902,7 +3903,7 @@ fn return_value() {
scope,
|scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
assert_eq!(args.length(), 0);
assert!(rv.get(scope).is_undefined());
rv.set_empty_string();
@ -4560,7 +4561,7 @@ fn security_token() {
|scope: &mut v8::HandleScope,
key: v8::Local<v8::Name>,
args: v8::PropertyCallbackArguments,
mut rv: v8::ReturnValue| {
mut rv: v8::ReturnValue<v8::Value>| {
let obj = v8::Local::<v8::Object>::try_from(args.data()).unwrap();
if let Some(val) = obj.get(scope, key.into()) {
rv.set(val);
@ -4614,7 +4615,7 @@ fn context_with_object_template() {
_key: v8::Local<'s, v8::Name>,
_descriptor: &v8::PropertyDescriptor,
_args: v8::PropertyCallbackArguments<'s>,
_rv: v8::ReturnValue,
_rv: v8::ReturnValue<()>,
) -> v8::Intercepted {
unsafe {
CALLS.push("definer".to_string());
@ -4627,7 +4628,7 @@ fn context_with_object_template() {
_key: v8::Local<'s, v8::Name>,
_value: v8::Local<'s, v8::Value>,
_args: v8::PropertyCallbackArguments<'s>,
_rv: v8::ReturnValue,
_rv: v8::ReturnValue<()>,
) -> v8::Intercepted {
unsafe {
CALLS.push("setter".to_string());
@ -6382,7 +6383,7 @@ fn try_from_data() {
let function_callback =
|_: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
_: v8::ReturnValue| { unreachable!() };
_: v8::ReturnValue<v8::Value>| { unreachable!() };
let function_template = v8::FunctionTemplate::new(scope, function_callback);
let d: v8::Local<v8::Data> = function_template.into();
@ -9597,7 +9598,7 @@ fn function_names() {
fn callback(
scope: &mut v8::HandleScope,
_args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
rv.set(v8::Integer::new(scope, 42).into())
}
@ -9740,7 +9741,7 @@ fn current_stack_trace() {
fn call_depth(
scope: &mut v8::HandleScope,
_args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
let stack = v8::StackTrace::current_stack_trace(scope, 5).unwrap();
let count = stack.get_frame_count();
@ -9784,7 +9785,7 @@ fn current_script_name_or_source_url() {
fn analyze_script_url_in_stack(
scope: &mut v8::HandleScope,
_args: v8::FunctionCallbackArguments,
_rv: v8::ReturnValue,
_rv: v8::ReturnValue<v8::Value>,
) {
let maybe_name = v8::StackTrace::current_script_name_or_source_url(scope);
assert!(maybe_name.is_some());
@ -10405,7 +10406,7 @@ fn test_fast_calls() {
fn slow_fn(
scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
unsafe { WHO = "slow" };
let a = args.get(0).uint32_value(scope).unwrap();
@ -10463,7 +10464,7 @@ fn test_fast_calls_empty_buffer() {
fn slow_fn(
_scope: &mut v8::HandleScope,
_args: v8::FunctionCallbackArguments,
_rv: v8::ReturnValue,
_rv: v8::ReturnValue<v8::Value>,
) {
unsafe {
WHO = "slow";
@ -10524,7 +10525,7 @@ fn test_fast_calls_sequence() {
fn slow_fn(
scope: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
unsafe { WHO = "slow" };
rv.set(v8::Boolean::new(scope, false).into());
@ -10583,7 +10584,7 @@ fn test_fast_calls_arraybuffer() {
fn slow_fn(
scope: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
unsafe { WHO = "slow" };
rv.set(v8::Boolean::new(scope, false).into());
@ -10647,7 +10648,7 @@ fn test_fast_calls_typedarray() {
fn slow_fn(
scope: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
unsafe { WHO = "slow" };
rv.set(v8::Boolean::new(scope, false).into());
@ -10714,7 +10715,7 @@ fn test_fast_calls_reciever() {
fn slow_fn(
scope: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
unsafe { WHO = "slow" };
rv.set(v8::Boolean::new(scope, false).into());
@ -10803,7 +10804,7 @@ fn test_fast_calls_overload() {
fn slow_fn(
scope: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
unsafe { WHO = "slow" };
rv.set(v8::Boolean::new(scope, false).into());
@ -10877,7 +10878,7 @@ fn test_fast_calls_callback_options_fallback() {
fn slow_fn(
scope: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
unsafe { WHO = "slow" };
rv.set(v8::Boolean::new(scope, false).into());
@ -10945,7 +10946,7 @@ fn test_fast_calls_callback_options_data() {
fn slow_fn(
scope: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
rv.set(v8::Boolean::new(scope, false).into());
}
@ -11052,7 +11053,7 @@ fn test_fast_calls_onebytestring() {
fn slow_fn(
_: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
_: v8::ReturnValue,
_: v8::ReturnValue<v8::Value>,
) {
unsafe { WHO = "slow" };
}
@ -11118,7 +11119,7 @@ fn test_fast_calls_i64representation() {
fn slow_fn(
_: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
_: v8::ReturnValue,
_: v8::ReturnValue<v8::Value>,
) {
unsafe { SLOW_CALL_COUNT += 1 };
}
@ -11287,7 +11288,7 @@ fn test_fast_calls_pointer() {
fn slow_fn(
scope: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
unsafe { WHO = "slow" };
rv.set(
@ -11432,7 +11433,7 @@ fn bubbling_up_exception() {
fn boom_fn(
scope: &mut v8::HandleScope,
_args: v8::FunctionCallbackArguments,
_retval: v8::ReturnValue,
_retval: v8::ReturnValue<v8::Value>,
) {
let msg = v8::String::new(scope, "boom").unwrap();
let exception = v8::Exception::type_error(scope, msg);
@ -11476,7 +11477,7 @@ fn bubbling_up_exception_in_function_call() {
fn boom_fn(
scope: &mut v8::HandleScope,
_args: v8::FunctionCallbackArguments,
_retval: v8::ReturnValue,
_retval: v8::ReturnValue<v8::Value>,
) {
let msg = v8::String::new(scope, "boom").unwrap();
let exception = v8::Exception::type_error(scope, msg);
@ -11548,7 +11549,7 @@ fn exception_thrown_but_continues_execution() {
fn print_fn(
scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
_retval: v8::ReturnValue,
_retval: v8::ReturnValue<v8::Value>,
) {
let local_arg = args.get(0);
CALL_COUNT.fetch_add(1, Ordering::SeqCst);
@ -11730,7 +11731,7 @@ fn microtask_queue() {
&mut scope,
|_: &mut v8::HandleScope,
_: v8::FunctionCallbackArguments,
_: v8::ReturnValue| {
_: v8::ReturnValue<v8::Value>| {
CALL_COUNT.fetch_add(1, Ordering::SeqCst);
},
)

View file

@ -55,12 +55,12 @@ fn cppgc_object_wrap() {
fn op_wrap(
scope: &mut v8::HandleScope,
args: v8::FunctionCallbackArguments,
mut rv: v8::ReturnValue,
mut rv: v8::ReturnValue<v8::Value>,
) {
fn empty(
_scope: &mut v8::HandleScope,
_args: v8::FunctionCallbackArguments,
_rv: v8::ReturnValue,
_rv: v8::ReturnValue<v8::Value>,
) {
}
let templ = v8::FunctionTemplate::new(scope, empty);

2
v8

@ -1 +1 @@
Subproject commit d1de2254854da6dd4ee35f376394c79209dd799e
Subproject commit 87231425200177829e5486aff2ed4b0bc49b56b4