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 5647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5658 } | 5658 } |
5659 | 5659 |
5660 | 5660 |
5661 template<typename T> | 5661 template<typename T> |
5662 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} | 5662 ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} |
5663 | 5663 |
5664 template<typename T> | 5664 template<typename T> |
5665 template<typename S> | 5665 template<typename S> |
5666 void ReturnValue<T>::Set(const Persistent<S>& handle) { | 5666 void ReturnValue<T>::Set(const Persistent<S>& handle) { |
5667 TYPE_CHECK(T, S); | 5667 TYPE_CHECK(T, S); |
5668 *value_ = *reinterpret_cast<internal::Object**>(*handle); | 5668 if (V8_UNLIKELY(handle.IsEmpty())) { |
| 5669 SetUndefined(); |
| 5670 } else { |
| 5671 *value_ = *reinterpret_cast<internal::Object**>(*handle); |
| 5672 } |
5669 } | 5673 } |
5670 | 5674 |
5671 template<typename T> | 5675 template<typename T> |
5672 template<typename S> | 5676 template<typename S> |
5673 void ReturnValue<T>::Set(const Handle<S> handle) { | 5677 void ReturnValue<T>::Set(const Handle<S> handle) { |
5674 TYPE_CHECK(T, S); | 5678 TYPE_CHECK(T, S); |
5675 *value_ = *reinterpret_cast<internal::Object**>(*handle); | 5679 if (V8_UNLIKELY(handle.IsEmpty())) { |
| 5680 SetUndefined(); |
| 5681 } else { |
| 5682 *value_ = *reinterpret_cast<internal::Object**>(*handle); |
| 5683 } |
5676 } | 5684 } |
5677 | 5685 |
5678 template<typename T> | 5686 template<typename T> |
5679 void ReturnValue<T>::Set(double i) { | 5687 void ReturnValue<T>::Set(double i) { |
5680 Set(Number::New(GetIsolate(), i)); | 5688 Set(Number::New(GetIsolate(), i)); |
5681 } | 5689 } |
5682 | 5690 |
5683 template<typename T> | 5691 template<typename T> |
5684 void ReturnValue<T>::Set(int32_t i) { | 5692 void ReturnValue<T>::Set(int32_t i) { |
5685 typedef internal::Internals I; | 5693 typedef internal::Internals I; |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6303 | 6311 |
6304 | 6312 |
6305 } // namespace v8 | 6313 } // namespace v8 |
6306 | 6314 |
6307 | 6315 |
6308 #undef V8EXPORT | 6316 #undef V8EXPORT |
6309 #undef TYPE_CHECK | 6317 #undef TYPE_CHECK |
6310 | 6318 |
6311 | 6319 |
6312 #endif // V8_H_ | 6320 #endif // V8_H_ |
OLD | NEW |