OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import idl_schema | 6 import idl_schema |
7 import json_parse | 7 import json_parse |
8 from js_externs_generator import JsExternsGenerator | 8 from js_externs_generator import JsExternsGenerator |
9 from datetime import datetime | 9 from datetime import datetime |
10 import model | 10 import model |
(...skipping 29 matching lines...) Expand all Loading... | |
40 Bar[]? optionalObjArr; | 40 Bar[]? optionalObjArr; |
41 Greek[] enumArr; | 41 Greek[] enumArr; |
42 any[] anythingGoes; | 42 any[] anythingGoes; |
43 Bar obj; | 43 Bar obj; |
44 long? maybe; | 44 long? maybe; |
45 (DOMString or Greek or long[]) choice; | 45 (DOMString or Greek or long[]) choice; |
46 object plainObj; | 46 object plainObj; |
47 ArrayBuffer arrayBuff; | 47 ArrayBuffer arrayBuff; |
48 }; | 48 }; |
49 | 49 |
50 dictionary Qux { | |
Devlin
2017/01/12 17:28:47
Can we expand this to use nullables and jsexterns?
dmazzoni
2017/01/13 21:22:53
Done.
| |
51 long num; | |
52 static void go(); | |
53 static void stop(); | |
54 }; | |
55 | |
50 callback VoidCallback = void(); | 56 callback VoidCallback = void(); |
51 | 57 |
52 callback BazGreekCallback = void(Baz baz, Greek greek); | 58 callback BazGreekCallback = void(Baz baz, Greek greek); |
53 | 59 |
54 interface Functions { | 60 interface Functions { |
55 // Does something exciting! And what's more, this is a multiline function | 61 // Does something exciting! And what's more, this is a multiline function |
56 // comment! It goes onto multiple lines! | 62 // comment! It goes onto multiple lines! |
57 // |baz| : The baz to use. | 63 // |baz| : The baz to use. |
58 static void doSomething(Baz baz, VoidCallback callback); | 64 static void doSomething(Baz baz, VoidCallback callback); |
59 | 65 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 * maybe: (number|undefined), | 131 * maybe: (number|undefined), |
126 * choice: (string|!chrome.fakeApi.Greek|!Array<number>), | 132 * choice: (string|!chrome.fakeApi.Greek|!Array<number>), |
127 * plainObj: Object, | 133 * plainObj: Object, |
128 * arrayBuff: ArrayBuffer | 134 * arrayBuff: ArrayBuffer |
129 * }} | 135 * }} |
130 * @see https://developer.chrome.com/extensions/fakeApi#type-Baz | 136 * @see https://developer.chrome.com/extensions/fakeApi#type-Baz |
131 */ | 137 */ |
132 chrome.fakeApi.Baz; | 138 chrome.fakeApi.Baz; |
133 | 139 |
134 /** | 140 /** |
141 * @constructor | |
142 * @private | |
143 * @see https://developer.chrome.com/extensions/fakeApi#type-Qux | |
144 */ | |
145 chrome.fakeApi.Qux = function() {}; | |
146 | |
147 /** | |
148 * @type {number} | |
149 * @see https://developer.chrome.com/extensions/fakeApi#type-num | |
150 */ | |
151 chrome.fakeApi.Qux.prototype.num; | |
152 | |
153 /** | |
154 * @see https://developer.chrome.com/extensions/fakeApi#method-go | |
155 */ | |
156 chrome.fakeApi.Qux.prototype.go = function() {}; | |
157 | |
158 /** | |
159 * @see https://developer.chrome.com/extensions/fakeApi#method-stop | |
160 */ | |
161 chrome.fakeApi.Qux.prototype.stop = function() {}; | |
162 | |
163 | |
164 /** | |
135 * Does something exciting! And what's more, this is a multiline function | 165 * Does something exciting! And what's more, this is a multiline function |
136 * comment! It goes onto multiple lines! | 166 * comment! It goes onto multiple lines! |
137 * @param {!chrome.fakeApi.Baz} baz The baz to use. | 167 * @param {!chrome.fakeApi.Baz} baz The baz to use. |
138 * @param {function():void} callback | 168 * @param {function():void} callback |
139 * @see https://developer.chrome.com/extensions/fakeApi#method-doSomething | 169 * @see https://developer.chrome.com/extensions/fakeApi#method-doSomething |
140 */ | 170 */ |
141 chrome.fakeApi.doSomething = function(baz, callback) {}; | 171 chrome.fakeApi.doSomething = function(baz, callback) {}; |
142 | 172 |
143 /** | 173 /** |
144 * @param {function(!chrome.fakeApi.Baz, !chrome.fakeApi.Greek):void=} callback | 174 * @param {function(!chrome.fakeApi.Baz, !chrome.fakeApi.Greek):void=} callback |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 JsExternsGenerator().Generate(namespace).Render()) | 336 JsExternsGenerator().Generate(namespace).Render()) |
307 | 337 |
308 def testJsonWithInlineObjects(self): | 338 def testJsonWithInlineObjects(self): |
309 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) | 339 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) |
310 self.assertMultiLineEqual(json_expected, | 340 self.assertMultiLineEqual(json_expected, |
311 JsExternsGenerator().Generate(namespace).Render()) | 341 JsExternsGenerator().Generate(namespace).Render()) |
312 | 342 |
313 | 343 |
314 if __name__ == '__main__': | 344 if __name__ == '__main__': |
315 unittest.main() | 345 unittest.main() |
OLD | NEW |