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

Unified Diff: lib/html/scripts/generator.py

Issue 11027033: Move Dart type narrowing to TypeRegistry. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 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 | « no previous file | lib/html/scripts/systemhtml.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/html/scripts/generator.py
diff --git a/lib/html/scripts/generator.py b/lib/html/scripts/generator.py
index 947ab8f063a6f3af01683cc30a8566f469782815..491fbe465b15ac385f2a18cc6a796ad9643e6934 100644
--- a/lib/html/scripts/generator.py
+++ b/lib/html/scripts/generator.py
@@ -15,6 +15,7 @@ _pure_interfaces = set([
'DOMStringMap',
'ElementTimeControl',
'ElementTraversal',
+ 'EventListener',
'MediaQueryListListener',
'NodeSelector',
'SVGExternalResourcesRequired',
@@ -505,6 +506,9 @@ def TypeName(type_ids, interface):
# Dynamically type this field for now.
return 'Dynamic'
+def ImplementationClassName(interface_name):
+ return '_%sImpl' % interface_name
+
# ------------------------------------------------------------------------------
class Conversion(object):
@@ -608,6 +612,9 @@ class IDLTypeInfo(object):
def dart_type(self):
return self._data.dart_type or self._idl_type
+ def narrow_dart_type(self):
+ return self.dart_type()
+
def native_type(self):
return self._data.native_type or self._idl_type
@@ -696,6 +703,23 @@ class InterfaceIDLTypeInfo(IDLTypeInfo):
def dart_type(self):
return self._data.dart_type or self._dart_interface_name
+ def narrow_dart_type(self):
+ # TODO(podivilov): introduce ListLikeIDLTypeInfo and remove this hack.
+ if self._data.suppress_public_interface:
+ return ImplementationClassName(self.idl_type())
+ # TODO(podivilov): only primitive and collection types should override
+ # dart_type.
+ if self._data.dart_type != None:
+ return self.dart_type()
+ if IsPureInterface(self.idl_type()):
+ return self.idl_type()
+ return ImplementationClassName(self._dart_interface_name)
+
+
+class CallbackIDLTypeInfo(IDLTypeInfo):
+ def __init__(self, idl_type, data):
+ super(CallbackIDLTypeInfo, self).__init__(idl_type, data)
+
class SequenceIDLTypeInfo(IDLTypeInfo):
def __init__(self, idl_type, data, item_info):
@@ -775,9 +799,9 @@ class PrimitiveIDLTypeInfo(IDLTypeInfo):
return re.sub(r'(^| )([a-z])', lambda x: x.group(2).upper(), self.native_type())
-class SVGTearOffIDLTypeInfo(IDLTypeInfo):
+class SVGTearOffIDLTypeInfo(InterfaceIDLTypeInfo):
def __init__(self, idl_type, data):
- super(SVGTearOffIDLTypeInfo, self).__init__(idl_type, data)
+ super(SVGTearOffIDLTypeInfo, self).__init__(idl_type, data, idl_type)
def native_type(self):
if self._data.native_type:
@@ -992,6 +1016,8 @@ class TypeRegistry(object):
if not type_name in _idl_type_registry:
interface = self._database.GetInterface(type_name)
+ if 'Callback' in interface.ext_attrs:
+ return CallbackIDLTypeInfo(type_name, TypeData('Callback'))
return InterfaceIDLTypeInfo(
type_name,
TypeData('Interface'),
« no previous file with comments | « no previous file | lib/html/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698