Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1102)

Unified Diff: vm/dart_api_impl.cc

Issue 11360114: - Add functionality to morph a string into an external string (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ---

Powered by Google App Engine
This is Rietveld 408576698