Chromium Code Reviews| 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 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2772 friend class ObjectTemplate; | 2772 friend class ObjectTemplate; |
| 2773 friend class FunctionTemplate; | 2773 friend class FunctionTemplate; |
| 2774 }; | 2774 }; |
| 2775 | 2775 |
| 2776 | 2776 |
| 2777 template<typename T> | 2777 template<typename T> |
| 2778 class ReturnValue { | 2778 class ReturnValue { |
| 2779 public: | 2779 public: |
| 2780 V8_INLINE(explicit ReturnValue(internal::Object** slot)); | 2780 V8_INLINE(explicit ReturnValue(internal::Object** slot)); |
| 2781 // Handle setters | 2781 // Handle setters |
| 2782 V8_INLINE(void Set(const Persistent<T>& handle)); | 2782 template <typename S> V8_INLINE(void Set(const Persistent<S>& handle)); |
| 2783 V8_INLINE(void Set(const Handle<T> handle)); | 2783 template <typename S> V8_INLINE(void Set(const Handle<S> handle)); |
| 2784 // Fast primitive setters | 2784 // Fast primitive setters |
| 2785 V8_INLINE(void Set(Isolate* isolate, bool value)); | 2785 V8_INLINE(void Set(Isolate* isolate, bool value)); |
| 2786 V8_INLINE(void Set(Isolate* isolate, double i)); | 2786 V8_INLINE(void Set(Isolate* isolate, double i)); |
| 2787 V8_INLINE(void Set(Isolate* isolate, int32_t i)); | 2787 V8_INLINE(void Set(Isolate* isolate, int32_t i)); |
| 2788 V8_INLINE(void Set(Isolate* isolate, uint32_t i)); | 2788 V8_INLINE(void Set(Isolate* isolate, uint32_t i)); |
| 2789 // Fast JS primitive setters | 2789 // Fast JS primitive setters |
| 2790 V8_INLINE(void SetNull(Isolate* isolate)); | 2790 V8_INLINE(void SetNull(Isolate* isolate)); |
| 2791 V8_INLINE(void SetUndefined(Isolate* isolate)); | 2791 V8_INLINE(void SetUndefined(Isolate* isolate)); |
| 2792 private: | 2792 private: |
| 2793 V8_INLINE(void SetTrue(Isolate* isolate)); | 2793 V8_INLINE(void SetTrue(Isolate* isolate)); |
| (...skipping 2883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5677 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); | 5677 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); |
| 5678 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; | 5678 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; |
| 5679 return *reinterpret_cast<uint16_t*>(addr); | 5679 return *reinterpret_cast<uint16_t*>(addr); |
| 5680 } | 5680 } |
| 5681 | 5681 |
| 5682 | 5682 |
| 5683 template<typename T> | 5683 template<typename T> |
| 5684 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} | 5684 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} |
| 5685 | 5685 |
| 5686 template<typename T> | 5686 template<typename T> |
| 5687 void ReturnValue<T>::Set(const Persistent<T>& handle) { | 5687 template<typename S> |
| 5688 void ReturnValue<T>::Set(const Persistent<S>& handle) { | |
|
dcarney
2013/05/27 12:34:36
you need the correct type check here
and a test to
marja
2013/05/27 13:09:28
Done.
| |
| 5688 *value_ = *reinterpret_cast<internal::Object**>(*handle); | 5689 *value_ = *reinterpret_cast<internal::Object**>(*handle); |
| 5689 } | 5690 } |
| 5690 | 5691 |
| 5691 template<typename T> | 5692 template<typename T> |
| 5692 void ReturnValue<T>::Set(const Handle<T> handle) { | 5693 template<typename S> |
| 5694 void ReturnValue<T>::Set(const Handle<S> handle) { | |
| 5693 *value_ = *reinterpret_cast<internal::Object**>(*handle); | 5695 *value_ = *reinterpret_cast<internal::Object**>(*handle); |
| 5694 } | 5696 } |
| 5695 | 5697 |
| 5696 template<typename T> | 5698 template<typename T> |
| 5697 void ReturnValue<T>::Set(Isolate* isolate, double i) { | 5699 void ReturnValue<T>::Set(Isolate* isolate, double i) { |
| 5698 Set(Number::New(isolate, i)); | 5700 Set(Number::New(isolate, i)); |
| 5699 } | 5701 } |
| 5700 | 5702 |
| 5701 template<typename T> | 5703 template<typename T> |
| 5702 void ReturnValue<T>::Set(Isolate* isolate, int32_t i) { | 5704 void ReturnValue<T>::Set(Isolate* isolate, int32_t i) { |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6324 | 6326 |
| 6325 | 6327 |
| 6326 } // namespace v8 | 6328 } // namespace v8 |
| 6327 | 6329 |
| 6328 | 6330 |
| 6329 #undef V8EXPORT | 6331 #undef V8EXPORT |
| 6330 #undef TYPE_CHECK | 6332 #undef TYPE_CHECK |
| 6331 | 6333 |
| 6332 | 6334 |
| 6333 #endif // V8_H_ | 6335 #endif // V8_H_ |
| OLD | NEW |