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 { |
| 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 * @see https://developer.chrome.com/extensions/fakeApi#type-Qux |
| 143 */ |
| 144 chrome.fakeApi.Qux = function() {}; |
| 145 |
| 146 /** |
| 147 * @type {number} |
| 148 * @see https://developer.chrome.com/extensions/fakeApi#type-num |
| 149 */ |
| 150 chrome.fakeApi.Qux.prototype.num; |
| 151 |
| 152 /** |
| 153 * @see https://developer.chrome.com/extensions/fakeApi#method-go |
| 154 */ |
| 155 chrome.fakeApi.Qux.prototype.go = function() {}; |
| 156 |
| 157 /** |
| 158 * @see https://developer.chrome.com/extensions/fakeApi#method-stop |
| 159 */ |
| 160 chrome.fakeApi.Qux.prototype.stop = function() {}; |
| 161 |
| 162 |
| 163 /** |
135 * Does something exciting! And what's more, this is a multiline function | 164 * Does something exciting! And what's more, this is a multiline function |
136 * comment! It goes onto multiple lines! | 165 * comment! It goes onto multiple lines! |
137 * @param {!chrome.fakeApi.Baz} baz The baz to use. | 166 * @param {!chrome.fakeApi.Baz} baz The baz to use. |
138 * @param {function():void} callback | 167 * @param {function():void} callback |
139 * @see https://developer.chrome.com/extensions/fakeApi#method-doSomething | 168 * @see https://developer.chrome.com/extensions/fakeApi#method-doSomething |
140 */ | 169 */ |
141 chrome.fakeApi.doSomething = function(baz, callback) {}; | 170 chrome.fakeApi.doSomething = function(baz, callback) {}; |
142 | 171 |
143 /** | 172 /** |
144 * @param {function(!chrome.fakeApi.Baz, !chrome.fakeApi.Greek):void=} callback | 173 * @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()) | 335 JsExternsGenerator().Generate(namespace).Render()) |
307 | 336 |
308 def testJsonWithInlineObjects(self): | 337 def testJsonWithInlineObjects(self): |
309 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) | 338 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) |
310 self.assertMultiLineEqual(json_expected, | 339 self.assertMultiLineEqual(json_expected, |
311 JsExternsGenerator().Generate(namespace).Render()) | 340 JsExternsGenerator().Generate(namespace).Render()) |
312 | 341 |
313 | 342 |
314 if __name__ == '__main__': | 343 if __name__ == '__main__': |
315 unittest.main() | 344 unittest.main() |
OLD | NEW |