| 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 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 if (array == NULL) { | 1780 if (array == NULL) { |
| 1781 RETURN_NULL_ERROR(array); | 1781 RETURN_NULL_ERROR(array); |
| 1782 } | 1782 } |
| 1783 intptr_t str_size = (str_obj.Length() * str_obj.CharSize()); | 1783 intptr_t str_size = (str_obj.Length() * str_obj.CharSize()); |
| 1784 if ((length < str_size) || (length > String::kMaxElements)) { | 1784 if ((length < str_size) || (length > String::kMaxElements)) { |
| 1785 return Api::NewError("Dart_MakeExternalString " | 1785 return Api::NewError("Dart_MakeExternalString " |
| 1786 "expects argument length to be in the range" | 1786 "expects argument length to be in the range" |
| 1787 "[%"Pd"..%"Pd"].", | 1787 "[%"Pd"..%"Pd"].", |
| 1788 str_size, String::kMaxElements); | 1788 str_size, String::kMaxElements); |
| 1789 } | 1789 } |
| 1790 if (str_obj.IsCanonical()) { | 1790 if (str_obj.InVMHeap()) { |
| 1791 // Since the string object is read only we do not externalize | 1791 // Since the string object is read only we do not externalize |
| 1792 // the string but instead copy the contents of the string into the | 1792 // the string but instead copy the contents of the string into the |
| 1793 // specified buffer and return a Null object. | 1793 // specified buffer and return a Null object. |
| 1794 // This ensures that the embedder does not have to call again | 1794 // This ensures that the embedder does not have to call again |
| 1795 // to get at the contents. | 1795 // to get at the contents. |
| 1796 intptr_t copy_len = str_obj.Length(); | 1796 intptr_t copy_len = str_obj.Length(); |
| 1797 if (str_obj.IsOneByteString()) { | 1797 if (str_obj.IsOneByteString()) { |
| 1798 ASSERT(length >= copy_len); | 1798 ASSERT(length >= copy_len); |
| 1799 uint8_t* latin1_array = reinterpret_cast<uint8_t*>(array); | 1799 uint8_t* latin1_array = reinterpret_cast<uint8_t*>(array); |
| 1800 for (intptr_t i = 0; i < copy_len; i++) { | 1800 for (intptr_t i = 0; i < copy_len; i++) { |
| (...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4523 } | 4523 } |
| 4524 { | 4524 { |
| 4525 NoGCScope no_gc; | 4525 NoGCScope no_gc; |
| 4526 RawObject* raw_obj = obj.raw(); | 4526 RawObject* raw_obj = obj.raw(); |
| 4527 isolate->heap()->SetPeer(raw_obj, peer); | 4527 isolate->heap()->SetPeer(raw_obj, peer); |
| 4528 } | 4528 } |
| 4529 return Api::Success(isolate); | 4529 return Api::Success(isolate); |
| 4530 } | 4530 } |
| 4531 | 4531 |
| 4532 } // namespace dart | 4532 } // namespace dart |
| OLD | NEW |