V8 Project
v8::ReturnValue< T > Class Template Reference

#include <v8.h>

+ Collaboration diagram for v8::ReturnValue< T >:

Public Member Functions

template<class S >
 ReturnValue (const ReturnValue< S > &that)
 
template<typename S >
void Set (const Persistent< S > &handle)
 
template<typename S >
void Set (const Handle< S > handle)
 
void Set (bool value)
 
void Set (double i)
 
void Set (int32_t i)
 
void Set (uint32_t i)
 
void SetNull ()
 
void SetUndefined ()
 
void SetEmptyString ()
 
IsolateGetIsolate ()
 
template<typename S >
void Set (S *whatever)
 

Private Member Functions

void SetInternal (internal::Object *value)
 
internal::ObjectGetDefaultValue ()
 
 ReturnValue (internal::Object **slot)
 

Private Attributes

internal::Object ** value_
 

Friends

template<class F >
class ReturnValue
 
template<class F >
class FunctionCallbackInfo
 
template<class F >
class PropertyCallbackInfo
 
template<class F , class G , class H >
class PersistentValueMap
 

Detailed Description

template<typename T>
class v8::ReturnValue< T >

Definition at line 2606 of file v8.h.

Constructor & Destructor Documentation

◆ ReturnValue() [1/2]

template<typename T >
template<class S >
v8::ReturnValue< T >::ReturnValue ( const ReturnValue< S > &  that)
inline

Definition at line 2608 of file v8.h.

2609  : value_(that.value_) {
2610  TYPE_CHECK(T, S);
2611  }
internal::Object ** value_
Definition: v8.h:2639
#define TYPE_CHECK(T, S)
Definition: v8.h:167
#define T(name, string, precedence)
Definition: token.cc:25
#define S(x)
Definition: version.cc:55

References S, T, and TYPE_CHECK.

◆ ReturnValue() [2/2]

template<typename T >
v8::ReturnValue< T >::ReturnValue ( internal::Object **  slot)
inlineexplicitprivate

Definition at line 6190 of file v8.h.

6190 : value_(slot) {}

Member Function Documentation

◆ GetDefaultValue()

template<typename T >
internal::Object * v8::ReturnValue< T >::GetDefaultValue
inlineprivate

Definition at line 6291 of file v8.h.

6291  {
6292  // Default value is always the pointer below value_ on the stack.
6293  return value_[-1];
6294 }

◆ GetIsolate()

template<typename T >
Isolate * v8::ReturnValue< T >::GetIsolate
inline

Definition at line 6278 of file v8.h.

6278  {
6279  // Isolate is always the pointer below the default value on the stack.
6280  return *reinterpret_cast<Isolate**>(&value_[-2]);
6281 }

◆ Set() [1/7]

template<typename T >
void v8::ReturnValue< T >::Set ( bool  value)
inline

Definition at line 6244 of file v8.h.

6244  {
6245  TYPE_CHECK(T, Boolean);
6246  typedef internal::Internals I;
6247  int root_index;
6248  if (value) {
6249  root_index = I::kTrueValueRootIndex;
6250  } else {
6251  root_index = I::kFalseValueRootIndex;
6252  }
6253  *value_ = *I::GetRoot(GetIsolate(), root_index);
6254 }
Isolate * GetIsolate()
Definition: v8.h:6278
#define I(name, number_of_args, result_size)
Definition: runtime.cc:9248

References I, T, and TYPE_CHECK.

◆ Set() [2/7]

template<typename T >
template<typename S >
void v8::ReturnValue< T >::Set ( const Handle< S handle)
inline

Definition at line 6205 of file v8.h.

6205  {
6206  TYPE_CHECK(T, S);
6207  if (V8_UNLIKELY(handle.IsEmpty())) {
6208  *value_ = GetDefaultValue();
6209  } else {
6210  *value_ = *reinterpret_cast<internal::Object**>(*handle);
6211  }
6212 }
internal::Object * GetDefaultValue()
Definition: v8.h:6291
kSerializedDataOffset Object
Definition: objects-inl.h:5322
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146
#define V8_UNLIKELY(condition)
Definition: v8config.h:342

References v8::internal::handle(), S, T, TYPE_CHECK, and V8_UNLIKELY.

+ Here is the call graph for this function:

◆ Set() [3/7]

template<typename T >
template<typename S >
void v8::ReturnValue< T >::Set ( const Persistent< S > &  handle)
inline

Definition at line 6194 of file v8.h.

6194  {
6195  TYPE_CHECK(T, S);
6196  if (V8_UNLIKELY(handle.IsEmpty())) {
6197  *value_ = GetDefaultValue();
6198  } else {
6199  *value_ = *reinterpret_cast<internal::Object**>(*handle);
6200  }
6201 }

References v8::internal::handle(), S, T, TYPE_CHECK, and V8_UNLIKELY.

