Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 3810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3821 // UTF-8 encoded characters and '\0' is considered a termination character. | 3821 // UTF-8 encoded characters and '\0' is considered a termination character. |
| 3822 // TODO(7123) - Rename this to FromCString(....). | 3822 // TODO(7123) - Rename this to FromCString(....). |
| 3823 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); | 3823 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); |
| 3824 | 3824 |
| 3825 // Creates a new String object from an array of UTF-8 encoded characters. | 3825 // Creates a new String object from an array of UTF-8 encoded characters. |
| 3826 static RawString* FromUTF8(const uint8_t* utf8_array, | 3826 static RawString* FromUTF8(const uint8_t* utf8_array, |
| 3827 intptr_t array_len, | 3827 intptr_t array_len, |
| 3828 Heap::Space space = Heap::kNew); | 3828 Heap::Space space = Heap::kNew); |
| 3829 | 3829 |
| 3830 // Creates a new String object from an array of Latin-1 encoded characters. | 3830 // Creates a new String object from an array of Latin-1 encoded characters. |
| 3831 // TODO(7123) - Rename this to FromLatin1(....). | 3831 static RawString* FromLatin1(const uint8_t* latin1_array, |
| 3832 static RawString* New(const uint8_t* latin1_array, | 3832 intptr_t array_len, |
| 3833 intptr_t array_len, | 3833 Heap::Space space = Heap::kNew); |
| 3834 Heap::Space space = Heap::kNew); | |
| 3835 | 3834 |
| 3836 // Creates a new String object from an array of UTF-16 encoded characters. | 3835 // Creates a new String object from an array of UTF-16 encoded characters. |
| 3837 // TODO(7123) - Rename this to FromUTF16(....). | 3836 static RawString* FromUTF16(const uint16_t* utf16_array, |
| 3838 static RawString* New(const uint16_t* utf16_array, | 3837 intptr_t array_len, |
| 3839 intptr_t array_len, | 3838 Heap::Space space = Heap::kNew); |
| 3840 Heap::Space space = Heap::kNew); | |
| 3841 | 3839 |
| 3842 // Creates a new String object from an array of UTF-32 encoded characters. | 3840 // Creates a new String object from an array of UTF-32 encoded characters. |
| 3843 // TODO(7123) - Rename this to FromUTF32(....). | 3841 static RawString* FromUTF32(const int32_t* utf32_array, |
| 3844 static RawString* New(const int32_t* utf32_array, | 3842 intptr_t array_len, |
| 3845 intptr_t array_len, | 3843 Heap::Space space = Heap::kNew); |
| 3846 Heap::Space space = Heap::kNew); | |
| 3847 | 3844 |
| 3848 // Create a new String object from another Dart String instance. | 3845 // Create a new String object from another Dart String instance. |
| 3849 static RawString* New(const String& str, Heap::Space space = Heap::kNew); | 3846 static RawString* New(const String& str, Heap::Space space = Heap::kNew); |
| 3850 | 3847 |
| 3851 // Creates a new External String object using the specified array of | 3848 // Creates a new External String object using the specified array of |
| 3852 // UTF-8 encoded characters as the external reference. | 3849 // UTF-8 encoded characters as the external reference. |
| 3853 static RawString* NewExternal(const uint8_t* utf8_array, | 3850 static RawString* NewExternal(const uint8_t* utf8_array, |
| 3854 intptr_t array_len, | 3851 intptr_t array_len, |
| 3855 void* peer, | 3852 void* peer, |
| 3856 Dart_PeerFinalizer callback, | 3853 Dart_PeerFinalizer callback, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3923 // This is only safe because we create a new Smi, which does not cause | 3920 // This is only safe because we create a new Smi, which does not cause |
| 3924 // heap allocation. | 3921 // heap allocation. |
| 3925 raw_ptr()->hash_ = Smi::New(value); | 3922 raw_ptr()->hash_ = Smi::New(value); |
| 3926 } | 3923 } |
| 3927 | 3924 |
| 3928 template<typename HandleType, typename ElementType> | 3925 template<typename HandleType, typename ElementType> |
| 3929 static void ReadFromImpl(SnapshotReader* reader, | 3926 static void ReadFromImpl(SnapshotReader* reader, |
| 3930 String* str_obj, | 3927 String* str_obj, |
| 3931 intptr_t len, | 3928 intptr_t len, |
| 3932 intptr_t tags, | 3929 intptr_t tags, |
| 3930 RawString* (*NewSymbol)(const ElementType* chars, | |
|
cshapiro
2012/12/05 20:40:16
You can greatly simplify this by having the callba
siva
2012/12/05 23:33:14
Done.
| |
| 3931 intptr_t len), | |
| 3933 Snapshot::Kind kind); | 3932 Snapshot::Kind kind); |
| 3934 | 3933 |
| 3935 HEAP_OBJECT_IMPLEMENTATION(String, Instance); | 3934 HEAP_OBJECT_IMPLEMENTATION(String, Instance); |
| 3936 | 3935 |
| 3937 friend class Class; | 3936 friend class Class; |
| 3938 friend class Symbols; | 3937 friend class Symbols; |
| 3939 friend class OneByteString; | 3938 friend class OneByteString; |
| 3940 friend class TwoByteString; | 3939 friend class TwoByteString; |
| 3941 friend class ExternalOneByteString; | 3940 friend class ExternalOneByteString; |
| 3942 friend class ExternalTwoByteString; | 3941 friend class ExternalTwoByteString; |
| (...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5993 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5992 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| 5994 return false; | 5993 return false; |
| 5995 } | 5994 } |
| 5996 } | 5995 } |
| 5997 return true; | 5996 return true; |
| 5998 } | 5997 } |
| 5999 | 5998 |
| 6000 } // namespace dart | 5999 } // namespace dart |
| 6001 | 6000 |
| 6002 #endif // VM_OBJECT_H_ | 6001 #endif // VM_OBJECT_H_ |
| OLD | NEW |