Commit acbbd59f authored by jochen's avatar jochen Committed by Commit bot

Expose IsConstructor to the C++ API

BUG=v8:4993
R=verwaest@chromium.org
LOG=y

Review-Url: https://codereview.chromium.org/1964433002
Cr-Commit-Position: refs/heads/master@{#36107}
parent 5d9f6da6
......@@ -2967,6 +2967,11 @@ class V8_EXPORT Object : public Value {
*/
bool IsCallable();
/**
* True if this object is a constructor.
*/
bool IsConstructor();
/**
* Call an Object as a function if a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method.
......
......@@ -4363,6 +4363,10 @@ bool v8::Object::IsCallable() {
return self->IsCallable();
}
bool v8::Object::IsConstructor() {
auto self = Utils::OpenHandle(this);
return self->IsConstructor();
}
MaybeLocal<Value> Object::CallAsFunction(Local<Context> context,
Local<Value> recv, int argc,
......
......@@ -11101,6 +11101,7 @@ THREADED_TEST(FunctionRemovePrototype) {
Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->RemovePrototype();
Local<v8::Function> fun = t1->GetFunction(context.local()).ToLocalChecked();
CHECK(!fun->IsConstructor());
CHECK(context->Global()->Set(context.local(), v8_str("fun"), fun).FromJust());
CHECK(!CompileRun("'prototype' in fun")
->BooleanValue(context.local())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment