5#ifndef INCLUDE_V8_FUNCTION_CALLBACK_H_
6#define INCLUDE_V8_FUNCTION_CALLBACK_H_
15class BasicTracedReference;
22class FunctionCallbackArguments;
23class PropertyCallbackArguments;
28class ConsoleCallArguments;
36 static_assert(std::is_base_of<T, S>::value,
"type check");
73 template <
class F,
class G,
class H>
80 static constexpr int kIsolateValueIndex = -2;
81 static constexpr int kDefaultValueValueIndex = -1;
131 static constexpr int kHolderIndex = 0;
132 static constexpr int kIsolateIndex = 1;
133 static constexpr int kReturnValueDefaultValueIndex = 2;
134 static constexpr int kReturnValueIndex = 3;
135 static constexpr int kDataIndex = 4;
136 static constexpr int kNewTargetIndex = 5;
138 static constexpr int kArgsLength = 6;
139 static constexpr int kArgsLengthWithReceiver = 7;
143 static constexpr int kImplicitArgsOffset = 0;
144 static constexpr int kValuesOffset =
146 static constexpr int kLengthOffset =
149 static constexpr int kThisValuesIndex = -1;
151 kReturnValueDefaultValueIndex - kReturnValueIndex);
153 kIsolateIndex - kReturnValueIndex);
258 static constexpr int kShouldThrowOnErrorIndex = 0;
259 static constexpr int kHolderIndex = 1;
260 static constexpr int kIsolateIndex = 2;
261 static constexpr int kReturnValueDefaultValueIndex = 3;
262 static constexpr int kReturnValueIndex = 4;
263 static constexpr int kDataIndex = 5;
264 static constexpr int kThisIndex = 6;
266 static constexpr int kArgsLength = 7;
285 static_assert(std::is_base_of<T, S>::value,
"type check");
287 *value_ = GetDefaultValue();
296 static_assert(std::is_base_of<T, S>::value,
"type check");
298 *value_ = GetDefaultValue();
307 static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
310 *value_ = GetDefaultValue();
312 *value_ = internal::ValueHelper::ValueAsAddress(*handle);
318 static_assert(std::is_base_of<T, Number>::value,
"type check");
319 Set(Number::New(GetIsolate(), i));
324 static_assert(std::is_base_of<T, Integer>::value,
"type check");
327 *value_ = I::IntToSmi(i);
330 Set(Integer::New(GetIsolate(), i));
335 static_assert(std::is_base_of<T, Integer>::value,
"type check");
337 bool fits_into_int32_t = (i & (1U << 31)) == 0;
339 Set(
static_cast<int32_t
>(i));
342 Set(Integer::NewFromUnsigned(GetIsolate(), i));
347 static_assert(std::is_base_of<T, Boolean>::value,
"type check");
351 root_index = I::kTrueValueRootIndex;
353 root_index = I::kFalseValueRootIndex;
355 *value_ = I::GetRoot(GetIsolate(), root_index);
360 static_assert(std::is_base_of<T, Primitive>::value,
"type check");
362 *value_ = I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
367 static_assert(std::is_base_of<T, Primitive>::value,
"type check");
369 *value_ = I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
374 static_assert(std::is_base_of<T, String>::value,
"type check");
376 *value_ = I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
382 return *
reinterpret_cast<Isolate**
>(&value_[kIsolateValueIndex]);
388#if V8_STATIC_ROOTS_BOOL
389 if (I::is_identical(*value_, I::StaticReadOnlyRoot::kTheHoleValue)) {
391 if (*value_ == I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex)) {
401 static_assert(
sizeof(S) < 0,
"incompilable to prevent inadvertent misuse");
407 return value_[kDefaultValueValueIndex];
411FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Address* implicit_args,
412 internal::Address* values,
414 : implicit_args_(implicit_args), values_(values), length_(length) {}
419 if (i < 0 || length_ <= i)
return Undefined(GetIsolate());
446 return *
reinterpret_cast<Isolate**
>(&implicit_args_[kIsolateIndex]);
456 return !NewTarget()->IsUndefined();
466 return *
reinterpret_cast<Isolate**
>(&args_[kIsolateIndex]);
492 if (args_[kShouldThrowOnErrorIndex] !=
493 I::IntToSmi(I::kInferShouldThrowMode)) {
494 return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow);
497 reinterpret_cast<v8::internal::Isolate*
>(GetIsolate()));
friend class internal::Builtins
V8_INLINE ReturnValue< T > GetReturnValue() const
V8_INLINE bool IsConstructCall() const
V8_INLINE Local< Object > This() const
V8_INLINE Local< Object > Holder() const
V8_INLINE Isolate * GetIsolate() const
V8_INLINE Local< Value > Data() const
V8_INLINE int Length() const
friend class debug::ConsoleCallArguments
V8_INLINE Local< Value > NewTarget() const
friend class internal::FunctionCallbackArguments
V8_INLINE Local< Value > operator[](int i) const
V8_INLINE bool IsEmpty() const
V8_INLINE bool IsEmpty() const
V8_INLINE ReturnValue< T > GetReturnValue() const
friend class internal::PropertyCallbackArguments
V8_INLINE Local< Object > This() const
V8_INLINE Local< Object > Holder() const
V8_INLINE Isolate * GetIsolate() const
V8_INLINE Local< Value > Data() const
V8_INLINE bool ShouldThrowOnError() const
friend class MacroAssembler
V8_INLINE ReturnValue(const ReturnValue< S > &that)
V8_INLINE Isolate * GetIsolate() const
V8_INLINE void Set(const BasicTracedReference< S > &handle)
V8_INLINE void SetUndefined()
V8_INLINE void Set(const Global< S > &handle)
V8_INLINE void SetEmptyString()
V8_INLINE void Set(const Local< S > handle)
V8_INLINE void Set(S *whatever)
V8_INLINE Local< Value > Get() const
const int kApiSystemPointerSize
V8_EXPORT bool ShouldThrowOnError(internal::Isolate *isolate)
void(*)(const FunctionCallbackInfo< Value > &info) FunctionCallback
V8_INLINE Local< Primitive > Undefined(Isolate *isolate)
#define V8_LIKELY(condition)
#define V8_UNLIKELY(condition)