V8 Project
v8::Template Class Reference

The superclass of object and function templates. More...

#include <v8.h>

+ Inheritance diagram for v8::Template:
+ Collaboration diagram for v8::Template:

Public Member Functions

void Set (Handle< Name > name, Handle< Data > value, PropertyAttribute attributes=None)
 Adds a property to each instance created by this template. More...
 
void Set (Isolate *isolate, const char *name, Handle< Data > value)
 
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=0, Handle< Value > data=Handle< Value >(), PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), AccessControl settings=DEFAULT)
 Whenever the property with the given name is accessed on objects created from this Template the getter and setter callbacks are called instead of getting and setting the property directly on the JavaScript object. More...
 
void SetNativeDataProperty (Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=0, Handle< Value > data=Handle< Value >(), PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), AccessControl settings=DEFAULT)
 
bool SetDeclaredAccessor (Local< Name > name, Local< DeclaredAccessorDescriptor > descriptor, PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), AccessControl settings=DEFAULT)
 

Private Member Functions

 Template ()
 

Friends

class ObjectTemplate
 
class FunctionTemplate
 

Detailed Description

The superclass of object and function templates.

Definition at line 3347 of file v8.h.

Constructor & Destructor Documentation

◆ Template()

v8::Template::Template ( )
private

Member Function Documentation

◆ Set() [1/2]

void v8::Template::Set ( v8::Handle< Name name,
v8::Handle< Data value,
v8::PropertyAttribute  attribute = None 
)

Adds a property to each instance created by this template.

Definition at line 802 of file api.cc.

804  {
805  i::Isolate* isolate = i::Isolate::Current();
806  ENTER_V8(isolate);
807  i::HandleScope scope(isolate);
808  const int kSize = 3;
809  v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
810  v8::Handle<v8::Data> data[kSize] = {
811  name,
812  value,
813  v8::Integer::New(v8_isolate, attribute)};
814  TemplateSet(isolate, this, kSize, data);
815 }
#define ENTER_V8(isolate)
Definition: api.cc:54
An object reference managed by the v8 garbage collector.
Definition: v8.h:198
static Local< Integer > New(Isolate *isolate, int32_t value)
Definition: api.cc:6281
Isolate represents an isolated instance of the V8 engine.
Definition: v8.h:4356
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
static void TemplateSet(i::Isolate *isolate, v8::Template *templ, int length, v8::Handle< v8::Data > *data)
Definition: api.cc:782

References ENTER_V8, name, v8::Integer::New(), and v8::TemplateSet().

+ Here is the call graph for this function:

◆ Set() [2/2]

void v8::Template::Set ( Isolate isolate,
const char *  name,
v8::Handle< Data value 
)
inline

Definition at line 6421 of file v8.h.

6421  {
6422  Set(v8::String::NewFromUtf8(isolate, name), value);
6423 }
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
Allocates a new string from UTF-8 data.
Definition: api.cc:5447
void Set(Handle< Name > name, Handle< Data > value, PropertyAttribute attributes=None)
Adds a property to each instance created by this template.
Definition: api.cc:802

References name, and v8::String::NewFromUtf8().

+ Here is the call graph for this function:

◆ SetAccessorProperty()

void v8::Template::SetAccessorProperty ( Local< Name name,
v8::Local< FunctionTemplate getter = Local<FunctionTemplate>(),
v8::Local< FunctionTemplate setter = Local<FunctionTemplate>(),
v8::PropertyAttribute  attribute = None,
v8::AccessControl  access_control = DEFAULT 
)

Definition at line 818 of file api.cc.

823  {
824  // TODO(verwaest): Remove |access_control|.
825  DCHECK_EQ(v8::DEFAULT, access_control);
826  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
827  ENTER_V8(isolate);
828  DCHECK(!name.IsEmpty());
829  DCHECK(!getter.IsEmpty() || !setter.IsEmpty());
830  i::HandleScope scope(isolate);
831  const int kSize = 5;
832  v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
833  v8::Handle<v8::Data> data[kSize] = {
834  name,
835  getter,
836  setter,
837  v8::Integer::New(v8_isolate, attribute)};
838  TemplateSet(isolate, this, kSize, data);
839 }
bool IsEmpty() const
Returns true if the handle is empty.
Definition: v8.h:228
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288
#define DCHECK(condition)
Definition: logging.h:205
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206
@ DEFAULT
Definition: v8.h:2273

References DCHECK, DCHECK_EQ, v8::DEFAULT, ENTER_V8, v8::Handle< T >::IsEmpty(), name, v8::Integer::New(), v8::Utils::OpenHandle(), and v8::TemplateSet().

+ Here is the call graph for this function:

◆ SetDeclaredAccessor()

bool v8::Template::SetDeclaredAccessor ( Local< Name name,
Local< DeclaredAccessorDescriptor descriptor,
PropertyAttribute  attribute = None,
Local< AccessorSignature signature = Local<AccessorSignature>(),
AccessControl  settings = DEFAULT 
)

Definition at line 1337 of file api.cc.

1342  {
1343  void* null = NULL;
1344  return TemplateSetAccessor(
1345  this, name, descriptor, null, null, settings, attribute, signature);
1346 }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
static bool TemplateSetAccessor(Template *template_obj, v8::Local< Name > name, Getter getter, Setter setter, Data data, AccessControl settings, PropertyAttribute attribute, v8::Local< AccessorSignature > signature)
Definition: api.cc:1316

References name, NULL, and v8::TemplateSetAccessor().

+ Here is the call graph for this function:

◆ SetNativeDataProperty() [1/2]

void v8::Template::SetNativeDataProperty ( v8::Local< Name name,
AccessorNameGetterCallback  getter,
AccessorNameSetterCallback  setter = 0,
v8::Handle< Value data = Handle<Value>(),
PropertyAttribute  attribute = None,
v8::Local< AccessorSignature signature = Local<AccessorSignature>(),
AccessControl  settings = DEFAULT 
)

Definition at line 1361 of file api.cc.

1367  {
1369  this, name, getter, setter, data, settings, attribute, signature);
1370 }

References name, and v8::TemplateSetAccessor().

+ Here is the call graph for this function:

◆ SetNativeDataProperty() [2/2]

void v8::Template::SetNativeDataProperty ( v8::Local< String name,
AccessorGetterCallback  getter,
AccessorSetterCallback  setter = 0,
v8::Handle< Value data = Handle<Value>(),
PropertyAttribute  attribute = None,
v8::Local< AccessorSignature signature = Local<AccessorSignature>(),
AccessControl  settings = DEFAULT 
)

Whenever the property with the given name is accessed on objects created from this Template 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 1349 of file api.cc.

1355  {
1357  this, name, getter, setter, data, settings, attribute, signature);
1358 }

References name, and v8::TemplateSetAccessor().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ FunctionTemplate

friend class FunctionTemplate
friend

Definition at line 3419 of file v8.h.

◆ ObjectTemplate

friend class ObjectTemplate
friend

Definition at line 3418 of file v8.h.


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