OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 // UTF-8 encoded characters. | 1077 // UTF-8 encoded characters. |
1078 V8EXPORT int WriteUtf8(char* buffer, | 1078 V8EXPORT int WriteUtf8(char* buffer, |
1079 int length = -1, | 1079 int length = -1, |
1080 int* nchars_ref = NULL, | 1080 int* nchars_ref = NULL, |
1081 int options = NO_OPTIONS) const; | 1081 int options = NO_OPTIONS) const; |
1082 | 1082 |
1083 /** | 1083 /** |
1084 * A zero length string. | 1084 * A zero length string. |
1085 */ | 1085 */ |
1086 V8EXPORT static v8::Local<v8::String> Empty(); | 1086 V8EXPORT static v8::Local<v8::String> Empty(); |
| 1087 inline static v8::Local<v8::String> Empty(Isolate* isolate); |
1087 | 1088 |
1088 /** | 1089 /** |
1089 * Returns true if the string is external | 1090 * Returns true if the string is external |
1090 */ | 1091 */ |
1091 V8EXPORT bool IsExternal() const; | 1092 V8EXPORT bool IsExternal() const; |
1092 | 1093 |
1093 /** | 1094 /** |
1094 * Returns true if the string is both external and ASCII | 1095 * Returns true if the string is both external and ASCII |
1095 */ | 1096 */ |
1096 V8EXPORT bool IsExternalAscii() const; | 1097 V8EXPORT bool IsExternalAscii() const; |
(...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3896 static const int kFullStringRepresentationMask = 0x07; | 3897 static const int kFullStringRepresentationMask = 0x07; |
3897 static const int kExternalTwoByteRepresentationTag = 0x02; | 3898 static const int kExternalTwoByteRepresentationTag = 0x02; |
3898 | 3899 |
3899 static const int kIsolateStateOffset = 0; | 3900 static const int kIsolateStateOffset = 0; |
3900 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; | 3901 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; |
3901 static const int kIsolateRootsOffset = 3 * kApiPointerSize; | 3902 static const int kIsolateRootsOffset = 3 * kApiPointerSize; |
3902 static const int kUndefinedValueRootIndex = 5; | 3903 static const int kUndefinedValueRootIndex = 5; |
3903 static const int kNullValueRootIndex = 7; | 3904 static const int kNullValueRootIndex = 7; |
3904 static const int kTrueValueRootIndex = 8; | 3905 static const int kTrueValueRootIndex = 8; |
3905 static const int kFalseValueRootIndex = 9; | 3906 static const int kFalseValueRootIndex = 9; |
| 3907 static const int kEmptySymbolRootIndex = 128; |
3906 | 3908 |
3907 static const int kJSObjectType = 0xaa; | 3909 static const int kJSObjectType = 0xaa; |
3908 static const int kFirstNonstringType = 0x80; | 3910 static const int kFirstNonstringType = 0x80; |
3909 static const int kOddballType = 0x82; | 3911 static const int kOddballType = 0x82; |
3910 static const int kForeignType = 0x85; | 3912 static const int kForeignType = 0x85; |
3911 | 3913 |
3912 static const int kUndefinedOddballKind = 5; | 3914 static const int kUndefinedOddballKind = 5; |
3913 static const int kNullOddballKind = 3; | 3915 static const int kNullOddballKind = 3; |
3914 | 3916 |
3915 static inline bool HasHeapObjectTag(internal::Object* value) { | 3917 static inline bool HasHeapObjectTag(internal::Object* value) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4214 | 4216 |
4215 | 4217 |
4216 String* String::Cast(v8::Value* value) { | 4218 String* String::Cast(v8::Value* value) { |
4217 #ifdef V8_ENABLE_CHECKS | 4219 #ifdef V8_ENABLE_CHECKS |
4218 CheckCast(value); | 4220 CheckCast(value); |
4219 #endif | 4221 #endif |
4220 return static_cast<String*>(value); | 4222 return static_cast<String*>(value); |
4221 } | 4223 } |
4222 | 4224 |
4223 | 4225 |
| 4226 Local<String> String::Empty(Isolate* isolate) { |
| 4227 typedef internal::Object* S; |
| 4228 typedef internal::Internals I; |
| 4229 if (!I::IsInitialized(isolate)) return Empty(); |
| 4230 S* slot = I::GetRoot(isolate, I::kEmptySymbolRootIndex); |
| 4231 return Local<String>(reinterpret_cast<String*>(slot)); |
| 4232 } |
| 4233 |
| 4234 |
4224 String::ExternalStringResource* String::GetExternalStringResource() const { | 4235 String::ExternalStringResource* String::GetExternalStringResource() const { |
4225 typedef internal::Object O; | 4236 typedef internal::Object O; |
4226 typedef internal::Internals I; | 4237 typedef internal::Internals I; |
4227 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | 4238 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); |
4228 String::ExternalStringResource* result; | 4239 String::ExternalStringResource* result; |
4229 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { | 4240 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { |
4230 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | 4241 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); |
4231 result = reinterpret_cast<String::ExternalStringResource*>(value); | 4242 result = reinterpret_cast<String::ExternalStringResource*>(value); |
4232 } else { | 4243 } else { |
4233 result = NULL; | 4244 result = NULL; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4461 | 4472 |
4462 | 4473 |
4463 } // namespace v8 | 4474 } // namespace v8 |
4464 | 4475 |
4465 | 4476 |
4466 #undef V8EXPORT | 4477 #undef V8EXPORT |
4467 #undef TYPE_CHECK | 4478 #undef TYPE_CHECK |
4468 | 4479 |
4469 | 4480 |
4470 #endif // V8_H_ | 4481 #endif // V8_H_ |
OLD | NEW |