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

Unified Diff: mojo/dart/packages/mojo/lib/src/buffer.dart

Issue 1439993003: Dart: Avoid MojoResult and MojoHandleSignals constructors. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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/dart/embedder/io/socket_patch.dart ('k') | mojo/dart/packages/mojo/lib/src/data_pipe.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/packages/mojo/lib/src/buffer.dart
diff --git a/mojo/dart/packages/mojo/lib/src/buffer.dart b/mojo/dart/packages/mojo/lib/src/buffer.dart
index 5e153be576f9ccc9647519e7797492f6ff872878..c218845c2e00f9eb6af3ed84e5c51b4ebd2c1d4b 100644
--- a/mojo/dart/packages/mojo/lib/src/buffer.dart
+++ b/mojo/dart/packages/mojo/lib/src/buffer.dart
@@ -10,11 +10,11 @@ class MojoSharedBuffer {
static const int MAP_FLAG_NONE = 0;
MojoHandle handle;
- MojoResult status;
ByteData mapping;
+ int status;
MojoSharedBuffer(this.handle,
- [this.status = MojoResult.OK, this.mapping = null]);
+ [this.status = MojoResult.kOk, this.mapping = null]);
factory MojoSharedBuffer.create(int numBytes, [int flags = 0]) {
List result = MojoSharedBufferNatives.Create(numBytes, flags);
@@ -22,13 +22,12 @@ class MojoSharedBuffer {
return null;
}
assert((result is List) && (result.length == 2));
- var r = new MojoResult(result[0]);
- if (!r.isOk) {
+ if (result[0] != MojoResult.kOk) {
return null;
}
MojoSharedBuffer buf =
- new MojoSharedBuffer(new MojoHandle(result[1]), r, null);
+ new MojoSharedBuffer(new MojoHandle(result[1]), result[0], null);
return buf;
}
@@ -38,47 +37,46 @@ class MojoSharedBuffer {
return null;
}
assert((result is List) && (result.length == 2));
- var r = new MojoResult(result[0]);
- if (!r.isOk) {
+ if (result[0] != MojoResult.kOk) {
return null;
}
MojoSharedBuffer dupe =
- new MojoSharedBuffer(new MojoHandle(result[1]), r, null);
+ new MojoSharedBuffer(new MojoHandle(result[1]), result[0], null);
return dupe;
}
- MojoResult close() {
+ int close() {
if (handle == null) {
- status = MojoResult.INVALID_ARGUMENT;
+ status = MojoResult.kInvalidArgument;
return status;
}
- MojoResult r = handle.close();
+ int r = handle.close();
status = r;
mapping = null;
return status;
}
- MojoResult map(int offset, int numBytes, [int flags = 0]) {
+ int map(int offset, int numBytes, [int flags = 0]) {
if (handle == null) {
- status = MojoResult.INVALID_ARGUMENT;
+ status = MojoResult.kInvalidArgument;
return status;
}
List result =
MojoSharedBufferNatives.Map(this, handle.h, offset, numBytes, flags);
if (result == null) {
- status = MojoResult.INVALID_ARGUMENT;
+ status = MojoResult.kInvalidArgument;
return status;
}
assert((result is List) && (result.length == 2));
- status = new MojoResult(result[0]);
+ status = result[0];
mapping = result[1];
return status;
}
- MojoResult unmap() {
+ int unmap() {
int r = MojoSharedBufferNatives.Unmap(mapping);
- status = new MojoResult(r);
+ status = r;
mapping = null;
return status;
}
« no previous file with comments | « mojo/dart/embedder/io/socket_patch.dart ('k') | mojo/dart/packages/mojo/lib/src/data_pipe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698