mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-26 09:13:46 -05:00
Make function signature of 'AccessorNameGetterCallback' match C++ (#214)
This commit is contained in:
parent
7862af65e0
commit
bed0088550
3 changed files with 7 additions and 11 deletions
|
@ -5,9 +5,9 @@ use crate::FunctionCallback;
|
|||
use crate::MessageCallback;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub union ExternalReference {
|
||||
pub union ExternalReference<'s> {
|
||||
pub function: FunctionCallback,
|
||||
pub getter: AccessorNameGetterCallback,
|
||||
pub getter: AccessorNameGetterCallback<'s>,
|
||||
pub message: MessageCallback,
|
||||
}
|
||||
|
||||
|
|
|
@ -246,13 +246,10 @@ where
|
|||
|
||||
/// AccessorNameGetterCallback is used as callback functions when getting a
|
||||
/// particular property. See Object and ObjectTemplate's method SetAccessor.
|
||||
// TODO(piscisaureus): The actual signature of this callback is
|
||||
// `extern "C" fn(Local<Name>, *const PropertyCallbackInfo)`. This works in
|
||||
// practice but is not strictly correct, and should be fixed.
|
||||
pub type AccessorNameGetterCallback =
|
||||
extern "C" fn(*mut Name, *const PropertyCallbackInfo);
|
||||
pub type AccessorNameGetterCallback<'s> =
|
||||
extern "C" fn(Local<'s, Name>, *const PropertyCallbackInfo);
|
||||
|
||||
impl<F> MapFnFrom<F> for AccessorNameGetterCallback
|
||||
impl<F> MapFnFrom<F> for AccessorNameGetterCallback<'_>
|
||||
where
|
||||
F: UnitType
|
||||
+ Fn(
|
||||
|
@ -263,11 +260,10 @@ where
|
|||
),
|
||||
{
|
||||
fn mapping() -> Self {
|
||||
let f = |key: *mut Name, info: *const PropertyCallbackInfo| {
|
||||
let f = |key: Local<Name>, info: *const PropertyCallbackInfo| {
|
||||
let scope: PropertyCallbackScope = unsafe {
|
||||
&mut *(info as *const _ as *mut Entered<PropertyCallbackInfo>)
|
||||
};
|
||||
let key = unsafe { scope.to_local(key) }.unwrap();
|
||||
let args = PropertyCallbackArguments::from_property_callback_info(info);
|
||||
let rv = ReturnValue::from_property_callback_info(info);
|
||||
(F::get())(scope, key, args, rv);
|
||||
|
|
|
@ -137,7 +137,7 @@ impl Object {
|
|||
&mut self,
|
||||
context: Local<Context>,
|
||||
name: Local<Name>,
|
||||
getter: impl MapFnTo<AccessorNameGetterCallback>,
|
||||
getter: impl for<'s> MapFnTo<AccessorNameGetterCallback<'s>>,
|
||||
) -> MaybeBool {
|
||||
unsafe {
|
||||
v8__Object__SetAccessor(self, &*context, &*name, getter.map_fn_to())
|
||||
|
|
Loading…
Reference in a new issue