v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
ObjectTemplate Class Reference

#include <v8-template.h>

Inheritance diagram for ObjectTemplate:
Collaboration diagram for ObjectTemplate:

Public Member Functions

V8_WARN_UNUSED_RESULT MaybeLocal< ObjectNewInstance (Local< Context > context)
 
void SetAccessor (Local< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter, Local< Value > data, AccessControl settings, PropertyAttribute attribute, Local< AccessorSignature > signature, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
 
void SetAccessor (Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter, Local< Value > data, AccessControl settings, PropertyAttribute attribute, Local< AccessorSignature > signature, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
 
void SetAccessor (Local< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
 
void SetAccessor (Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
 
void SetHandler (const NamedPropertyHandlerConfiguration &configuration)
 
void SetIndexedPropertyHandler (IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter=nullptr, IndexedPropertyQueryCallback query=nullptr, IndexedPropertyDeleterCallback deleter=nullptr, IndexedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >())
 
void SetHandler (const IndexedPropertyHandlerConfiguration &configuration)
 
void SetCallAsFunctionHandler (FunctionCallback callback, Local< Value > data=Local< Value >())
 
void MarkAsUndetectable ()
 
void SetAccessCheckCallback (AccessCheckCallback callback, Local< Value > data=Local< Value >())
 
void SetAccessCheckCallbackAndHandler (AccessCheckCallback callback, const NamedPropertyHandlerConfiguration &named_handler, const IndexedPropertyHandlerConfiguration &indexed_handler, Local< Value > data=Local< Value >())
 
int InternalFieldCount () const
 
void SetInternalFieldCount (int value)
 
bool IsImmutableProto () const
 
void SetImmutableProto ()
 
void SetCodeLike ()
 
bool IsCodeLike () const
 
- Public Member Functions inherited from Template
void Set (Local< Name > name, Local< Data > value, PropertyAttribute attributes=None)
 
void SetPrivate (Local< Private > name, Local< Data > value, PropertyAttribute attributes=None)
 
V8_INLINE void Set (Isolate *isolate, const char *name, Local< Data > value, PropertyAttribute attributes=None)
 
void SetAccessorProperty (Local< Name > name, Local< FunctionTemplate > getter=Local< FunctionTemplate >(), Local< FunctionTemplate > setter=Local< FunctionTemplate >(), PropertyAttribute attribute=None, AccessControl settings=DEFAULT)
 
void SetNativeDataProperty (Local< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter, Local< Value > data, PropertyAttribute attribute, Local< AccessorSignature > signature, AccessControl settings=DEFAULT, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
 
void SetNativeDataProperty (Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter, Local< Value > data, PropertyAttribute attribute, Local< AccessorSignature > signature, AccessControl settings=DEFAULT, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
 
void SetNativeDataProperty (Local< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attribute=None, AccessControl settings=DEFAULT, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
 
void SetNativeDataProperty (Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attribute=None, AccessControl settings=DEFAULT, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
 
void SetLazyDataProperty (Local< Name > name, AccessorNameGetterCallback getter, Local< Value > data=Local< Value >(), PropertyAttribute attribute=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
 
void SetIntrinsicDataProperty (Local< Name > name, Intrinsic intrinsic, PropertyAttribute attribute=None)
 
- Public Member Functions inherited from Data
bool IsValue () const
 
bool IsModule () const
 
bool IsFixedArray () const
 
bool IsPrivate () const
 
bool IsObjectTemplate () const
 
bool IsFunctionTemplate () const
 
bool IsContext () const
 

Static Public Member Functions

static Local< ObjectTemplateNew (Isolate *isolate, Local< FunctionTemplate > constructor=Local< FunctionTemplate >())
 
static V8_INLINE ObjectTemplateCast (Data *data)
 

Friends

class FunctionTemplate
 

Detailed Description

An ObjectTemplate is used to create objects at runtime.

Properties added to an ObjectTemplate are added to each object created from the ObjectTemplate.

Definition at line 791 of file v8-template.h.

Member Function Documentation

◆ Cast()

ObjectTemplate * Cast ( Data data)
static

Definition at line 1056 of file v8-template.h.

◆ InternalFieldCount()

int InternalFieldCount ( ) const

Gets the number of internal fields for objects generated from this template.

◆ IsCodeLike()

bool IsCodeLike ( ) const

◆ IsImmutableProto()

bool IsImmutableProto ( ) const

Returns true if the object will be an immutable prototype exotic object.

◆ MarkAsUndetectable()

void MarkAsUndetectable ( )

Mark object instances of the template as undetectable.

In many ways, undetectable objects behave as though they are not there. They behave like 'undefined' in conditionals and when printed. However, properties can be accessed and called as on normal objects.

◆ New()

static Local< ObjectTemplate > New ( Isolate isolate,
Local< FunctionTemplate constructor = LocalFunctionTemplate >() 
)
static

Creates an ObjectTemplate.

◆ NewInstance()

V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstance ( Local< Context context)

Creates a new instance of this template.

◆ SetAccessCheckCallback()

void SetAccessCheckCallback ( AccessCheckCallback  callback,
Local< Value data = LocalValue >() 
)

Sets access check callback on the object template and enables access checks.

When accessing properties on instances of this object template, the access check callback will be called to determine whether or not to allow cross-context access to the properties.

◆ SetAccessCheckCallbackAndHandler()

void SetAccessCheckCallbackAndHandler ( AccessCheckCallback  callback,
const NamedPropertyHandlerConfiguration named_handler,
const IndexedPropertyHandlerConfiguration indexed_handler,
Local< Value data = LocalValue >() 
)

Like SetAccessCheckCallback but invokes an interceptor on failed access checks instead of looking up all-can-read properties. You can only use either this method or SetAccessCheckCallback, but not both at the same time.

◆ SetAccessor() [1/4]

void SetAccessor ( Local< Name name,
AccessorNameGetterCallback  getter,
AccessorNameSetterCallback  setter,
Local< Value data,
AccessControl  settings,
PropertyAttribute  attribute,
Local< AccessorSignature signature,
SideEffectType  getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType  setter_side_effect_type = SideEffectType::kHasSideEffect 
)

◆ SetAccessor() [2/4]

void SetAccessor ( Local< Name name,
AccessorNameGetterCallback  getter,
AccessorNameSetterCallback  setter = nullptr,
Local< Value data = LocalValue >(),
AccessControl  settings = DEFAULT,
PropertyAttribute  attribute = None,
SideEffectType  getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType  setter_side_effect_type = SideEffectType::kHasSideEffect 
)

◆ SetAccessor() [3/4]

void SetAccessor ( Local< String name,
AccessorGetterCallback  getter,
AccessorSetterCallback  setter,
Local< Value data,
AccessControl  settings,
PropertyAttribute  attribute,
Local< AccessorSignature signature,
SideEffectType  getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType  setter_side_effect_type = SideEffectType::kHasSideEffect 
)

Sets an accessor on the object template.

Whenever the property with the given name is accessed on objects created from this ObjectTemplate the getter and setter callbacks are called instead of getting and setting the property directly on the JavaScript object.

Parameters
nameThe name of the property for which an accessor is added.
getterThe callback to invoke when getting the property.
setterThe callback to invoke when setting the property.
dataA piece of data that will be passed to the getter and setter callbacks whenever they are invoked.
settingsAccess control settings for the accessor. This is a bit field consisting of one of more of DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2. The default is to not allow cross-context access. ALL_CAN_READ means that all cross-context reads are allowed. ALL_CAN_WRITE means that all cross-context writes are allowed. The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all cross-context access.
attributeThe attributes of the property for which an accessor is added.
signatureThe signature describes valid receivers for the accessor and is used to perform implicit instance checks against them. If the receiver is incompatible (i.e. is not an instance of the constructor as defined by FunctionTemplate::HasInstance()), an implicit TypeError is thrown and no callback is invoked.

◆ SetAccessor() [4/4]

void SetAccessor ( Local< String name,
AccessorGetterCallback  getter,
AccessorSetterCallback  setter = nullptr,
Local< Value data = LocalValue >(),
AccessControl  settings = DEFAULT,
PropertyAttribute  attribute = None,
SideEffectType  getter_side_effect_type = SideEffectType::kHasSideEffect,
SideEffectType  setter_side_effect_type = SideEffectType::kHasSideEffect 
)

◆ SetCallAsFunctionHandler()

void SetCallAsFunctionHandler ( FunctionCallback  callback,
Local< Value data = LocalValue >() 
)

Sets the callback to be used when calling instances created from this template as a function. If no callback is set, instances behave like normal JavaScript objects that cannot be called as a function.

◆ SetCodeLike()

void SetCodeLike ( )

Support for TC39 "dynamic code brand checks" proposal.

This API allows to mark (& query) objects as "code like", which causes them to be treated like Strings in the context of eval and function constructor.

Reference: https://github.com/tc39/proposal-dynamic-code-brand-checks

◆ SetHandler() [1/2]

void SetHandler ( const IndexedPropertyHandlerConfiguration configuration)

Sets an indexed property handler on the object template.

Whenever an indexed property is accessed on objects created from this object template, the provided callback is invoked instead of accessing the property directly on the JavaScript object.

Parameters
configurationThe IndexedPropertyHandlerConfiguration that defines the callbacks to invoke when accessing a property.

◆ SetHandler() [2/2]

void SetHandler ( const NamedPropertyHandlerConfiguration configuration)

Sets a named property handler on the object template.

Whenever a property whose name is a string or a symbol is accessed on objects created from this object template, the provided callback is invoked instead of accessing the property directly on the JavaScript object.

Parameters
configurationThe NamedPropertyHandlerConfiguration that defines the callbacks to invoke when accessing a property.

◆ SetImmutableProto()

void SetImmutableProto ( )

Makes the ObjectTemplate for an immutable prototype exotic object, with an immutable proto.

◆ SetIndexedPropertyHandler()

void SetIndexedPropertyHandler ( IndexedPropertyGetterCallback  getter,
IndexedPropertySetterCallback  setter = nullptr,
IndexedPropertyQueryCallback  query = nullptr,
IndexedPropertyDeleterCallback  deleter = nullptr,
IndexedPropertyEnumeratorCallback  enumerator = nullptr,
Local< Value data = Local<Value>() 
)
inline

Sets an indexed property handler on the object template.

Whenever an indexed property is accessed on objects created from this object template, the provided callback is invoked instead of accessing the property directly on the JavaScript object.

Parameters
getterThe callback to invoke when getting a property.
setterThe callback to invoke when setting a property.
queryThe callback to invoke to check if an object has a property.
deleterThe callback to invoke when deleting a property.
enumeratorThe callback to invoke to enumerate all the indexed properties of an object.
dataA piece of data that will be passed to the callbacks whenever they are invoked.

Definition at line 890 of file v8-template.h.

◆ SetInternalFieldCount()

void SetInternalFieldCount ( int  value)

Sets the number of internal fields for objects generated from this template.

Friends And Related Symbol Documentation

◆ FunctionTemplate

friend class FunctionTemplate
friend

Definition at line 997 of file v8-template.h.


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