| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 // to get at the contents. | 1797 // to get at the contents. |
| 1798 intptr_t copy_len = str_obj.Length(); | 1798 intptr_t copy_len = str_obj.Length(); |
| 1799 if (str_obj.IsOneByteString()) { | 1799 if (str_obj.IsOneByteString()) { |
| 1800 ASSERT(length >= copy_len); | 1800 ASSERT(length >= copy_len); |
| 1801 uint8_t* latin1_array = reinterpret_cast<uint8_t*>(array); | 1801 uint8_t* latin1_array = reinterpret_cast<uint8_t*>(array); |
| 1802 for (intptr_t i = 0; i < copy_len; i++) { | 1802 for (intptr_t i = 0; i < copy_len; i++) { |
| 1803 latin1_array[i] = static_cast<uint8_t>(str_obj.CharAt(i)); | 1803 latin1_array[i] = static_cast<uint8_t>(str_obj.CharAt(i)); |
| 1804 } | 1804 } |
| 1805 } else { | 1805 } else { |
| 1806 ASSERT(str_obj.IsTwoByteString()); | 1806 ASSERT(str_obj.IsTwoByteString()); |
| 1807 ASSERT(length >= (copy_len * sizeof(uint16_t))); | 1807 ASSERT(length >= (copy_len * str_obj.CharSize())); |
| 1808 uint16_t* utf16_array = reinterpret_cast<uint16_t*>(array); | 1808 uint16_t* utf16_array = reinterpret_cast<uint16_t*>(array); |
| 1809 for (intptr_t i = 0; i < copy_len; i++) { | 1809 for (intptr_t i = 0; i < copy_len; i++) { |
| 1810 utf16_array[i] = static_cast<uint16_t>(str_obj.CharAt(i)); | 1810 utf16_array[i] = static_cast<uint16_t>(str_obj.CharAt(i)); |
| 1811 } | 1811 } |
| 1812 } | 1812 } |
| 1813 return Api::Null(isolate); | 1813 return Api::Null(isolate); |
| 1814 } | 1814 } |
| 1815 return Api::NewHandle(isolate, | 1815 return Api::NewHandle(isolate, |
| 1816 str_obj.MakeExternal(array, length, peer, cback)); | 1816 str_obj.MakeExternal(array, length, peer, cback)); |
| 1817 } | 1817 } |
| (...skipping 2688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4506 } | 4506 } |
| 4507 { | 4507 { |
| 4508 NoGCScope no_gc; | 4508 NoGCScope no_gc; |
| 4509 RawObject* raw_obj = obj.raw(); | 4509 RawObject* raw_obj = obj.raw(); |
| 4510 isolate->heap()->SetPeer(raw_obj, peer); | 4510 isolate->heap()->SetPeer(raw_obj, peer); |
| 4511 } | 4511 } |
| 4512 return Api::Success(isolate); | 4512 return Api::Success(isolate); |
| 4513 } | 4513 } |
| 4514 | 4514 |
| 4515 } // namespace dart | 4515 } // namespace dart |
| OLD | NEW |