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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 11362009: New APIs for external byte arrays (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 2 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 | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index f1acf1c55617c9db862c4d8ac567aa2d93ac84bf..876710d32cfffbd1b63d348113836aad86e4fad6 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -1610,8 +1610,6 @@ DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object,
}
// It's not an external string, return appropriate error.
- // Note: this is invoked outside of the NoGCScope'd block above, since
- // error messages allocate new handles.
if (!RawObject::IsStringClassId(Api::ClassId(object))) {
RETURN_TYPE_ERROR(Isolate::Current(), object, String);
} else {
@@ -2171,6 +2169,11 @@ DART_EXPORT bool Dart_IsByteArray(Dart_Handle object) {
}
+DART_EXPORT bool Dart_IsByteArrayExternal(Dart_Handle object) {
+ return RawObject::IsExternalByteArrayClassId(Api::ClassId(object));
+}
+
+
DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
@@ -2194,6 +2197,23 @@ DART_EXPORT Dart_Handle Dart_NewExternalByteArray(uint8_t* data,
}
+DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetData(Dart_Handle object,
+ void** data) {
+ Isolate* isolate = Isolate::Current();
+ DARTSCOPE(isolate);
+ const ExternalUint8Array& array =
+ Api::UnwrapExternalUint8ArrayHandle(isolate, object);
+ if (array.IsNull()) {
+ RETURN_TYPE_ERROR(isolate, object, ExternalUint8Array);
+ }
+ if (data == NULL) {
+ RETURN_NULL_ERROR(data);
+ }
+ *data = array.GetData();
+ return Api::Success(isolate);
+}
+
+
DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetPeer(Dart_Handle object,
void** peer) {
Isolate* isolate = Isolate::Current();
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698