| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 | 1237 |
| 1238 | 1238 |
| 1239 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, | 1239 DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, |
| 1240 intptr_t offset, | 1240 intptr_t offset, |
| 1241 uint8_t* native_array, | 1241 uint8_t* native_array, |
| 1242 intptr_t length) { | 1242 intptr_t length) { |
| 1243 Isolate* isolate = Isolate::Current(); | 1243 Isolate* isolate = Isolate::Current(); |
| 1244 DARTSCOPE(isolate); | 1244 DARTSCOPE(isolate); |
| 1245 const Object& obj = Object::Handle(Api::UnwrapHandle(list)); | 1245 const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| 1246 if (obj.IsArray()) { | 1246 if (obj.IsArray()) { |
| 1247 if (obj.IsImmutableArray()) { |
| 1248 return Api::Error("Cannot modify immutable array"); |
| 1249 } |
| 1247 Array& array_obj = Array::Handle(); | 1250 Array& array_obj = Array::Handle(); |
| 1248 array_obj ^= obj.raw(); | 1251 array_obj ^= obj.raw(); |
| 1249 Integer& integer = Integer::Handle(); | 1252 Integer& integer = Integer::Handle(); |
| 1250 if ((offset + length) <= array_obj.Length()) { | 1253 if ((offset + length) <= array_obj.Length()) { |
| 1251 for (int i = 0; i < length; i++) { | 1254 for (int i = 0; i < length; i++) { |
| 1252 integer ^= Integer::New(native_array[i]); | 1255 integer ^= Integer::New(native_array[i]); |
| 1253 array_obj.SetAt(offset + i, integer); | 1256 array_obj.SetAt(offset + i, integer); |
| 1254 } | 1257 } |
| 1255 return Api::Success(); | 1258 return Api::Success(); |
| 1256 } | 1259 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1282 } | 1285 } |
| 1283 | 1286 |
| 1284 | 1287 |
| 1285 DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, | 1288 DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, |
| 1286 intptr_t index, | 1289 intptr_t index, |
| 1287 Dart_Handle value) { | 1290 Dart_Handle value) { |
| 1288 Isolate* isolate = Isolate::Current(); | 1291 Isolate* isolate = Isolate::Current(); |
| 1289 DARTSCOPE(isolate); | 1292 DARTSCOPE(isolate); |
| 1290 const Object& obj = Object::Handle(Api::UnwrapHandle(list)); | 1293 const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| 1291 if (obj.IsArray()) { | 1294 if (obj.IsArray()) { |
| 1295 if (obj.IsImmutableArray()) { |
| 1296 return Api::Error("Cannot modify immutable array"); |
| 1297 } |
| 1292 Array& array_obj = Array::Handle(); | 1298 Array& array_obj = Array::Handle(); |
| 1293 array_obj ^= obj.raw(); | 1299 array_obj ^= obj.raw(); |
| 1294 const Object& value_obj = Object::Handle(Api::UnwrapHandle(value)); | 1300 const Object& value_obj = Object::Handle(Api::UnwrapHandle(value)); |
| 1295 if ((index >= 0) && (index < array_obj.Length())) { | 1301 if ((index >= 0) && (index < array_obj.Length())) { |
| 1296 array_obj.SetAt(index, value_obj); | 1302 array_obj.SetAt(index, value_obj); |
| 1297 return Api::Success(); | 1303 return Api::Success(); |
| 1298 } | 1304 } |
| 1299 return Api::Error("Invalid index passed in to set array element"); | 1305 return Api::Error("Invalid index passed in to set array element"); |
| 1300 } | 1306 } |
| 1301 // TODO(5526318): Make access to GrowableObjectArray more efficient. | 1307 // TODO(5526318): Make access to GrowableObjectArray more efficient. |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2133 ASSERT(isolate != NULL); | 2139 ASSERT(isolate != NULL); |
| 2134 ApiState* state = isolate->api_state(); | 2140 ApiState* state = isolate->api_state(); |
| 2135 ASSERT(state != NULL); | 2141 ASSERT(state != NULL); |
| 2136 ApiLocalScope* scope = state->top_scope(); | 2142 ApiLocalScope* scope = state->top_scope(); |
| 2137 ASSERT(scope != NULL); | 2143 ASSERT(scope != NULL); |
| 2138 return scope->zone().Reallocate(ptr, old_size, new_size); | 2144 return scope->zone().Reallocate(ptr, old_size, new_size); |
| 2139 } | 2145 } |
| 2140 | 2146 |
| 2141 | 2147 |
| 2142 } // namespace dart | 2148 } // namespace dart |
| OLD | NEW |