Chromium Code Reviews| Index: vm/dart_api_impl.cc |
| =================================================================== |
| --- vm/dart_api_impl.cc (revision 14589) |
| +++ vm/dart_api_impl.cc (working copy) |
| @@ -1707,6 +1707,32 @@ |
| } |
| +DART_EXPORT Dart_Handle Dart_MakeExternalString(Dart_Handle str, |
| + void* array, |
| + intptr_t length, |
| + void* peer, |
| + Dart_PeerFinalizer cback) { |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| + const String& str_obj = Api::UnwrapStringHandle(isolate, str); |
| + if (str_obj.IsNull() || str_obj.IsExternal()) { |
| + RETURN_TYPE_ERROR(isolate, str, String); |
|
Tom Ball
2012/11/07 00:38:43
Is passing in an external string necessarily an er
siva
2012/11/07 21:43:27
Yes we could.
Does that make sense however, it se
|
| + } |
| + if (array == NULL) { |
| + RETURN_NULL_ERROR(array); |
| + } |
| + intptr_t str_length = (str_obj.Length() * str_obj.CharSize()); |
| + if ((length < str_length) || (length > String::kMaxElements)) { |
| + return Api::NewError("Dart_MakeExternalString " |
| + "expects argument length to be in the range" |
| + "[%"Pd"..%"Pd"].", |
| + str_length, String::kMaxElements); |
| + } |
| + return Api::NewHandle(isolate, |
| + str_obj.MakeExternal(array, length, peer, cback)); |
| +} |
| + |
| + |
| // --- Lists --- |