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 notOptionalLong; |
| 52 long? optionalLong; |
| 53 |
| 54 // A map from string to number. |
| 55 // <jsexterns>@type {Object<string, number>}</jsexterns> |
| 56 object dict; |
| 57 |
| 58 static void go(); |
| 59 static void stop(); |
| 60 }; |
| 61 |
50 callback VoidCallback = void(); | 62 callback VoidCallback = void(); |
51 | 63 |
52 callback BazGreekCallback = void(Baz baz, Greek greek); | 64 callback BazGreekCallback = void(Baz baz, Greek greek); |
53 | 65 |
54 interface Functions { | 66 interface Functions { |
55 // Does something exciting! And what's more, this is a multiline function | 67 // Does something exciting! And what's more, this is a multiline function |
56 // comment! It goes onto multiple lines! | 68 // comment! It goes onto multiple lines! |
57 // |baz| : The baz to use. | 69 // |baz| : The baz to use. |
58 static void doSomething(Baz baz, VoidCallback callback); | 70 static void doSomething(Baz baz, VoidCallback callback); |
59 | 71 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 * maybe: (number|undefined), | 137 * maybe: (number|undefined), |
126 * choice: (string|!chrome.fakeApi.Greek|!Array<number>), | 138 * choice: (string|!chrome.fakeApi.Greek|!Array<number>), |
127 * plainObj: Object, | 139 * plainObj: Object, |
128 * arrayBuff: ArrayBuffer | 140 * arrayBuff: ArrayBuffer |
129 * }} | 141 * }} |
130 * @see https://developer.chrome.com/extensions/fakeApi#type-Baz | 142 * @see https://developer.chrome.com/extensions/fakeApi#type-Baz |
131 */ | 143 */ |
132 chrome.fakeApi.Baz; | 144 chrome.fakeApi.Baz; |
133 | 145 |
134 /** | 146 /** |
| 147 * @constructor |
| 148 * @private |
| 149 * @see https://developer.chrome.com/extensions/fakeApi#type-Qux |
| 150 */ |
| 151 chrome.fakeApi.Qux = function() {}; |
| 152 |
| 153 /** |
| 154 * @type {number} |
| 155 * @see https://developer.chrome.com/extensions/fakeApi#type-notOptionalLong |
| 156 */ |
| 157 chrome.fakeApi.Qux.prototype.notOptionalLong; |
| 158 |
| 159 /** |
| 160 * @type {(number|undefined)} |
| 161 * @see https://developer.chrome.com/extensions/fakeApi#type-optionalLong |
| 162 */ |
| 163 chrome.fakeApi.Qux.prototype.optionalLong; |
| 164 |
| 165 /** |
| 166 * A map from string to number. |
| 167 * @type {Object<string, number>} |
| 168 * @see https://developer.chrome.com/extensions/fakeApi#type-dict |
| 169 */ |
| 170 chrome.fakeApi.Qux.prototype.dict; |
| 171 |
| 172 /** |
| 173 * @see https://developer.chrome.com/extensions/fakeApi#method-go |
| 174 */ |
| 175 chrome.fakeApi.Qux.prototype.go = function() {}; |
| 176 |
| 177 /** |
| 178 * @see https://developer.chrome.com/extensions/fakeApi#method-stop |
| 179 */ |
| 180 chrome.fakeApi.Qux.prototype.stop = function() {}; |
| 181 |
| 182 |
| 183 /** |
135 * Does something exciting! And what's more, this is a multiline function | 184 * Does something exciting! And what's more, this is a multiline function |
136 * comment! It goes onto multiple lines! | 185 * comment! It goes onto multiple lines! |
137 * @param {!chrome.fakeApi.Baz} baz The baz to use. | 186 * @param {!chrome.fakeApi.Baz} baz The baz to use. |
138 * @param {function():void} callback | 187 * @param {function():void} callback |
139 * @see https://developer.chrome.com/extensions/fakeApi#method-doSomething | 188 * @see https://developer.chrome.com/extensions/fakeApi#method-doSomething |
140 */ | 189 */ |
141 chrome.fakeApi.doSomething = function(baz, callback) {}; | 190 chrome.fakeApi.doSomething = function(baz, callback) {}; |
142 | 191 |
143 /** | 192 /** |
144 * @param {function(!chrome.fakeApi.Baz, !chrome.fakeApi.Greek):void=} callback | 193 * @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()) | 355 JsExternsGenerator().Generate(namespace).Render()) |
307 | 356 |
308 def testJsonWithInlineObjects(self): | 357 def testJsonWithInlineObjects(self): |
309 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) | 358 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) |
310 self.assertMultiLineEqual(json_expected, | 359 self.assertMultiLineEqual(json_expected, |
311 JsExternsGenerator().Generate(namespace).Render()) | 360 JsExternsGenerator().Generate(namespace).Render()) |
312 | 361 |
313 | 362 |
314 if __name__ == '__main__': | 363 if __name__ == '__main__': |
315 unittest.main() | 364 unittest.main() |
OLD | NEW |