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 5630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5641 kIsolateEmbedderDataOffset + slot * kApiPointerSize; | 5641 kIsolateEmbedderDataOffset + slot * kApiPointerSize; |
5642 return *reinterpret_cast<void**>(addr); | 5642 return *reinterpret_cast<void**>(addr); |
5643 } | 5643 } |
5644 | 5644 |
5645 V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate, | 5645 V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate, |
5646 int index) { | 5646 int index) { |
5647 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; | 5647 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; |
5648 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); | 5648 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); |
5649 } | 5649 } |
5650 | 5650 |
5651 template <typename T> V8_INLINE static T ReadField(Object* ptr, int offset) { | 5651 template <typename T> |
| 5652 V8_INLINE static T ReadField(internal::Object* ptr, int offset) { |
5652 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; | 5653 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; |
5653 return *reinterpret_cast<T*>(addr); | 5654 return *reinterpret_cast<T*>(addr); |
5654 } | 5655 } |
5655 | 5656 |
5656 template <typename T> | 5657 template <typename T> |
5657 V8_INLINE static T ReadEmbedderData(Context* context, int index) { | 5658 V8_INLINE static T ReadEmbedderData(v8::Context* context, int index) { |
5658 typedef internal::Object O; | 5659 typedef internal::Object O; |
5659 typedef internal::Internals I; | 5660 typedef internal::Internals I; |
5660 O* ctx = *reinterpret_cast<O**>(context); | 5661 O* ctx = *reinterpret_cast<O**>(context); |
5661 int embedder_data_offset = I::kContextHeaderSize + | 5662 int embedder_data_offset = I::kContextHeaderSize + |
5662 (internal::kApiPointerSize * I::kContextEmbedderDataIndex); | 5663 (internal::kApiPointerSize * I::kContextEmbedderDataIndex); |
5663 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); | 5664 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); |
5664 int value_offset = | 5665 int value_offset = |
5665 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); | 5666 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); |
5666 return I::ReadField<T>(embedder_data, value_offset); | 5667 return I::ReadField<T>(embedder_data, value_offset); |
5667 } | 5668 } |
5668 | |
5669 V8_INLINE static bool CanCastToHeapObject(void* o) { return false; } | |
5670 V8_INLINE static bool CanCastToHeapObject(Context* o) { return true; } | |
5671 V8_INLINE static bool CanCastToHeapObject(String* o) { return true; } | |
5672 V8_INLINE static bool CanCastToHeapObject(Object* o) { return true; } | |
5673 V8_INLINE static bool CanCastToHeapObject(Message* o) { return true; } | |
5674 V8_INLINE static bool CanCastToHeapObject(StackTrace* o) { return true; } | |
5675 V8_INLINE static bool CanCastToHeapObject(StackFrame* o) { return true; } | |
5676 }; | 5669 }; |
5677 | 5670 |
5678 } // namespace internal | 5671 } // namespace internal |
5679 | 5672 |
5680 | 5673 |
5681 template <class T> | 5674 template <class T> |
5682 Local<T>::Local() : Handle<T>() { } | 5675 Local<T>::Local() : Handle<T>() { } |
5683 | 5676 |
5684 | 5677 |
5685 template <class T> | 5678 template <class T> |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6636 */ | 6629 */ |
6637 | 6630 |
6638 | 6631 |
6639 } // namespace v8 | 6632 } // namespace v8 |
6640 | 6633 |
6641 | 6634 |
6642 #undef TYPE_CHECK | 6635 #undef TYPE_CHECK |
6643 | 6636 |
6644 | 6637 |
6645 #endif // V8_H_ | 6638 #endif // V8_H_ |
OLD | NEW |