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

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

Issue 265293004: Create fewer local v8::TryCatch objects in generated bindings code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added comment 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/V8TestInterfaceConstructor2.cpp
diff --git a/Source/bindings/tests/results/V8TestInterfaceConstructor2.cpp b/Source/bindings/tests/results/V8TestInterfaceConstructor2.cpp
index c5ff0e3334e3b85d96189638fe5f226cbfc3a8e8..b74863c567c1fd5a47185d5b6edec4b2c38920e6 100644
--- a/Source/bindings/tests/results/V8TestInterfaceConstructor2.cpp
+++ b/Source/bindings/tests/results/V8TestInterfaceConstructor2.cpp
@@ -48,7 +48,10 @@ template <typename T> void V8_USE(T) { }
static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
- TOSTRING_VOID(V8StringResource<>, stringArg, info[0]);
+ V8StringResource<> stringArg;
+ {
+ TOSTRING_VOID_INTERNAL(stringArg, info[0]);
+ }
RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(stringArg);
v8::Handle<v8::Object> wrapper = info.Holder();
@@ -59,10 +62,15 @@ static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info)
static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
- TONATIVE_VOID(Dictionary, dictionaryArg, Dictionary(info[0], info.GetIsolate()));
- if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) {
- throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstructor2", "parameter 1 ('dictionaryArg') is not an object."), info.GetIsolate());
- return;
+ Dictionary dictionaryArg;
+ {
+ v8::TryCatch block;
+ TONATIVE_VOID_INTERNAL(dictionaryArg, Dictionary(info[0], info.GetIsolate()));
+ if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) {
+ throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstructor2", "parameter 1 ('dictionaryArg') is not an object."), info.GetIsolate());
+ block.ReThrow();
+ return;
+ }
}
RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(dictionaryArg);
@@ -75,24 +83,34 @@ static void constructor3(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Isolate* isolate = info.GetIsolate();
ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor2", info.Holder(), isolate);
- TONATIVE_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
- TONATIVE_VOID_EXCEPTIONSTATE(int, longArg, toInt32(info[1], exceptionState), exceptionState);
- TOSTRING_VOID(V8StringResource<>, defaultUndefinedOptionalStringArg, info[2]);
- TOSTRING_VOID(V8StringResource<>, defaultNullStringOptionalStringArg, argumentOrNull(info, 3));
- TONATIVE_VOID(Dictionary, defaultUndefinedOptionalDictionaryArg, Dictionary(info[4], info.GetIsolate()));
- if (!defaultUndefinedOptionalDictionaryArg.isUndefinedOrNull() && !defaultUndefinedOptionalDictionaryArg.isObject()) {
- exceptionState.throwTypeError("parameter 5 ('defaultUndefinedOptionalDictionaryArg') is not an object.");
- exceptionState.throwIfNeeded();
- return;
- }
- if (UNLIKELY(info.Length() <= 5)) {
- RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg);
- v8::Handle<v8::Object> wrapper = info.Holder();
- V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
- v8SetReturnValue(info, wrapper);
- return;
+ TestInterfaceEmpty* testInterfaceEmptyArg;
+ int longArg;
+ V8StringResource<> defaultUndefinedOptionalStringArg;
+ V8StringResource<> defaultNullStringOptionalStringArg;
+ Dictionary defaultUndefinedOptionalDictionaryArg;
+ V8StringResource<> optionalStringArg;
+ {
+ v8::TryCatch block;
+ TONATIVE_VOID_INTERNAL(testInterfaceEmptyArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
+ TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(longArg, toInt32(info[1], exceptionState), exceptionState);
+ TOSTRING_VOID_INTERNAL_RETHROW(defaultUndefinedOptionalStringArg, info[2], block);
+ TOSTRING_VOID_INTERNAL_RETHROW(defaultNullStringOptionalStringArg, argumentOrNull(info, 3), block);
+ TONATIVE_VOID_INTERNAL(defaultUndefinedOptionalDictionaryArg, Dictionary(info[4], info.GetIsolate()));
+ if (!defaultUndefinedOptionalDictionaryArg.isUndefinedOrNull() && !defaultUndefinedOptionalDictionaryArg.isObject()) {
+ exceptionState.throwTypeError("parameter 5 ('defaultUndefinedOptionalDictionaryArg') is not an object.");
+ exceptionState.throwIfNeeded();
+ block.ReThrow();
+ return;
+ }
+ if (UNLIKELY(info.Length() <= 5)) {
+ RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg);
+ v8::Handle<v8::Object> wrapper = info.Holder();
+ V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
+ v8SetReturnValue(info, wrapper);
+ return;
+ }
+ TOSTRING_VOID_INTERNAL_RETHROW(optionalStringArg, info[5], block);
}
- TOSTRING_VOID(V8StringResource<>, optionalStringArg, info[5]);
RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg, optionalStringArg);
v8::Handle<v8::Object> wrapper = info.Holder();

Powered by Google App Engine
This is Rietveld 408576698