Index: runtime/vm/object.h |
diff --git a/runtime/vm/object.h b/runtime/vm/object.h |
index 031a8541598da68e52d7e4eba1aefbd5114350b9..f97153561a21dcde18c44aee6e4e5e643f8db5b1 100644 |
--- a/runtime/vm/object.h |
+++ b/runtime/vm/object.h |
@@ -17,6 +17,7 @@ |
#include "vm/os.h" |
#include "vm/raw_object.h" |
#include "vm/scanner.h" |
+#include "vm/unicode.h" |
namespace dart { |
@@ -3718,7 +3719,11 @@ class String : public Instance { |
static intptr_t Hash(const uint16_t* characters, intptr_t len); |
static intptr_t Hash(const uint32_t* characters, intptr_t len); |
- int32_t CharAt(intptr_t index) const; |
+ // Returns the UTF-16 code unit at an index. UTF-16 is a superset of ASCII |
+ // so you can always use this if you are looking for ASCII. If you need to |
+ // support arbitrary Unicode characters then you should perhaps be using |
+ // Utf16::CharCodeAt(string, index) instead. |
+ uint32_t CodeUnitAt(intptr_t index) const; |
intptr_t CharSize() const; |
@@ -3884,7 +3889,7 @@ class String : public Instance { |
class OneByteString : public AllStatic { |
public: |
- static int32_t CharAt(const String& str, intptr_t index) { |
+ static uint32_t CodeUnitAt(const String& str, intptr_t index) { |
cshapiro
2012/11/15 20:14:51
Why did the signedness of the return type change?
erikcorry
2012/11/15 23:47:05
There is a mixture in the VM of signed and unsigne
|
return *CharAddr(str, index); |
} |
@@ -3941,6 +3946,7 @@ class OneByteString : public AllStatic { |
static RawOneByteString* Transform(int32_t (*mapping)(int32_t ch), |
const String& str, |
+ int out_length, |
Heap::Space space); |
static const ClassId kClassId = kOneByteStringCid; |
@@ -3978,7 +3984,7 @@ class OneByteString : public AllStatic { |
class TwoByteString : public AllStatic { |
public: |
- static int32_t CharAt(const String& str, intptr_t index) { |
+ static uint32_t CodeUnitAt(const String& str, intptr_t index) { |
return *CharAddr(str, index); |
} |
@@ -4024,6 +4030,7 @@ class TwoByteString : public AllStatic { |
static RawTwoByteString* Transform(int32_t (*mapping)(int32_t ch), |
const String& str, |
+ int out_length, |
Heap::Space space); |
static RawTwoByteString* null() { |
@@ -4062,7 +4069,7 @@ class TwoByteString : public AllStatic { |
class ExternalOneByteString : public AllStatic { |
public: |
- static int32_t CharAt(const String& str, intptr_t index) { |
+ static uint32_t CodeUnitAt(const String& str, intptr_t index) { |
return *CharAddr(str, index); |
} |
@@ -4128,7 +4135,7 @@ class ExternalOneByteString : public AllStatic { |
class ExternalTwoByteString : public AllStatic { |
public: |
- static int32_t CharAt(const String& str, intptr_t index) { |
+ static uint32_t CodeUnitAt(const String& str, intptr_t index) { |
return *CharAddr(str, index); |
} |
@@ -5904,7 +5911,7 @@ bool String::Equals(const String& str, |
return false; // Lengths don't match. |
} |
for (intptr_t i = 0; i < len; i++) { |
- if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
+ if (this->CodeUnitAt(i) != str.CodeUnitAt(begin_index + i)) { |
return false; |
} |
} |