v8
3.14.5 (node 0.10.48)
V8 is Google's open source JavaScript engine
|
#include <v8.h>
Public Member Functions | |
Local< Function > | GetFunction () |
void | SetCallHandler (InvocationCallback callback, Handle< Value > data=Handle< Value >()) |
Local< ObjectTemplate > | InstanceTemplate () |
void | Inherit (Handle< FunctionTemplate > parent) |
Local< ObjectTemplate > | PrototypeTemplate () |
void | SetClassName (Handle< String > name) |
void | SetHiddenPrototype (bool value) |
void | ReadOnlyPrototype () |
bool | HasInstance (Handle< Value > object) |
Public Member Functions inherited from Template | |
void | Set (Handle< String > name, Handle< Data > value, PropertyAttribute attributes=None) |
void | Set (const char *name, Handle< Data > value) |
Static Public Member Functions | |
static Local< FunctionTemplate > | New (InvocationCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >()) |
Friends | |
class | Context |
class | ObjectTemplate |
A FunctionTemplate is used to create functions at runtime. There can only be one function created from a FunctionTemplate in a context. The lifetime of the created function is equal to the lifetime of the context. So in case the embedder needs to create temporary functions that can be collected using Scripts is preferred.
A FunctionTemplate can have properties, these properties are added to the function object when it is created.
A FunctionTemplate has a corresponding instance template which is used to create object instances when the function is used as a constructor. Properties added to the instance template are added to each object instance.
A FunctionTemplate can have a prototype template. The prototype template is used to create the prototype object of the function.
The following example shows how to use a FunctionTemplate:
Let's use "function" as the JS variable name of the function object and "instance" for the instance object created above. The function and the instance will have the following properties:
A FunctionTemplate can inherit from another one by calling the FunctionTemplate::Inherit method. The following graph illustrates the semantics of inheritance:
A FunctionTemplate 'Child' inherits from 'Parent', the prototype object of the Child() function has proto pointing to the Parent() function's prototype object. An instance of the Child function has all properties on Parent's instance templates.
Let Parent be the FunctionTemplate initialized in the previous section and create a Child FunctionTemplate by:
The Child function and Child instance will have the following properties:
Returns the unique function instance in the current execution context.
Returns true if the given object is an instance of this function template.
void Inherit | ( | Handle< FunctionTemplate > | parent | ) |
Causes the function template to inherit from a parent function template.
Local<ObjectTemplate> InstanceTemplate | ( | ) |
Get the InstanceTemplate.
|
static |
Creates a function template.
Local<ObjectTemplate> PrototypeTemplate | ( | ) |
A PrototypeTemplate is the template used to create the prototype object of the function created by this template.
void ReadOnlyPrototype | ( | ) |
Sets the ReadOnly flag in the attributes of the 'prototype' property of functions created from this FunctionTemplate to true.
void SetCallHandler | ( | InvocationCallback | callback, |
Handle< Value > | data = Handle< Value >() |
||
) |
Set the call-handler callback for a FunctionTemplate. This callback is called whenever the function created from this FunctionTemplate is called.
Set the class name of the FunctionTemplate. This is used for printing objects created with the function created from the FunctionTemplate as its constructor.
void SetHiddenPrototype | ( | bool | value | ) |
Determines whether the proto accessor ignores instances of the function template. If instances of the function template are ignored, proto skips all instances and instead returns the next object in the prototype chain.
Call with a value of true to make the proto accessor ignore instances of the function template. Call with a value of false to make the proto accessor not ignore instances of the function template. By default, instances of a function template are not ignored.
|
friend |