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

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

Issue 27100003: Add support for nullable operation arguments in IDL files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add test for optional argument Created 7 years, 2 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/idls/TestObject.idl ('k') | Source/bindings/tests/results/V8TestTypedefs.cpp » ('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 95e2eb80179a2fd6d570c71ce461f88a92ee168b..d9efedb001fe636b49c168becd1eb0f2fd02753c 100644
--- a/Source/bindings/tests/results/V8TestObject.cpp
+++ b/Source/bindings/tests/results/V8TestObject.cpp
@@ -3922,8 +3922,9 @@ static void overloadedMethod7Method(const v8::FunctionCallbackInfo<v8::Value>& a
return;
}
TestObj* imp = V8TestObject::toNative(args.Holder());
+ bool arrayArgIsNull = args[0]->IsNull();
V8TRYCATCH_VOID(Vector<String>, arrayArg, toNativeArray<String>(args[0], args.GetIsolate()));
- imp->overloadedMethod(arrayArg);
+ imp->overloadedMethod(arrayArgIsNull ? 0 : &arrayArg);
return;
}
@@ -4517,6 +4518,38 @@ static void variadicNodeMethodMethodCallback(const v8::FunctionCallbackInfo<v8::
TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
}
+static void methodWithNullableArgumentsMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ if (UNLIKELY(args.Length() < 3)) {
+ throwTypeError(ExceptionMessages::failedToExecute("methodWithNullableArguments", "TestObject", ExceptionMessages::notEnoughArguments(3, args.Length())), args.GetIsolate());
+ return;
+ }
+ TestObj* imp = V8TestObject::toNative(args.Holder());
+ bool strIsNull = args[0]->IsNull();
+ V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strStringResource, args[0]);
+ String str = strStringResource;
+ bool lIsNull = args[1]->IsNull();
+ V8TRYCATCH_VOID(int, l, toInt32(args[1]));
+ V8TRYCATCH_VOID(TestObj*, obj, V8TestObject::HasInstance(args[2], args.GetIsolate(), worldType(args.GetIsolate())) ? V8TestObject::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
+ if (UNLIKELY(args.Length() <= 3)) {
+ imp->methodWithNullableArguments(strIsNull ? 0 : &str, lIsNull ? 0 : &l, obj);
+
+ return;
+ }
+ bool dIsNull = args[3]->IsNull();
+ V8TRYCATCH_VOID(double, d, static_cast<double>(args[3]->NumberValue()));
+ imp->methodWithNullableArguments(strIsNull ? 0 : &str, lIsNull ? 0 : &l, obj, dIsNull ? 0 : &d);
+
+ return;
+}
+
+static void methodWithNullableArgumentsMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
+ TestObjV8Internal::methodWithNullableArgumentsMethod(args);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
+}
+
static void perWorldMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
{
TestObj* imp = V8TestObject::toNative(args.Holder());
@@ -5179,6 +5212,7 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"strictFunction", TestObjV8Internal::strictFunctionMethodCallback, 0, 3},
{"variadicStringMethod", TestObjV8Internal::variadicStringMethodMethodCallback, 0, 2},
{"variadicDoubleMethod", TestObjV8Internal::variadicDoubleMethodMethodCallback, 0, 2},
+ {"methodWithNullableArguments", TestObjV8Internal::methodWithNullableArgumentsMethodCallback, 0, 3},
{"perWorldMethod", TestObjV8Internal::perWorldMethodMethodCallback, TestObjV8Internal::perWorldMethodMethodCallbackForMainWorld, 0},
{"overloadedPerWorldMethod", TestObjV8Internal::overloadedPerWorldMethodMethodCallback, TestObjV8Internal::overloadedPerWorldMethodMethodCallbackForMainWorld, 1},
{"activityLoggedMethod1", TestObjV8Internal::activityLoggedMethod1MethodCallback, 0, 1},
« no previous file with comments | « Source/bindings/tests/idls/TestObject.idl ('k') | Source/bindings/tests/results/V8TestTypedefs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698