| Index: runtime/lib/string.cc
|
| diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc
|
| index 3b5b633a9e9802114463d9bfd90b71426f257511..48b81e96fb72e94bebc075241071b3fb7dc97098 100644
|
| --- a/runtime/lib/string.cc
|
| +++ b/runtime/lib/string.cc
|
| @@ -197,4 +197,27 @@ DEFINE_NATIVE_ENTRY(Strings_concatAll, 1) {
|
| return String::ConcatAll(strings);
|
| }
|
|
|
| +
|
| +DEFINE_NATIVE_ENTRY(StringBuffer_createStringFromUint16Array, 3) {
|
| + GET_NON_NULL_NATIVE_ARGUMENT(Uint16Array, codeUnits,
|
| + arguments->NativeArgAt(0));
|
| + GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(1));
|
| + GET_NON_NULL_NATIVE_ARGUMENT(Bool, isLatin1, arguments->NativeArgAt(2));
|
| + intptr_t array_length = codeUnits.Length();
|
| + intptr_t length_value = length.Value();
|
| + if (length_value < 0 || length_value > array_length) {
|
| + const Array& args = Array::Handle(Array::New(1));
|
| + args.SetAt(0, length);
|
| + Exceptions::ThrowByType(Exceptions::kRange, args);
|
| + }
|
| + const String& result = isLatin1.value()
|
| + ? String::Handle(OneByteString::New(length_value, Heap::kNew))
|
| + : String::Handle(TwoByteString::New(length_value, Heap::kNew));
|
| + NoGCScope no_gc;
|
| +
|
| + uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.ByteAddr(0));
|
| + String::Copy(result, 0, data_position, length_value);
|
| + return result.raw();
|
| +}
|
| +
|
| } // namespace dart
|
|
|