OLD | NEW |
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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 mojom.MSGPIPE: "null", | 24 mojom.MSGPIPE: "null", |
25 mojom.SHAREDBUFFER: "null", | 25 mojom.SHAREDBUFFER: "null", |
26 mojom.NULLABLE_HANDLE: "null", | 26 mojom.NULLABLE_HANDLE: "null", |
27 mojom.NULLABLE_DCPIPE: "null", | 27 mojom.NULLABLE_DCPIPE: "null", |
28 mojom.NULLABLE_DPPIPE: "null", | 28 mojom.NULLABLE_DPPIPE: "null", |
29 mojom.NULLABLE_MSGPIPE: "null", | 29 mojom.NULLABLE_MSGPIPE: "null", |
30 mojom.NULLABLE_SHAREDBUFFER: "null", | 30 mojom.NULLABLE_SHAREDBUFFER: "null", |
31 mojom.INT64: "0", | 31 mojom.INT64: "0", |
32 mojom.UINT64: "0", | 32 mojom.UINT64: "0", |
33 mojom.DOUBLE: "0", | 33 mojom.DOUBLE: "0", |
34 mojom.STRING: '""', | 34 mojom.STRING: "null", |
35 mojom.NULLABLE_STRING: '""' | 35 mojom.NULLABLE_STRING: "null" |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 def JavaScriptType(kind): | 39 def JavaScriptType(kind): |
40 if kind.imported_from: | 40 if kind.imported_from: |
41 return kind.imported_from["unique_name"] + "." + kind.name | 41 return kind.imported_from["unique_name"] + "." + kind.name |
42 return kind.name | 42 return kind.name |
43 | 43 |
44 | 44 |
45 def JavaScriptDefaultValue(field): | 45 def JavaScriptDefaultValue(field): |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 self.Write(self.GenerateJsModule(), "%s.js" % self.module.name) | 266 self.Write(self.GenerateJsModule(), "%s.js" % self.module.name) |
267 | 267 |
268 def GetImports(self): | 268 def GetImports(self): |
269 # Since each import is assigned a variable in JS, they need to have unique | 269 # Since each import is assigned a variable in JS, they need to have unique |
270 # names. | 270 # names. |
271 counter = 1 | 271 counter = 1 |
272 for each in self.module.imports: | 272 for each in self.module.imports: |
273 each["unique_name"] = "import" + str(counter) | 273 each["unique_name"] = "import" + str(counter) |
274 counter += 1 | 274 counter += 1 |
275 return self.module.imports | 275 return self.module.imports |
OLD | NEW |