v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
|
#include <v8-template.h>
Static Public Member Functions | |
static Local< ObjectTemplate > | New (Isolate *isolate, Local< FunctionTemplate > constructor=Local< FunctionTemplate >()) |
static V8_INLINE ObjectTemplate * | Cast (Data *data) |
Friends | |
class | FunctionTemplate |
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 1018 of file v8-template.h.
|
static |
Definition at line 1274 of file v8-template.h.
int InternalFieldCount | ( | ) | const |
Gets the number of internal fields for objects generated from this template.
bool IsCodeLike | ( | ) | const |
bool IsImmutableProto | ( | ) | const |
Returns true if the object will be an immutable prototype exotic object.
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.
|
static |
Creates an ObjectTemplate.
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstance | ( | Local< Context > | context | ) |
Creates a new instance of this template.
context | The context in which the instance is created. |
void 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.
void 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.
void SetAccessor | ( | 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 SetAccessor | ( | Local< String > | name, |
AccessorGetterCallback | getter, | ||
AccessorSetterCallback | setter = nullptr , |
||
Local< Value > | data = Local< Value >() , |
||
PropertyAttribute | attribute = None , |
||
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.
name | The name of the property for which an accessor is added. |
getter | The callback to invoke when getting the property. |
setter | The callback to invoke when setting the property. |
data | A piece of data that will be passed to the getter and setter callbacks whenever they are invoked. |
attribute | The attributes of the property for which an accessor is added. |
void 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.
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
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.
configuration | The IndexedPropertyHandlerConfiguration that defines the callbacks to invoke when accessing a property. |
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.
configuration | The NamedPropertyHandlerConfiguration that defines the callbacks to invoke when accessing a property. |
void SetImmutableProto | ( | ) |
Makes the ObjectTemplate for an immutable prototype exotic object, with an immutable proto.
|
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.
getter | The callback to invoke when getting a property. |
setter | The callback to invoke when setting a property. |
query | The callback to invoke to check if an object has a property. |
deleter | The callback to invoke when deleting a property. |
enumerator | The callback to invoke to enumerate all the indexed properties of an object. |
data | A piece of data that will be passed to the callbacks whenever they are invoked. |
Definition at line 1092 of file v8-template.h.
void SetInternalFieldCount | ( | int | value | ) |
Sets the number of internal fields for objects generated from this template.
|
friend |
Definition at line 1198 of file v8-template.h.