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 1a05e80aa668cea14bdcfae074688dbfb9029a0b..2300cb6f0381da79efca73960eae00f5b59a3725 100644 |
--- a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py |
+++ b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py |
@@ -37,6 +37,12 @@ def _MapKind(kind): |
return map_to_kind[kind] |
return 'x:' + kind |
+def _MapAttributes(attributes): |
+ if not attributes: |
+ return {} |
+ return dict([(attribute[1], attribute[2]) |
+ for attribute in attributes if attribute[0] == 'ATTRIBUTE']) |
+ |
def _GetAttribute(attributes, name): |
out = None |
if attributes: |
@@ -74,8 +80,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 |
@@ -98,9 +103,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): |