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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 11411204: When externalizing a string ensure that the basic tag bits are preserved. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « no previous file | runtime/vm/object.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 const String& str_obj = Api::UnwrapStringHandle(isolate, str); 1742 const String& str_obj = Api::UnwrapStringHandle(isolate, str);
1743 if (str_obj.IsExternal()) { 1743 if (str_obj.IsExternal()) {
1744 return str; // String is already an external string. 1744 return str; // String is already an external string.
1745 } 1745 }
1746 if (str_obj.IsNull()) { 1746 if (str_obj.IsNull()) {
1747 RETURN_TYPE_ERROR(isolate, str, String); 1747 RETURN_TYPE_ERROR(isolate, str, String);
1748 } 1748 }
1749 if (array == NULL) { 1749 if (array == NULL) {
1750 RETURN_NULL_ERROR(array); 1750 RETURN_NULL_ERROR(array);
1751 } 1751 }
1752 if (str_obj.IsCanonical()) {
1753 return Api::NewError("Dart_MakeExternalString "
1754 "cannot externalize a read-only string.");
Anton Muhin 2012/11/30 21:37:45 might be worth clarifying what's the difference be
1755 }
1752 intptr_t str_size = (str_obj.Length() * str_obj.CharSize()); 1756 intptr_t str_size = (str_obj.Length() * str_obj.CharSize());
1753 if ((length < str_size) || (length > String::kMaxElements)) { 1757 if ((length < str_size) || (length > String::kMaxElements)) {
1754 return Api::NewError("Dart_MakeExternalString " 1758 return Api::NewError("Dart_MakeExternalString "
1755 "expects argument length to be in the range" 1759 "expects argument length to be in the range"
1756 "[%"Pd"..%"Pd"].", 1760 "[%"Pd"..%"Pd"].",
1757 str_size, String::kMaxElements); 1761 str_size, String::kMaxElements);
1758 } 1762 }
1759 return Api::NewHandle(isolate, 1763 return Api::NewHandle(isolate,
1760 str_obj.MakeExternal(array, length, peer, cback)); 1764 str_obj.MakeExternal(array, length, peer, cback));
1761 } 1765 }
(...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after
4451 } 4455 }
4452 { 4456 {
4453 NoGCScope no_gc; 4457 NoGCScope no_gc;
4454 RawObject* raw_obj = obj.raw(); 4458 RawObject* raw_obj = obj.raw();
4455 isolate->heap()->SetPeer(raw_obj, peer); 4459 isolate->heap()->SetPeer(raw_obj, peer);
4456 } 4460 }
4457 return Api::Success(isolate); 4461 return Api::Success(isolate);
4458 } 4462 }
4459 4463
4460 } // namespace dart 4464 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698