chromium/v8/test/cctest/test-api.h

// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_TEST_CCTEST_TEST_API_H_
#define V8_TEST_CCTEST_TEST_API_H_

#include "src/api/api-inl.h"
#include "src/execution/isolate.h"
#include "src/execution/vm-state.h"
#include "test/cctest/cctest.h"

template <typename T>
static i::Tagged<i::Object> Get(v8::ReturnValue<T> return_value) {}

template <typename T>
static void CheckReturnValueImpl(v8::Isolate* v8_isolate,
                                 v8::ReturnValue<T> return_value,
                                 i::Address callback) {}

template <typename TCallbackInfo>
static void CheckReturnValue(const TCallbackInfo& info, i::Address callback) {}

template <typename T>
static void CheckInternalFieldsAreZero(v8::Local<T> value) {}

template <typename T>
struct ConvertJSValue {};

template <>
struct ConvertJSValue<int32_t> {};

template <>
struct ConvertJSValue<uint32_t> {};

template <>
struct ConvertJSValue<std::nullptr_t> {};

// NaNs and +/-Infinity should be 0, otherwise (modulo 2^64) - 2^63.
// Step 8 - 12 of https://heycam.github.io/webidl/#abstract-opdef-converttoint
// The int64_t and uint64_t implementations below are copied from Blink:
// https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h;l=249?q=doubletointeger&sq=&ss=chromium%2Fchromium%2Fsrc
template <>
struct ConvertJSValue<int64_t> {};

template <>
struct ConvertJSValue<uint64_t> {};

template <>
struct ConvertJSValue<v8::BigInt> {};

template <>
struct ConvertJSValue<float> {};

template <>
struct ConvertJSValue<double> {};

template <>
struct ConvertJSValue<bool> {};

#endif  // V8_TEST_CCTEST_TEST_API_H_