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

Side by Side Diff: mojo/public/tools/bindings/generate_type_mappings.py

Issue 2689513003: Add field-initializing constructors to generated mojo structs. (Closed)
Patch Set: rebase Created 3 years, 9 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Generates a JSON typemap from its command-line arguments and dependencies. 5 """Generates a JSON typemap from its command-line arguments and dependencies.
6 6
7 Each typemap should be specified in an command-line argument of the form 7 Each typemap should be specified in an command-line argument of the form
8 key=value, with an argument of "--start-typemap" preceding each typemap. 8 key=value, with an argument of "--start-typemap" preceding each typemap.
9 9
10 For example, 10 For example,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 attributes = [] 100 attributes = []
101 if match_result.group(3): 101 if match_result.group(3):
102 attributes = match_result.group(3).split(',') 102 attributes = match_result.group(3).split(',')
103 103
104 assert mojom_type not in result, ( 104 assert mojom_type not in result, (
105 "Cannot map multiple native types (%s, %s) to the same mojom type: %s" % 105 "Cannot map multiple native types (%s, %s) to the same mojom type: %s" %
106 (result[mojom_type]['typename'], native_type, mojom_type)) 106 (result[mojom_type]['typename'], native_type, mojom_type))
107 107
108 result[mojom_type] = { 108 result[mojom_type] = {
109 'typename': native_type, 109 'typename': native_type,
110 'non_copyable_non_movable': 'non_copyable_non_movable' in attributes,
110 'move_only': 'move_only' in attributes, 111 'move_only': 'move_only' in attributes,
111 'copyable_pass_by_value': 'copyable_pass_by_value' in attributes, 112 'copyable_pass_by_value': 'copyable_pass_by_value' in attributes,
112 'nullable_is_same_type': 'nullable_is_same_type' in attributes, 113 'nullable_is_same_type': 'nullable_is_same_type' in attributes,
113 'hashable': 'hashable' in attributes, 114 'hashable': 'hashable' in attributes,
114 'public_headers': values['public_headers'], 115 'public_headers': values['public_headers'],
115 'traits_headers': values['traits_headers'], 116 'traits_headers': values['traits_headers'],
116 } 117 }
117 return result 118 return result
118 119
119 120
(...skipping 18 matching lines...) Expand all
138 if missing: 139 if missing:
139 raise IOError('Missing dependencies: %s' % ', '.join(missing)) 140 raise IOError('Missing dependencies: %s' % ', '.join(missing))
140 for path in params.dependency: 141 for path in params.dependency:
141 typemaps.update(ReadTypemap(path)) 142 typemaps.update(ReadTypemap(path))
142 with open(params.output, 'w') as f: 143 with open(params.output, 'w') as f:
143 json.dump({'c++': typemaps}, f, indent=2) 144 json.dump({'c++': typemaps}, f, indent=2)
144 145
145 146
146 if __name__ == '__main__': 147 if __name__ == '__main__':
147 main() 148 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698