Sha256: d1174be110647bb6235b7f3e443c4c41e34c8bdb355f19041012c07c2941c157

Contents?: true

Size: 1.53 KB

Versions: 62

Compression:

Stored size: 1.53 KB

Contents

// 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_CUSTOM_SPACE_H_
#define INCLUDE_CPPGC_CUSTOM_SPACE_H_

#include <stddef.h>

namespace cppgc {

struct CustomSpaceIndex {
  CustomSpaceIndex(size_t value) : value(value) {}  // NOLINT
  size_t value;
};

/**
 * Top-level base class for custom spaces. Users must inherit from CustomSpace
 * below.
 */
class CustomSpaceBase {
 public:
  virtual ~CustomSpaceBase() = default;
  virtual CustomSpaceIndex GetCustomSpaceIndex() const = 0;
};

/**
 * Base class custom spaces should directly inherit from. The class inheriting
 * from CustomSpace must define kSpaceIndex as unique space index. These
 * indices need for form a sequence starting at 0.
 *
 * Example:
 * \code
 * class CustomSpace1 : public CustomSpace<CustomSpace1> {
 *  public:
 *   static constexpr CustomSpaceIndex kSpaceIndex = 0;
 * };
 * class CustomSpace2 : public CustomSpace<CustomSpace2> {
 *  public:
 *   static constexpr CustomSpaceIndex kSpaceIndex = 1;
 * };
 * \endcode
 */
template <typename ConcreteCustomSpace>
class CustomSpace : public CustomSpaceBase {
 public:
  CustomSpaceIndex GetCustomSpaceIndex() const final {
    return ConcreteCustomSpace::kSpaceIndex;
  }
};

/**
 * User-overridable trait that allows pinning types to custom spaces.
 */
template <typename T, typename = void>
struct SpaceTrait {
  using Space = void;
};

}  // namespace cppgc

#endif  // INCLUDE_CPPGC_CUSTOM_SPACE_H_

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
libv8-node-15.5.1.0.beta1-arm64-darwin-21 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.5.1.0.beta1-x86_64-darwin-21 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-x86_64-darwin-21 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-arm64-darwin-21 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-aarch64-linux-musl vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-aarch64-linux vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-arm64-darwin-20 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-x86_64-linux vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-x86_64-linux-musl vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-x86_64-darwin-20 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-x86_64-darwin-19 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-x86_64-darwin-18 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.1-x86_64-darwin-17 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.0-x86_64-linux-musl vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.0-x86_64-linux vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.0-x86_64-darwin-20 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.0-x86_64-darwin-19 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.0-x86_64-darwin-18 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.0-x86_64-darwin-17 vendor/v8/include/cppgc/custom-space.h
libv8-node-15.14.0.0-arm64-darwin-20 vendor/v8/include/cppgc/custom-space.h