Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: sky/engine/bindings2/builtin.dart

Issue 918333002: Add the c++ code part of bindings2/ (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Updated per earlier reviews Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/bindings2/builtin.cc ('k') | sky/engine/bindings2/builtin_natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/bindings2/builtin.dart
diff --git a/sky/engine/bindings2/builtin.dart b/sky/engine/bindings2/builtin.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8dc83511346b80f7798266fcbd7ab832ecc22c54
--- /dev/null
+++ b/sky/engine/bindings2/builtin.dart
@@ -0,0 +1,53 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+library sky_builtin;
+
+import "dart:async";
+
+// Corelib 'print' implementation.
+void _print(arg) {
+ _Logger._printString(arg.toString());
+}
+
+class _Logger {
+ static void _printString(String s) native "Logger_PrintString";
+}
+
+class _Timer implements Timer {
+ _Timer(int milliseconds,
+ void callback(Timer timer),
+ bool repeating) {
+ _id = _create(milliseconds, () {
+ if (!repeating)
+ _id = 0;
+ callback(this);
+ }, repeating);
+ }
+
+ void cancel() {
+ _cancel(_id);
+ _id = 0;
+ }
+
+ bool get isActive => _id != 0;
+
+ static int _create(int milliseconds,
+ void callback(),
+ bool repeating) native "Timer_create";
+ static void _cancel(int id) native "Timer_cancel";
+
+ int _id;
+}
+
+void _scheduleMicrotask(void callback()) native "ScheduleMicrotask";
+Timer _createTimer(int milliseconds,
+ void callback(Timer timer),
+ bool repeating) {
+ return new _Timer(milliseconds, callback, repeating);
+}
+
+_getPrintClosure() => _print;
+_getScheduleMicrotaskClosure() => _scheduleMicrotask;
+_getCreateTimerClosure() => _createTimer;
« no previous file with comments | « sky/engine/bindings2/builtin.cc ('k') | sky/engine/bindings2/builtin_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698