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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 8383029: Implement external strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: pre-review clean-up Created 9 years, 2 months 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: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 3c2932efc6c7995b21660180e8142758adb1fb3e..1e2c3417ed67875965eb14896b66dd6ff3b8fc9d 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -723,17 +723,55 @@ DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints,
intptr_t length) {
Zone zone; // Setup a VM zone as we are creating some handles.
HandleScope scope; // Setup a VM handle scope.
- UNIMPLEMENTED();
const String& obj = String::Handle(String::New(codepoints, length));
return Api::NewLocalHandle(obj);
}
+DART_EXPORT Dart_Handle Dart_NewExternalString8(
+ uint8_t* codepoints,
+ intptr_t length,
+ Dart_ExternalString8Finalizer finalizer) {
+ Zone zone; // Setup a VM zone as we are creating some handles.
+ HandleScope scope; // Setup a VM handle scope.
+ const String& obj =
+ String::Handle(
+ ExternalOneByteString::New(codepoints, length, finalizer));
+ return Api::NewLocalHandle(obj);
+}
+
+
+DART_EXPORT Dart_Handle Dart_NewExternalString16(
+ uint16_t* codepoints,
+ intptr_t length,
+ Dart_ExternalString16Finalizer finalizer) {
+ Zone zone; // Setup a VM zone as we are creating some handles.
+ HandleScope scope; // Setup a VM handle scope.
+ const String& obj =
+ String::Handle(
+ ExternalTwoByteString::New(codepoints, length, finalizer));
+ return Api::NewLocalHandle(obj);
+}
+
+
+DART_EXPORT Dart_Handle Dart_NewExternalString32(
+ uint32_t* codepoints,
+ intptr_t length,
+ Dart_ExternalString32Finalizer finalizer) {
+ Zone zone; // Setup a VM zone as we are creating some handles.
+ HandleScope scope; // Setup a VM handle scope.
+ const String& obj =
+ String::Handle(
+ ExternalFourByteString::New(codepoints, length, finalizer));
+ return Api::NewLocalHandle(obj);
+}
+
+
DART_EXPORT bool Dart_IsString8(Dart_Handle object) {
Zone zone; // Setup a VM zone as we are creating some handles.
HandleScope scope; // Setup a VM handle scope.
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
- return obj.IsOneByteString();
+ return obj.IsOneByteString() || obj.IsExternalOneByteString();
}
@@ -741,7 +779,8 @@ DART_EXPORT bool Dart_IsString16(Dart_Handle object) {
Zone zone; // Setup a VM zone as we are creating some handles.
HandleScope scope; // Setup a VM handle scope.
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
- return obj.IsOneByteString() || obj.IsTwoByteString();
+ return (obj.IsOneByteString() || obj.IsExternalOneByteString() ||
+ obj.IsTwoByteString() || obj.IsExternalOneByteString());
}

Powered by Google App Engine
This is Rietveld 408576698