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

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

Issue 9341007: Use 'field' syntax in dart:dom interfaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 8 years, 10 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/dartgenerator.py
diff --git a/client/dom/scripts/dartgenerator.py b/client/dom/scripts/dartgenerator.py
index d0cd539e694c058a4a24ec2b0d78025c0d2929e9..44e671ea586fcc4fc7e14e29c66a274f232091c9 100755
--- a/client/dom/scripts/dartgenerator.py
+++ b/client/dom/scripts/dartgenerator.py
@@ -1250,12 +1250,16 @@ class DartInterfaceGenerator(object):
VALUE=constant.value)
def AddAttribute(self, getter, setter):
- if getter:
- self._members_emitter.Emit('\n $TYPE get $NAME();\n',
- NAME=getter.id, TYPE=getter.type.id)
- if setter:
- self._members_emitter.Emit('\n void set $NAME($TYPE value);\n',
- NAME=setter.id, TYPE=setter.type.id)
+ if getter and setter and getter.type.id == setter.type.id:
+ self._members_emitter.Emit('\n $TYPE $NAME;\n',
+ NAME=getter.id, TYPE=getter.type.id);
+ return
+ if getter and not setter:
+ self._members_emitter.Emit('\n final $TYPE $NAME;\n',
+ NAME=getter.id, TYPE=getter.type.id);
+ return
+ raise Exception('Unexpected getter/setter combination %s %s' %
+ (getter, setter))
def AddIndexer(self, element_type):
# Interface inherits all operations from List<element_type>.
@@ -1978,20 +1982,18 @@ class FrogInterfaceGenerator(object):
pass
def AddAttribute(self, getter, setter):
- use_fields = True
output_type = getter and self._NarrowOutputType(getter.type.id)
input_type = setter and self._NarrowInputType(setter.type.id)
- if use_fields and getter and setter:
- if input_type == output_type:
- self._members_emitter.Emit(
- '\n $TYPE $NAME;\n',
- NAME=getter.id, TYPE=output_type)
- return
- if use_fields and getter and not setter:
- self._members_emitter.Emit(
- '\n final $TYPE $NAME;\n',
- NAME=getter.id, TYPE=output_type)
- return
+ if getter and setter and input_type == output_type:
+ self._members_emitter.Emit(
+ '\n $TYPE $NAME;\n',
+ NAME=getter.id, TYPE=output_type)
+ return
+ if getter and not setter:
+ self._members_emitter.Emit(
+ '\n final $TYPE $NAME;\n',
+ NAME=getter.id, TYPE=output_type)
+ return
if getter:
self._AddGetter(getter)
if setter:

Powered by Google App Engine
This is Rietveld 408576698