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

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

Issue 312683005: IDL: Support optional argument default value syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 d96b3ef96cd3ce5c1f33857b4864c6683e4f8a6b..de0bb328f7e3566d11987f0b24683289a0b94d79 100644
--- a/Source/bindings/tests/results/V8TestObject.cpp
+++ b/Source/bindings/tests/results/V8TestObject.cpp
@@ -6597,6 +6597,185 @@ static void voidMethodOptionalDictionaryArgMethodCallback(const v8::FunctionCall
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
+static void voidMethodDefaultStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ V8StringResource<> defaultStringArg;
+ {
+ if (info.Length() > 0) {
+ TOSTRING_VOID_INTERNAL(defaultStringArg, info[0]);
+ } else {
+ defaultStringArg = String("foo");
+ }
+ }
+ impl->voidMethodDefaultStringArg(defaultStringArg);
+}
+
+static void voidMethodDefaultStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodDefaultStringArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void voidMethodDefaultNullStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ V8StringResource<> defaultStringArg;
+ {
+ if (info.Length() > 0) {
+ TOSTRING_VOID_INTERNAL(defaultStringArg, info[0]);
+ } else {
+ defaultStringArg = String();
+ }
+ }
+ impl->voidMethodDefaultNullStringArg(defaultStringArg);
+}
+
+static void voidMethodDefaultNullStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodDefaultNullStringArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void voidMethodDefaultLongArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodDefaultLongArg", "TestObject", info.Holder(), info.GetIsolate());
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ int defaultLongArg;
+ {
+ v8::TryCatch block;
+ V8RethrowTryCatchScope rethrow(block);
+ if (info.Length() > 0) {
+ TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(defaultLongArg, toInt32(info[0], exceptionState), exceptionState);
+ } else {
+ defaultLongArg = 10;
+ }
+ }
+ impl->voidMethodDefaultLongArg(defaultLongArg);
+}
+
+static void voidMethodDefaultLongArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodDefaultLongArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void voidMethodDefaultDoubleArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ double defaultDoubleArg;
+ {
+ v8::TryCatch block;
+ V8RethrowTryCatchScope rethrow(block);
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(defaultDoubleArg, static_cast<double>(info[0]->NumberValue()));
+ } else {
+ defaultDoubleArg = 0.5;
+ }
+ }
+ impl->voidMethodDefaultDoubleArg(defaultDoubleArg);
+}
+
+static void voidMethodDefaultDoubleArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodDefaultDoubleArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void voidMethodDefaultTrueBooleanArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ bool defaultBooleanArg;
+ {
+ v8::TryCatch block;
+ V8RethrowTryCatchScope rethrow(block);
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(defaultBooleanArg, info[0]->BooleanValue());
+ } else {
+ defaultBooleanArg = true;
+ }
+ }
+ impl->voidMethodDefaultTrueBooleanArg(defaultBooleanArg);
+}
+
+static void voidMethodDefaultTrueBooleanArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodDefaultTrueBooleanArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void voidMethodDefaultFalseBooleanArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ bool defaultBooleanArg;
+ {
+ v8::TryCatch block;
+ V8RethrowTryCatchScope rethrow(block);
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(defaultBooleanArg, info[0]->BooleanValue());
+ } else {
+ defaultBooleanArg = false;
+ }
+ }
+ impl->voidMethodDefaultFalseBooleanArg(defaultBooleanArg);
+}
+
+static void voidMethodDefaultFalseBooleanArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodDefaultFalseBooleanArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void voidMethodDefaultNullableStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ V8StringResource<> defaultStringArg;
+ {
+ if (info.Length() > 0) {
+ TOSTRING_VOID_INTERNAL(defaultStringArg, info[0]);
+ } else {
+ defaultStringArg = String();
+ }
+ }
+ impl->voidMethodDefaultNullableStringArg(defaultStringArg);
+}
+
+static void voidMethodDefaultNullableStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodDefaultNullableStringArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+static void voidMethodDefaultNullableTestInterfaceArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ TestInterfaceImplementation* defaultTestInterfaceArg;
+ {
+ v8::TryCatch block;
+ V8RethrowTryCatchScope rethrow(block);
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(defaultTestInterfaceArg, V8TestInterface::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
+ } else {
+ defaultTestInterfaceArg = nullptr;
+ }
+ }
+ impl->voidMethodDefaultNullableTestInterfaceArg(defaultTestInterfaceArg);
+}
+
+static void voidMethodDefaultNullableTestInterfaceArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodDefaultNullableTestInterfaceArgMethod(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
static void voidMethodVariadicStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TestObject* impl = V8TestObject::toNative(info.Holder());
@@ -7130,7 +7309,11 @@ static void overloadedMethodG2Method(const v8::FunctionCallbackInfo<v8::Value>&
{
v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
- TONATIVE_VOID_INTERNAL(testInterfaceEmptyOrNullArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(testInterfaceEmptyOrNullArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
+ } else {
+ testInterfaceEmptyOrNullArg = nullptr;
+ }
}
impl->overloadedMethodG(testInterfaceEmptyOrNullArg);
}
@@ -7140,7 +7323,17 @@ static void overloadedMethodGMethod(const v8::FunctionCallbackInfo<v8::Value>& i
v8::Isolate* isolate = info.GetIsolate();
ExceptionState exceptionState(ExceptionState::ExecutionContext, "overloadedMethodG", "TestObject", info.Holder(), isolate);
switch (std::min(1, info.Length())) {
+ case 0:
+ if (true) {
+ overloadedMethodG2Method(info);
+ return;
+ }
+ break;
case 1:
+ if (info[0]->IsUndefined()) {
+ overloadedMethodG2Method(info);
+ return;
+ }
if (isUndefinedOrNull(info[0])) {
overloadedMethodG2Method(info);
return;
@@ -7155,7 +7348,7 @@ static void overloadedMethodGMethod(const v8::FunctionCallbackInfo<v8::Value>& i
}
break;
default:
- exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
+ exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, info.Length()));
exceptionState.throwIfNeeded();
return;
}
@@ -7551,23 +7744,6 @@ static void voidMethodDefaultUndefinedStringArgMethodCallback(const v8::Function
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
-static void voidMethodDefaultNullStringStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- TestObject* impl = V8TestObject::toNative(info.Holder());
- V8StringResource<> defaultNullStringStringArg;
- {
- TOSTRING_VOID_INTERNAL(defaultNullStringStringArg, argumentOrNull(info, 0));
- }
- impl->voidMethodDefaultNullStringStringArg(defaultNullStringStringArg);
-}
-
-static void voidMethodDefaultNullStringStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
- TestObjectV8Internal::voidMethodDefaultNullStringStringArgMethod(info);
- TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
-}
-
static void voidMethodEnforceRangeLongArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodEnforceRangeLongArg", "TestObject", info.Holder(), info.GetIsolate());
@@ -9214,6 +9390,14 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"voidMethodLongArgOptionalTestInterfaceEmptyArg", TestObjectV8Internal::voidMethodLongArgOptionalTestInterfaceEmptyArgMethodCallback, 0, 1},
{"voidMethodTestInterfaceEmptyArgOptionalLongArg", TestObjectV8Internal::voidMethodTestInterfaceEmptyArgOptionalLongArgMethodCallback, 0, 1},
{"voidMethodOptionalDictionaryArg", TestObjectV8Internal::voidMethodOptionalDictionaryArgMethodCallback, 0, 0},
+ {"voidMethodDefaultStringArg", TestObjectV8Internal::voidMethodDefaultStringArgMethodCallback, 0, 0},
+ {"voidMethodDefaultNullStringArg", TestObjectV8Internal::voidMethodDefaultNullStringArgMethodCallback, 0, 0},
+ {"voidMethodDefaultLongArg", TestObjectV8Internal::voidMethodDefaultLongArgMethodCallback, 0, 0},
+ {"voidMethodDefaultDoubleArg", TestObjectV8Internal::voidMethodDefaultDoubleArgMethodCallback, 0, 0},
+ {"voidMethodDefaultTrueBooleanArg", TestObjectV8Internal::voidMethodDefaultTrueBooleanArgMethodCallback, 0, 0},
+ {"voidMethodDefaultFalseBooleanArg", TestObjectV8Internal::voidMethodDefaultFalseBooleanArgMethodCallback, 0, 0},
+ {"voidMethodDefaultNullableStringArg", TestObjectV8Internal::voidMethodDefaultNullableStringArgMethodCallback, 0, 0},
+ {"voidMethodDefaultNullableTestInterfaceArg", TestObjectV8Internal::voidMethodDefaultNullableTestInterfaceArgMethodCallback, 0, 0},
{"voidMethodVariadicStringArg", TestObjectV8Internal::voidMethodVariadicStringArgMethodCallback, 0, 1},
{"voidMethodStringArgVariadicStringArg", TestObjectV8Internal::voidMethodStringArgVariadicStringArgMethodCallback, 0, 2},
{"voidMethodVariadicTestInterfaceEmptyArg", TestObjectV8Internal::voidMethodVariadicTestInterfaceEmptyArgMethodCallback, 0, 1},
@@ -9235,7 +9419,6 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"voidMethodDefaultUndefinedTestInterfaceEmptyArg", TestObjectV8Internal::voidMethodDefaultUndefinedTestInterfaceEmptyArgMethodCallback, 0, 0},
{"voidMethodDefaultUndefinedLongArg", TestObjectV8Internal::voidMethodDefaultUndefinedLongArgMethodCallback, 0, 0},
{"voidMethodDefaultUndefinedStringArg", TestObjectV8Internal::voidMethodDefaultUndefinedStringArgMethodCallback, 0, 0},
- {"voidMethodDefaultNullStringStringArg", TestObjectV8Internal::voidMethodDefaultNullStringStringArgMethodCallback, 0, 0},
{"voidMethodEnforceRangeLongArg", TestObjectV8Internal::voidMethodEnforceRangeLongArgMethodCallback, 0, 1},
{"voidMethodTreatNullAsNullStringStringArg", TestObjectV8Internal::voidMethodTreatNullAsNullStringStringArgMethodCallback, 0, 1},
{"voidMethodTreatNullAsNullStringTreatUndefinedAsNullStringStringArg", TestObjectV8Internal::voidMethodTreatNullAsNullStringTreatUndefinedAsNullStringStringArgMethodCallback, 0, 1},

Powered by Google App Engine
This is Rietveld 408576698