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

Unified Diff: Source/bindings/templates/methods.cpp

Issue 340443004: IDL: reuse more code between CG for methods and constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index ae5bfbd527bd6b238a2662ce2f2303b54adba2ed..2890b9c16bb3a390e8031192f58910f6ba121ec1 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -489,12 +489,12 @@ static void constructor{{constructor.overload_index}}(const v8::FunctionCallback
{{generate_arguments(constructor) | indent}}
{% endif %}
{% if is_constructor_call_with_execution_context %}
- ExecutionContext* context = currentExecutionContext(isolate);
+ ExecutionContext* scriptContext = currentExecutionContext(isolate);
Jens Widell 2014/06/17 10:40:20 Renamed to make [CallWith] handling more uniform;
haraken 2014/06/17 11:28:05 scriptContext sounds unnatural. Shall we rename it
haraken 2014/06/17 12:38:53 Let's use |executionContext| consistently.
Jens Widell 2014/06/17 12:53:16 Done.
{% endif %}
{% if is_constructor_call_with_document %}
Document& document = *toDocument(currentExecutionContext(isolate));
{% endif %}
- {{constructor.cpp_type}} impl = {{cpp_class}}::create({{constructor.argument_list | join(', ')}});
+ {{constructor.cpp_type}} impl = {{constructor.cpp_value}};
{% if is_constructor_raises_exception %}
if (exceptionState.throwIfNeeded())
return;
@@ -535,12 +535,13 @@ static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V
return;
}
- Document* document = currentDOMWindow(isolate)->document();
- ASSERT(document);
+ Document* documentPtr = currentDOMWindow(isolate)->document();
Jens Widell 2014/06/17 10:40:20 Since this code is here, unconditionally, CallWith
Jens Widell 2014/06/17 12:53:16 This code uses 'currentDOMWindow(isolate)->documen
haraken 2014/06/17 12:57:39 The issue I want to address is just that we have b
+ ASSERT(documentPtr);
+ Document& document = *documentPtr;
Jens Widell 2014/06/17 10:40:20 Introduced to make [CallWith] handling more unifor
haraken 2014/06/17 11:28:05 Given that we're planning to remove CallWith=Docum
Jens Widell 2014/06/17 12:29:41 Yeah, maybe. Would you prefer I upload a patch tha
haraken 2014/06/17 12:38:53 Yes. A follow-up CL is fine :)
Jens Widell 2014/06/17 13:31:02 Hmm. Replacing ConstructorCallWith=Document with E
// Make sure the document is added to the DOM Node map. Otherwise, the {{cpp_class}} instance
// may end up being the only node in the map and get garbage-collected prematurely.
- toV8(document, info.Holder(), isolate);
+ toV8(documentPtr, info.Holder(), isolate);
{% if constructor.has_exception_state %}
ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interface_name}}", info.Holder(), isolate);
@@ -554,7 +555,7 @@ static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V
{% if constructor.arguments %}
{{generate_arguments(constructor) | indent}}
{% endif %}
- {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{constructor.argument_list | join(', ')}});
+ {{constructor.cpp_type}} impl = {{constructor.cpp_value}};
{% if is_constructor_raises_exception %}
if (exceptionState.throwIfNeeded())
return;

Powered by Google App Engine
This is Rietveld 408576698