Index: Source/bindings/tests/results/V8TestInterfacePython2.cpp |
diff --git a/Source/bindings/tests/results/V8TestInterfacePython2.cpp b/Source/bindings/tests/results/V8TestInterfacePython2.cpp |
index 2afe2cf2467b793023a6a7fb2a33242dae0f93e1..3e223d10f2e9da888ec845a801b47fa3c3c1a1d7 100644 |
--- a/Source/bindings/tests/results/V8TestInterfacePython2.cpp |
+++ b/Source/bindings/tests/results/V8TestInterfacePython2.cpp |
@@ -36,6 +36,7 @@ |
#include "RuntimeEnabledFeatures.h" |
#include "V8Interface1.h" |
#include "V8Interface2.h" |
+#include "V8int.h" |
#include "bindings/v8/ExceptionState.h" |
#include "bindings/v8/V8DOMConfiguration.h" |
#include "bindings/v8/V8GCController.h" |
@@ -44,6 +45,7 @@ |
#include "core/dom/ContextFeatures.h" |
#include "core/dom/Document.h" |
#include "core/dom/Element.h" |
+#include "core/frame/DOMWindow.h" |
#include "platform/TraceEvent.h" |
#include "wtf/GetPtr.h" |
#include "wtf/RefPtr.h" |
@@ -76,6 +78,18 @@ namespace TestInterfacePython2V8Internal { |
template <typename T> void V8_USE(T) { } |
+static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ if (UNLIKELY(info.Length() < 1)) { |
+ throwTypeError(ExceptionMessages::failedToConstruct("TestInterfacePython2", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); |
+ return; |
+ } |
+ V8TRYCATCH_VOID(int*, width, V8int::toNativeWithTypeCheck(info.GetIsolate(), info[0])); |
+ RefPtr<TestInterfacePython2> impl = TestInterfacePython2::create(width); |
+ |
+ v8SetReturnValue(info, wrap(impl.get(), info.Holder(), info.GetIsolate())); |
+} |
+ |
} // namespace TestInterfacePython2V8Internal |
void V8TestInterfacePython2::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) |
@@ -90,6 +104,22 @@ void V8TestInterfacePython2::visitDOMWrapper(void* object, const v8::Persistent< |
setObjectGroup(object, wrapper, isolate); |
} |
+void V8TestInterfacePython2::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); |
+ if (!info.IsConstructCall()) { |
+ throwTypeError(ExceptionMessages::failedToConstruct("TestInterfacePython2", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), info.GetIsolate()); |
+ return; |
+ } |
+ |
+ if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { |
+ v8SetReturnValue(info, info.Holder()); |
+ return; |
+ } |
+ |
+ TestInterfacePython2V8Internal::constructor(info); |
+} |
+ |
static void configureV8TestInterfacePython2Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) |
{ |
functionTemplate->ReadOnlyPrototype(); |
@@ -100,6 +130,8 @@ static void configureV8TestInterfacePython2Template(v8::Handle<v8::FunctionTempl |
0, 0, |
0, 0, |
isolate); |
+ functionTemplate->SetCallHandler(V8TestInterfacePython2::constructorCallback); |
+ functionTemplate->SetLength(1); |
v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate(); |
v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate(); |