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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 9235067: Use ByteArray's native for Socket and File. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 3811)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -1391,6 +1391,12 @@
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
const Object& obj = Object::Handle(Api::UnwrapHandle(list));
+ if (obj.IsByteArray()) {
+ ByteArray& byte_array = ByteArray::Handle();
+ byte_array ^= obj.raw();
+ *len = byte_array.Length();
+ return Api::Success();
+ }
if (obj.IsArray()) {
Array& array_obj = Array::Handle();
array_obj ^= obj.raw();
@@ -1596,6 +1602,15 @@
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
const Object& obj = Object::Handle(Api::UnwrapHandle(list));
+ if (obj.IsByteArray()) {
+ ByteArray& byte_array = ByteArray::Handle();
+ byte_array ^= obj.raw();
+ if (Utils::RangeCheck(offset, length, byte_array.Length())) {
+ ByteArray::Copy(native_array, byte_array, offset, length);
+ return Api::Success();
+ }
+ return Api::NewError("Invalid length passed in to access list elements");
+ }
if (obj.IsArray()) {
Array& array_obj = Array::Handle();
array_obj ^= obj.raw();
@@ -1659,6 +1674,15 @@
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
const Object& obj = Object::Handle(Api::UnwrapHandle(list));
+ if (obj.IsByteArray()) {
+ ByteArray& byte_array = ByteArray::Handle();
+ byte_array ^= obj.raw();
+ if (Utils::RangeCheck(offset, length, byte_array.Length())) {
+ ByteArray::Copy(byte_array, offset, native_array, length);
+ return Api::Success();
+ }
+ return Api::NewError("Invalid length passed in to set list elements");
+ }
if (obj.IsArray()) {
if (obj.IsImmutableArray()) {
return Api::NewError("Cannot modify immutable array");

Powered by Google App Engine
This is Rietveld 408576698