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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 1127
1128 1128
1129 DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints, 1129 DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints,
1130 intptr_t length) { 1130 intptr_t length) {
1131 DARTSCOPE(Isolate::Current()); 1131 DARTSCOPE(Isolate::Current());
1132 const String& obj = String::Handle(String::New(codepoints, length)); 1132 const String& obj = String::Handle(String::New(codepoints, length));
1133 return Api::NewLocalHandle(obj); 1133 return Api::NewLocalHandle(obj);
1134 } 1134 }
1135 1135
1136 1136
1137 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) {
1138 DARTSCOPE(Isolate::Current());
1139 const String& str = Api::UnwrapStringHandle(object);
1140 if (str.IsNull()) {
1141 return false;
1142 }
1143 return str.IsExternal();
1144 }
1145
1146
1147 DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object,
1148 void** peer) {
1149 DARTSCOPE(Isolate::Current());
1150 const String& str = Api::UnwrapStringHandle(object);
1151 if (str.IsNull()) {
1152 RETURN_TYPE_ERROR(object, String);
1153 }
1154 if (!str.IsExternal()) {
1155 return Api::Error("%s expects argument 'object' to be an external String.",
1156 CURRENT_FUNC);
1157 }
1158 if (peer == NULL) {
1159 return Api::Error("%s expects argument 'peer' to be non-NULL.",
1160 CURRENT_FUNC);
1161 }
1162 *peer = str.GetPeer();
1163 return Api::Success();
1164 }
1165
1166
1137 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints, 1167 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints,
1138 intptr_t length, 1168 intptr_t length,
1139 void* peer, 1169 void* peer,
1140 Dart_PeerFinalizer callback) { 1170 Dart_PeerFinalizer callback) {
1141 DARTSCOPE(Isolate::Current()); 1171 DARTSCOPE(Isolate::Current());
1142 const String& obj = 1172 const String& obj =
1143 String::Handle(String::NewExternal(codepoints, length, peer, callback)); 1173 String::Handle(String::NewExternal(codepoints, length, peer, callback));
1144 return Api::NewLocalHandle(obj); 1174 return Api::NewLocalHandle(obj);
1145 } 1175 }
1146 1176
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 } 2407 }
2378 delete debug_region; 2408 delete debug_region;
2379 } else { 2409 } else {
2380 *buffer = NULL; 2410 *buffer = NULL;
2381 *buffer_size = 0; 2411 *buffer_size = 0;
2382 } 2412 }
2383 } 2413 }
2384 2414
2385 2415
2386 } // namespace dart 2416 } // namespace dart
OLDNEW
« 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