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. |