| 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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/native_entry.h" | 8 #include "vm/native_entry.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 const Array& args = Array::Handle(Array::New(1)); | 208 const Array& args = Array::Handle(Array::New(1)); |
| 209 args.SetAt(0, elem); | 209 args.SetAt(0, elem); |
| 210 Exceptions::ThrowByType(Exceptions::kArgument, args); | 210 Exceptions::ThrowByType(Exceptions::kArgument, args); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 return String::ConcatAll(strings); | 213 return String::ConcatAll(strings); |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 DEFINE_NATIVE_ENTRY(StringBuffer_createStringFromUint16Array, 3) { | 217 DEFINE_NATIVE_ENTRY(StringBuffer_createStringFromUint16Array, 3) { |
| 218 GET_NON_NULL_NATIVE_ARGUMENT(Uint16Array, codeUnits, | 218 GET_NON_NULL_NATIVE_ARGUMENT(TypedData, codeUnits, arguments->NativeArgAt(0)); |
| 219 arguments->NativeArgAt(0)); | |
| 220 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(1)); | 219 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(1)); |
| 221 GET_NON_NULL_NATIVE_ARGUMENT(Bool, isLatin1, arguments->NativeArgAt(2)); | 220 GET_NON_NULL_NATIVE_ARGUMENT(Bool, isLatin1, arguments->NativeArgAt(2)); |
| 222 intptr_t array_length = codeUnits.Length(); | 221 intptr_t array_length = codeUnits.Length(); |
| 223 intptr_t length_value = length.Value(); | 222 intptr_t length_value = length.Value(); |
| 224 if (length_value < 0 || length_value > array_length) { | 223 if (length_value < 0 || length_value > array_length) { |
| 225 const Array& args = Array::Handle(Array::New(1)); | 224 const Array& args = Array::Handle(Array::New(1)); |
| 226 args.SetAt(0, length); | 225 args.SetAt(0, length); |
| 227 Exceptions::ThrowByType(Exceptions::kRange, args); | 226 Exceptions::ThrowByType(Exceptions::kRange, args); |
| 228 } | 227 } |
| 229 const String& result = isLatin1.value() | 228 const String& result = isLatin1.value() |
| 230 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) | 229 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) |
| 231 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); | 230 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); |
| 232 NoGCScope no_gc; | 231 NoGCScope no_gc; |
| 233 | 232 |
| 234 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.ByteAddr(0)); | 233 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); |
| 235 String::Copy(result, 0, data_position, length_value); | 234 String::Copy(result, 0, data_position, length_value); |
| 236 return result.raw(); | 235 return result.raw(); |
| 237 } | 236 } |
| 238 | 237 |
| 239 } // namespace dart | 238 } // namespace dart |
| OLD | NEW |