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

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

Issue 808373002: IDL: Simplify [TypeChecking=Interface] code generation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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/core/V8TestObject.cpp
diff --git a/Source/bindings/tests/results/core/V8TestObject.cpp b/Source/bindings/tests/results/core/V8TestObject.cpp
index 7900903a79e95e40339fc720fe64871a4718e591..a994117bf475914ac1cd4538417b3b23593c02f0 100644
--- a/Source/bindings/tests/results/core/V8TestObject.cpp
+++ b/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -4556,13 +4556,13 @@ static void typeCheckingInterfaceTestInterfaceAttributeAttributeSetter(v8::Local
{
v8::Handle<v8::Object> holder = info.Holder();
ExceptionState exceptionState(ExceptionState::SetterContext, "typeCheckingInterfaceTestInterfaceAttribute", "TestObject", holder, info.GetIsolate());
- if (!V8TestInterface::hasInstance(v8Value, info.GetIsolate())) {
+ TestObject* impl = V8TestObject::toImpl(holder);
+ TestInterfaceImplementation* cppValue = V8TestInterface::toImplWithTypeCheck(info.GetIsolate(), v8Value);
+ if (!cppValue) {
exceptionState.throwTypeError("The provided value is not of type 'TestInterface'.");
exceptionState.throwIfNeeded();
return;
}
- TestObject* impl = V8TestObject::toImpl(holder);
- TestInterfaceImplementation* cppValue = V8TestInterface::toImpl(v8::Handle<v8::Object>::Cast(v8Value));
impl->setTypeCheckingInterfaceTestInterfaceAttribute(WTF::getPtr(cppValue));
}
@@ -4591,13 +4591,13 @@ static void typeCheckingInterfaceTestInterfaceOrNullAttributeAttributeSetter(v8:
{
v8::Handle<v8::Object> holder = info.Holder();
ExceptionState exceptionState(ExceptionState::SetterContext, "typeCheckingInterfaceTestInterfaceOrNullAttribute", "TestObject", holder, info.GetIsolate());
- if (!isUndefinedOrNull(v8Value) && !V8TestInterface::hasInstance(v8Value, info.GetIsolate())) {
+ TestObject* impl = V8TestObject::toImpl(holder);
+ TestInterfaceImplementation* cppValue = V8TestInterface::toImplWithTypeCheck(info.GetIsolate(), v8Value);
+ if (!cppValue && !isUndefinedOrNull(v8Value)) {
exceptionState.throwTypeError("The provided value is not of type 'TestInterface'.");
exceptionState.throwIfNeeded();
return;
}
- TestObject* impl = V8TestObject::toImpl(holder);
- TestInterfaceImplementation* cppValue = V8TestInterface::toImplWithTypeCheck(info.GetIsolate(), v8Value);
impl->setTypeCheckingInterfaceTestInterfaceOrNullAttribute(WTF::getPtr(cppValue));
}
@@ -10111,11 +10111,11 @@ static void typeCheckingInterfaceVoidMethodTestInterfaceEmptyArgMethod(const v8:
TestObject* impl = V8TestObject::toImpl(info.Holder());
TestInterfaceEmpty* testInterfaceEmptyArg;
{
- if (info.Length() > 0 && !V8TestInterfaceEmpty::hasInstance(info[0], info.GetIsolate())) {
+ testInterfaceEmptyArg = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[0]);
+ if (!testInterfaceEmptyArg) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("typeCheckingInterfaceVoidMethodTestInterfaceEmptyArg", "TestObject", "parameter 1 is not of type 'TestInterfaceEmpty'."));
return;
}
- testInterfaceEmptyArg = V8TestInterfaceEmpty::toImpl(v8::Handle<v8::Object>::Cast(info[0]));
}
impl->typeCheckingInterfaceVoidMethodTestInterfaceEmptyArg(testInterfaceEmptyArg);
}
@@ -10162,20 +10162,20 @@ static void useToImpl4ArgumentsCheckingIfPossibleWithOptionalArgMethod(const v8:
Node* node1;
Node* node2;
{
- if (info.Length() > 0 && !V8Node::hasInstance(info[0], info.GetIsolate())) {
+ node1 = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[0]);
+ if (!node1) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("useToImpl4ArgumentsCheckingIfPossibleWithOptionalArg", "TestObject", "parameter 1 is not of type 'Node'."));
return;
}
- node1 = V8Node::toImpl(v8::Handle<v8::Object>::Cast(info[0]));
if (UNLIKELY(info.Length() <= 1)) {
impl->useToImpl4ArgumentsCheckingIfPossibleWithOptionalArg(node1);
return;
}
- if (info.Length() > 1 && !V8Node::hasInstance(info[1], info.GetIsolate())) {
+ node2 = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[1]);
+ if (!node2) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("useToImpl4ArgumentsCheckingIfPossibleWithOptionalArg", "TestObject", "parameter 2 is not of type 'Node'."));
return;
}
- node2 = V8Node::toImpl(v8::Handle<v8::Object>::Cast(info[1]));
}
impl->useToImpl4ArgumentsCheckingIfPossibleWithOptionalArg(node1, node2);
}
@@ -10197,16 +10197,16 @@ static void useToImpl4ArgumentsCheckingIfPossibleWithNullableArgMethod(const v8:
Node* node1;
Node* node2;
{
- if (info.Length() > 0 && !V8Node::hasInstance(info[0], info.GetIsolate())) {
+ node1 = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[0]);
+ if (!node1) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("useToImpl4ArgumentsCheckingIfPossibleWithNullableArg", "TestObject", "parameter 1 is not of type 'Node'."));
return;
}
- node1 = V8Node::toImpl(v8::Handle<v8::Object>::Cast(info[0]));
- if (info.Length() > 1 && !isUndefinedOrNull(info[1]) && !V8Node::hasInstance(info[1], info.GetIsolate())) {
+ node2 = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[1]);
+ if (!node2 && !isUndefinedOrNull(info[1])) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("useToImpl4ArgumentsCheckingIfPossibleWithNullableArg", "TestObject", "parameter 2 is not of type 'Node'."));
return;
}
- node2 = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[1]);
}
impl->useToImpl4ArgumentsCheckingIfPossibleWithNullableArg(node1, node2);
}
@@ -10228,16 +10228,16 @@ static void useToImpl4ArgumentsCheckingIfPossibleWithUndefinedArgMethod(const v8
Node* node1;
Node* node2;
{
- if (info.Length() > 0 && !V8Node::hasInstance(info[0], info.GetIsolate())) {
+ node1 = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[0]);
+ if (!node1) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("useToImpl4ArgumentsCheckingIfPossibleWithUndefinedArg", "TestObject", "parameter 1 is not of type 'Node'."));
return;
}
- node1 = V8Node::toImpl(v8::Handle<v8::Object>::Cast(info[0]));
- if (info.Length() > 1 && !V8Node::hasInstance(info[1], info.GetIsolate())) {
Jens Widell 2014/12/18 13:47:05 I dropped the "info.Length() > N" check on purpose
haraken 2014/12/18 14:50:27 This sounds like a valid reasoning.
+ node2 = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[1]);
+ if (!node2) {
V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("useToImpl4ArgumentsCheckingIfPossibleWithUndefinedArg", "TestObject", "parameter 2 is not of type 'Node'."));
return;
}
- node2 = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[1]);
}
impl->useToImpl4ArgumentsCheckingIfPossibleWithUndefinedArg(node1, node2);
}

Powered by Google App Engine
This is Rietveld 408576698