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

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

Issue 437643002: Support nullable types in mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return result 92 return result
93 return value 93 return value
94 94
95 def KindToData(kind): 95 def KindToData(kind):
96 return kind.spec 96 return kind.spec
97 97
98 def KindFromData(kinds, data, scope): 98 def KindFromData(kinds, data, scope):
99 kind = LookupKind(kinds, data, scope) 99 kind = LookupKind(kinds, data, scope)
100 if kind: 100 if kind:
101 return kind 101 return kind
102 if data.startswith('a:'): 102 if data.startswith('?'):
103 kind = mojom.Nullable()
104 kind.SetKind(KindFromData(kinds, data[1:], scope))
105 elif data.startswith('a:'):
103 kind = mojom.Array() 106 kind = mojom.Array()
104 kind.kind = KindFromData(kinds, data[2:], scope) 107 kind.kind = KindFromData(kinds, data[2:], scope)
105 elif data.startswith('r:'): 108 elif data.startswith('r:'):
106 kind = mojom.InterfaceRequest() 109 kind = mojom.InterfaceRequest()
107 kind.kind = KindFromData(kinds, data[2:], scope) 110 kind.kind = KindFromData(kinds, data[2:], scope)
108 elif data.startswith('a'): 111 elif data.startswith('a'):
109 colon = data.find(':') 112 colon = data.find(':')
110 length = int(data[1:colon]) 113 length = int(data[1:colon])
111 kind = mojom.FixedArray(length) 114 kind = mojom.FixedArray(length)
112 kind.kind = KindFromData(kinds, data[colon+1:], scope) 115 kind.kind = KindFromData(kinds, data[colon+1:], scope)
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 def OrderedModuleFromData(data): 354 def OrderedModuleFromData(data):
352 module = ModuleFromData(data) 355 module = ModuleFromData(data)
353 next_interface_ordinal = 0 356 next_interface_ordinal = 0
354 for interface in module.interfaces: 357 for interface in module.interfaces:
355 next_ordinal = 0 358 next_ordinal = 0
356 for method in interface.methods: 359 for method in interface.methods:
357 if method.ordinal is None: 360 if method.ordinal is None:
358 method.ordinal = next_ordinal 361 method.ordinal = next_ordinal
359 next_ordinal = method.ordinal + 1 362 next_ordinal = method.ordinal + 1
360 return module 363 return module
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698