Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: include/v8.h

Issue 16102002: Add template parameter to ReturnValue::Set. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: rebased Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(bool value)); 2785 V8_INLINE(void Set(bool value));
2786 V8_INLINE(void Set(double i)); 2786 V8_INLINE(void Set(double i));
2787 V8_INLINE(void Set(int32_t i)); 2787 V8_INLINE(void Set(int32_t i));
2788 V8_INLINE(void Set(uint32_t i)); 2788 V8_INLINE(void Set(uint32_t i));
2789 // Fast JS primitive setters 2789 // Fast JS primitive setters
2790 V8_INLINE(void SetNull()); 2790 V8_INLINE(void SetNull());
2791 V8_INLINE(void SetUndefined()); 2791 V8_INLINE(void SetUndefined());
2792 // Convenience getter for Isolate 2792 // Convenience getter for Isolate
2793 V8_INLINE(Isolate* GetIsolate()); 2793 V8_INLINE(Isolate* GetIsolate());
(...skipping 2883 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
5689 TYPE_CHECK(T, S);
5688 *value_ = *reinterpret_cast<internal::Object**>(*handle); 5690 *value_ = *reinterpret_cast<internal::Object**>(*handle);
5689 } 5691 }
5690 5692
5691 template<typename T> 5693 template<typename T>
5692 void ReturnValue<T>::Set(const Handle<T> handle) { 5694 template<typename S>
5695 void ReturnValue<T>::Set(const Handle<S> handle) {
5696 TYPE_CHECK(T, S);
5693 *value_ = *reinterpret_cast<internal::Object**>(*handle); 5697 *value_ = *reinterpret_cast<internal::Object**>(*handle);
5694 } 5698 }
5695 5699
5696 template<typename T> 5700 template<typename T>
5697 void ReturnValue<T>::Set(double i) { 5701 void ReturnValue<T>::Set(double i) {
5698 Set(Number::New(GetIsolate(), i)); 5702 Set(Number::New(GetIsolate(), i));
5699 } 5703 }
5700 5704
5701 template<typename T> 5705 template<typename T>
5702 void ReturnValue<T>::Set(int32_t i) { 5706 void ReturnValue<T>::Set(int32_t i) {
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
6321 6325
6322 6326
6323 } // namespace v8 6327 } // namespace v8
6324 6328
6325 6329
6326 #undef V8EXPORT 6330 #undef V8EXPORT
6327 #undef TYPE_CHECK 6331 #undef TYPE_CHECK
6328 6332
6329 6333
6330 #endif // V8_H_ 6334 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698