Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1459)

Side by Side Diff: src/api.cc

Issue 2123143002: Make it possible to create a v8::Function directly w/o a prototype (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 4479 matching lines...) Expand 10 before | Expand all | Expand 10 after
4490 } 4490 }
4491 4491
4492 4492
4493 Local<v8::Value> Object::CallAsConstructor(int argc, 4493 Local<v8::Value> Object::CallAsConstructor(int argc,
4494 v8::Local<v8::Value> argv[]) { 4494 v8::Local<v8::Value> argv[]) {
4495 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 4495 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
4496 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); 4496 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv);
4497 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); 4497 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value);
4498 } 4498 }
4499 4499
4500
4501 MaybeLocal<Function> Function::New(Local<Context> context, 4500 MaybeLocal<Function> Function::New(Local<Context> context,
4502 FunctionCallback callback, Local<Value> data, 4501 FunctionCallback callback, Local<Value> data,
4503 int length) { 4502 int length, bool remove_prototype) {
4504 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); 4503 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate();
4505 LOG_API(isolate, Function, New); 4504 LOG_API(isolate, Function, New);
4506 ENTER_V8(isolate); 4505 ENTER_V8(isolate);
4507 return FunctionTemplateNew(isolate, callback, nullptr, data, 4506 auto templ = FunctionTemplateNew(isolate, callback, nullptr, data,
4508 Local<Signature>(), length, true) 4507 Local<Signature>(), length, true);
4509 ->GetFunction(context); 4508 if (remove_prototype) templ->RemovePrototype();
4509 return templ->GetFunction(context);
4510 } 4510 }
4511 4511
4512 4512
4513 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback, 4513 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback,
4514 Local<Value> data, int length) { 4514 Local<Value> data, int length) {
4515 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length) 4515 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length,
4516 false)
4516 .FromMaybe(Local<Function>()); 4517 .FromMaybe(Local<Function>());
4517 } 4518 }
4518 4519
4519 4520
4520 Local<v8::Object> Function::NewInstance() const { 4521 Local<v8::Object> Function::NewInstance() const {
4521 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) 4522 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL)
4522 .FromMaybe(Local<Object>()); 4523 .FromMaybe(Local<Object>());
4523 } 4524 }
4524 4525
4525 4526
(...skipping 4413 matching lines...) Expand 10 before | Expand all | Expand 10 after
8939 Address callback_address = 8940 Address callback_address =
8940 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8941 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8941 VMState<EXTERNAL> state(isolate); 8942 VMState<EXTERNAL> state(isolate);
8942 ExternalCallbackScope call_scope(isolate, callback_address); 8943 ExternalCallbackScope call_scope(isolate, callback_address);
8943 callback(info); 8944 callback(info);
8944 } 8945 }
8945 8946
8946 8947
8947 } // namespace internal 8948 } // namespace internal
8948 } // namespace v8 8949 } // namespace v8
OLDNEW
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698