Chromium Code Reviews| 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 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1662 | 1662 |
| 1663 DART_EXPORT Dart_Handle Dart_StringToUTF8(Dart_Handle str, | 1663 DART_EXPORT Dart_Handle Dart_StringToUTF8(Dart_Handle str, |
| 1664 uint8_t* utf8_array, | 1664 uint8_t* utf8_array, |
| 1665 intptr_t* length) { | 1665 intptr_t* length) { |
| 1666 Isolate* isolate = Isolate::Current(); | 1666 Isolate* isolate = Isolate::Current(); |
| 1667 DARTSCOPE(isolate); | 1667 DARTSCOPE(isolate); |
| 1668 const String& str_obj = Api::UnwrapStringHandle(isolate, str); | 1668 const String& str_obj = Api::UnwrapStringHandle(isolate, str); |
| 1669 if (str_obj.IsNull()) { | 1669 if (str_obj.IsNull()) { |
| 1670 RETURN_TYPE_ERROR(isolate, str, String); | 1670 RETURN_TYPE_ERROR(isolate, str, String); |
| 1671 } | 1671 } |
| 1672 intptr_t str_len = str_obj.Length(); | 1672 intptr_t str_len = Utf8::Length(str_obj); |
|
Bill Hesse
2012/11/01 20:38:01
There is still no way for the user to know the len
siva
2012/11/01 21:23:03
I have changed the API to do a scope allocation in
| |
| 1673 if (str_len > *length) { | 1673 if (str_len > *length) { |
|
Bill Hesse
2012/11/01 20:38:01
I think this is not enough. There is no way for t
siva
2012/11/01 21:23:03
Check removed.
On 2012/11/01 20:38:01, Bill Hesse
| |
| 1674 return Api::NewError("Input array is not large enough to hold the result"); | 1674 return Api::NewError("Input array is not large enough to hold the result"); |
| 1675 } | 1675 } |
| 1676 str_obj.ToUTF8(utf8_array, str_len); | 1676 str_obj.ToUTF8(utf8_array, str_len); |
| 1677 *length= str_len; | 1677 *length= str_len; |
|
cshapiro
2012/11/01 20:59:30
missing horizontal space.
siva
2012/11/01 21:23:03
Done.
| |
| 1678 return Api::Success(isolate); | 1678 return Api::Success(isolate); |
| 1679 } | 1679 } |
| 1680 | 1680 |
| 1681 | 1681 |
| 1682 DART_EXPORT Dart_Handle Dart_StringToUTF16(Dart_Handle str, | 1682 DART_EXPORT Dart_Handle Dart_StringToUTF16(Dart_Handle str, |
| 1683 uint16_t* utf16_array, | 1683 uint16_t* utf16_array, |
| 1684 intptr_t* length) { | 1684 intptr_t* length) { |
| 1685 Isolate* isolate = Isolate::Current(); | 1685 Isolate* isolate = Isolate::Current(); |
| 1686 DARTSCOPE(isolate); | 1686 DARTSCOPE(isolate); |
| 1687 const String& str_obj = Api::UnwrapStringHandle(isolate, str); | 1687 const String& str_obj = Api::UnwrapStringHandle(isolate, str); |
| (...skipping 2793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4481 } | 4481 } |
| 4482 { | 4482 { |
| 4483 NoGCScope no_gc; | 4483 NoGCScope no_gc; |
| 4484 RawObject* raw_obj = obj.raw(); | 4484 RawObject* raw_obj = obj.raw(); |
| 4485 isolate->heap()->SetPeer(raw_obj, peer); | 4485 isolate->heap()->SetPeer(raw_obj, peer); |
| 4486 } | 4486 } |
| 4487 return Api::Success(isolate); | 4487 return Api::Success(isolate); |
| 4488 } | 4488 } |
| 4489 | 4489 |
| 4490 } // namespace dart | 4490 } // namespace dart |
| OLD | NEW |