+ Here is the call graph for this function:

◆ Set() [4/7]

template<typename T >
void v8::ReturnValue< T >::Set ( double  i)
inline

Definition at line 6215 of file v8.h.

6215  {
6216  TYPE_CHECK(T, Number);
6217  Set(Number::New(GetIsolate(), i));
6218 }
static Local< Number > New(Isolate *isolate, double value)
Definition: api.cc:6268
void Set(const Persistent< S > &handle)
Definition: v8.h:6194

References v8::Number::New(), T, and TYPE_CHECK.

+ Here is the call graph for this function:

◆ Set() [5/7]

template<typename T >
void v8::ReturnValue< T >::Set ( int32_t  i)
inline

Definition at line 6221 of file v8.h.

6221  {
6222  TYPE_CHECK(T, Integer);
6223  typedef internal::Internals I;
6224  if (V8_LIKELY(I::IsValidSmi(i))) {
6225  *value_ = I::IntToSmi(i);
6226  return;
6227  }
6229 }
static Local< Integer > New(Isolate *isolate, int32_t value)
Definition: api.cc:6281
internal::Object * IntToSmi(int value)
Definition: v8.h:5749
#define V8_LIKELY(condition)
Definition: v8config.h:343

References I, v8::internal::IntToSmi(), v8::Integer::New(), T, TYPE_CHECK, and V8_LIKELY.

+ Here is the call graph for this function:

◆ Set() [6/7]

template<typename T >
template<typename S >
void v8::ReturnValue< T >::Set ( S whatever)
inline

Definition at line 6285 of file v8.h.

6285  {
6286  // Uncompilable to prevent inadvertent misuse.
6287  TYPE_CHECK(S*, Primitive);
6288 }

References S, and TYPE_CHECK.

◆ Set() [7/7]

template<typename T >
void v8::ReturnValue< T >::Set ( uint32_t  i)
inline

Definition at line 6232 of file v8.h.

6232  {
6233  TYPE_CHECK(T, Integer);
6234  // Can't simply use INT32_MAX here for whatever reason.
6235  bool fits_into_int32_t = (i & (1U << 31)) == 0;
6236  if (V8_LIKELY(fits_into_int32_t)) {
6237  Set(static_cast<int32_t>(i));
6238  return;
6239  }
6241 }
static Local< Integer > NewFromUnsigned(Isolate *isolate, uint32_t value)
Definition: api.cc:6294
int int32_t
Definition: unicode.cc:24

References v8::Integer::NewFromUnsigned(), T, TYPE_CHECK, and V8_LIKELY.

+ Here is the call graph for this function:

◆ SetEmptyString()

template<typename T >
void v8::ReturnValue< T >::SetEmptyString
inline

Definition at line 6271 of file v8.h.

6271  {
6272  TYPE_CHECK(T, String);
6273  typedef internal::Internals I;
6274  *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
6275 }

References I, T, and TYPE_CHECK.

◆ SetInternal()

template<typename T >
void v8::ReturnValue< T >::SetInternal ( internal::Object value)
inlineprivate

Definition at line 2636 of file v8.h.

2636 { *value_ = value; }

References v8::ReturnValue< T >::value_.

Referenced by v8::PersistentValueMap< K, V, Traits >::SetReturnValueFromVal().

+ Here is the caller graph for this function:

◆ SetNull()

template<typename T >
void v8::ReturnValue< T >::SetNull
inline

Definition at line 6257 of file v8.h.

6257  {
6258  TYPE_CHECK(T, Primitive);
6259  typedef internal::Internals I;
6260  *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
6261 }

References I, T, and TYPE_CHECK.

◆ SetUndefined()

template<typename T >
void v8::ReturnValue< T >::SetUndefined
inline

Definition at line 6264 of file v8.h.

6264  {
6265  TYPE_CHECK(T, Primitive);
6266  typedef internal::Internals I;
6267  *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
6268 }

References I, T, and TYPE_CHECK.

Friends And Related Function Documentation

◆ FunctionCallbackInfo

template<typename T >
template<class F >
friend class FunctionCallbackInfo
friend

Definition at line 2633 of file v8.h.

◆ PersistentValueMap

template<typename T >
template<class F , class G , class H >
friend class PersistentValueMap
friend

Definition at line 2635 of file v8.h.

◆ PropertyCallbackInfo

template<typename T >
template<class F >
friend class PropertyCallbackInfo
friend

Definition at line 2634 of file v8.h.

◆ ReturnValue

template<typename T >
template<class F >
friend class ReturnValue
friend

Definition at line 2632 of file v8.h.

Member Data Documentation

◆ value_

template<typename T >
internal::Object** v8::ReturnValue< T >::value_
private

Definition at line 2639 of file v8.h.

Referenced by v8::ReturnValue< T >::SetInternal().


The documentation for this class was generated from the following file: