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

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

Issue 337343002: IDL: make optional arguments (without default) explicit sometimes Base URL: https://chromium.googlesource.com/chromium/blink.git@idl-default-arguments-next
Patch Set: Created 6 years, 4 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/V8TestInterfaceConstructor.cpp
diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor.cpp b/Source/bindings/tests/results/V8TestInterfaceConstructor.cpp
index d8bc6fb4304b6fa9673d9e365c6c561acc820c48..eff1b014057b47d712cfdecb098f20e48737bd82 100644
--- a/Source/bindings/tests/results/V8TestInterfaceConstructor.cpp
+++ b/Source/bindings/tests/results/V8TestInterfaceConstructor.cpp
@@ -9,6 +9,7 @@
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/Optional.h"
#include "bindings/core/v8/V8DOMConfiguration.h"
#include "bindings/core/v8/V8HiddenValue.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
@@ -71,7 +72,9 @@ static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
Vector<String> sequenceStringArg;
Vector<Dictionary> sequenceDictionaryArg;
Dictionary optionalDictionaryArg;
- TestInterfaceEmpty* optionalTestInterfaceEmptyArg;
+ bool optionalDictionaryArgMissing = false;
+ TestInterfaceEmpty* optionalTestInterfaceEmptyArg = nullptr;
+ bool optionalTestInterfaceEmptyArgMissing = false;
{
v8::TryCatch block;
V8RethrowTryCatchScope rethrow(block);
@@ -86,17 +89,25 @@ static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
}
TONATIVE_VOID_INTERNAL(sequenceStringArg, toNativeArray<String>(info[4], 5, info.GetIsolate()));
TONATIVE_VOID_INTERNAL(sequenceDictionaryArg, toNativeArray<Dictionary>(info[5], 6, info.GetIsolate()));
- TONATIVE_VOID_INTERNAL(optionalDictionaryArg, Dictionary(info[6], info.GetIsolate()));
- if (!optionalDictionaryArg.isUndefinedOrNull() && !optionalDictionaryArg.isObject()) {
- exceptionState.throwTypeError("parameter 7 ('optionalDictionaryArg') is not an object.");
- exceptionState.throwIfNeeded();
- return;
+ if (!info[6]->IsUndefined()) {
+ TONATIVE_VOID_INTERNAL(optionalDictionaryArg, Dictionary(info[6], info.GetIsolate()));
+ if (!optionalDictionaryArg.isUndefinedOrNull() && !optionalDictionaryArg.isObject()) {
+ exceptionState.throwTypeError("parameter 7 ('optionalDictionaryArg') is not an object.");
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ } else {
+ optionalDictionaryArgMissing = true;
+ }
+ if (!info[7]->IsUndefined()) {
+ TONATIVE_VOID_INTERNAL(optionalTestInterfaceEmptyArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[7]));
+ } else {
+ optionalTestInterfaceEmptyArgMissing = true;
}
- TONATIVE_VOID_INTERNAL(optionalTestInterfaceEmptyArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[7]));
}
ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
- RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(executionContext, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequenceStringArg, sequenceDictionaryArg, optionalDictionaryArg, optionalTestInterfaceEmptyArg, exceptionState);
+ RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(executionContext, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequenceStringArg, sequenceDictionaryArg, Optional<Dictionary>(optionalDictionaryArg, optionalDictionaryArgMissing), Optional<RefPtr<TestInterfaceEmpty> >(optionalTestInterfaceEmptyArg, optionalTestInterfaceEmptyArgMissing), exceptionState);
if (exceptionState.hadException()) {
exceptionState.throwIfNeeded();
return;
@@ -111,26 +122,18 @@ static void constructor3(const v8::FunctionCallbackInfo<v8::Value>& info)
ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor", info.Holder(), info.GetIsolate());
V8StringResource<> arg;
V8StringResource<> optArg;
+ bool optArgMissing = false;
{
TOSTRING_VOID_INTERNAL(arg, info[0]);
- if (UNLIKELY(info.Length() <= 1)) {
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
- RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(executionContext, document, arg, exceptionState);
- if (exceptionState.hadException()) {
- exceptionState.throwIfNeeded();
- return;
- }
- v8::Handle<v8::Object> wrapper = info.Holder();
- V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.release(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
- v8SetReturnValue(info, wrapper);
- return;
+ if (!info[1]->IsUndefined()) {
+ TOSTRING_VOID_INTERNAL(optArg, info[1]);
+ } else {
+ optArgMissing = true;
}
- TOSTRING_VOID_INTERNAL(optArg, info[1]);
}
ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
- RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(executionContext, document, arg, optArg, exceptionState);
+ RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(executionContext, document, arg, Optional<V8StringResource<> >(optArg, optArgMissing), exceptionState);
if (exceptionState.hadException()) {
exceptionState.throwIfNeeded();
return;
@@ -245,26 +248,18 @@ static void V8TestInterfaceConstructorConstructorCallback(const v8::FunctionCall
}
V8StringResource<> arg;
V8StringResource<> optArg;
+ bool optArgMissing = false;
{
TOSTRING_VOID_INTERNAL(arg, info[0]);
- if (UNLIKELY(info.Length() <= 1)) {
- ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
- Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
- RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::createForJSConstructor(executionContext, document, arg, exceptionState);
- if (exceptionState.hadException()) {
- exceptionState.throwIfNeeded();
- return;
- }
- v8::Handle<v8::Object> wrapper = info.Holder();
- V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.release(), &V8TestInterfaceConstructorConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
- v8SetReturnValue(info, wrapper);
- return;
+ if (!info[1]->IsUndefined()) {
+ TOSTRING_VOID_INTERNAL(optArg, info[1]);
+ } else {
+ optArgMissing = true;
}
- TOSTRING_VOID_INTERNAL(optArg, info[1]);
}
ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
- RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::createForJSConstructor(executionContext, document, arg, optArg, exceptionState);
+ RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::createForJSConstructor(executionContext, document, arg, Optional<V8StringResource<> >(optArg, optArgMissing), exceptionState);
if (exceptionState.hadException()) {
exceptionState.throwIfNeeded();
return;
« no previous file with comments | « Source/bindings/tests/idls/TestObject.idl ('k') | Source/bindings/tests/results/V8TestInterfaceConstructor2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698