Loading...
Searching...
No Matches
v8-cpp-heap-external.h
Go to the documentation of this file.
1// Copyright 2025 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_HEAP_EXTERNAL_H_
6#define INCLUDE_V8_HEAP_EXTERNAL_H_
7
8#include "cppgc/type-traits.h" // NOLINT(build/include_directory)
9#include "v8-sandbox.h" // NOLINT(build/include_directory)
10#include "v8-value.h" // NOLINT(build/include_directory)
11#include "v8config.h" // NOLINT(build/include_directory)
12
13namespace v8 {
14
15class Isolate;
16
24 public:
25 template <typename T>
26 static Local<CppHeapExternal> New(Isolate* isolate, T* value,
28 static_assert(cppgc::IsGarbageCollectedTypeV<T>,
29 "Object must be of type GarbageCollected.");
30 return NewImpl(isolate, value, tag);
31 }
32
34#ifdef V8_ENABLE_CHECKS
35 CheckCast(data);
36#endif
37 return static_cast<CppHeapExternal*>(data);
38 }
39
40 template <typename T>
41 T* Value(Isolate* isolate, CppHeapPointerTagRange tag_range) const {
42 static_assert(cppgc::IsGarbageCollectedTypeV<T>,
43 "Object must be of type GarbageCollected.");
44 return static_cast<T*>(ValueImpl(isolate, tag_range));
45 }
46
47 private:
48 static void CheckCast(v8::Data* obj);
49 static Local<CppHeapExternal> NewImpl(Isolate* isolate, void* value,
51 void* ValueImpl(Isolate*, CppHeapPointerTagRange tag_range) const;
52};
53
54} // namespace v8
55
56#endif // INCLUDE_V8_HEAP_EXTERNAL_H_
Definition: v8-cpp-heap-external.h:23
static CppHeapExternal * Cast(Data *data)
Definition: v8-cpp-heap-external.h:33
T * Value(Isolate *isolate, CppHeapPointerTagRange tag_range) const
Definition: v8-cpp-heap-external.h:41
static Local< CppHeapExternal > New(Isolate *isolate, T *value, CppHeapPointerTag tag)
Definition: v8-cpp-heap-external.h:26
Definition: v8-data.h:18
Definition: v8-isolate.h:274
Definition: v8-local-handle.h:267
Definition: libplatform.h:15
CppHeapPointerTag
Definition: v8-sandbox.h:28
Definition: v8-sandbox.h:70
#define V8_EXPORT
Definition: v8config.h:800
#define V8_INLINE
Definition: v8config.h:500