diff options
author | qsr@chromium.org <qsr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-05 14:17:27 +0000 |
---|---|---|
committer | qsr@chromium.org <qsr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-05 14:17:27 +0000 |
commit | f254de0554f123092fe41628075271a07a783cd1 (patch) | |
tree | 5520a6bf0b8da5aa89dabf175a971518d7c1b0fe /mojo/public | |
parent | ac55ceb444f18dd372352a56d5d14e3e817e9a62 (diff) | |
download | chromium_src-f254de0554f123092fe41628075271a07a783cd1.zip chromium_src-f254de0554f123092fe41628075271a07a783cd1.tar.gz chromium_src-f254de0554f123092fe41628075271a07a783cd1.tar.bz2 |
Adding attributes to module and struct in mojom.
Struct already had attributes, but were discarding the result. Module attributes will be used by the java generator to set the java package.
R=darin@chromium.org
Review URL: https://codereview.chromium.org/262633005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/public')
10 files changed, 24 insertions, 8 deletions
diff --git a/mojo/public/interfaces/bindings/tests/math_calculator.mojom b/mojo/public/interfaces/bindings/tests/math_calculator.mojom index b38a8e2..e4a1c94 100644 --- a/mojo/public/interfaces/bindings/tests/math_calculator.mojom +++ b/mojo/public/interfaces/bindings/tests/math_calculator.mojom @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +[JavaPackage="org.chromium.mojo.bindings.test"] module math { [Peer=CalculatorUI] diff --git a/mojo/public/interfaces/bindings/tests/sample_factory.mojom b/mojo/public/interfaces/bindings/tests/sample_factory.mojom index 00ab1ef..bad466f 100644 --- a/mojo/public/interfaces/bindings/tests/sample_factory.mojom +++ b/mojo/public/interfaces/bindings/tests/sample_factory.mojom @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +[JavaPackage="org.chromium.mojo.bindings.test"] module sample { // This sample shows how handles to MessagePipes can be sent as both parameters diff --git a/mojo/public/interfaces/bindings/tests/sample_import.mojom b/mojo/public/interfaces/bindings/tests/sample_import.mojom index d68c5bf..61f7b9c 100644 --- a/mojo/public/interfaces/bindings/tests/sample_import.mojom +++ b/mojo/public/interfaces/bindings/tests/sample_import.mojom @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +[JavaPackage="org.chromium.mojo.bindings.test"] module imported { // This sample just defines some types that are imported into diff --git a/mojo/public/interfaces/bindings/tests/sample_import2.mojom b/mojo/public/interfaces/bindings/tests/sample_import2.mojom index e5fd72d..1c5ec39 100644 --- a/mojo/public/interfaces/bindings/tests/sample_import2.mojom +++ b/mojo/public/interfaces/bindings/tests/sample_import2.mojom @@ -4,6 +4,7 @@ import "sample_import.mojom" +[JavaPackage="org.chromium.mojo.bindings.test"] module imported { // This sample adds more types and constants to the "imported" namespace, diff --git a/mojo/public/interfaces/bindings/tests/sample_interfaces.mojom b/mojo/public/interfaces/bindings/tests/sample_interfaces.mojom index 7c20b30..462e3cd 100644 --- a/mojo/public/interfaces/bindings/tests/sample_interfaces.mojom +++ b/mojo/public/interfaces/bindings/tests/sample_interfaces.mojom @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +[JavaPackage="org.chromium.mojo.bindings.test", + Foo = "hello world"] module sample { enum Enum { diff --git a/mojo/public/interfaces/bindings/tests/sample_service.mojom b/mojo/public/interfaces/bindings/tests/sample_service.mojom index 04893a4..0336998 100644 --- a/mojo/public/interfaces/bindings/tests/sample_service.mojom +++ b/mojo/public/interfaces/bindings/tests/sample_service.mojom @@ -5,6 +5,7 @@ import "sample_import.mojom" import "sample_import2.mojom" +[JavaPackage="org.chromium.mojo.bindings.test"] module sample { struct Bar { diff --git a/mojo/public/interfaces/bindings/tests/test_structs.mojom b/mojo/public/interfaces/bindings/tests/test_structs.mojom index c205e84..168771e 100644 --- a/mojo/public/interfaces/bindings/tests/test_structs.mojom +++ b/mojo/public/interfaces/bindings/tests/test_structs.mojom @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +[JavaPackage="org.chromium.mojo.bindings.test"] module test_structs { struct Rect { diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/data.py b/mojo/public/tools/bindings/pylib/mojom/generate/data.py index 513b50b..cbe65a7 100644 --- a/mojo/public/tools/bindings/pylib/mojom/generate/data.py +++ b/mojo/public/tools/bindings/pylib/mojom/generate/data.py @@ -132,6 +132,7 @@ def StructToData(struct): def StructFromData(module, data): struct = mojom.Struct(module=module) struct.name = data['name'] + struct.attributes = data['attributes'] struct.spec = 'x:' + module.namespace + '.' + struct.name module.kinds[struct.spec] = struct struct.enums = map(lambda enum: @@ -284,6 +285,7 @@ def ModuleFromData(data): module.name = data['name'] module.namespace = data['namespace'] + module.attributes = data['attributes'] # Imports must come first, because they add to module.kinds which is used # by by the others. module.imports = map( diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/parser.py b/mojo/public/tools/bindings/pylib/mojom/parse/parser.py index 4ad89d9..9dd6e07 100644 --- a/mojo/public/tools/bindings/pylib/mojom/parse/parser.py +++ b/mojo/public/tools/bindings/pylib/mojom/parse/parser.py @@ -79,7 +79,7 @@ class Parser(object): # Generator expects a module. If one wasn't specified insert one with an # empty name. if p[1][0] != 'MODULE': - p[0] = [('MODULE', '', p[1])] + p[0] = [('MODULE', '', [], p[1])] else: p[0] = [p[1]] @@ -89,8 +89,8 @@ class Parser(object): p[0] = ('IMPORT', eval(p[2])) def p_module(self, p): - """module : MODULE identifier LBRACE definitions RBRACE""" - p[0] = ('MODULE', p[2], p[4]) + """module : attribute_section MODULE identifier LBRACE definitions RBRACE""" + p[0] = ('MODULE', p[3], p[1], p[5]) def p_definitions(self, p): """definitions : definition definitions diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py index 1a05e80..2300cb6 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): |