v8  10.1.124 (node 18.2.0)
V8 is Google's open source JavaScript engine
PropertyCallbackInfo< T > Class Template Reference

#include <v8-function-callback.h>

Public Member Functions

V8_INLINE IsolateGetIsolate () const
 
V8_INLINE Local< ValueData () const
 
V8_INLINE Local< ObjectThis () const
 
V8_INLINE Local< ObjectHolder () const
 
V8_INLINE ReturnValue< T > GetReturnValue () const
 
V8_INLINE bool ShouldThrowOnError () const
 

Static Public Attributes

static const int kArgsLength = 7
 

Protected Member Functions

V8_INLINE PropertyCallbackInfo (internal::Address *args)
 

Protected Attributes

internal::Addressargs_
 

Static Protected Attributes

static const int kShouldThrowOnErrorIndex = 0
 
static const int kHolderIndex = 1
 
static const int kIsolateIndex = 2
 
static const int kReturnValueDefaultValueIndex = 3
 
static const int kReturnValueIndex = 4
 
static const int kDataIndex = 5
 
static const int kThisIndex = 6
 

Friends

class MacroAssembler
 
class internal::PropertyCallbackArguments
 
class internal::CustomArguments< PropertyCallbackInfo >
 

Detailed Description

template<typename T>
class v8::PropertyCallbackInfo< T >

The information passed to a property callback about the context of the property access.

Definition at line 145 of file v8-function-callback.h.

Constructor & Destructor Documentation

◆ PropertyCallbackInfo()

V8_INLINE PropertyCallbackInfo ( internal::Address args)
inlineprotected

Definition at line 247 of file v8-function-callback.h.

References PropertyCallbackInfo< T >::args_.

Member Function Documentation

◆ Data()

◆ GetIsolate()

Isolate * GetIsolate
Returns
The isolate of the property access.

Definition at line 438 of file v8-function-callback.h.

References PropertyCallbackInfo< T >::args_, and PropertyCallbackInfo< T >::kIsolateIndex.

Referenced by PropertyCallbackInfo< T >::ShouldThrowOnError().

◆ GetReturnValue()

ReturnValue< T > GetReturnValue
Returns
The return value of the callback. Can be changed by calling Set().
info.GetReturnValue().Set(...)

Definition at line 458 of file v8-function-callback.h.

References PropertyCallbackInfo< T >::args_, and PropertyCallbackInfo< T >::kReturnValueIndex.

◆ Holder()

Local< Object > Holder
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. The Holder() could be a hidden object (the global object, rather than the global proxy).
Note
For security reasons, do not pass the object back into the runtime.

Definition at line 453 of file v8-function-callback.h.

References PropertyCallbackInfo< T >::args_, PropertyCallbackInfo< T >::kHolderIndex, and HandleScope::Local.

◆ ShouldThrowOnError()

bool ShouldThrowOnError
Returns
True if the intercepted function should throw if an error occurs. Usually, true corresponds to ‘'use strict’`.
Note
Always false when intercepting Reflect.set() independent of the language mode.

Definition at line 463 of file v8-function-callback.h.

References PropertyCallbackInfo< T >::args_, PropertyCallbackInfo< T >::GetIsolate(), Internals::IntToSmi(), Internals::kDontThrow, Internals::kInferShouldThrowMode, PropertyCallbackInfo< T >::kShouldThrowOnErrorIndex, and v8::internal::ShouldThrowOnError().

◆ This()

Local< Object > This
Returns
The receiver. In many cases, this is the object on which the property access was intercepted. When using Reflect.get, Function.prototype.call, or similar functions, it is the object passed in as receiver or thisArg.
void GetterCallback(Local<Name> name,
auto context = info.GetIsolate()->GetCurrentContext();
info.This()
->GetRealNamedProperty(context, v8_str("a"))
.ToLocalChecked();
info.Holder()
->GetRealNamedProperty(context, v8_str("a"))
.ToLocalChecked();
CHECK(v8_str("r")->Equals(context, a_this).FromJust());
CHECK(v8_str("obj")->Equals(context, a_holder).FromJust());
info.GetReturnValue().Set(name);
}
templ->InstanceTemplate()->SetHandler(
LocalContext env;
env->Global()
->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
.ToLocalChecked()
->NewInstance(env.local())
.ToLocalChecked())
.FromJust();
CompileRun("obj.a = 'obj'; var r = {a: 'r'}; Reflect.get(obj, 'x', r)");
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=nullptr, Local< Value > data=Local< Value >(), Local< Signature > signature=Local< Signature >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow, SideEffectType side_effect_type=SideEffectType::kHasSideEffect, const CFunction *c_function=nullptr, uint16_t instance_type=0, uint16_t allowed_receiver_instance_type_range_start=0, uint16_t allowed_receiver_instance_type_range_end=0)
Local< Context > GetCurrentContext()
V8_INLINE ReturnValue< T > GetReturnValue() const
V8_INLINE Local< Object > This() const
V8_INLINE Local< Object > Holder() const
V8_INLINE Isolate * GetIsolate() const

Definition at line 448 of file v8-function-callback.h.

References PropertyCallbackInfo< T >::args_, PropertyCallbackInfo< T >::kThisIndex, and HandleScope::Local.

Friends And Related Function Documentation

◆ internal::CustomArguments< PropertyCallbackInfo >

Definition at line 237 of file v8-function-callback.h.

◆ internal::PropertyCallbackArguments

friend class internal::PropertyCallbackArguments
friend

Definition at line 237 of file v8-function-callback.h.

◆ MacroAssembler

friend class MacroAssembler
friend

Definition at line 236 of file v8-function-callback.h.

Field Documentation

◆ args_

◆ kArgsLength

const int kArgsLength = 7
static

Definition at line 233 of file v8-function-callback.h.

◆ kDataIndex

const int kDataIndex = 5
staticprotected

Definition at line 244 of file v8-function-callback.h.

Referenced by PropertyCallbackInfo< T >::Data().

◆ kHolderIndex

const int kHolderIndex = 1
staticprotected

Definition at line 240 of file v8-function-callback.h.

Referenced by PropertyCallbackInfo< T >::Holder().

◆ kIsolateIndex

const int kIsolateIndex = 2
staticprotected

Definition at line 241 of file v8-function-callback.h.

Referenced by PropertyCallbackInfo< T >::GetIsolate().

◆ kReturnValueDefaultValueIndex

const int kReturnValueDefaultValueIndex = 3
staticprotected

Definition at line 242 of file v8-function-callback.h.

◆ kReturnValueIndex

const int kReturnValueIndex = 4
staticprotected

Definition at line 243 of file v8-function-callback.h.

Referenced by PropertyCallbackInfo< T >::GetReturnValue().

◆ kShouldThrowOnErrorIndex

const int kShouldThrowOnErrorIndex = 0
staticprotected

◆ kThisIndex

const int kThisIndex = 6
staticprotected

Definition at line 245 of file v8-function-callback.h.

Referenced by PropertyCallbackInfo< T >::This().


The documentation for this class was generated from the following file: