Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 22228c4e8b175b67db90b04b0089e023280822cc..696f9c24a04d6c277760d823c6a7e17e99af5442 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -1052,22 +1052,24 @@ void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { |
} |
-Local<FunctionTemplate> FunctionTemplate::New( |
+static Local<FunctionTemplate> FunctionTemplateNew( |
+ i::Isolate* isolate, |
FunctionCallback callback, |
v8::Handle<Value> data, |
v8::Handle<Signature> signature, |
- int length) { |
- i::Isolate* isolate = i::Isolate::Current(); |
- EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); |
- LOG_API(isolate, "FunctionTemplate::New"); |
- ENTER_V8(isolate); |
+ int length, |
+ bool do_not_cache) { |
i::Handle<i::Struct> struct_obj = |
isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); |
i::Handle<i::FunctionTemplateInfo> obj = |
i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); |
InitializeFunctionTemplate(obj); |
- int next_serial_number = isolate->next_serial_number(); |
- isolate->set_next_serial_number(next_serial_number + 1); |
+ obj->set_do_not_cache(do_not_cache); |
+ int next_serial_number = 0; |
+ if (!do_not_cache) { |
+ next_serial_number = isolate->next_serial_number() + 1; |
+ isolate->set_next_serial_number(next_serial_number); |
+ } |
obj->set_serial_number(i::Smi::FromInt(next_serial_number)); |
if (callback != 0) { |
if (data.IsEmpty()) data = v8::Undefined(); |
@@ -1076,12 +1078,24 @@ Local<FunctionTemplate> FunctionTemplate::New( |
obj->set_length(length); |
obj->set_undetectable(false); |
obj->set_needs_access_check(false); |
- |
if (!signature.IsEmpty()) |
obj->set_signature(*Utils::OpenHandle(*signature)); |
return Utils::ToLocal(obj); |
} |
+Local<FunctionTemplate> FunctionTemplate::New( |
+ FunctionCallback callback, |
+ v8::Handle<Value> data, |
+ v8::Handle<Signature> signature, |
+ int length) { |
+ i::Isolate* isolate = i::Isolate::Current(); |
+ EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); |
+ LOG_API(isolate, "FunctionTemplate::New"); |
+ ENTER_V8(isolate); |
+ return FunctionTemplateNew( |
+ isolate, callback, data, signature, length, false); |
+} |
+ |
Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, |
int argc, Handle<FunctionTemplate> argv[]) { |
@@ -4189,6 +4203,19 @@ Local<v8::Value> Object::CallAsConstructor(int argc, |
} |
+Local<Function> Function::New(Isolate* v8_isolate, |
+ FunctionCallback callback, |
+ Local<Value> data, |
+ int length) { |
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
+ LOG_API(isolate, "Function::New"); |
+ ENTER_V8(isolate); |
+ return FunctionTemplateNew( |
+ isolate, callback, data, Local<Signature>(), length, true)-> |
+ GetFunction(); |
+} |
+ |
+ |
Local<v8::Object> Function::NewInstance() const { |
return NewInstance(0, NULL); |
} |
@@ -7865,7 +7892,7 @@ void InvokeAccessorGetterCallback( |
getter)); |
VMState<EXTERNAL> state(isolate); |
ExternalCallbackScope call_scope(isolate, getter_address); |
- return getter(property, info); |
+ getter(property, info); |
} |
@@ -7876,7 +7903,7 @@ void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info, |
reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
VMState<EXTERNAL> state(isolate); |
ExternalCallbackScope call_scope(isolate, callback_address); |
- return callback(info); |
+ callback(info); |
} |