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

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
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom/generate/module.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
103 kind = mojom.Array() 103 if data.startswith('?'):
104 kind.kind = KindFromData(kinds, data[2:], scope) 104 kind = KindFromData(kinds, data[1:], scope).MakeNullableKind()
105 elif data.startswith('a:'):
106 kind = mojom.Array(KindFromData(kinds, data[2:], scope))
105 elif data.startswith('r:'): 107 elif data.startswith('r:'):
106 kind = mojom.InterfaceRequest() 108 kind = mojom.InterfaceRequest(KindFromData(kinds, data[2:], scope))
107 kind.kind = KindFromData(kinds, data[2:], scope)
108 elif data.startswith('a'): 109 elif data.startswith('a'):
109 colon = data.find(':') 110 colon = data.find(':')
110 length = int(data[1:colon]) 111 length = int(data[1:colon])
111 kind = mojom.FixedArray(length) 112 kind = mojom.FixedArray(length, KindFromData(kinds, data[colon+1:], scope))
112 kind.kind = KindFromData(kinds, data[colon+1:], scope)
113 else: 113 else:
114 kind = mojom.Kind() 114 kind = mojom.Kind(data)
115 kind.spec = data 115
116 kinds[data] = kind 116 kinds[data] = kind
117 return kind 117 return kind
118 118
119 def KindFromImport(original_kind, imported_from): 119 def KindFromImport(original_kind, imported_from):
120 """Used with 'import module' - clones the kind imported from the given 120 """Used with 'import module' - clones the kind imported from the given
121 module's namespace. Only used with Structs, Interfaces and Enums.""" 121 module's namespace. Only used with Structs, Interfaces and Enums."""
122 kind = copy.deepcopy(original_kind) 122 kind = copy.deepcopy(original_kind)
123 kind.imported_from = imported_from 123 kind.imported_from = imported_from
124 return kind 124 return kind
125 125
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 def OrderedModuleFromData(data): 351 def OrderedModuleFromData(data):
352 module = ModuleFromData(data) 352 module = ModuleFromData(data)
353 next_interface_ordinal = 0 353 next_interface_ordinal = 0
354 for interface in module.interfaces: 354 for interface in module.interfaces:
355 next_ordinal = 0 355 next_ordinal = 0
356 for method in interface.methods: 356 for method in interface.methods:
357 if method.ordinal is None: 357 if method.ordinal is None:
358 method.ordinal = next_ordinal 358 method.ordinal = next_ordinal
359 next_ordinal = method.ordinal + 1 359 next_ordinal = method.ordinal + 1
360 return module 360 return module
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom/generate/module.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698