Commit f69727d8 authored by dcarney@chromium.org's avatar dcarney@chromium.org

Add template parameter to ReturnValue::Set.

E.g., v8-i18n wants to set the return value with a different type of a Persistent.

BUG=NONE
R=dcarney@chromium.org, svenpanne@chromium.org

Review URL: https://codereview.chromium.org/16102002

Patch from Marja Hölttä <marja@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14826 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6fda4e4c
...@@ -2779,8 +2779,8 @@ class ReturnValue { ...@@ -2779,8 +2779,8 @@ class ReturnValue {
public: public:
V8_INLINE(explicit ReturnValue(internal::Object** slot)); V8_INLINE(explicit ReturnValue(internal::Object** slot));
// Handle setters // Handle setters
V8_INLINE(void Set(const Persistent<T>& handle)); template <typename S> V8_INLINE(void Set(const Persistent<S>& handle));
V8_INLINE(void Set(const Handle<T> handle)); template <typename S> V8_INLINE(void Set(const Handle<S> handle));
// Fast primitive setters // Fast primitive setters
V8_INLINE(void Set(bool value)); V8_INLINE(void Set(bool value));
V8_INLINE(void Set(double i)); V8_INLINE(void Set(double i));
...@@ -5684,12 +5684,16 @@ template<typename T> ...@@ -5684,12 +5684,16 @@ template<typename T>
ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
template<typename T> template<typename T>
void ReturnValue<T>::Set(const Persistent<T>& handle) { template<typename S>
void ReturnValue<T>::Set(const Persistent<S>& handle) {
TYPE_CHECK(T, S);
*value_ = *reinterpret_cast<internal::Object**>(*handle); *value_ = *reinterpret_cast<internal::Object**>(*handle);
} }
template<typename T> template<typename T>
void ReturnValue<T>::Set(const Handle<T> handle) { template<typename S>
void ReturnValue<T>::Set(const Handle<S> handle) {
TYPE_CHECK(T, S);
*value_ = *reinterpret_cast<internal::Object**>(*handle); *value_ = *reinterpret_cast<internal::Object**>(*handle);
} }
......
...@@ -1074,6 +1074,12 @@ void FastReturnValueCallback<void>( ...@@ -1074,6 +1074,12 @@ void FastReturnValueCallback<void>(
} }
} }
template<>
void FastReturnValueCallback<Object>(
const v8::FunctionCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(Object::New());
}
template<typename T> template<typename T>
Handle<Value> TestFastReturnValues() { Handle<Value> TestFastReturnValues() {
LocalContext env; LocalContext env;
...@@ -1118,6 +1124,8 @@ THREADED_TEST(FastReturnValues) { ...@@ -1118,6 +1124,8 @@ THREADED_TEST(FastReturnValues) {
CHECK(value->IsUndefined()); CHECK(value->IsUndefined());
} }
} }
value = TestFastReturnValues<Object>();
CHECK(value->IsObject());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment