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

Side by Side Diff: mojo/public/bindings/pylib/generate/mojom_generator.py

Issue 207503004: Mojo: add javascript bindings for request/response (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: --similarity=15 Created 6 years, 8 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 | « mojo/public/bindings/js/router.js ('k') | mojo/public/bindings/tests/sample_interfaces.mojom » ('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 """Code shared by the various language-specific code generators.""" 5 """Code shared by the various language-specific code generators."""
6 6
7 import os 7 import os
8 import mojom 8 import mojom
9 import mojom_pack 9 import mojom_pack
10 import re 10 import re
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 # files to stdout. 74 # files to stdout.
75 def __init__(self, module, output_dir=None): 75 def __init__(self, module, output_dir=None):
76 self.module = module 76 self.module = module
77 self.output_dir = output_dir 77 self.output_dir = output_dir
78 78
79 def GetStructsFromMethods(self): 79 def GetStructsFromMethods(self):
80 result = [] 80 result = []
81 for interface in self.module.interfaces: 81 for interface in self.module.interfaces:
82 for method in interface.methods: 82 for method in interface.methods:
83 result.append(GetStructFromMethod(interface, method)) 83 result.append(GetStructFromMethod(interface, method))
84 if method.response_parameters != None:
85 result.append(GetResponseStructFromMethod(interface, method))
84 return map(partial(GetStructInfo, False), result) 86 return map(partial(GetStructInfo, False), result)
85 87
86 def GetStructs(self): 88 def GetStructs(self):
87 return map(partial(GetStructInfo, True), self.module.structs) 89 return map(partial(GetStructInfo, True), self.module.structs)
88 90
89 def Write(self, contents, filename): 91 def Write(self, contents, filename):
90 if self.output_dir is None: 92 if self.output_dir is None:
91 print contents 93 print contents
92 return 94 return
93 with open(os.path.join(self.output_dir, filename), "w+") as f: 95 with open(os.path.join(self.output_dir, filename), "w+") as f:
94 f.write(contents) 96 f.write(contents)
95 97
96 def GenerateFiles(self): 98 def GenerateFiles(self):
97 raise NotImplementedError("Subclasses must override/implement this method") 99 raise NotImplementedError("Subclasses must override/implement this method")
OLDNEW
« no previous file with comments | « mojo/public/bindings/js/router.js ('k') | mojo/public/bindings/tests/sample_interfaces.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698