v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::ObjectTemplate Class Reference

#include <v8-template.h>

Inheritance diagram for v8::ObjectTemplate:
Collaboration diagram for v8::ObjectTemplate:

Public Member Functions

V8_WARN_UNUSED_RESULT MaybeLocal< ObjectNewInstance (Local< Context > context)
 
void SetHandler (const NamedPropertyHandlerConfiguration &configuration)
 
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 v8::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)
 
void SetNativeDataProperty (Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attribute=None, 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 v8::Data
bool IsValue () const
 
bool IsModule () const
 
bool IsModuleRequest () 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)
 

Private Member Functions

 ObjectTemplate ()
 

Static Private Member Functions

static void CheckCast (Data *that)
 

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 938 of file v8-template.h.

Constructor & Destructor Documentation

◆ ObjectTemplate()

v8::ObjectTemplate::ObjectTemplate ( )
private

Member Function Documentation

◆ Cast()

ObjectTemplate * v8::ObjectTemplate::Cast ( Data * data)
static

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

Here is the call graph for this function:

◆ CheckCast()

void v8::ObjectTemplate::CheckCast ( Data * that)
staticprivate

Definition at line 7386 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InternalFieldCount()

int v8::ObjectTemplate::InternalFieldCount ( ) const

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

Definition at line 1667 of file api.cc.

Here is the call graph for this function:

◆ IsCodeLike()

bool v8::ObjectTemplate::IsCodeLike ( ) const

Definition at line 1699 of file api.cc.

Here is the call graph for this function:

◆ IsImmutableProto()

bool v8::ObjectTemplate::IsImmutableProto ( ) const

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

Definition at line 1688 of file api.cc.

Here is the call graph for this function:

◆ MarkAsUndetectable()

void v8::ObjectTemplate::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.

Definition at line 1558 of file api.cc.

Here is the call graph for this function:

◆ New()

Local< ObjectTemplate > v8::ObjectTemplate::New ( Isolate * isolate,
v8::Local< FunctionTemplate > constructor = Local<FunctionTemplate>() )
static

Creates an ObjectTemplate.

Definition at line 1376 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NewInstance()

MaybeLocal< v8::Object > v8::ObjectTemplate::NewInstance ( Local< Context > context)

Creates a new instance of this template.

Parameters
contextThe context in which the instance is created.

Definition at line 7376 of file api.cc.

Here is the call graph for this function:

◆ SetAccessCheckCallback()

void v8::ObjectTemplate::SetAccessCheckCallback ( AccessCheckCallback callback,
Local< Value > data = Local<Value>() )

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.

Definition at line 1567 of file api.cc.

Here is the call graph for this function:

◆ SetAccessCheckCallbackAndHandler()

void v8::ObjectTemplate::SetAccessCheckCallbackAndHandler ( AccessCheckCallback callback,
const NamedPropertyHandlerConfiguration & named_handler,
const IndexedPropertyHandlerConfiguration & indexed_handler,
Local< Value > data = Local<Value>() )

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.

Definition at line 1593 of file api.cc.

Here is the call graph for this function:

◆ SetCallAsFunctionHandler()

void v8::ObjectTemplate::SetCallAsFunctionHandler ( FunctionCallback callback,
Local< Value > data = Local<Value>() )

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.

Definition at line 1647 of file api.cc.

Here is the call graph for this function:

◆ SetCodeLike()

void v8::ObjectTemplate::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

Definition at line 1703 of file api.cc.

Here is the call graph for this function:

◆ SetHandler() [1/2]

void v8::ObjectTemplate::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.

Definition at line 1633 of file api.cc.

Here is the call graph for this function:

◆ SetHandler() [2/2]

void v8::ObjectTemplate::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.

Definition at line 1550 of file api.cc.

◆ SetImmutableProto()

void v8::ObjectTemplate::SetImmutableProto ( )

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

Definition at line 1692 of file api.cc.

Here is the call graph for this function:

◆ SetInternalFieldCount()

void v8::ObjectTemplate::SetInternalFieldCount ( int value)

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

Definition at line 1671 of file api.cc.

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ FunctionTemplate

friend class FunctionTemplate
friend

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


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