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

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 3621)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -1359,6 +1359,12 @@
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
const Object& obj = Object::Handle(Api::UnwrapHandle(list));
+ if (obj.IsByteArray()) {
cshapiro 2012/01/27 23:00:04 Two questions. Why is this ahead of array and why
Anders Johnsen 2012/01/27 23:42:39 Adding the native operations for getting/setting d
+ 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();
@@ -1564,6 +1570,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 ((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 array elements");
cshapiro 2012/01/27 23:00:04 list elements, right? I think the list interface
Anders Johnsen 2012/01/27 23:42:39 Done.
+ }
if (obj.IsArray()) {
Array& array_obj = Array::Handle();
array_obj ^= obj.raw();
@@ -1627,6 +1642,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 ((offset + length) <= byte_array.Length()) {
+ ByteArray::Copy(byte_array, offset, native_array, length);
+ return Api::Success();
+ }
+ return Api::NewError("Invalid length passed in to access array elements");
+ }
if (obj.IsArray()) {
if (obj.IsImmutableArray()) {
return Api::NewError("Cannot modify immutable array");

Powered by Google App Engine
This is Rietveld 408576698