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

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

Issue 9695015: Provide DartDomNameOfAttribute (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix native Created 8 years, 9 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: client/dom/scripts/generator.py
diff --git a/client/dom/scripts/generator.py b/client/dom/scripts/generator.py
index a5407d802145a2303f3e8cffd4c4c7901a8ba570..e4053525b85306101ae7a9b5ecd17154f7a39d75 100644
--- a/client/dom/scripts/generator.py
+++ b/client/dom/scripts/generator.py
@@ -78,6 +78,13 @@ def IsPureInterface(interface_name):
_javascript_keywords = ['delete', 'continue']
#
+# Renames for attributes that have names that are not legal Dart names.
+#
+_dart_attribute_renames = {
+ 'default': 'defaultValue'
+}
+
+#
# Interface version of the DOM needs to delegate typed array constructors to a
# factory provider.
#
@@ -341,6 +348,19 @@ def FindMatchingAttribute(interface, attr1):
return None
+def DartDomNameOfAttribute(attr):
+ """Returns the Dart name for an IDLAttribute.
+
+ attr.id is the 'native' or JavaScript name.
+
+ To ensure uniformity, work with the true IDL name until as late a possible,
+ e.g. translate to the Dart name when generating Dart code.
+ """
+ name = attr.id
+ name = _dart_attribute_renames.get(name, name)
+ name = attr.ext_attrs.get('DartName', None) or name
Anton Muhin 2012/03/13 12:53:47 nit: attr.ext_attrs.get('DartName', name)
+ return name
+
class OperationInfo(object):
"""Holder for various derived information from a set of overloaded operations.

Powered by Google App Engine
This is Rietveld 408576698