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

Unified Diff: mojo/public/tools/bindings/pylib/mojom/parse/translate.py

Issue 262633005: Adding attributes to module and struct in mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « mojo/public/tools/bindings/pylib/mojom/parse/parser.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/pylib/mojom/parse/translate.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
index 6060c83bf960f04be2092fda471965d8534ceccb..6bd4157d34dbac502e6a213ac78b9e2511495ef6 100755
--- a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
+++ b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
@@ -41,6 +41,16 @@ def MapKind(kind):
return map_to_kind[kind]
return 'x:' + kind
+def MapAttributes(attributes):
+ def _AttributeValueToString(v):
qsr 2014/04/30 13:03:45 Not sure this is the best solution. If you think i
darin (slow to review) 2014/05/02 07:44:01 Do you think that would help us catch syntactic er
qsr 2014/05/05 12:40:05 Finally, I let the expression, and decided to use
+ if isinstance(v, basestring):
+ return v
+ return ''.join(v[1])
+ if not attributes:
+ return {}
+ return dict([(attribute[1], _AttributeValueToString(attribute[2]))
+ for attribute in attributes if attribute[0] == 'ATTRIBUTE'])
+
def GetAttribute(attributes, name):
out = None
if attributes:
@@ -78,8 +88,7 @@ def MapEnumField(tree):
def MapStruct(tree):
struct = {}
struct['name'] = tree[1]
- # TODO(darin): Add support for |attributes|
- #struct['attributes'] = MapAttributes(tree[2])
+ struct['attributes'] = MapAttributes(tree[2])
struct['fields'] = MapTree(MapField, tree[3], 'FIELD')
struct['enums'] = MapTree(MapEnum, tree[3], 'ENUM')
return struct
@@ -102,9 +111,10 @@ def MapModule(tree, name):
mojom = {}
mojom['name'] = name
mojom['namespace'] = tree[1]
- mojom['structs'] = MapTree(MapStruct, tree[2], 'STRUCT')
- mojom['interfaces'] = MapTree(MapInterface, tree[2], 'INTERFACE')
- mojom['enums'] = MapTree(MapEnum, tree[2], 'ENUM')
+ mojom['attributes'] = MapAttributes(tree[2])
+ mojom['structs'] = MapTree(MapStruct, tree[3], 'STRUCT')
+ mojom['interfaces'] = MapTree(MapInterface, tree[3], 'INTERFACE')
+ mojom['enums'] = MapTree(MapEnum, tree[3], 'ENUM')
return mojom
def MapImport(tree):
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/parser.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698