v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ObjectTemplate Class Reference

#include <v8.h>

Inheritance diagram for ObjectTemplate:
Collaboration diagram for ObjectTemplate:

Public Member Functions

Local< ObjectNewInstance ()
 
void SetAccessor (Handle< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter=0, Handle< Value > data=Handle< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, Handle< AccessorSignature > signature=Handle< AccessorSignature >())
 
void SetNamedPropertyHandler (NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter=0, NamedPropertyQueryCallback query=0, NamedPropertyDeleterCallback deleter=0, NamedPropertyEnumeratorCallback enumerator=0, Handle< Value > data=Handle< Value >())
 
void SetIndexedPropertyHandler (IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter=0, IndexedPropertyQueryCallback query=0, IndexedPropertyDeleterCallback deleter=0, IndexedPropertyEnumeratorCallback enumerator=0, Handle< Value > data=Handle< Value >())
 
void SetCallAsFunctionHandler (FunctionCallback callback, Handle< Value > data=Handle< Value >())
 
void MarkAsUndetectable ()
 
void SetAccessCheckCallbacks (NamedSecurityCallback named_handler, IndexedSecurityCallback indexed_handler, Handle< Value > data=Handle< Value >(), bool turned_on_by_default=true)
 
int InternalFieldCount ()
 
void SetInternalFieldCount (int value)
 
- Public Member Functions inherited from Template
void Set (Handle< String > name, Handle< Data > value, PropertyAttribute attributes=None)
 
V8_INLINE void Set (Isolate *isolate, const char *name, Handle< Data > value)
 
void SetAccessorProperty (Local< String > 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=0, Handle< Value > data=Handle< Value >(), PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), AccessControl settings=DEFAULT)
 
bool SetDeclaredAccessor (Local< String > name, Local< DeclaredAccessorDescriptor > descriptor, PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), AccessControl settings=DEFAULT)
 

Static Public Member Functions

static Local< ObjectTemplateNew (Isolate *isolate)
 
static Local< ObjectTemplateNew ()
 

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

Member Function Documentation

int InternalFieldCount ( )

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

Definition at line 1547 of file api.cc.

References Smi::cast(), v8::internal::internal_field_count, Utils::OpenHandle(), and Smi::value().

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.

Definition at line 1449 of file api.cc.

References FunctionTemplateInfo::cast(), ENTER_V8, and Utils::OpenHandle().

Local< ObjectTemplate > New ( Isolate isolate)
static

Creates an ObjectTemplate.

Definition at line 1281 of file api.cc.

References ObjectTemplate::New().

Local< v8::Object > NewInstance ( )

Creates a new instance of this template.

Definition at line 5284 of file api.cc.

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, Execution::InstantiateObject(), LOG_API, ON_BAILOUT, Utils::OpenHandle(), and Utils::ToLocal().

Referenced by TEST(), TestFastReturnValues(), and THREADED_TEST().

void SetAccessCheckCallbacks ( NamedSecurityCallback  named_handler,
IndexedSecurityCallback  indexed_handler,
Handle< Value data = Handle<Value>(),
bool  turned_on_by_default = true 
)

Sets access check callbacks on the object template.

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. The last parameter specifies whether access checks are turned on by default on instances. If access checks are off by default, they can be turned on on individual instances by calling Object::TurnOnAccessCheck().

Definition at line 1461 of file api.cc.

References v8::internal::ACCESS_CHECK_INFO_TYPE, Handle< T >::cast(), FunctionTemplateInfo::cast(), ENTER_V8, Isolate::factory(), Handle< T >::IsEmpty(), Factory::NewStruct(), Utils::OpenHandle(), SET_FIELD_WRAPPED, and v8::Undefined().

Referenced by TEST(), and THREADED_TEST().

void SetAccessor ( v8::Handle< String name,
AccessorGetterCallback  getter,
AccessorSetterCallback  setter = 0,
v8::Handle< Value data = Handle<Value>(),
AccessControl  settings = DEFAULT,
PropertyAttribute  attribute = None,
v8::Handle< AccessorSignature signature = Handle<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.

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.

Definition at line 1404 of file api.cc.

Referenced by TEST(), and THREADED_TEST().

void SetCallAsFunctionHandler ( FunctionCallback  callback,
Handle< Value data = Handle<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 1525 of file api.cc.

References v8::internal::CALL_HANDLER_INFO_TYPE, Handle< T >::cast(), FunctionTemplateInfo::cast(), ENTER_V8, Isolate::factory(), Handle< T >::IsEmpty(), Factory::NewStruct(), Utils::OpenHandle(), SET_FIELD_WRAPPED, and v8::Undefined().

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

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 1492 of file api.cc.

References Handle< T >::cast(), FunctionTemplateInfo::cast(), ENTER_V8, Isolate::factory(), v8::internal::INTERCEPTOR_INFO_TYPE, Handle< T >::IsEmpty(), Factory::NewStruct(), Utils::OpenHandle(), SET_FIELD_WRAPPED, and v8::Undefined().

Referenced by THREADED_TEST().

void SetInternalFieldCount ( int  value)

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

Definition at line 1552 of file api.cc.

References Utils::ApiCheck(), ENTER_V8, Smi::FromInt(), Smi::IsValid(), and Utils::OpenHandle().

Referenced by TEST(), and THREADED_TEST().

void SetNamedPropertyHandler ( NamedPropertyGetterCallback  getter,
NamedPropertySetterCallback  setter = 0,
NamedPropertyQueryCallback  query = 0,
NamedPropertyDeleterCallback  deleter = 0,
NamedPropertyEnumeratorCallback  enumerator = 0,
Handle< Value data = Handle<Value>() 
)

Sets a named property handler on the object template.

Whenever a named 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 a property is present, and if present, get its attributes.
deleterThe callback to invoke when deleting a property.
enumeratorThe callback to invoke to enumerate all the named properties of an object.
dataA piece of data that will be passed to the callbacks whenever they are invoked.

Definition at line 1416 of file api.cc.

References Handle< T >::cast(), FunctionTemplateInfo::cast(), ENTER_V8, Isolate::factory(), v8::internal::INTERCEPTOR_INFO_TYPE, Handle< T >::IsEmpty(), Factory::NewStruct(), Utils::OpenHandle(), SET_FIELD_WRAPPED, and v8::Undefined().

Referenced by TEST(), RequestInterruptTestWithMethodCallAndInterceptor::TestBody(), THREADED_PROFILED_TEST(), and THREADED_TEST().

Friends And Related Function Documentation

friend class FunctionTemplate
friend

Definition at line 3752 of file v8.h.


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