OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
6 * | 6 * |
7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
8 * | 8 * |
9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
(...skipping 6178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6189 typedef internal::Internals I; | 6189 typedef internal::Internals I; |
6190 I::CheckInitialized(isolate); | 6190 I::CheckInitialized(isolate); |
6191 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); | 6191 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); |
6192 return Local<String>(reinterpret_cast<String*>(slot)); | 6192 return Local<String>(reinterpret_cast<String*>(slot)); |
6193 } | 6193 } |
6194 | 6194 |
6195 | 6195 |
6196 String::ExternalStringResource* String::GetExternalStringResource() const { | 6196 String::ExternalStringResource* String::GetExternalStringResource() const { |
6197 typedef internal::Object O; | 6197 typedef internal::Object O; |
6198 typedef internal::Internals I; | 6198 typedef internal::Internals I; |
6199 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | 6199 O* obj = *reinterpret_cast<O* const*>(this); |
6200 String::ExternalStringResource* result; | 6200 String::ExternalStringResource* result; |
6201 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { | 6201 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { |
6202 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | 6202 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); |
6203 result = reinterpret_cast<String::ExternalStringResource*>(value); | 6203 result = reinterpret_cast<String::ExternalStringResource*>(value); |
6204 } else { | 6204 } else { |
6205 result = NULL; | 6205 result = NULL; |
6206 } | 6206 } |
6207 #ifdef V8_ENABLE_CHECKS | 6207 #ifdef V8_ENABLE_CHECKS |
6208 VerifyExternalStringResource(result); | 6208 VerifyExternalStringResource(result); |
6209 #endif | 6209 #endif |
6210 return result; | 6210 return result; |
6211 } | 6211 } |
6212 | 6212 |
6213 | 6213 |
6214 String::ExternalStringResourceBase* String::GetExternalStringResourceBase( | 6214 String::ExternalStringResourceBase* String::GetExternalStringResourceBase( |
6215 String::Encoding* encoding_out) const { | 6215 String::Encoding* encoding_out) const { |
6216 typedef internal::Object O; | 6216 typedef internal::Object O; |
6217 typedef internal::Internals I; | 6217 typedef internal::Internals I; |
6218 O* obj = *reinterpret_cast<O**>(const_cast<String*>(this)); | 6218 O* obj = *reinterpret_cast<O* const*>(this); |
6219 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; | 6219 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; |
6220 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask); | 6220 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask); |
6221 ExternalStringResourceBase* resource = NULL; | 6221 ExternalStringResourceBase* resource = NULL; |
6222 if (type == I::kExternalAsciiRepresentationTag || | 6222 if (type == I::kExternalAsciiRepresentationTag || |
6223 type == I::kExternalTwoByteRepresentationTag) { | 6223 type == I::kExternalTwoByteRepresentationTag) { |
6224 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); | 6224 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); |
6225 resource = static_cast<ExternalStringResourceBase*>(value); | 6225 resource = static_cast<ExternalStringResourceBase*>(value); |
6226 } | 6226 } |
6227 #ifdef V8_ENABLE_CHECKS | 6227 #ifdef V8_ENABLE_CHECKS |
6228 VerifyExternalStringResourceBase(resource, *encoding_out); | 6228 VerifyExternalStringResourceBase(resource, *encoding_out); |
6229 #endif | 6229 #endif |
6230 return resource; | 6230 return resource; |
6231 } | 6231 } |
6232 | 6232 |
6233 | 6233 |
6234 bool Value::IsUndefined() const { | 6234 bool Value::IsUndefined() const { |
6235 #ifdef V8_ENABLE_CHECKS | 6235 #ifdef V8_ENABLE_CHECKS |
6236 return FullIsUndefined(); | 6236 return FullIsUndefined(); |
6237 #else | 6237 #else |
6238 return QuickIsUndefined(); | 6238 return QuickIsUndefined(); |
6239 #endif | 6239 #endif |
6240 } | 6240 } |
6241 | 6241 |
6242 bool Value::QuickIsUndefined() const { | 6242 bool Value::QuickIsUndefined() const { |
6243 typedef internal::Object O; | 6243 typedef internal::Object O; |
6244 typedef internal::Internals I; | 6244 typedef internal::Internals I; |
6245 O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); | 6245 O* obj = *reinterpret_cast<O* const*>(this); |
6246 if (!I::HasHeapObjectTag(obj)) return false; | 6246 if (!I::HasHeapObjectTag(obj)) return false; |
6247 if (I::GetInstanceType(obj) != I::kOddballType) return false; | 6247 if (I::GetInstanceType(obj) != I::kOddballType) return false; |
6248 return (I::GetOddballKind(obj) == I::kUndefinedOddballKind); | 6248 return (I::GetOddballKind(obj) == I::kUndefinedOddballKind); |
6249 } | 6249 } |
6250 | 6250 |
6251 | 6251 |
6252 bool Value::IsNull() const { | 6252 bool Value::IsNull() const { |
6253 #ifdef V8_ENABLE_CHECKS | 6253 #ifdef V8_ENABLE_CHECKS |
6254 return FullIsNull(); | 6254 return FullIsNull(); |
6255 #else | 6255 #else |
6256 return QuickIsNull(); | 6256 return QuickIsNull(); |
6257 #endif | 6257 #endif |
6258 } | 6258 } |
6259 | 6259 |
6260 bool Value::QuickIsNull() const { | 6260 bool Value::QuickIsNull() const { |
6261 typedef internal::Object O; | 6261 typedef internal::Object O; |
6262 typedef internal::Internals I; | 6262 typedef internal::Internals I; |
6263 O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); | 6263 O* obj = *reinterpret_cast<O* const*>(this); |
6264 if (!I::HasHeapObjectTag(obj)) return false; | 6264 if (!I::HasHeapObjectTag(obj)) return false; |
6265 if (I::GetInstanceType(obj) != I::kOddballType) return false; | 6265 if (I::GetInstanceType(obj) != I::kOddballType) return false; |
6266 return (I::GetOddballKind(obj) == I::kNullOddballKind); | 6266 return (I::GetOddballKind(obj) == I::kNullOddballKind); |
6267 } | 6267 } |
6268 | 6268 |
6269 | 6269 |
6270 bool Value::IsString() const { | 6270 bool Value::IsString() const { |
6271 #ifdef V8_ENABLE_CHECKS | 6271 #ifdef V8_ENABLE_CHECKS |
6272 return FullIsString(); | 6272 return FullIsString(); |
6273 #else | 6273 #else |
6274 return QuickIsString(); | 6274 return QuickIsString(); |
6275 #endif | 6275 #endif |
6276 } | 6276 } |
6277 | 6277 |
6278 bool Value::QuickIsString() const { | 6278 bool Value::QuickIsString() const { |
6279 typedef internal::Object O; | 6279 typedef internal::Object O; |
6280 typedef internal::Internals I; | 6280 typedef internal::Internals I; |
6281 O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); | 6281 O* obj = *reinterpret_cast<O* const*>(this); |
6282 if (!I::HasHeapObjectTag(obj)) return false; | 6282 if (!I::HasHeapObjectTag(obj)) return false; |
6283 return (I::GetInstanceType(obj) < I::kFirstNonstringType); | 6283 return (I::GetInstanceType(obj) < I::kFirstNonstringType); |
6284 } | 6284 } |
6285 | 6285 |
6286 | 6286 |
6287 template <class T> Value* Value::Cast(T* value) { | 6287 template <class T> Value* Value::Cast(T* value) { |
6288 return static_cast<Value*>(value); | 6288 return static_cast<Value*>(value); |
6289 } | 6289 } |
6290 | 6290 |
6291 | 6291 |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6683 */ | 6683 */ |
6684 | 6684 |
6685 | 6685 |
6686 } // namespace v8 | 6686 } // namespace v8 |
6687 | 6687 |
6688 | 6688 |
6689 #undef TYPE_CHECK | 6689 #undef TYPE_CHECK |
6690 | 6690 |
6691 | 6691 |
6692 #endif // V8_H_ | 6692 #endif // V8_H_ |
OLD | NEW |