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

Unified Diff: mojo/public/dart/system/lib/src/types.dart

Issue 674383002: Initial work on Dart bindings for Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Merge. Work on templates. Created 6 years, 1 month 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 | « mojo/public/dart/system/lib/src/mojo_dart_system.cc ('k') | mojo/public/dart/system/tests/core_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/dart/system/lib/src/types.dart
diff --git a/mojo/public/dart/system/lib/src/types.dart b/mojo/public/dart/system/lib/src/types.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c14934ebe38e6b8633639b9818b2c461abda155b
--- /dev/null
+++ b/mojo/public/dart/system/lib/src/types.dart
@@ -0,0 +1,69 @@
+// 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.
+
+part of core;
+
+class MojoResult {
+ static const int OK = 0;
+ static const int CANCELLED = -1;
+ static const int UNKNOWN = -2;
+ static const int INVALID_ARGUMENT = -3;
+ static const int DEADLINE_EXCEEDED = -4;
+ static const int NOT_FOUND = -5;
+ static const int ALREADY_EXISTS = -6;
+ static const int PERMISSION_DENIED = -7;
+ static const int RESOURCE_EXHAUSTED = -8;
+ static const int FAILED_PRECONDITION = -9;
+ static const int ABORTED = -10;
+ static const int OUT_OF_RANGE = -11;
+ static const int UNIMPLEMENTED = -12;
+ static const int INTERNAL = -13;
+ static const int UNAVAILABLE = -14;
+ static const int DATA_LOSS = -15;
+ static const int BUSY = -16;
+ static const int SHOULD_WAIT = -17;
+
+ static bool isResult(int value) => (value <= OK) && (value >= SHOULD_WAIT);
+
+ static bool isOk(int value) => (value == OK);
+ static bool isCancelled(int value) => (value == CANCELLED);
+ static bool isUnknown(int value) => (value == UNKNOWN);
+ static bool isInvalidArgument(int value) => (value == INVALID_ARGUMENT);
+ static bool isDeadlineExceeded(int value) => (value == DEADLINE_EXCEEDED);
+ static bool isNotFound(int value) => (value == NOT_FOUND);
+ static bool isAlreadExists(int value) => (value == ALREADY_EXISTS);
+ static bool isPermissionDenied(int value) => (value == PERMISSION_DENIED);
+ static bool isResourceExhausted(int value) => (value == RESOURCE_EXHAUSTED);
+ static bool isFailedPrecondition(int value) => (value == FAILED_PRECONDITION);
+ static bool isAborted(int value) => (value == ABORTED);
+ static bool isOutOfRange(int value) => (value == OUT_OF_RANGE);
+ static bool isUnimplemented(int value) => (value == UNIMPLEMENTED);
+ static bool isInternal(int value) => (value == INTERNAL);
+ static bool isUnavailable(int value) => (value == UNAVAILABLE);
+ static bool isDataLoss(int value) => (value == DATA_LOSS);
+ static bool isBusy(int value) => (value == BUSY);
+ static bool isShouldWait(int value) => (value == SHOULD_WAIT);
+}
+
+
+class MojoHandleSignals {
+ static const int NONE = 0;
+ static const int READABLE = 1 << 0;
+ static const int WRITABLE = 1 << 1;
+ static const int READWRITE = READABLE | WRITABLE;
+
+ static bool isReadable(int mask) => (mask & READABLE) == READABLE;
+ static bool isWritable(int mask) => (mask & WRITABLE) == WRITABLE;
+ static bool isReadWrite(int mask) => (mask & READWRITE) == READWRITE;
+ static int toggleWrite(int mask) =>
+ isWritable(mask) ? (mask & ~WRITABLE) : (mask | WRITABLE);
+}
+
+
+class MojoHandleSignalsState {
+ const MojoHandleSignalsState(this.satisfied_signals,
+ this.satisfiable_signals);
+ final int satisfied_signals;
+ final int satisfiable_signals;
+}
« no previous file with comments | « mojo/public/dart/system/lib/src/mojo_dart_system.cc ('k') | mojo/public/dart/system/tests/core_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698