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

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/generate/data.py

Issue 262633005: Adding attributes to module and struct in mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix annotations Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # TODO(vtl): "data" is a pretty vague name. Rename it? 5 # TODO(vtl): "data" is a pretty vague name. Rename it?
6 6
7 import copy 7 import copy
8 8
9 import module as mojom 9 import module as mojom
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 def StructToData(struct): 126 def StructToData(struct):
127 return { 127 return {
128 istr(0, 'name'): struct.name, 128 istr(0, 'name'): struct.name,
129 istr(1, 'fields'): map(FieldToData, struct.fields) 129 istr(1, 'fields'): map(FieldToData, struct.fields)
130 } 130 }
131 131
132 def StructFromData(module, data): 132 def StructFromData(module, data):
133 struct = mojom.Struct(module=module) 133 struct = mojom.Struct(module=module)
134 struct.name = data['name'] 134 struct.name = data['name']
135 struct.attributes = data['attributes']
135 struct.spec = 'x:' + module.namespace + '.' + struct.name 136 struct.spec = 'x:' + module.namespace + '.' + struct.name
136 module.kinds[struct.spec] = struct 137 module.kinds[struct.spec] = struct
137 struct.enums = map(lambda enum: 138 struct.enums = map(lambda enum:
138 EnumFromData(module, enum, struct), data['enums']) 139 EnumFromData(module, enum, struct), data['enums'])
139 # Stash fields data here temporarily. 140 # Stash fields data here temporarily.
140 struct.fields_data = data['fields'] 141 struct.fields_data = data['fields']
141 return struct 142 return struct
142 143
143 def FieldToData(field): 144 def FieldToData(field):
144 data = { 145 data = {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 def ModuleFromData(data): 278 def ModuleFromData(data):
278 module = mojom.Module() 279 module = mojom.Module()
279 module.kinds = {} 280 module.kinds = {}
280 for kind in mojom.PRIMITIVES: 281 for kind in mojom.PRIMITIVES:
281 module.kinds[kind.spec] = kind 282 module.kinds[kind.spec] = kind
282 283
283 module.constants = {} 284 module.constants = {}
284 285
285 module.name = data['name'] 286 module.name = data['name']
286 module.namespace = data['namespace'] 287 module.namespace = data['namespace']
288 module.attributes = data['attributes']
287 # Imports must come first, because they add to module.kinds which is used 289 # Imports must come first, because they add to module.kinds which is used
288 # by by the others. 290 # by by the others.
289 module.imports = map( 291 module.imports = map(
290 lambda import_data: ImportFromData(module, import_data), 292 lambda import_data: ImportFromData(module, import_data),
291 data['imports']) 293 data['imports'])
292 294
293 # First pass collects kinds. 295 # First pass collects kinds.
294 module.enums = map( 296 module.enums = map(
295 lambda enum: EnumFromData(module, enum, None), data['enums']) 297 lambda enum: EnumFromData(module, enum, None), data['enums'])
296 module.structs = map( 298 module.structs = map(
(...skipping 18 matching lines...) Expand all
315 def OrderedModuleFromData(data): 317 def OrderedModuleFromData(data):
316 module = ModuleFromData(data) 318 module = ModuleFromData(data)
317 next_interface_ordinal = 0 319 next_interface_ordinal = 0
318 for interface in module.interfaces: 320 for interface in module.interfaces:
319 next_ordinal = 0 321 next_ordinal = 0
320 for method in interface.methods: 322 for method in interface.methods:
321 if method.ordinal is None: 323 if method.ordinal is None:
322 method.ordinal = next_ordinal 324 method.ordinal = next_ordinal
323 next_ordinal = method.ordinal + 1 325 next_ordinal = method.ordinal + 1
324 return module 326 return module
OLDNEW
« no previous file with comments | « mojo/public/interfaces/bindings/tests/test_structs.mojom ('k') | mojo/public/tools/bindings/pylib/mojom/parse/parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698