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

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

Issue 335113002: IDL: Support argument default values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 6 years, 6 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
« no previous file with comments | « Source/bindings/tests/results/V8TestInterfaceNamedConstructor.cpp ('k') | Source/bindings/v8/V8Binding.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/tests/results/V8TestObject.cpp
diff --git a/Source/bindings/tests/results/V8TestObject.cpp b/Source/bindings/tests/results/V8TestObject.cpp
index 4b312e40b928d0b9eed5158f1026900df98c2222..8834935477d05b468e7df6570ff34e8edd361e7c 100644
--- a/Source/bindings/tests/results/V8TestObject.cpp
+++ b/Source/bindings/tests/results/V8TestObject.cpp
@@ -6872,37 +6872,48 @@ static void voidMethodOptionalDictionaryArgMethodCallback(const v8::FunctionCall
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
-static void voidMethodDefaultStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+static void voidMethodDefaultByteStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodDefaultByteStringArg", "TestObject", info.Holder(), info.GetIsolate());
TestObject* impl = V8TestObject::toNative(info.Holder());
- V8StringResource<> defaultStringArg;
+ V8StringResource<> defaultByteStringArg;
{
- TOSTRING_VOID_INTERNAL(defaultStringArg, info[0]);
+ v8::TryCatch block;
+ V8RethrowTryCatchScope rethrow(block);
+ if (info.Length() > 0) {
+ TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(defaultByteStringArg, toByteString(info[0], exceptionState), exceptionState);
+ } else {
+ defaultByteStringArg = String("foo");
+ }
}
- impl->voidMethodDefaultStringArg(defaultStringArg);
+ impl->voidMethodDefaultByteStringArg(defaultByteStringArg);
}
-static void voidMethodDefaultStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+static void voidMethodDefaultByteStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
- TestObjectV8Internal::voidMethodDefaultStringArgMethod(info);
+ TestObjectV8Internal::voidMethodDefaultByteStringArgMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
-static void voidMethodDefaultNullStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+static void voidMethodDefaultStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TestObject* impl = V8TestObject::toNative(info.Holder());
V8StringResource<> defaultStringArg;
{
- TOSTRING_VOID_INTERNAL(defaultStringArg, argumentOrNull(info, 0));
+ if (info.Length() > 0) {
+ TOSTRING_VOID_INTERNAL(defaultStringArg, info[0]);
+ } else {
+ defaultStringArg = String("foo");
+ }
}
- impl->voidMethodDefaultNullStringArg(defaultStringArg);
+ impl->voidMethodDefaultStringArg(defaultStringArg);
}
-static void voidMethodDefaultNullStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+static void voidMethodDefaultStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
- TestObjectV8Internal::voidMethodDefaultNullStringArgMethod(info);
+ TestObjectV8Internal::voidMethodDefaultStringArgMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
@@ -6914,7 +6925,11 @@ static void voidMethodDefaultLongArgMethod(const v8::FunctionCallbackInfo<v8::Va
{
v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
- TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(defaultLongArg, toInt32(info[0], exceptionState), exceptionState);
+ if (info.Length() > 0) {
+ TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(defaultLongArg, toInt32(info[0], exceptionState), exceptionState);
+ } else {
+ defaultLongArg = 10;
+ }
}
impl->voidMethodDefaultLongArg(defaultLongArg);
}
@@ -6933,7 +6948,11 @@ static void voidMethodDefaultDoubleArgMethod(const v8::FunctionCallbackInfo<v8::
{
v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
- TONATIVE_VOID_INTERNAL(defaultDoubleArg, static_cast<double>(info[0]->NumberValue()));
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(defaultDoubleArg, static_cast<double>(info[0]->NumberValue()));
+ } else {
+ defaultDoubleArg = 0.5;
+ }
}
impl->voidMethodDefaultDoubleArg(defaultDoubleArg);
}
@@ -6952,7 +6971,11 @@ static void voidMethodDefaultTrueBooleanArgMethod(const v8::FunctionCallbackInfo
{
v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
- TONATIVE_VOID_INTERNAL(defaultBooleanArg, info[0]->BooleanValue());
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(defaultBooleanArg, info[0]->BooleanValue());
+ } else {
+ defaultBooleanArg = true;
+ }
}
impl->voidMethodDefaultTrueBooleanArg(defaultBooleanArg);
}
@@ -6971,7 +6994,11 @@ static void voidMethodDefaultFalseBooleanArgMethod(const v8::FunctionCallbackInf
{
v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
- TONATIVE_VOID_INTERNAL(defaultBooleanArg, info[0]->BooleanValue());
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(defaultBooleanArg, info[0]->BooleanValue());
+ } else {
+ defaultBooleanArg = false;
+ }
}
impl->voidMethodDefaultFalseBooleanArg(defaultBooleanArg);
}
@@ -6983,12 +7010,39 @@ static void voidMethodDefaultFalseBooleanArgMethodCallback(const v8::FunctionCal
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
+static void voidMethodDefaultNullableByteStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TestObject* impl = V8TestObject::toNative(info.Holder());
+ V8StringResource<> defaultStringArg;
+ {
+ v8::TryCatch block;
+ V8RethrowTryCatchScope rethrow(block);
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(defaultStringArg, toByteString(info[0]));
+ } else {
+ defaultStringArg = nullptr;
+ }
+ }
+ impl->voidMethodDefaultNullableByteStringArg(defaultStringArg);
+}
+
+static void voidMethodDefaultNullableByteStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjectV8Internal::voidMethodDefaultNullableByteStringArgMethod(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;
{
- TOSTRING_VOID_INTERNAL(defaultStringArg, argumentOrNull(info, 0));
+ if (info.Length() > 0) {
+ TOSTRING_VOID_INTERNAL(defaultStringArg, info[0]);
+ } else {
+ defaultStringArg = nullptr;
+ }
}
impl->voidMethodDefaultNullableStringArg(defaultStringArg);
}
@@ -7007,7 +7061,11 @@ static void voidMethodDefaultNullableTestInterfaceArgMethod(const v8::FunctionCa
{
v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
- TONATIVE_VOID_INTERNAL(defaultTestInterfaceArg, V8TestInterface::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
+ if (info.Length() > 0) {
+ TONATIVE_VOID_INTERNAL(defaultTestInterfaceArg, V8TestInterface::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
+ } else {
+ defaultTestInterfaceArg = nullptr;
+ }
}
impl->voidMethodDefaultNullableTestInterfaceArg(defaultTestInterfaceArg);
}
@@ -7560,7 +7618,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);
}
@@ -9843,12 +9905,13 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"voidMethodLongArgOptionalTestInterfaceEmptyArg", TestObjectV8Internal::voidMethodLongArgOptionalTestInterfaceEmptyArgMethodCallback, 0, 1},
{"voidMethodTestInterfaceEmptyArgOptionalLongArg", TestObjectV8Internal::voidMethodTestInterfaceEmptyArgOptionalLongArgMethodCallback, 0, 1},
{"voidMethodOptionalDictionaryArg", TestObjectV8Internal::voidMethodOptionalDictionaryArgMethodCallback, 0, 0},
+ {"voidMethodDefaultByteStringArg", TestObjectV8Internal::voidMethodDefaultByteStringArgMethodCallback, 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},
+ {"voidMethodDefaultNullableByteStringArg", TestObjectV8Internal::voidMethodDefaultNullableByteStringArgMethodCallback, 0, 0},
{"voidMethodDefaultNullableStringArg", TestObjectV8Internal::voidMethodDefaultNullableStringArgMethodCallback, 0, 0},
{"voidMethodDefaultNullableTestInterfaceArg", TestObjectV8Internal::voidMethodDefaultNullableTestInterfaceArgMethodCallback, 0, 0},
{"voidMethodVariadicStringArg", TestObjectV8Internal::voidMethodVariadicStringArgMethodCallback, 0, 0},
« no previous file with comments | « Source/bindings/tests/results/V8TestInterfaceNamedConstructor.cpp ('k') | Source/bindings/v8/V8Binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698