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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 8775039: Add Dart_IsExternalString and Dart_ExternalStringGetPeer to the dart (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 2079)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -1134,6 +1134,36 @@
}
+DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) {
+ DARTSCOPE(Isolate::Current());
+ const String& str = Api::UnwrapStringHandle(object);
+ if (str.IsNull()) {
+ return false;
+ }
+ return str.IsExternal();
+}
+
+
+DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object,
+ void** peer) {
+ DARTSCOPE(Isolate::Current());
+ const String& str = Api::UnwrapStringHandle(object);
+ if (str.IsNull()) {
+ RETURN_TYPE_ERROR(object, String);
+ }
+ if (!str.IsExternal()) {
+ return Api::Error("%s expects argument 'object' to be an external String.",
+ CURRENT_FUNC);
+ }
+ if (peer == NULL) {
+ return Api::Error("%s expects argument 'peer' to be non-NULL.",
+ CURRENT_FUNC);
+ }
+ *peer = str.GetPeer();
+ return Api::Success();
+}
+
+
DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints,
intptr_t length,
void* peer,
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698