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

Side by Side Diff: mojo/public/tools/bindings/generators/mojom_js_generator.py

Issue 278093003: Break dependency on core from generated mojom.js files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Specialize Converter<gin::Handle<gin::HandleWrapper> > Created 6 years, 7 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/tools/bindings/generators/js_templates/module.js.tmpl ('k') | no next file » | 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 """Generates JavaScript source files from a mojom.Module.""" 5 """Generates JavaScript source files from a mojom.Module."""
6 6
7 import mojom.generate.generator as generator 7 import mojom.generate.generator as generator
8 import mojom.generate.module as mojom 8 import mojom.generate.module as mojom
9 import mojom.generate.pack as pack 9 import mojom.generate.pack as pack
10 from mojom.generate.template_expander import UseJinja 10 from mojom.generate.template_expander import UseJinja
11 11
12 _kind_to_javascript_default_value = { 12 _kind_to_javascript_default_value = {
13 mojom.BOOL: "false", 13 mojom.BOOL: "false",
14 mojom.INT8: "0", 14 mojom.INT8: "0",
15 mojom.UINT8: "0", 15 mojom.UINT8: "0",
16 mojom.INT16: "0", 16 mojom.INT16: "0",
17 mojom.UINT16: "0", 17 mojom.UINT16: "0",
18 mojom.INT32: "0", 18 mojom.INT32: "0",
19 mojom.UINT32: "0", 19 mojom.UINT32: "0",
20 mojom.FLOAT: "0", 20 mojom.FLOAT: "0",
21 mojom.HANDLE: "core.kInvalidHandle", 21 mojom.HANDLE: "null",
22 mojom.DCPIPE: "core.kInvalidHandle", 22 mojom.DCPIPE: "null",
23 mojom.DPPIPE: "core.kInvalidHandle", 23 mojom.DPPIPE: "null",
24 mojom.MSGPIPE: "core.kInvalidHandle", 24 mojom.MSGPIPE: "null",
25 mojom.SHAREDBUFFER: "core.kInvalidHandle", 25 mojom.SHAREDBUFFER: "null",
26 mojom.INT64: "0", 26 mojom.INT64: "0",
27 mojom.UINT64: "0", 27 mojom.UINT64: "0",
28 mojom.DOUBLE: "0", 28 mojom.DOUBLE: "0",
29 mojom.STRING: '""', 29 mojom.STRING: '""',
30 } 30 }
31 31
32 32
33 def JavaScriptDefaultValue(field): 33 def JavaScriptDefaultValue(field):
34 if field.default: 34 if field.default:
35 raise Exception("Default values should've been handled in jinja.") 35 raise Exception("Default values should've been handled in jinja.")
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 self.Write(self.GenerateJsModule(), "%s.js" % self.module.name) 175 self.Write(self.GenerateJsModule(), "%s.js" % self.module.name)
176 176
177 def GetImports(self): 177 def GetImports(self):
178 # Since each import is assigned a variable in JS, they need to have unique 178 # Since each import is assigned a variable in JS, they need to have unique
179 # names. 179 # names.
180 counter = 1 180 counter = 1
181 for each in self.module.imports: 181 for each in self.module.imports:
182 each["unique_name"] = "import" + str(counter) 182 each["unique_name"] = "import" + str(counter)
183 counter += 1 183 counter += 1
184 return self.module.imports 184 return self.module.imports
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/js_templates/module.js.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698