Public メソッド | Static Public メソッド | Private メソッド | フレンド

クラス v8::FunctionTemplate

#include <v8.h>

v8::Templateを継承しています。

すべてのメンバ一覧

Public メソッド

Local< FunctionGetFunction ()
void SetCallHandler (InvocationCallback callback, Handle< Value > data=Handle< Value >())
Local< ObjectTemplateInstanceTemplate ()
void Inherit (Handle< FunctionTemplate > parent)
Local< ObjectTemplatePrototypeTemplate ()
void SetClassName (Handle< String > name)
void SetHiddenPrototype (bool value)
bool HasInstance (Handle< Value > object)

Static Public メソッド

static Local< FunctionTemplateNew (InvocationCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >())

Private メソッド

 FunctionTemplate ()
void AddInstancePropertyAccessor (Handle< String > name, AccessorGetter getter, AccessorSetter setter, Handle< Value > data, AccessControl settings, PropertyAttribute attributes)
void SetNamedInstancePropertyHandler (NamedPropertyGetter getter, NamedPropertySetter setter, NamedPropertyQuery query, NamedPropertyDeleter remover, NamedPropertyEnumerator enumerator, Handle< Value > data)
void SetIndexedInstancePropertyHandler (IndexedPropertyGetter getter, IndexedPropertySetter setter, IndexedPropertyQuery query, IndexedPropertyDeleter remover, IndexedPropertyEnumerator enumerator, Handle< Value > data)
void SetInstanceCallAsFunctionHandler (InvocationCallback callback, Handle< Value > data)

フレンド

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.

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:

    v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
    t->Set("func_property", v8::Number::New(1));

    v8::Local<v8::Template> proto_t = t->PrototypeTemplate();
    proto_t->Set("proto_method", v8::FunctionTemplate::New(InvokeCallback));
    proto_t->Set("proto_const", v8::Number::New(2));

    v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
    instance_t->SetAccessor("instance_accessor", InstanceAccessorCallback);
    instance_t->SetNamedPropertyHandler(PropertyHandlerCallback, ...);
    instance_t->Set("instance_property", Number::New(3));

    v8::Local<v8::Function> function = t->GetFunction();
    v8::Local<v8::Object> instance = function->NewInstance();

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:

   func_property in function == true;
   function.func_property == 1;

   function.prototype.proto_method() invokes 'InvokeCallback'
   function.prototype.proto_const == 2;

   instance instanceof function == true;
   instance.instance_accessor calls 'InstanceAccessorCallback'
   instance.instance_property == 3;

A FunctionTemplate can inherit from another one by calling the FunctionTemplate::Inherit method. The following graph illustrates the semantics of inheritance:

   FunctionTemplate Parent  -> Parent() . prototype -> { }
     ^                                                  ^
     | Inherit(Parent)                                  | .__proto__
     |                                                  |
   FunctionTemplate Child   -> Child()  . prototype -> { }

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:

   Local<FunctionTemplate> parent = t;
   Local<FunctionTemplate> child = FunctionTemplate::New();
   child->Inherit(parent);

   Local<Function> child_function = child->GetFunction();
   Local<Object> child_instance = child_function->NewInstance();

The Child function and Child instance will have the following properties:

   child_func.prototype.__proto__ == function.prototype;
   child_instance.instance_accessor calls 'InstanceAccessorCallback'
   child_instance.instance_property == 3;

v8.h1433 行で定義されています。


コンストラクタとデストラクタ

v8::FunctionTemplate::FunctionTemplate (  )  [private]

関数

void v8::FunctionTemplate::AddInstancePropertyAccessor ( v8::Handle< String name,
AccessorGetter  getter,
AccessorSetter  setter,
v8::Handle< Value data,
v8::AccessControl  settings,
v8::PropertyAttribute  attributes 
) [private]
Local< v8::Function > v8::FunctionTemplate::GetFunction (  ) 

Returns the unique function instance in the current execution context.

api.cc2349 行で定義されています。

参照先 EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Execution::InstantiateFunction(), LOG_API, ON_BAILOUT, v8::Utils::OpenHandle(), と v8::Utils::ToLocal().

bool v8::FunctionTemplate::HasInstance ( Handle< Value object  ) 

Returns true if the given object is an instance of this function template.

api.cc2362 行で定義されています。

参照先 v8::internal::Object, ON_BAILOUT, と v8::Utils::OpenHandle().

void v8::FunctionTemplate::Inherit ( v8::Handle< FunctionTemplate value  ) 

Causes the function template to inherit from a parent function template.

api.cc580 行で定義されています。

参照先 v8::IsDeadCheck(), と v8::Utils::OpenHandle().

Local< ObjectTemplate > v8::FunctionTemplate::InstanceTemplate (  ) 
Local< FunctionTemplate > v8::FunctionTemplate::New ( InvocationCallback  callback = 0,
v8::Handle< Value data = Handle<Value>(),
v8::Handle< Signature signature = Handle<Signature>() 
) [static]
Local< ObjectTemplate > v8::FunctionTemplate::PrototypeTemplate (  ) 

A PrototypeTemplate is the template used to create the prototype object of the function created by this template.

api.cc567 行で定義されています。

参照先 v8::IsDeadCheck(), v8::ObjectTemplate::New(), と v8::Utils::OpenHandle().

void v8::FunctionTemplate::SetCallHandler ( InvocationCallback  callback,
v8::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.

api.cc669 行で定義されています。

参照先 v8::internal::CALL_HANDLER_INFO_TYPE, v8::FromCData(), v8::IsDeadCheck(), v8::Handle< T >::IsEmpty(), v8::internal::Factory::NewStruct(), v8::Utils::OpenHandle(), と v8::Undefined().

void v8::FunctionTemplate::SetClassName ( Handle< String name  ) 

Set the class name of the FunctionTemplate. This is used for printing objects created with the function created from the FunctionTemplate as its constructor.

api.cc731 行で定義されています。

参照先 v8::IsDeadCheck(), と v8::Utils::OpenHandle().

void v8::FunctionTemplate::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.

api.cc737 行で定義されています。

参照先 v8::IsDeadCheck(), と v8::Utils::OpenHandle().

void v8::FunctionTemplate::SetIndexedInstancePropertyHandler ( IndexedPropertyGetter  getter,
IndexedPropertySetter  setter,
IndexedPropertyQuery  query,
IndexedPropertyDeleter  remover,
IndexedPropertyEnumerator  enumerator,
Handle< Value data 
) [private]
void v8::FunctionTemplate::SetInstanceCallAsFunctionHandler ( InvocationCallback  callback,
Handle< Value data 
) [private]
void v8::FunctionTemplate::SetNamedInstancePropertyHandler ( NamedPropertyGetter  getter,
NamedPropertySetter  setter,
NamedPropertyQuery  query,
NamedPropertyDeleter  remover,
NamedPropertyEnumerator  enumerator,
Handle< Value data 
) [private]

フレンドと関連する関数

friend class Context [friend]

v8.h1514 行で定義されています。

friend class ObjectTemplate [friend]

v8::Templateを再定義しています。

v8.h1515 行で定義されています。


このクラスの説明は次のファイルから生成されました:
 全て クラス ネームスペース ファイル 関数 変数 型定義 列挙型 列挙型の値 フレンド マクロ定義