| 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 2826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2837 // Fast JS primitive setters | 2837 // Fast JS primitive setters |
| 2838 V8_INLINE(void SetNull()); | 2838 V8_INLINE(void SetNull()); |
| 2839 V8_INLINE(void SetUndefined()); | 2839 V8_INLINE(void SetUndefined()); |
| 2840 // Convenience getter for Isolate | 2840 // Convenience getter for Isolate |
| 2841 V8_INLINE(Isolate* GetIsolate()); | 2841 V8_INLINE(Isolate* GetIsolate()); |
| 2842 | 2842 |
| 2843 private: | 2843 private: |
| 2844 template<class F> friend class ReturnValue; | 2844 template<class F> friend class ReturnValue; |
| 2845 template<class F> friend class FunctionCallbackInfo; | 2845 template<class F> friend class FunctionCallbackInfo; |
| 2846 template<class F> friend class PropertyCallbackInfo; | 2846 template<class F> friend class PropertyCallbackInfo; |
| 2847 V8_INLINE(internal::Object* GetDefaultValue()); |
| 2847 V8_INLINE(explicit ReturnValue(internal::Object** slot)); | 2848 V8_INLINE(explicit ReturnValue(internal::Object** slot)); |
| 2848 internal::Object** value_; | 2849 internal::Object** value_; |
| 2849 }; | 2850 }; |
| 2850 | 2851 |
| 2851 | 2852 |
| 2852 /** | 2853 /** |
| 2853 * The argument information given to function call callbacks. This | 2854 * The argument information given to function call callbacks. This |
| 2854 * class provides access to information about the context of the call, | 2855 * class provides access to information about the context of the call, |
| 2855 * including the receiver, the number and values of arguments, and | 2856 * including the receiver, the number and values of arguments, and |
| 2856 * the holder of the function. | 2857 * the holder of the function. |
| 2857 */ | 2858 */ |
| 2858 template<typename T> | 2859 template<typename T> |
| 2859 class FunctionCallbackInfo { | 2860 class FunctionCallbackInfo { |
| 2860 public: | 2861 public: |
| 2861 V8_INLINE(int Length() const); | 2862 V8_INLINE(int Length() const); |
| 2862 V8_INLINE(Local<Value> operator[](int i) const); | 2863 V8_INLINE(Local<Value> operator[](int i) const); |
| 2863 V8_INLINE(Local<Function> Callee() const); | 2864 V8_INLINE(Local<Function> Callee() const); |
| 2864 V8_INLINE(Local<Object> This() const); | 2865 V8_INLINE(Local<Object> This() const); |
| 2865 V8_INLINE(Local<Object> Holder() const); | 2866 V8_INLINE(Local<Object> Holder() const); |
| 2866 V8_INLINE(bool IsConstructCall() const); | 2867 V8_INLINE(bool IsConstructCall() const); |
| 2867 V8_INLINE(Local<Value> Data() const); | 2868 V8_INLINE(Local<Value> Data() const); |
| 2868 V8_INLINE(Isolate* GetIsolate() const); | 2869 V8_INLINE(Isolate* GetIsolate() const); |
| 2869 V8_INLINE(ReturnValue<T> GetReturnValue() const); | 2870 V8_INLINE(ReturnValue<T> GetReturnValue() const); |
| 2870 // This shouldn't be public, but the arm compiler needs it. | 2871 // This shouldn't be public, but the arm compiler needs it. |
| 2871 static const int kArgsLength = 5; | 2872 static const int kArgsLength = 6; |
| 2872 | 2873 |
| 2873 protected: | 2874 protected: |
| 2874 friend class internal::FunctionCallbackArguments; | 2875 friend class internal::FunctionCallbackArguments; |
| 2875 friend class internal::CustomArguments<FunctionCallbackInfo>; | 2876 friend class internal::CustomArguments<FunctionCallbackInfo>; |
| 2876 static const int kReturnValueIndex = 0; | 2877 static const int kReturnValueIndex = 0; |
| 2877 static const int kIsolateIndex = -1; | 2878 static const int kReturnValueDefaultValueIndex = -1; |
| 2878 static const int kDataIndex = -2; | 2879 static const int kIsolateIndex = -2; |
| 2879 static const int kCalleeIndex = -3; | 2880 static const int kDataIndex = -3; |
| 2880 static const int kHolderIndex = -4; | 2881 static const int kCalleeIndex = -4; |
| 2882 static const int kHolderIndex = -5; |
| 2881 | 2883 |
| 2882 V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args, | 2884 V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args, |
| 2883 internal::Object** values, | 2885 internal::Object** values, |
| 2884 int length, | 2886 int length, |
| 2885 bool is_construct_call)); | 2887 bool is_construct_call)); |
| 2886 internal::Object** implicit_args_; | 2888 internal::Object** implicit_args_; |
| 2887 internal::Object** values_; | 2889 internal::Object** values_; |
| 2888 int length_; | 2890 int length_; |
| 2889 bool is_construct_call_; | 2891 bool is_construct_call_; |
| 2890 }; | 2892 }; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2905 */ | 2907 */ |
| 2906 template<typename T> | 2908 template<typename T> |
| 2907 class PropertyCallbackInfo { | 2909 class PropertyCallbackInfo { |
| 2908 public: | 2910 public: |
| 2909 V8_INLINE(Isolate* GetIsolate() const); | 2911 V8_INLINE(Isolate* GetIsolate() const); |
| 2910 V8_INLINE(Local<Value> Data() const); | 2912 V8_INLINE(Local<Value> Data() const); |
| 2911 V8_INLINE(Local<Object> This() const); | 2913 V8_INLINE(Local<Object> This() const); |
| 2912 V8_INLINE(Local<Object> Holder() const); | 2914 V8_INLINE(Local<Object> Holder() const); |
| 2913 V8_INLINE(ReturnValue<T> GetReturnValue() const); | 2915 V8_INLINE(ReturnValue<T> GetReturnValue() const); |
| 2914 // This shouldn't be public, but the arm compiler needs it. | 2916 // This shouldn't be public, but the arm compiler needs it. |
| 2915 static const int kArgsLength = 5; | 2917 static const int kArgsLength = 6; |
| 2916 | 2918 |
| 2917 protected: | 2919 protected: |
| 2918 friend class MacroAssembler; | 2920 friend class MacroAssembler; |
| 2919 friend class internal::PropertyCallbackArguments; | 2921 friend class internal::PropertyCallbackArguments; |
| 2920 friend class internal::CustomArguments<PropertyCallbackInfo>; | 2922 friend class internal::CustomArguments<PropertyCallbackInfo>; |
| 2921 static const int kThisIndex = 0; | 2923 static const int kThisIndex = 0; |
| 2922 static const int kHolderIndex = -1; | 2924 static const int kHolderIndex = -1; |
| 2923 static const int kDataIndex = -2; | 2925 static const int kDataIndex = -2; |
| 2924 static const int kReturnValueIndex = -3; | 2926 static const int kReturnValueIndex = -3; |
| 2925 static const int kIsolateIndex = -4; | 2927 static const int kReturnValueDefaultValueIndex = -4; |
| 2928 static const int kIsolateIndex = -5; |
| 2926 | 2929 |
| 2927 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) | 2930 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) |
| 2928 : args_(args) { } | 2931 : args_(args) { } |
| 2929 internal::Object** args_; | 2932 internal::Object** args_; |
| 2930 }; | 2933 }; |
| 2931 | 2934 |
| 2932 | 2935 |
| 2933 class V8EXPORT AccessorInfo : public PropertyCallbackInfo<Value> { | 2936 class V8EXPORT AccessorInfo : public PropertyCallbackInfo<Value> { |
| 2934 private: | 2937 private: |
| 2935 friend class internal::PropertyCallbackArguments; | 2938 friend class internal::PropertyCallbackArguments; |
| (...skipping 2707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5643 | 5646 |
| 5644 | 5647 |
| 5645 template<typename T> | 5648 template<typename T> |
| 5646 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} | 5649 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} |
| 5647 | 5650 |
| 5648 template<typename T> | 5651 template<typename T> |
| 5649 template<typename S> | 5652 template<typename S> |
| 5650 void ReturnValue<T>::Set(const Persistent<S>& handle) { | 5653 void ReturnValue<T>::Set(const Persistent<S>& handle) { |
| 5651 TYPE_CHECK(T, S); | 5654 TYPE_CHECK(T, S); |
| 5652 if (V8_UNLIKELY(handle.IsEmpty())) { | 5655 if (V8_UNLIKELY(handle.IsEmpty())) { |
| 5653 SetUndefined(); | 5656 *value_ = GetDefaultValue(); |
| 5654 } else { | 5657 } else { |
| 5655 *value_ = *reinterpret_cast<internal::Object**>(*handle); | 5658 *value_ = *reinterpret_cast<internal::Object**>(*handle); |
| 5656 } | 5659 } |
| 5657 } | 5660 } |
| 5658 | 5661 |
| 5659 template<typename T> | 5662 template<typename T> |
| 5660 template<typename S> | 5663 template<typename S> |
| 5661 void ReturnValue<T>::Set(const Handle<S> handle) { | 5664 void ReturnValue<T>::Set(const Handle<S> handle) { |
| 5662 TYPE_CHECK(T, S); | 5665 TYPE_CHECK(T, S); |
| 5663 if (V8_UNLIKELY(handle.IsEmpty())) { | 5666 if (V8_UNLIKELY(handle.IsEmpty())) { |
| 5664 SetUndefined(); | 5667 *value_ = GetDefaultValue(); |
| 5665 } else { | 5668 } else { |
| 5666 *value_ = *reinterpret_cast<internal::Object**>(*handle); | 5669 *value_ = *reinterpret_cast<internal::Object**>(*handle); |
| 5667 } | 5670 } |
| 5668 } | 5671 } |
| 5669 | 5672 |
| 5670 template<typename T> | 5673 template<typename T> |
| 5671 void ReturnValue<T>::Set(double i) { | 5674 void ReturnValue<T>::Set(double i) { |
| 5672 Set(Number::New(GetIsolate(), i)); | 5675 Set(Number::New(GetIsolate(), i)); |
| 5673 } | 5676 } |
| 5674 | 5677 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5713 } | 5716 } |
| 5714 | 5717 |
| 5715 template<typename T> | 5718 template<typename T> |
| 5716 void ReturnValue<T>::SetUndefined() { | 5719 void ReturnValue<T>::SetUndefined() { |
| 5717 typedef internal::Internals I; | 5720 typedef internal::Internals I; |
| 5718 *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex); | 5721 *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex); |
| 5719 } | 5722 } |
| 5720 | 5723 |
| 5721 template<typename T> | 5724 template<typename T> |
| 5722 Isolate* ReturnValue<T>::GetIsolate() { | 5725 Isolate* ReturnValue<T>::GetIsolate() { |
| 5723 // Isolate is always the pointer below value_ on the stack. | 5726 // Isolate is always the pointer below the default value on the stack. |
| 5724 return *reinterpret_cast<Isolate**>(&value_[-1]); | 5727 return *reinterpret_cast<Isolate**>(&value_[-2]); |
| 5728 } |
| 5729 |
| 5730 template<typename T> |
| 5731 internal::Object* ReturnValue<T>::GetDefaultValue() { |
| 5732 // Default value is always the pointer below value_ on the stack. |
| 5733 return value_[-1]; |
| 5725 } | 5734 } |
| 5726 | 5735 |
| 5727 | 5736 |
| 5728 template<typename T> | 5737 template<typename T> |
| 5729 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, | 5738 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, |
| 5730 internal::Object** values, | 5739 internal::Object** values, |
| 5731 int length, | 5740 int length, |
| 5732 bool is_construct_call) | 5741 bool is_construct_call) |
| 5733 : implicit_args_(implicit_args), | 5742 : implicit_args_(implicit_args), |
| 5734 values_(values), | 5743 values_(values), |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6310 | 6319 |
| 6311 | 6320 |
| 6312 } // namespace v8 | 6321 } // namespace v8 |
| 6313 | 6322 |
| 6314 | 6323 |
| 6315 #undef V8EXPORT | 6324 #undef V8EXPORT |
| 6316 #undef TYPE_CHECK | 6325 #undef TYPE_CHECK |
| 6317 | 6326 |
| 6318 | 6327 |
| 6319 #endif // V8_H_ | 6328 #endif // V8_H_ |
| OLD | NEW |