OLD | NEW |
1 APIS | 1 APIS |
2 ==== | 2 ==== |
3 | 3 |
4 The Sky core API | 4 The Sky core API |
5 ---------------- | 5 ---------------- |
6 | 6 |
7 ``` | 7 ```javascript |
8 module 'sky:core' { | 8 module 'sky:core' { |
9 | 9 |
10 // EVENTS | 10 // EVENTS |
11 | 11 |
12 interface Event { | 12 interface Event { |
13 constructor (String type, Boolean bubbles, any data); // O(1) | 13 constructor (String type, Boolean bubbles, any data); // O(1) |
14 readonly attribute String type; // O(1) | 14 readonly attribute String type; // O(1) |
15 readonly attribute Boolean bubbles; // O(1) | 15 readonly attribute Boolean bubbles; // O(1) |
16 attribute any data; // O(1) | 16 attribute any data; // O(1) |
17 | 17 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 The Sky IDL language is used to describe JS APIs found in Sky, in | 211 The Sky IDL language is used to describe JS APIs found in Sky, in |
212 particular, the JS APIs exposed by the four magical imports defined in | 212 particular, the JS APIs exposed by the four magical imports defined in |
213 this document. | 213 this document. |
214 | 214 |
215 Sky IDL definitions are typically compiled to C++ that exposes the C++ | 215 Sky IDL definitions are typically compiled to C++ that exposes the C++ |
216 implementations of the APIs to JavaScript. | 216 implementations of the APIs to JavaScript. |
217 | 217 |
218 Sky IDL works more or less the same as Web IDL but the syntax is a bit | 218 Sky IDL works more or less the same as Web IDL but the syntax is a bit |
219 different. | 219 different. |
220 | 220 |
221 ``` | 221 ```javascript |
222 module 'sky:modulename' { | 222 module 'sky:modulename' { |
223 | 223 |
224 // this is a comment | 224 // this is a comment |
225 | 225 |
226 typedef NewType OldType; // useful when OldType is a commonly-used union | 226 typedef NewType OldType; // useful when OldType is a commonly-used union |
227 | 227 |
228 interface InterfaceName { | 228 interface InterfaceName { |
229 // an interface corresponds to a JavaScript prototype | 229 // an interface corresponds to a JavaScript prototype |
230 } | 230 } |
231 | 231 |
(...skipping 28 matching lines...) Expand all Loading... |
260 | 260 |
261 // the module can have properties and methods also | 261 // the module can have properties and methods also |
262 attribute String Foo; | 262 attribute String Foo; |
263 void method(); | 263 void method(); |
264 | 264 |
265 } | 265 } |
266 ``` | 266 ``` |
267 | 267 |
268 The following types are available: | 268 The following types are available: |
269 | 269 |
270 * ```Integer``` - WebIDL ```long long``` | 270 * ``Integer`` - WebIDL ``long long`` |
271 * ```Float``` - WebIDL ```double``` | 271 * ``Float`` - WebIDL ``double`` |
272 * ```String``` - WebIDL ```USVString``` | 272 * ``String`` - WebIDL ``USVString`` |
273 * ```Boolean``` - WebIDL ```boolean``` | 273 * ``Boolean`` - WebIDL ``boolean`` |
274 # ```Object``` - WebIDL ```object``` | 274 # ``Object`` - WebIDL ``object`` |
275 * ```InterfaceName``` - an instance of the interface InterfaceName | 275 * ``InterfaceName`` - an instance of the interface InterfaceName |
276 * ```Promise<Type>``` - WebIDL ```Promise<T>``` | 276 * ``Promise<Type>`` - WebIDL ``Promise<T>`` |
277 * ```Array<Type>``` - WebIDL ```sequence<T>``` | 277 * ``Array<Type>`` - WebIDL ``sequence<T>`` |
278 * ```Dictionary``` - unordered set of name-value String-String pairs with no dup
licate names | 278 * ``Dictionary`` - unordered set of name-value String-String pairs with no dupli
cate names |
279 * ```Type?``` - union of Type and the singleton type with value "null" (WebIDL n
ullable) | 279 * ``Type?`` - union of Type and the singleton type with value "null" (WebIDL nul
lable) |
280 * ```(Type1 or Type2)``` - union of Type1 and Type2 (WebIDL union) | 280 * ``(Type1 or Type2)`` - union of Type1 and Type2 (WebIDL union) |
281 * ```any``` - union of all types (WebIDL ```any```) | 281 * ``any`` - union of all types (WebIDL ``any``) |
282 | 282 |
283 Methods that return nothing (undefined, in JS) use the keyword "void" | 283 Methods that return nothing (undefined, in JS) use the keyword "void" |
284 instead of a type. | 284 instead of a type. |
285 | 285 |
286 TODO(ianh): Figure out what should happen with omitted and extraneous parameters | 286 TODO(ianh): Figure out what should happen with omitted and extraneous parameters |
287 | 287 |
288 TODO(ianh): Define in detail how this actually works | 288 TODO(ianh): Define in detail how this actually works |
289 | 289 |
290 Mojom IDL | 290 Mojom IDL |
291 --------- | 291 --------- |
292 | 292 |
293 The Mojom IDL language is used to describe the APIs exposed over Mojo | 293 The Mojom IDL language is used to describe the APIs exposed over Mojo |
294 pipes. | 294 pipes. |
295 | 295 |
296 Mojom IDL definitions are typically compiled to wrappers in each | 296 Mojom IDL definitions are typically compiled to wrappers in each |
297 language, which are then used as imports. | 297 language, which are then used as imports. |
298 | 298 |
299 TODO(ianh): Define in detail how this actually works | 299 TODO(ianh): Define in detail how this actually works |
300 | 300 |
301 | 301 |
302 Notes | 302 Notes |
303 ----- | 303 ----- |
304 ``` | 304 ```javascript |
305 global object = {} // with Math, RegExp, etc | 305 global object = {} // with Math, RegExp, etc |
306 | 306 |
307 magical imports: | 307 magical imports: |
308 the core mojo fabric JS API sky:mojo:fabric:core | 308 the core mojo fabric JS API sky:mojo:fabric:core |
309 the asyncWait/cancelWait mojo fabric JS API (interface to IPC thread) sky:moj
o:fabric:ipc | 309 the asyncWait/cancelWait mojo fabric JS API (interface to IPC thread) sky:moj
o:fabric:ipc |
310 the mojom for the shell, proxying through C++ so that the shell pipe isn't exp
osed sky:mojo:shell | 310 the mojom for the shell, proxying through C++ so that the shell pipe isn't exp
osed sky:mojo:shell |
311 the sky API sky:core | 311 the sky API sky:core |
312 ``` | 312 ``` |
313 | 313 |
314 TODO(ianh): determine if we want to separate the "this" from the | 314 TODO(ianh): determine if we want to separate the "this" from the |
315 Document, especially for Modules, so that exposing a module's element | 315 Document, especially for Modules, so that exposing a module's element |
316 doesn't expose the module's exports attribute. | 316 doesn't expose the module's exports attribute. |
OLD | NEW |