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

Unified Diff: client/dom/scripts/dartgenerator.py

Issue 8569017: Generate constructors for frog DOM (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Refresh the single file version Created 9 years, 1 month 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: client/dom/scripts/dartgenerator.py
diff --git a/client/dom/scripts/dartgenerator.py b/client/dom/scripts/dartgenerator.py
index 438088729d87bf23d4bba215f46fa8942841a2ab..a512602742338ff42c1408ac2db95f41fee46e90 100755
--- a/client/dom/scripts/dartgenerator.py
+++ b/client/dom/scripts/dartgenerator.py
@@ -65,6 +65,22 @@ _evasive_types = set(['CanvasPixelArray',
])
#
+# Types with user-invocable constructors. We do not have enough
+# information in IDL to create the signature.
+#
+# Each entry is of the form:
+# type name: constructor parameters
+_constructable_types = {
+ 'FileReader': '',
+ 'XMLHttpRequest': '',
+ 'WebKitCSSMatrix': '[String spec]',
+ 'WebKitPoint': 'num x, num y',
+ # dart:html types
+ 'CSSMatrix': '[String spec]',
+ 'Point': 'num x, num y',
+}
+
+#
# Custom methods that must be implemented by hand.
#
_custom_methods = set([
@@ -96,7 +112,6 @@ _alternate_methods = {
('WheelEvent', 'initWheelEvent'): ['initWebKitWheelEvent', 'initWheelEvent']
}
-
def _MatchSourceFilter(filter, thing):
if not filter:
return True
@@ -1913,13 +1928,20 @@ class FrogInterfaceGenerator(object):
else:
extends = ""
+ if interface_name in _constructable_types.keys():
+ parameters = _constructable_types[interface_name]
+ constructor = ' %s(%s) native;\n\n' % (interface_name, parameters)
+ else:
+ constructor = ''
+
(self._members_emitter, self._base_emitter) = self._dart_code.Emit(
'\n'
'class $CLASS$BASE native "$CLASS" {\n'
- '$!MEMBERS'
+ '$CONSTRUCTOR$!MEMBERS'
'$!ADDITIONS'
'}\n',
- CLASS=self._class_name, BASE=extends, INTERFACE=interface_name)
+ CLASS=self._class_name, BASE=extends,
+ INTERFACE=interface_name, CONSTRUCTOR=constructor)
if not base:
# Emit shared base functionality here as we have no common base type.

Powered by Google App Engine
This is Rietveld 408576698