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

Unified Diff: lib/dom/scripts/systemnative.py

Issue 10443122: Revert "Revert "Rework Element constructors"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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: lib/dom/scripts/systemnative.py
diff --git a/lib/dom/scripts/systemnative.py b/lib/dom/scripts/systemnative.py
index 729d51e3657b8e9c886e99f76c3849a6612c7aa7..dab7b584e28b2d855bc7be6f639b72e9338bc8ec 100644
--- a/lib/dom/scripts/systemnative.py
+++ b/lib/dom/scripts/systemnative.py
@@ -11,6 +11,8 @@ import os
from generator import *
from systembase import *
from systemhtml import DomToHtmlEvent, DomToHtmlEvents, HtmlSystemShared
+from systemhtml import HtmlElementConstructorInfos
+from systemhtml import EmitHtmlElementFactoryConstructors
class NativeImplementationSystem(System):
@@ -24,6 +26,7 @@ class NativeImplementationSystem(System):
self._cpp_header_files = []
self._cpp_impl_files = []
self._html_system = HtmlSystemShared(html_database)
+ self._factory_provider_emitters = {}
def InterfaceGenerator(self,
interface,
@@ -176,6 +179,15 @@ class NativeImplementationSystem(System):
def _FilePathForCppImplementation(self, interface_name):
return os.path.join(self._output_dir, 'cpp', 'Dart%s.cpp' % interface_name)
+ def _EmitterForFactoryProviderBody(self, name):
+ if name not in self._factory_provider_emitters:
+ file_name = self._FilePathForDartFactoryProviderImplementation(name)
+ self._dom_impl_files.append(file_name)
+ template = self._templates.Load('factoryprovider_%s.darttemplate' % name)
+ file_emitter = self._emitters.FileEmitter(file_name)
+ self._factory_provider_emitters[name] = file_emitter.Emit(template)
+ return self._factory_provider_emitters[name]
+
def DartImplementationFiles(self):
return self._dom_impl_files
@@ -223,6 +235,11 @@ class NativeImplementationGenerator(object):
self._GenerateEvents()
def _GenerateConstructors(self):
+ html_interface_name = self._HTMLInterfaceName(self._interface.id)
+ infos = HtmlElementConstructorInfos(html_interface_name)
+ if infos:
+ self._EmitHtmlElementFactoryConstructors(infos, html_interface_name)
+
if not self._IsConstructable():
return
@@ -290,6 +307,14 @@ class NativeImplementationGenerator(object):
needs_receiver=False, invocation=invocation,
raises_exceptions=raises_exceptions)
+ def _EmitHtmlElementFactoryConstructors(self, infos, html_interface_name):
+ EmitHtmlElementFactoryConstructors(
+ self._system._EmitterForFactoryProviderBody(
+ infos[0].factory_provider_name),
+ infos,
+ html_interface_name,
+ html_interface_name)
+
def _GenerateEvents(self):
if self._interface.id == 'DocumentFragment':
# Interface DocumentFragment extends Element in dart:html but this fact
@@ -365,6 +390,9 @@ class NativeImplementationGenerator(object):
supertype = self._interface.parents[0].type.id
+ if IsPureInterface(supertype): # The class is a root.
+ return '_DOMWrapperBase'
+
# FIXME: We're currently injecting List<..> and EventTarget as
# supertypes in dart.idl. We should annotate/preserve as
# attributes instead. For now, this hack lets the self._interfaces
« no previous file with comments | « lib/dom/scripts/systemhtml.py ('k') | lib/dom/templates/html/dartium/factoryprovider__Elements.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698