| OLD | NEW |
| 1 Sky Module System | 1 Sky Module System |
| 2 ================= | 2 ================= |
| 3 | 3 |
| 4 This document describes the Sky module system. | 4 This document describes the Sky module system. |
| 5 | 5 |
| 6 Overview | 6 Overview |
| 7 -------- | 7 -------- |
| 8 | 8 |
| 9 The Sky module system is based on the ``import`` element. In its | 9 The Sky module system is based on the ``import`` element. In its |
| 10 most basic form, you import a module as follows: | 10 most basic form, you import a module as follows: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 element, all the libraries are bound to the same name. | 64 element, all the libraries are bound to the same name. |
| 65 | 65 |
| 66 At the end of the ``<script>`` block's source, if it parsed correctly | 66 At the end of the ``<script>`` block's source, if it parsed correctly |
| 67 and completely, the conceptual equivalent of the following code is | 67 and completely, the conceptual equivalent of the following code is |
| 68 appended (but without affecting the library's list of declarations and | 68 appended (but without affecting the library's list of declarations and |
| 69 without any possibility of it clashing with identifiers described in | 69 without any possibility of it clashing with identifiers described in |
| 70 the library itself): | 70 the library itself): |
| 71 | 71 |
| 72 ```dart | 72 ```dart |
| 73 class _ { } | 73 class _ { } |
| 74 void main() { | 74 void main(ScriptElement script) { |
| 75 LibraryMirror library = reflectClass(_).owner as LibraryMirror; | 75 LibraryMirror library = reflectClass(_).owner as LibraryMirror; |
| 76 if (library.declarations.containsKey(#init) && library.declarations[#init] is
MethodMirror) | 76 if (library.declarations.containsKey(#_init) && library.declarations[#_init] i
s MethodMirror) |
| 77 init(); | 77 _init(script); |
| 78 AutomaticMetadata.runLibrary(library, module); | 78 AutomaticMetadata.runLibrary(library, module, script); |
| 79 } | 79 } |
| 80 ``` | 80 ``` |
| 81 | 81 |
| 82 Then, that ``main()`` function is called. | 82 Then, that ``main(script)`` function is called, with ``script`` set to |
| 83 the ``ScriptElement`` object representing the relevant ``<script>`` |
| 84 element. |
| 83 | 85 |
| 84 TODO(ianh): decide what URL and name we should give the libraries, as | 86 TODO(ianh): decide what URL and name we should give the libraries, as |
| 85 exposed in MirrorSystem.getName(libraryMirror.qualifiedName) etc | 87 exposed in MirrorSystem.getName(libraryMirror.qualifiedName) etc |
| 86 | 88 |
| 87 The ``Module`` class is defined in ``dart:sky`` as follows: | 89 The ``Module`` class is defined in ``dart:sky`` as follows: |
| 88 | 90 |
| 89 ```dart | 91 ```dart |
| 90 abstract class AbstractModule extends EventTarget { | 92 abstract class AbstractModule extends EventTarget { |
| 91 AbstractModule({this.url, this.elements}); | 93 AbstractModule({this.url, this.elements}); |
| 92 | 94 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 122 } | 124 } |
| 123 | 125 |
| 124 class Application extends AbstractModule { | 126 class Application extends AbstractModule { |
| 125 Application({String url, Root elements, this.gestureManager}) : | 127 Application({String url, Root elements, this.gestureManager}) : |
| 126 super(url: url, elements: elements); // O(1) | 128 super(url: url, elements: elements); // O(1) |
| 127 external String get title; // O(1) | 129 external String get title; // O(1) |
| 128 external void set title(String newValue); // O(1) | 130 external void set title(String newValue); // O(1) |
| 129 final GestureManager gestureManager; | 131 final GestureManager gestureManager; |
| 130 } | 132 } |
| 131 ``` | 133 ``` |
| OLD | NEW |