v8.h | v8.h | |||
---|---|---|---|---|
skipping to change at line 5578 | skipping to change at line 5578 | |||
TYPE_CHECK(T, S); | TYPE_CHECK(T, S); | |||
if (V8_UNLIKELY(handle.IsEmpty())) { | if (V8_UNLIKELY(handle.IsEmpty())) { | |||
*value_ = GetDefaultValue(); | *value_ = GetDefaultValue(); | |||
} else { | } else { | |||
*value_ = *reinterpret_cast<internal::Object**>(*handle); | *value_ = *reinterpret_cast<internal::Object**>(*handle); | |||
} | } | |||
} | } | |||
template<typename T> | template<typename T> | |||
void ReturnValue<T>::Set(double i) { | void ReturnValue<T>::Set(double i) { | |||
TYPE_CHECK(T, Number); | ||||
Set(Number::New(GetIsolate(), i)); | Set(Number::New(GetIsolate(), i)); | |||
} | } | |||
template<typename T> | template<typename T> | |||
void ReturnValue<T>::Set(int32_t i) { | void ReturnValue<T>::Set(int32_t i) { | |||
TYPE_CHECK(T, Integer); | ||||
typedef internal::Internals I; | typedef internal::Internals I; | |||
if (V8_LIKELY(I::IsValidSmi(i))) { | if (V8_LIKELY(I::IsValidSmi(i))) { | |||
*value_ = I::IntToSmi(i); | *value_ = I::IntToSmi(i); | |||
return; | return; | |||
} | } | |||
Set(Integer::New(i, GetIsolate())); | Set(Integer::New(i, GetIsolate())); | |||
} | } | |||
template<typename T> | template<typename T> | |||
void ReturnValue<T>::Set(uint32_t i) { | void ReturnValue<T>::Set(uint32_t i) { | |||
TYPE_CHECK(T, Integer); | ||||
typedef internal::Internals I; | typedef internal::Internals I; | |||
// Can't simply use INT32_MAX here for whatever reason. | // Can't simply use INT32_MAX here for whatever reason. | |||
bool fits_into_int32_t = (i & (1 << 31)) == 0; | bool fits_into_int32_t = (i & (1 << 31)) == 0; | |||
if (V8_LIKELY(fits_into_int32_t)) { | if (V8_LIKELY(fits_into_int32_t)) { | |||
Set(static_cast<int32_t>(i)); | Set(static_cast<int32_t>(i)); | |||
return; | return; | |||
} | } | |||
Set(Integer::NewFromUnsigned(i, GetIsolate())); | Set(Integer::NewFromUnsigned(i, GetIsolate())); | |||
} | } | |||
template<typename T> | template<typename T> | |||
void ReturnValue<T>::Set(bool value) { | void ReturnValue<T>::Set(bool value) { | |||
TYPE_CHECK(T, Boolean); | ||||
typedef internal::Internals I; | typedef internal::Internals I; | |||
int root_index; | int root_index; | |||
if (value) { | if (value) { | |||
root_index = I::kTrueValueRootIndex; | root_index = I::kTrueValueRootIndex; | |||
} else { | } else { | |||
root_index = I::kFalseValueRootIndex; | root_index = I::kFalseValueRootIndex; | |||
} | } | |||
*value_ = *I::GetRoot(GetIsolate(), root_index); | *value_ = *I::GetRoot(GetIsolate(), root_index); | |||
} | } | |||
template<typename T> | template<typename T> | |||
void ReturnValue<T>::SetNull() { | void ReturnValue<T>::SetNull() { | |||
TYPE_CHECK(T, Primitive); | ||||
typedef internal::Internals I; | typedef internal::Internals I; | |||
*value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex); | *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex); | |||
} | } | |||
template<typename T> | template<typename T> | |||
void ReturnValue<T>::SetUndefined() { | void ReturnValue<T>::SetUndefined() { | |||
TYPE_CHECK(T, Primitive); | ||||
typedef internal::Internals I; | typedef internal::Internals I; | |||
*value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex); | *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex); | |||
} | } | |||
template<typename T> | template<typename T> | |||
void ReturnValue<T>::SetEmptyString() { | void ReturnValue<T>::SetEmptyString() { | |||
TYPE_CHECK(T, String); | ||||
typedef internal::Internals I; | typedef internal::Internals I; | |||
*value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex); | *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex); | |||
} | } | |||
template<typename T> | template<typename T> | |||
Isolate* ReturnValue<T>::GetIsolate() { | Isolate* ReturnValue<T>::GetIsolate() { | |||
// Isolate is always the pointer below the default value on the stack. | // Isolate is always the pointer below the default value on the stack. | |||
return *reinterpret_cast<Isolate**>(&value_[-2]); | return *reinterpret_cast<Isolate**>(&value_[-2]); | |||
} | } | |||
End of changes. 7 change blocks. | ||||
0 lines changed or deleted | 7 lines changed or added | |||