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

Unified Diff: Source/bindings/tests/results/V8TestObject.cpp

Issue 289843006: Avoid extra arity and type check on distinguishing argument (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: additional test Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/tests/results/V8TestObject.cpp
diff --git a/Source/bindings/tests/results/V8TestObject.cpp b/Source/bindings/tests/results/V8TestObject.cpp
index 4bceb917e99176bda10c006ab6740cc257126ad2..e259627f8c14332510e238bd70b6bd99265cbee5 100644
--- a/Source/bindings/tests/results/V8TestObject.cpp
+++ b/Source/bindings/tests/results/V8TestObject.cpp
@@ -6923,6 +6923,142 @@ static void overloadedMethodLMethodCallback(const v8::FunctionCallbackInfo<v8::V
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
+static void overloadedMethodM1Method(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ if (info.Length() > 0 && !V8TestInterface::hasInstance(info[0], info.GetIsolate())) {
+ throwTypeError(ExceptionMessages::failedToExecute("overloadedMethodM", "TestObject", "parameter 1 is not of type 'TestInterface'."), info.GetIsolate());
+ return;
+ }
+ TONATIVE_VOID(TestInterfaceImplementation*, testInterfaceArg1, V8TestInterface::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
+ TONATIVE_VOID(TestInterfaceImplementation*, testInterfaceArg2, V8TestInterface::toNativeWithTypeCheck(info.GetIsolate(), info[1]));
+ impl->overloadedMethodM(testInterfaceArg1, testInterfaceArg2);
+}
+
+static void overloadedMethodM2Method(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ if (info.Length() > 0 && !V8TestInterface::hasInstance(info[0], info.GetIsolate())) {
+ throwTypeError(ExceptionMessages::failedToExecute("overloadedMethodM", "TestObject", "parameter 1 is not of type 'TestInterface'."), info.GetIsolate());
+ return;
+ }
+ TONATIVE_VOID(TestInterfaceImplementation*, testInterfaceArg, V8TestInterface::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
+ TONATIVE_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[1]));
+ impl->overloadedMethodM(testInterfaceArg, testInterfaceEmptyArg);
+}
+
+static void overloadedMethodMMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ switch (info.Length()) {
+ case 2:
+ if (V8TestInterface::hasInstance(info[1], info.GetIsolate())) {
+ overloadedMethodM1Method(info);
+ return;
+ }
+ if (V8TestInterfaceEmpty::hasInstance(info[1], info.GetIsolate())) {
+ overloadedMethodM2Method(info);
+ return;
+ }
+ break;
+ }
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "overloadedMethodM", "TestObject", info.Holder(), info.GetIsolate());
+ if (UNLIKELY(info.Length() < 2)) {
+ throwArityTypeError(exceptionState, 2, info.Length());
+ return;
+ }
+ exceptionState.throwTypeError("No function was found that matched the signature provided.");
+ exceptionState.throwIfNeeded();
+}
+
+static void overloadedMethodMMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::overloadedMethodMMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void overloadedMethodN1Method(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ TONATIVE_VOID(double, a, static_cast<double>(info[0]->NumberValue()));
+ TONATIVE_VOID(TestInterfaceImplementation*, b, V8TestInterface::toNativeWithTypeCheck(info.GetIsolate(), info[1]));
+ impl->overloadedMethodN(a, b);
+}
+
+static void overloadedMethodN2Method(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ TONATIVE_VOID(double, a, static_cast<double>(info[0]->NumberValue()));
+ if (info.Length() > 1 && !V8TestInterfaceEmpty::hasInstance(info[1], info.GetIsolate())) {
+ throwTypeError(ExceptionMessages::failedToExecute("overloadedMethodN", "TestObject", "parameter 2 is not of type 'TestInterfaceEmpty'."), info.GetIsolate());
+ return;
+ }
+ TONATIVE_VOID(TestInterfaceEmpty*, b, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[1]));
+ if (UNLIKELY(info.Length() <= 2)) {
+ impl->overloadedMethodN(a, b);
+ return;
+ }
+ TONATIVE_VOID(TestInterfaceImplementation*, c, V8TestInterface::toNativeWithTypeCheck(info.GetIsolate(), info[2]));
+ impl->overloadedMethodN(a, b, c);
+}
+
+static void overloadedMethodN3Method(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ TONATIVE_VOID(double, a, static_cast<double>(info[0]->NumberValue()));
+ if (info.Length() > 1 && !V8TestInterfaceEmpty::hasInstance(info[1], info.GetIsolate())) {
+ throwTypeError(ExceptionMessages::failedToExecute("overloadedMethodN", "TestObject", "parameter 2 is not of type 'TestInterfaceEmpty'."), info.GetIsolate());
+ return;
+ }
+ TONATIVE_VOID(TestInterfaceEmpty*, b, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[1]));
+ TONATIVE_VOID(TestInterfaceEmpty*, c, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[2]));
+ impl->overloadedMethodN(a, b, c);
+}
+
+static void overloadedMethodNMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ switch (info.Length()) {
+ case 2:
+ if (V8TestInterface::hasInstance(info[1], info.GetIsolate())) {
+ overloadedMethodN1Method(info);
+ return;
+ }
+ if (V8TestInterfaceEmpty::hasInstance(info[1], info.GetIsolate())) {
+ overloadedMethodN2Method(info);
+ return;
+ }
+ break;
+ case 3:
+ if (info[2]->IsUndefined()) {
+ overloadedMethodN2Method(info);
+ return;
+ }
+ if (V8TestInterface::hasInstance(info[2], info.GetIsolate())) {
+ overloadedMethodN2Method(info);
+ return;
+ }
+ if (V8TestInterfaceEmpty::hasInstance(info[2], info.GetIsolate())) {
+ overloadedMethodN3Method(info);
+ return;
+ }
+ break;
+ }
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "overloadedMethodN", "TestObject", info.Holder(), info.GetIsolate());
+ if (UNLIKELY(info.Length() < 2)) {
+ throwArityTypeError(exceptionState, 2, info.Length());
+ return;
+ }
+ exceptionState.throwTypeError("No function was found that matched the signature provided.");
+ exceptionState.throwIfNeeded();
+}
+
+static void overloadedMethodNMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::overloadedMethodNMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
static void overloadedPerWorldBindingsMethod1Method(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TestObject* impl = V8TestObject::toNative(info.Holder());
@@ -8632,6 +8768,8 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"overloadedMethodJ", TestObjectV8Internal::overloadedMethodJMethodCallback, 0, 1},
{"overloadedMethodK", TestObjectV8Internal::overloadedMethodKMethodCallback, 0, 1},
{"overloadedMethodL", TestObjectV8Internal::overloadedMethodLMethodCallback, 0, 1},
+ {"overloadedMethodM", TestObjectV8Internal::overloadedMethodMMethodCallback, 0, 2},
+ {"overloadedMethodN", TestObjectV8Internal::overloadedMethodNMethodCallback, 0, 2},
{"overloadedPerWorldBindingsMethod", TestObjectV8Internal::overloadedPerWorldBindingsMethodMethodCallback, TestObjectV8Internal::overloadedPerWorldBindingsMethodMethodCallbackForMainWorld, 0},
{"voidMethodClampUnsignedShortArg", TestObjectV8Internal::voidMethodClampUnsignedShortArgMethodCallback, 0, 1},
{"voidMethodClampUnsignedLongArg", TestObjectV8Internal::voidMethodClampUnsignedLongArgMethodCallback, 0, 1},
« Source/bindings/tests/idls/TestObject.idl ('K') | « Source/bindings/tests/idls/TestObject.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698