v8
4.5.103 (node 4.8.7)
V8 is Google's open source JavaScript engine
|
#include <v8.h>
Static Public Member Functions | |
static Local< ObjectTemplate > | New (Isolate *isolate, Local< FunctionTemplate > constructor=Local< FunctionTemplate >()) |
static | V8_DEPRECATE_SOON ("Use isolate version", Local< ObjectTemplate > New()) |
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.
int InternalFieldCount | ( | ) |
Gets the number of internal fields for objects generated from this template.
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 | ) |
void SetAccessCheckCallbacks | ( | NamedSecurityCallback | named_handler, |
IndexedSecurityCallback | indexed_handler, | ||
Local< Value > | data = Local< Value >() |
||
) |
Sets access check callbacks 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 SetAccessor | ( | Local< Name > | name, |
AccessorNameGetterCallback | getter, | ||
AccessorNameSetterCallback | setter = 0 , |
||
Local< Value > | data = Local< Value >() , |
||
AccessControl | settings = DEFAULT , |
||
PropertyAttribute | attribute = None , |
||
Local< AccessorSignature > | signature = Local< AccessorSignature >() |
||
) |
void SetAccessor | ( | Local< String > | name, |
AccessorGetterCallback | getter, | ||
AccessorSetterCallback | setter = 0 , |
||
Local< Value > | data = Local< Value >() , |
||
AccessControl | settings = DEFAULT , |
||
PropertyAttribute | attribute = None , |
||
Local< AccessorSignature > | signature = Local< AccessorSignature >() |
||
) |
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. |
settings | Access 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. |
attribute | The attributes of the property for which an accessor is added. |
signature | The 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. |
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 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.
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. |
Referenced by ObjectTemplate::SetIndexedPropertyHandler().
void SetHandler | ( | const NamedPropertyHandlerConfiguration & | configuration | ) |
|
inline |
Definition at line 4609 of file v8.h.
References IndexedPropertyHandlerConfiguration::IndexedPropertyHandlerConfiguration(), and ObjectTemplate::SetHandler().
void SetInternalFieldCount | ( | int | value | ) |
Sets the number of internal fields for objects generated from this template.
void SetNamedPropertyHandler | ( | NamedPropertyGetterCallback | getter, |
NamedPropertySetterCallback | setter = 0 , |
||
NamedPropertyQueryCallback | query = 0 , |
||
NamedPropertyDeleterCallback | deleter = 0 , |
||
NamedPropertyEnumeratorCallback | enumerator = 0 , |
||
Local< Value > | data = Local< Value >() |
||
) |
Sets a named property handler on the object template.
Whenever a property whose name is a string is accessed on objects created from this object template, the provided callback is invoked instead of accessing the property directly on the JavaScript object.
Note that new code should use the second version that can intercept symbol-named properties as well as string-named properties.
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 a property is present, and if present, get its attributes. |
deleter | The callback to invoke when deleting a property. |
enumerator | The callback to invoke to enumerate all the named properties of an object. |
data | A piece of data that will be passed to the callbacks whenever they are invoked. |
|
static |
Creates a new instance of this template.
|
friend |