chromium/v8/include/cppgc/trace-trait.h

// Copyright 2020 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 INCLUDE_CPPGC_TRACE_TRAIT_H_
#define INCLUDE_CPPGC_TRACE_TRAIT_H_

#include <type_traits>

#include "cppgc/type-traits.h"
#include "v8config.h"  // NOLINT(build/include_directory)

namespace cppgc {

class Visitor;

namespace internal {

class RootVisitor;

TraceRootCallback;

// Implementation of the default TraceTrait handling GarbageCollected and
// GarbageCollectedMixin.
template <typename T,
          bool =
              IsGarbageCollectedMixinTypeV<typename std::remove_const<T>::type>>
struct TraceTraitImpl;

}  // namespace internal

/**
 * Callback for invoking tracing on a given object.
 *
 * \param visitor The visitor to dispatch to.
 * \param object The object to invoke tracing on.
 */
TraceCallback;

/**
 * Describes how to trace an object, i.e., how to visit all Oilpan-relevant
 * fields of an object.
 */
struct TraceDescriptor {};

/**
 * Callback for getting a TraceDescriptor for a given address.
 *
 * \param address Possibly inner address of an object.
 * \returns a TraceDescriptor for the provided address.
 */
TraceDescriptorCallback;

namespace internal {

struct V8_EXPORT TraceTraitFromInnerAddressImpl {};

/**
 * Trait specifying how the garbage collector processes an object of type T.
 *
 * Advanced users may override handling by creating a specialization for their
 * type.
 */
template <typename T>
struct TraceTraitBase {};

}  // namespace internal

template <typename T>
struct TraceTrait : public internal::TraceTraitBase<T> {};

namespace internal {

TraceTraitImpl<T, false>;

TraceTraitImpl<T, true>;

}  // namespace internal
}  // namespace cppgc

#endif  // INCLUDE_CPPGC_TRACE_TRAIT_H_