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 26 matching lines...) Expand all Loading... |
37 Greek letter; | 37 Greek letter; |
38 Greek? optionalLetter; | 38 Greek? optionalLetter; |
39 long[] arr; | 39 long[] arr; |
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 }; | 48 }; |
48 | 49 |
49 callback VoidCallback = void(); | 50 callback VoidCallback = void(); |
50 | 51 |
51 callback BazGreekCallback = void(Baz baz, Greek greek); | 52 callback BazGreekCallback = void(Baz baz, Greek greek); |
52 | 53 |
53 interface Functions { | 54 interface Functions { |
54 // 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 |
55 // comment! It goes onto multiple lines! | 56 // comment! It goes onto multiple lines! |
56 // |baz| : The baz to use. | 57 // |baz| : The baz to use. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 * b: boolean, | 117 * b: boolean, |
117 * letter: !chrome.fakeApi.Greek, | 118 * letter: !chrome.fakeApi.Greek, |
118 * optionalLetter: (!chrome.fakeApi.Greek|undefined), | 119 * optionalLetter: (!chrome.fakeApi.Greek|undefined), |
119 * arr: !Array<number>, | 120 * arr: !Array<number>, |
120 * optionalObjArr: (!Array<!chrome.fakeApi.Bar>|undefined), | 121 * optionalObjArr: (!Array<!chrome.fakeApi.Bar>|undefined), |
121 * enumArr: !Array<!chrome.fakeApi.Greek>, | 122 * enumArr: !Array<!chrome.fakeApi.Greek>, |
122 * anythingGoes: !Array<*>, | 123 * anythingGoes: !Array<*>, |
123 * obj: !chrome.fakeApi.Bar, | 124 * obj: !chrome.fakeApi.Bar, |
124 * maybe: (number|undefined), | 125 * maybe: (number|undefined), |
125 * choice: (string|!chrome.fakeApi.Greek|!Array<number>), | 126 * choice: (string|!chrome.fakeApi.Greek|!Array<number>), |
126 * plainObj: Object | 127 * plainObj: Object, |
| 128 * arrayBuff: ArrayBuffer |
127 * }} | 129 * }} |
128 * @see https://developer.chrome.com/extensions/fakeApi#type-Baz | 130 * @see https://developer.chrome.com/extensions/fakeApi#type-Baz |
129 */ | 131 */ |
130 chrome.fakeApi.Baz; | 132 chrome.fakeApi.Baz; |
131 | 133 |
132 /** | 134 /** |
133 * 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 |
134 * comment! It goes onto multiple lines! | 136 * comment! It goes onto multiple lines! |
135 * @param {!chrome.fakeApi.Baz} baz The baz to use. | 137 * @param {!chrome.fakeApi.Baz} baz The baz to use. |
136 * @param {function():void} callback | 138 * @param {function():void} callback |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 "description": "The bar." | 197 "description": "The bar." |
196 }, | 198 }, |
197 "baz": { | 199 "baz": { |
198 "type": "object", | 200 "type": "object", |
199 "description": "Inception object.", | 201 "description": "Inception object.", |
200 "properties": { | 202 "properties": { |
201 "depth": { | 203 "depth": { |
202 "type": "integer" | 204 "type": "integer" |
203 } | 205 } |
204 } | 206 } |
| 207 }, |
| 208 "quu": { |
| 209 "type": "binary", |
| 210 "description": "The array buffer" |
205 } | 211 } |
206 } | 212 } |
207 }, | 213 }, |
208 { | 214 { |
209 "name": "callback", | 215 "name": "callback", |
210 "type": "function", | 216 "type": "function", |
211 "parameters": [ | 217 "parameters": [ |
212 { | 218 { |
213 "type": "object", | 219 "type": "object", |
214 "name": "returnObj", | 220 "name": "returnObj", |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 _5NUM_FIRST: '5NumFirst', | 265 _5NUM_FIRST: '5NumFirst', |
260 _3JUST_PLAIN_OLD_MEAN: '3Just-plainOld_MEAN', | 266 _3JUST_PLAIN_OLD_MEAN: '3Just-plainOld_MEAN', |
261 }; | 267 }; |
262 | 268 |
263 /** | 269 /** |
264 * @param {{ | 270 * @param {{ |
265 * foo: (boolean|undefined), | 271 * foo: (boolean|undefined), |
266 * bar: number, | 272 * bar: number, |
267 * baz: { | 273 * baz: { |
268 * depth: number | 274 * depth: number |
269 * } | 275 * }, |
| 276 * quu: ArrayBuffer |
270 * }} inlineObj Evil inline object! With a super duper duper long string | 277 * }} inlineObj Evil inline object! With a super duper duper long string |
271 * description that causes problems! | 278 * description that causes problems! |
272 * @param {function({ | 279 * @param {function({ |
273 * str: string | 280 * str: string |
274 * }):void} callback The callback to this heinous method | 281 * }):void} callback The callback to this heinous method |
275 * @return {{ | 282 * @return {{ |
276 * str: string, | 283 * str: string, |
277 * int: number | 284 * int: number |
278 * }} | 285 * }} |
279 * @see https://developer.chrome.com/extensions/fakeJson#method-funcWithInlineOb
j | 286 * @see https://developer.chrome.com/extensions/fakeJson#method-funcWithInlineOb
j |
(...skipping 19 matching lines...) Expand all Loading... |
299 JsExternsGenerator().Generate(namespace).Render()) | 306 JsExternsGenerator().Generate(namespace).Render()) |
300 | 307 |
301 def testJsonWithInlineObjects(self): | 308 def testJsonWithInlineObjects(self): |
302 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) | 309 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) |
303 self.assertMultiLineEqual(json_expected, | 310 self.assertMultiLineEqual(json_expected, |
304 JsExternsGenerator().Generate(namespace).Render()) | 311 JsExternsGenerator().Generate(namespace).Render()) |
305 | 312 |
306 | 313 |
307 if __name__ == '__main__': | 314 if __name__ == '__main__': |
308 unittest.main() | 315 unittest.main() |
OLD | NEW |