|
25 | 25 | * preferred.
|
26 | 26 | *
|
27 | 27 | * Any modification of a FunctionTemplate after first instantiation will trigger
|
28 |
| - *a crash. |
| 28 | + * a crash. |
29 | 29 | *
|
30 | 30 | * A FunctionTemplate can have properties, these properties are added to the
|
31 | 31 | * function object when it is created.
|
|
41 | 41 | * The following example shows how to use a FunctionTemplate:
|
42 | 42 | *
|
43 | 43 | * \code
|
44 |
| - * v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); |
45 |
| - * t->Set("func_property", v8::Number::New(1)); |
| 44 | + * v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
| 45 | + * t->Set(isolate, "func_property", v8::Number::New(isolate, 1)); |
46 | 46 | *
|
47 | 47 | * v8::Local<v8::Template> proto_t = t->PrototypeTemplate();
|
48 |
| - * proto_t->Set("proto_method", v8::FunctionTemplate::New(InvokeCallback)); |
49 |
| - * proto_t->Set("proto_const", v8::Number::New(2)); |
| 48 | + * proto_t->Set(isolate, |
| 49 | + * "proto_method", |
| 50 | + * v8::FunctionTemplate::New(isolate, InvokeCallback)); |
| 51 | + * proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2)); |
50 | 52 | *
|
51 | 53 | * v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
|
52 |
| - * instance_t->SetAccessor("instance_accessor", InstanceAccessorCallback); |
53 |
| - * instance_t->SetNamedPropertyHandler(PropertyHandlerCallback, ...); |
54 |
| - * instance_t->Set("instance_property", Number::New(3)); |
| 54 | + * instance_t->SetAccessor(String::NewFromUtf8(isolate, "instance_accessor"), |
| 55 | + * InstanceAccessorCallback); |
| 56 | + * instance_t->SetNamedPropertyHandler(PropertyHandlerCallback); |
| 57 | + * instance_t->Set(String::NewFromUtf8(isolate, "instance_property"), |
| 58 | + * Number::New(isolate, 3)); |
55 | 59 | *
|
56 | 60 | * v8::Local<v8::Function> function = t->GetFunction();
|
57 | 61 | * v8::Local<v8::Object> instance = function->NewInstance();
|
|
111 | 115 | * child_instance.instance_property == 3;
|
112 | 116 | * \endcode
|
113 | 117 | */
|
114 |
| -//class FunctionTemplateInterface extends TemplateInterface |
115 | 118 | class FunctionTemplate extends Template implements AdjustableExternalMemoryInterface
|
116 | 119 | {
|
117 |
| - private $isolate; |
118 |
| - |
119 |
| - //static Local<FunctionTemplate> New( |
120 |
| - // Isolate* isolate, |
121 |
| - // FunctionCallback callback = 0, |
122 |
| - // Handle<Value> data = Handle<Value>(), |
123 |
| - // Handle<Signature> signature = Handle<Signature>(), |
124 |
| - // int length = 0); |
125 |
| - public function __construct(Isolate $isolate, callable $callback = null, int $length = 0) |
| 120 | + /** |
| 121 | + * @param Isolate $isolate |
| 122 | + * @param callable|null $callback |
| 123 | + * @param int $length |
| 124 | + * @param int $behavior |
| 125 | + */ |
| 126 | + public function __construct(Isolate $isolate, callable $callback = null, int $length = 0, int $behavior = ConstructorBehavior::kAllow) |
126 | 127 | {
|
127 | 128 | parent::__construct($isolate);
|
128 | 129 | }
|
129 | 130 |
|
130 |
| - public function GetIsolate() |
131 |
| - { |
132 |
| - return $this->isolate; |
133 |
| - } |
134 |
| - |
135 | 131 | /**
|
136 | 132 | * Returns the unique function instance in the current execution context.
|
137 | 133 | *
|
|
0 commit comments