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 3174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3185 */ | 3185 */ |
3186 template<typename T> | 3186 template<typename T> |
3187 class FunctionCallbackInfo { | 3187 class FunctionCallbackInfo { |
3188 public: | 3188 public: |
3189 V8_INLINE int Length() const; | 3189 V8_INLINE int Length() const; |
3190 V8_INLINE Local<Value> operator[](int i) const; | 3190 V8_INLINE Local<Value> operator[](int i) const; |
3191 V8_INLINE V8_DEPRECATED("Use Data() to explicitly pass Callee instead", | 3191 V8_INLINE V8_DEPRECATED("Use Data() to explicitly pass Callee instead", |
3192 Local<Function> Callee() const); | 3192 Local<Function> Callee() const); |
3193 V8_INLINE Local<Object> This() const; | 3193 V8_INLINE Local<Object> This() const; |
3194 V8_INLINE Local<Object> Holder() const; | 3194 V8_INLINE Local<Object> Holder() const; |
| 3195 V8_INLINE Local<Value> NewTarget() const; |
3195 V8_INLINE bool IsConstructCall() const; | 3196 V8_INLINE bool IsConstructCall() const; |
3196 V8_INLINE Local<Value> Data() const; | 3197 V8_INLINE Local<Value> Data() const; |
3197 V8_INLINE Isolate* GetIsolate() const; | 3198 V8_INLINE Isolate* GetIsolate() const; |
3198 V8_INLINE ReturnValue<T> GetReturnValue() const; | 3199 V8_INLINE ReturnValue<T> GetReturnValue() const; |
3199 // This shouldn't be public, but the arm compiler needs it. | 3200 // This shouldn't be public, but the arm compiler needs it. |
3200 static const int kArgsLength = 7; | 3201 static const int kArgsLength = 8; |
3201 | 3202 |
3202 protected: | 3203 protected: |
3203 friend class internal::FunctionCallbackArguments; | 3204 friend class internal::FunctionCallbackArguments; |
3204 friend class internal::CustomArguments<FunctionCallbackInfo>; | 3205 friend class internal::CustomArguments<FunctionCallbackInfo>; |
3205 static const int kHolderIndex = 0; | 3206 static const int kHolderIndex = 0; |
3206 static const int kIsolateIndex = 1; | 3207 static const int kIsolateIndex = 1; |
3207 static const int kReturnValueDefaultValueIndex = 2; | 3208 static const int kReturnValueDefaultValueIndex = 2; |
3208 static const int kReturnValueIndex = 3; | 3209 static const int kReturnValueIndex = 3; |
3209 static const int kDataIndex = 4; | 3210 static const int kDataIndex = 4; |
3210 static const int kCalleeIndex = 5; | 3211 static const int kCalleeIndex = 5; |
3211 static const int kContextSaveIndex = 6; | 3212 static const int kContextSaveIndex = 6; |
| 3213 static const int kNewTargetIndex = 7; |
3212 | 3214 |
3213 V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, | 3215 V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, |
3214 internal::Object** values, | 3216 internal::Object** values, int length); |
3215 int length, | |
3216 bool is_construct_call); | |
3217 internal::Object** implicit_args_; | 3217 internal::Object** implicit_args_; |
3218 internal::Object** values_; | 3218 internal::Object** values_; |
3219 int length_; | 3219 int length_; |
3220 int is_construct_call_; | |
3221 }; | 3220 }; |
3222 | 3221 |
3223 | 3222 |
3224 /** | 3223 /** |
3225 * The information passed to a property callback about the context | 3224 * The information passed to a property callback about the context |
3226 * of the property access. | 3225 * of the property access. |
3227 */ | 3226 */ |
3228 template<typename T> | 3227 template<typename T> |
3229 class PropertyCallbackInfo { | 3228 class PropertyCallbackInfo { |
3230 public: | 3229 public: |
(...skipping 4627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7858 // Uncompilable to prevent inadvertent misuse. | 7857 // Uncompilable to prevent inadvertent misuse. |
7859 TYPE_CHECK(S*, Primitive); | 7858 TYPE_CHECK(S*, Primitive); |
7860 } | 7859 } |
7861 | 7860 |
7862 template<typename T> | 7861 template<typename T> |
7863 internal::Object* ReturnValue<T>::GetDefaultValue() { | 7862 internal::Object* ReturnValue<T>::GetDefaultValue() { |
7864 // Default value is always the pointer below value_ on the stack. | 7863 // Default value is always the pointer below value_ on the stack. |
7865 return value_[-1]; | 7864 return value_[-1]; |
7866 } | 7865 } |
7867 | 7866 |
7868 | 7867 template <typename T> |
7869 template<typename T> | |
7870 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, | 7868 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, |
7871 internal::Object** values, | 7869 internal::Object** values, |
7872 int length, | 7870 int length) |
7873 bool is_construct_call) | 7871 : implicit_args_(implicit_args), values_(values), length_(length) {} |
7874 : implicit_args_(implicit_args), | |
7875 values_(values), | |
7876 length_(length), | |
7877 is_construct_call_(is_construct_call) { } | |
7878 | |
7879 | 7872 |
7880 template<typename T> | 7873 template<typename T> |
7881 Local<Value> FunctionCallbackInfo<T>::operator[](int i) const { | 7874 Local<Value> FunctionCallbackInfo<T>::operator[](int i) const { |
7882 if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate())); | 7875 if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate())); |
7883 return Local<Value>(reinterpret_cast<Value*>(values_ - i)); | 7876 return Local<Value>(reinterpret_cast<Value*>(values_ - i)); |
7884 } | 7877 } |
7885 | 7878 |
7886 | 7879 |
7887 template<typename T> | 7880 template<typename T> |
7888 Local<Function> FunctionCallbackInfo<T>::Callee() const { | 7881 Local<Function> FunctionCallbackInfo<T>::Callee() const { |
7889 return Local<Function>(reinterpret_cast<Function*>( | 7882 return Local<Function>(reinterpret_cast<Function*>( |
7890 &implicit_args_[kCalleeIndex])); | 7883 &implicit_args_[kCalleeIndex])); |
7891 } | 7884 } |
7892 | 7885 |
7893 | 7886 |
7894 template<typename T> | 7887 template<typename T> |
7895 Local<Object> FunctionCallbackInfo<T>::This() const { | 7888 Local<Object> FunctionCallbackInfo<T>::This() const { |
7896 return Local<Object>(reinterpret_cast<Object*>(values_ + 1)); | 7889 return Local<Object>(reinterpret_cast<Object*>(values_ + 1)); |
7897 } | 7890 } |
7898 | 7891 |
7899 | 7892 |
7900 template<typename T> | 7893 template<typename T> |
7901 Local<Object> FunctionCallbackInfo<T>::Holder() const { | 7894 Local<Object> FunctionCallbackInfo<T>::Holder() const { |
7902 return Local<Object>(reinterpret_cast<Object*>( | 7895 return Local<Object>(reinterpret_cast<Object*>( |
7903 &implicit_args_[kHolderIndex])); | 7896 &implicit_args_[kHolderIndex])); |
7904 } | 7897 } |
7905 | 7898 |
| 7899 template <typename T> |
| 7900 Local<Value> FunctionCallbackInfo<T>::NewTarget() const { |
| 7901 return Local<Value>( |
| 7902 reinterpret_cast<Value*>(&implicit_args_[kNewTargetIndex])); |
| 7903 } |
7906 | 7904 |
7907 template<typename T> | 7905 template <typename T> |
7908 Local<Value> FunctionCallbackInfo<T>::Data() const { | 7906 Local<Value> FunctionCallbackInfo<T>::Data() const { |
7909 return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex])); | 7907 return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex])); |
7910 } | 7908 } |
7911 | 7909 |
7912 | 7910 |
7913 template<typename T> | 7911 template<typename T> |
7914 Isolate* FunctionCallbackInfo<T>::GetIsolate() const { | 7912 Isolate* FunctionCallbackInfo<T>::GetIsolate() const { |
7915 return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]); | 7913 return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]); |
7916 } | 7914 } |
7917 | 7915 |
7918 | 7916 |
7919 template<typename T> | 7917 template<typename T> |
7920 ReturnValue<T> FunctionCallbackInfo<T>::GetReturnValue() const { | 7918 ReturnValue<T> FunctionCallbackInfo<T>::GetReturnValue() const { |
7921 return ReturnValue<T>(&implicit_args_[kReturnValueIndex]); | 7919 return ReturnValue<T>(&implicit_args_[kReturnValueIndex]); |
7922 } | 7920 } |
7923 | 7921 |
7924 | 7922 |
7925 template<typename T> | 7923 template<typename T> |
7926 bool FunctionCallbackInfo<T>::IsConstructCall() const { | 7924 bool FunctionCallbackInfo<T>::IsConstructCall() const { |
7927 return is_construct_call_ & 0x1; | 7925 return !NewTarget()->IsUndefined(); |
7928 } | 7926 } |
7929 | 7927 |
7930 | 7928 |
7931 template<typename T> | 7929 template<typename T> |
7932 int FunctionCallbackInfo<T>::Length() const { | 7930 int FunctionCallbackInfo<T>::Length() const { |
7933 return length_; | 7931 return length_; |
7934 } | 7932 } |
7935 | 7933 |
7936 ScriptOrigin::ScriptOrigin(Local<Value> resource_name, | 7934 ScriptOrigin::ScriptOrigin(Local<Value> resource_name, |
7937 Local<Integer> resource_line_offset, | 7935 Local<Integer> resource_line_offset, |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8771 */ | 8769 */ |
8772 | 8770 |
8773 | 8771 |
8774 } // namespace v8 | 8772 } // namespace v8 |
8775 | 8773 |
8776 | 8774 |
8777 #undef TYPE_CHECK | 8775 #undef TYPE_CHECK |
8778 | 8776 |
8779 | 8777 |
8780 #endif // INCLUDE_V8_H_ | 8778 #endif // INCLUDE_V8_H_ |
OLD | NEW |