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

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

Issue 11368138: Add some support for the code-point code-unit distinction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: New version integrates feedback, adds less to standard String class. 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 unified diff | Download patch | Annotate | Revision Log
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 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 intptr_t* length) { 1696 intptr_t* length) {
1697 Isolate* isolate = Isolate::Current(); 1697 Isolate* isolate = Isolate::Current();
1698 DARTSCOPE(isolate); 1698 DARTSCOPE(isolate);
1699 const String& str_obj = Api::UnwrapStringHandle(isolate, str); 1699 const String& str_obj = Api::UnwrapStringHandle(isolate, str);
1700 if (str_obj.IsNull()) { 1700 if (str_obj.IsNull()) {
1701 RETURN_TYPE_ERROR(isolate, str, String); 1701 RETURN_TYPE_ERROR(isolate, str, String);
1702 } 1702 }
1703 intptr_t str_len = str_obj.Length(); 1703 intptr_t str_len = str_obj.Length();
1704 intptr_t copy_len = (str_len > *length) ? *length : str_len; 1704 intptr_t copy_len = (str_len > *length) ? *length : str_len;
1705 for (intptr_t i = 0; i < copy_len; i++) { 1705 for (intptr_t i = 0; i < copy_len; i++) {
1706 utf16_array[i] = static_cast<uint16_t>(str_obj.CharAt(i)); 1706 utf16_array[i] = static_cast<uint16_t>(str_obj.CodeUnitAt(i));
1707 } 1707 }
1708 *length = copy_len; 1708 *length = copy_len;
1709 return Api::Success(isolate); 1709 return Api::Success(isolate);
1710 } 1710 }
1711 1711
1712 1712
1713 // --- Lists --- 1713 // --- Lists ---
1714 1714
1715 1715
1716 static RawInstance* GetListInstance(Isolate* isolate, const Object& obj) { 1716 static RawInstance* GetListInstance(Isolate* isolate, const Object& obj) {
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 } 2594 }
2595 return Api::NewHandle(isolate, cls.signature_function()); 2595 return Api::NewHandle(isolate, cls.signature_function());
2596 } 2596 }
2597 2597
2598 2598
2599 // --- Function and Variable Reflection --- 2599 // --- Function and Variable Reflection ---
2600 2600
2601 2601
2602 // Outside of the vm, we expose setter names with a trailing '='. 2602 // Outside of the vm, we expose setter names with a trailing '='.
2603 static bool HasExternalSetterSuffix(const String& name) { 2603 static bool HasExternalSetterSuffix(const String& name) {
2604 return name.CharAt(name.Length() - 1) == '='; 2604 return name.CodeUnitAt(name.Length() - 1) == '=';
2605 } 2605 }
2606 2606
2607 2607
2608 static RawString* RemoveExternalSetterSuffix(const String& name) { 2608 static RawString* RemoveExternalSetterSuffix(const String& name) {
2609 ASSERT(HasExternalSetterSuffix(name)); 2609 ASSERT(HasExternalSetterSuffix(name));
2610 return String::SubString(name, 0, name.Length() - 1); 2610 return String::SubString(name, 0, name.Length() - 1);
2611 } 2611 }
2612 2612
2613 2613
2614 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target) { 2614 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target) {
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
4466 } 4466 }
4467 { 4467 {
4468 NoGCScope no_gc; 4468 NoGCScope no_gc;
4469 RawObject* raw_obj = obj.raw(); 4469 RawObject* raw_obj = obj.raw();
4470 isolate->heap()->SetPeer(raw_obj, peer); 4470 isolate->heap()->SetPeer(raw_obj, peer);
4471 } 4471 }
4472 return Api::Success(isolate); 4472 return Api::Success(isolate);
4473 } 4473 }
4474 4474
4475 } // namespace dart 4475 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698