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

Unified Diff: tools/dom/scripts/htmldartgenerator.py

Issue 21555003: Exposing native doubles as doubles when they are read-only or method return values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | « sdk/lib/web_audio/dartium/web_audio_dartium.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/htmldartgenerator.py
diff --git a/tools/dom/scripts/htmldartgenerator.py b/tools/dom/scripts/htmldartgenerator.py
index 52d1de8e3ab088443839ffe0af5c66cfcc22efc5..8d42110b00786bc3bf71a2f48baf77f5593b9ff5 100644
--- a/tools/dom/scripts/htmldartgenerator.py
+++ b/tools/dom/scripts/htmldartgenerator.py
@@ -625,13 +625,22 @@ class HtmlDartGenerator(object):
})
self._members_emitter.Emit(template, E=element_name)
- def SecureOutputType(self, type_name, is_dart_type=False):
+ def SecureOutputType(self, type_name, is_dart_type=False,
+ can_narrow_type=False):
""" Converts the type name to the secure type name for return types.
+ Arguments:
+ can_narrow_type - True if the output type can be narrowed further than
+ what would be accepted for input, used to narrow num APIs down to double
+ or int.
"""
if is_dart_type:
dart_name = type_name
else:
- dart_name = self._DartType(type_name)
+ type_info = self._TypeInfo(type_name)
+ dart_name = type_info.dart_type()
+ if can_narrow_type and dart_name == 'num':
+ dart_name = type_info.native_type()
+
# We only need to secure Window. Only local History and Location are
# returned in generated code.
assert(dart_name != 'HistoryBase' and dart_name != 'LocationBase')
@@ -645,3 +654,6 @@ class HtmlDartGenerator(object):
def _DartType(self, type_name):
return self._type_registry.DartType(type_name)
+
+ def _TypeInfo(self, type_name):
+ return self._type_registry.TypeInfo(type_name)
« no previous file with comments | « sdk/lib/web_audio/dartium/web_audio_dartium.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698