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

Side by Side Diff: tools/json_schema_compiler/js_interface_generator.py

Issue 1605083002: Elim 'new ChromeEvent' from interface generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_563744_line_wrap
Patch Set: Rebase Created 4 years, 11 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
« no previous file with comments | « no previous file | tools/json_schema_compiler/js_interface_generator_test.py » ('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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 Generator that produces an interface file for the Closure Compiler. 5 Generator that produces an interface file for the Closure Compiler.
6 Note: This is a work in progress, and generated interfaces may require tweaking. 6 Note: This is a work in progress, and generated interfaces may require tweaking.
7 """ 7 """
8 8
9 from code import Code 9 from code import Code
10 from js_util import JsUtil 10 from js_util import JsUtil
(...skipping 28 matching lines...) Expand all
39 .Append()) 39 .Append())
40 40
41 self._AppendInterfaceObject(c) 41 self._AppendInterfaceObject(c)
42 c.Append() 42 c.Append()
43 43
44 c.Sblock('%s.prototype = {' % self._interface) 44 c.Sblock('%s.prototype = {' % self._interface)
45 45
46 for function in self._namespace.functions.values(): 46 for function in self._namespace.functions.values():
47 self._AppendFunction(c, function) 47 self._AppendFunction(c, function)
48 48
49 c.TrimTrailingNewlines()
50 c.Eblock('};')
51 c.Append()
52
49 for event in self._namespace.events.values(): 53 for event in self._namespace.events.values():
50 self._AppendEvent(c, event) 54 self._AppendEvent(c, event)
51 55
52 c.TrimTrailingNewlines() 56 c.TrimTrailingNewlines()
53 57
54 c.Eblock('};')
55
56 return c 58 return c
57 59
58 def _GetHeader(self, tool, namespace): 60 def _GetHeader(self, tool, namespace):
59 """Returns the file header text. 61 """Returns the file header text.
60 """ 62 """
61 return (self._js_util.GetLicense() + '\n' + 63 return (self._js_util.GetLicense() + '\n' +
62 self._js_util.GetInfo(tool) + '\n' + 64 self._js_util.GetInfo(tool) + '\n' +
63 ('/** @fileoverview Interface for %s that can be overriden. */' % 65 ('/** @fileoverview Interface for %s that can be overriden. */' %
64 namespace) + '\n' + 66 namespace) + '\n' +
65 ASSERT); 67 ASSERT);
(...skipping 20 matching lines...) Expand all
86 def _AppendEvent(self, c, event): 88 def _AppendEvent(self, c, event):
87 """Appends the interface for an event. 89 """Appends the interface for an event.
88 """ 90 """
89 c.Sblock(line='/**', line_prefix=' * ') 91 c.Sblock(line='/**', line_prefix=' * ')
90 if (event.description): 92 if (event.description):
91 c.Comment(event.description, comment_prefix='') 93 c.Comment(event.description, comment_prefix='')
92 c.Append('@type {!ChromeEvent}') 94 c.Append('@type {!ChromeEvent}')
93 c.Append(self._js_util.GetSeeLink(self._namespace.name, 'event', 95 c.Append(self._js_util.GetSeeLink(self._namespace.name, 'event',
94 event.name)) 96 event.name))
95 c.Eblock(' */') 97 c.Eblock(' */')
96 c.Append('%s: new ChromeEvent(),' % (event.name)) 98
99 c.Append('%s.prototype.%s;' % (self._interface, event.name))
100
97 c.Append() 101 c.Append()
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/js_interface_generator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698