OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 library sky_builtin; | |
6 | |
7 import "dart:async"; | |
8 | |
9 // Corelib 'print' implementation. | |
10 void _print(arg) { | |
11 _Logger._printString(arg.toString()); | |
12 } | |
13 | |
14 class _Logger { | |
15 static void _printString(String s) native "Logger_PrintString"; | |
16 } | |
17 | |
18 class _Timer implements Timer { | |
19 _Timer(int milliseconds, | |
20 void callback(Timer timer), | |
21 bool repeating) { | |
22 _id = _create(milliseconds, () { | |
23 if (!repeating) | |
24 _id = 0; | |
25 callback(this); | |
26 }, repeating); | |
27 } | |
28 | |
29 void cancel() { | |
30 _cancel(_id); | |
31 _id = 0; | |
32 } | |
33 | |
34 bool get isActive => _id != 0; | |
35 | |
36 static int _create(int milliseconds, | |
37 void callback(), | |
38 bool repeating) native "Timer_create"; | |
39 static void _cancel(int id) native "Timer_cancel"; | |
40 | |
41 int _id; | |
42 } | |
43 | |
44 void _scheduleMicrotask(void callback()) native "ScheduleMicrotask"; | |
45 Timer _createTimer(int milliseconds, | |
46 void callback(Timer timer), | |
47 bool repeating) { | |
48 return new _Timer(milliseconds, callback, repeating); | |
49 } | |
50 | |
51 String _getBaseURLString() native "GetBaseURLString"; | |
52 Uri _getBaseURL() => Uri.parse(_getBaseURLString()); | |
53 | |
54 _getPrintClosure() => _print; | |
55 _getScheduleMicrotaskClosure() => _scheduleMicrotask; | |
56 _getGetBaseURLClosure() =>_getBaseURL; | |
57 _getCreateTimerClosure() => _createTimer; | |
OLD | NEW |