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

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

Issue 2136733002: Mojo C++ bindings: add a new mode to generator to use native STL/WTF types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@67_new
Patch Set: . Created 4 years, 5 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 # 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 """Code shared by the various language-specific code generators.""" 5 """Code shared by the various language-specific code generators."""
6 6
7 from functools import partial 7 from functools import partial
8 import os.path 8 import os.path
9 import re 9 import re
10 10
(...skipping 19 matching lines...) Expand all
30 fileutil.EnsureDirectoryExists(full_dir) 30 fileutil.EnsureDirectoryExists(full_dir)
31 31
32 # Dump the data to disk. 32 # Dump the data to disk.
33 with open(full_path, "w+") as f: 33 with open(full_path, "w+") as f:
34 f.write(contents) 34 f.write(contents)
35 35
36 class Generator(object): 36 class Generator(object):
37 # Pass |output_dir| to emit files to disk. Omit |output_dir| to echo all 37 # Pass |output_dir| to emit files to disk. Omit |output_dir| to echo all
38 # files to stdout. 38 # files to stdout.
39 def __init__(self, module, output_dir=None, typemap=None, variant=None, 39 def __init__(self, module, output_dir=None, typemap=None, variant=None,
40 bytecode_path=None, for_blink=False): 40 bytecode_path=None, for_blink=False,
41 use_new_wrapper_types=False):
41 self.module = module 42 self.module = module
42 self.output_dir = output_dir 43 self.output_dir = output_dir
43 self.typemap = typemap or {} 44 self.typemap = typemap or {}
44 self.variant = variant 45 self.variant = variant
45 self.bytecode_path = bytecode_path 46 self.bytecode_path = bytecode_path
46 self.for_blink = for_blink 47 self.for_blink = for_blink
48 self.use_new_wrapper_types = use_new_wrapper_types
47 49
48 def GetStructsFromMethods(self): 50 def GetStructsFromMethods(self):
49 result = [] 51 result = []
50 for interface in self.module.interfaces: 52 for interface in self.module.interfaces:
51 for method in interface.methods: 53 for method in interface.methods:
52 result.append(self._GetStructFromMethod(method)) 54 result.append(self._GetStructFromMethod(method))
53 if method.response_parameters != None: 55 if method.response_parameters != None:
54 result.append(self._GetResponseStructFromMethod(method)) 56 result.append(self._GetResponseStructFromMethod(method))
55 return result 57 return result
56 58
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return self._AddStructComputedData(False, struct) 139 return self._AddStructComputedData(False, struct)
138 140
139 def _GetResponseStructFromMethod(self, method): 141 def _GetResponseStructFromMethod(self, method):
140 """Converts a method's response_parameters into the fields of a struct.""" 142 """Converts a method's response_parameters into the fields of a struct."""
141 params_class = "%s_%s_ResponseParams" % (method.interface.name, method.name) 143 params_class = "%s_%s_ResponseParams" % (method.interface.name, method.name)
142 struct = mojom.Struct(params_class, module=method.interface.module) 144 struct = mojom.Struct(params_class, module=method.interface.module)
143 for param in method.response_parameters: 145 for param in method.response_parameters:
144 struct.AddField(param.name, param.kind, param.ordinal, 146 struct.AddField(param.name, param.kind, param.ordinal,
145 attributes=param.attributes) 147 attributes=param.attributes)
146 return self._AddStructComputedData(False, struct) 148 return self._AddStructComputedData(False, struct)
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/mojom_bindings_generator.py ('k') | mojo/public/tools/bindings/pylib/mojom/generate/module.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698