Chromium Code Reviews| Index: runtime/lib/string.cc |
| diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc |
| index 3b5b633a9e9802114463d9bfd90b71426f257511..2e72aadb0cf3cb5e4e88df5b74ab161026e26626 100644 |
| --- a/runtime/lib/string.cc |
| +++ b/runtime/lib/string.cc |
| @@ -49,7 +49,6 @@ DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { |
| return TwoByteString::New(utf16_len, utf32_array, array_len, Heap::kNew); |
| } |
| - |
|
srdjan
2013/03/07 17:58:34
Please restore line
Lasse Reichstein Nielsen
2013/03/08 07:18:44
Done. *And* saving the buffer this time.
|
| DEFINE_NATIVE_ENTRY(StringBase_substringUnchecked, 3) { |
| const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); |
| GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_obj, arguments->NativeArgAt(1)); |
| @@ -197,4 +196,26 @@ DEFINE_NATIVE_ENTRY(Strings_concatAll, 1) { |
| return String::ConcatAll(strings); |
| } |
| +DEFINE_NATIVE_ENTRY(StringBuffer_createStringFromUint16Array, 3) { |
| + GET_NON_NULL_NATIVE_ARGUMENT(Uint16Array, a, arguments->NativeArgAt(0)); |
|
Vyacheslav Egorov (Google)
2013/03/07 13:50:52
I'd give a longer name to a.
Lasse Reichstein Nielsen
2013/03/08 07:18:44
Done.
|
| + GET_NON_NULL_NATIVE_ARGUMENT(Smi, smiLength, arguments->NativeArgAt(1)); |
|
Vyacheslav Egorov (Google)
2013/03/07 13:50:52
smiLength -> length
Lasse Reichstein Nielsen
2013/03/08 07:18:44
Done.
|
| + GET_NON_NULL_NATIVE_ARGUMENT(Bool, isLatin1, arguments->NativeArgAt(2)); |
| + intptr_t array_len = a.Length(); |
| + int32_t length = smiLength.Value(); |
|
Vyacheslav Egorov (Google)
2013/03/07 13:50:52
length -> length_value
srdjan
2013/03/07 17:58:34
intr32_t -> intptr_t; on x64 Smi is greater than i
Lasse Reichstein Nielsen
2013/03/08 07:18:44
Done.
|
| + if (length < 0 || length > array_len) { |
| + const Array& args = Array::Handle(Array::New(1)); |
| + args.SetAt(0, smiLength); |
| + Exceptions::ThrowByType(Exceptions::kRange, args); |
| + } |
| + const String& result = isLatin1.value() |
| + ? String::Handle(OneByteString::New(length, Heap::kNew)) |
| + : String::Handle(TwoByteString::New(length, Heap::kNew)); |
| + NoGCScope no_gc; |
| + uint16_t* data_position = reinterpret_cast<uint16_t*>( |
|
Vyacheslav Egorov (Google)
2013/03/07 13:50:52
consider a.ByteAddr(0)
Lasse Reichstein Nielsen
2013/03/08 07:18:44
I already tried that, but it seems to be private o
Ivan Posva
2013/03/08 09:15:41
I told Lasse to make the ByteAddr public. This is
Lasse Reichstein Nielsen
2013/03/08 10:19:37
And it works with a public ByteAddr.
|
| + reinterpret_cast<char*>(a.raw()) + |
| + Uint16Array::data_offset() - kHeapObjectTag); |
| + String::Copy(result, 0, data_position, length); |
| + return result.raw(); |
| +} |
| + |
| } // namespace dart |