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 | |
62 callback VoidCallback = void(); | 50 callback VoidCallback = void(); |
63 | 51 |
64 callback BazGreekCallback = void(Baz baz, Greek greek); | 52 callback BazGreekCallback = void(Baz baz, Greek greek); |
65 | 53 |
66 interface Functions { | 54 interface Functions { |
67 // Does something exciting! And what's more, this is a multiline function | 55 // Does something exciting! And what's more, this is a multiline function |
68 // comment! It goes onto multiple lines! | 56 // comment! It goes onto multiple lines! |
69 // |baz| : The baz to use. | 57 // |baz| : The baz to use. |
70 static void doSomething(Baz baz, VoidCallback callback); | 58 static void doSomething(Baz baz, VoidCallback callback); |
71 | 59 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 * maybe: (number|undefined), | 125 * maybe: (number|undefined), |
138 * choice: (string|!chrome.fakeApi.Greek|!Array<number>), | 126 * choice: (string|!chrome.fakeApi.Greek|!Array<number>), |
139 * plainObj: Object, | 127 * plainObj: Object, |
140 * arrayBuff: ArrayBuffer | 128 * arrayBuff: ArrayBuffer |
141 * }} | 129 * }} |
142 * @see https://developer.chrome.com/extensions/fakeApi#type-Baz | 130 * @see https://developer.chrome.com/extensions/fakeApi#type-Baz |
143 */ | 131 */ |
144 chrome.fakeApi.Baz; | 132 chrome.fakeApi.Baz; |
145 | 133 |
146 /** | 134 /** |
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 /** | |
184 * Does something exciting! And what's more, this is a multiline function | 135 * Does something exciting! And what's more, this is a multiline function |
185 * comment! It goes onto multiple lines! | 136 * comment! It goes onto multiple lines! |
186 * @param {!chrome.fakeApi.Baz} baz The baz to use. | 137 * @param {!chrome.fakeApi.Baz} baz The baz to use. |
187 * @param {function():void} callback | 138 * @param {function():void} callback |
188 * @see https://developer.chrome.com/extensions/fakeApi#method-doSomething | 139 * @see https://developer.chrome.com/extensions/fakeApi#method-doSomething |
189 */ | 140 */ |
190 chrome.fakeApi.doSomething = function(baz, callback) {}; | 141 chrome.fakeApi.doSomething = function(baz, callback) {}; |
191 | 142 |
192 /** | 143 /** |
193 * @param {function(!chrome.fakeApi.Baz, !chrome.fakeApi.Greek):void=} callback | 144 * @param {function(!chrome.fakeApi.Baz, !chrome.fakeApi.Greek):void=} callback |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 JsExternsGenerator().Generate(namespace).Render()) | 306 JsExternsGenerator().Generate(namespace).Render()) |
356 | 307 |
357 def testJsonWithInlineObjects(self): | 308 def testJsonWithInlineObjects(self): |
358 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) | 309 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) |
359 self.assertMultiLineEqual(json_expected, | 310 self.assertMultiLineEqual(json_expected, |
360 JsExternsGenerator().Generate(namespace).Render()) | 311 JsExternsGenerator().Generate(namespace).Render()) |
361 | 312 |
362 | 313 |
363 if __name__ == '__main__': | 314 if __name__ == '__main__': |
364 unittest.main() | 315 unittest.main() |
OLD | NEW |