v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-container.h
Go to the documentation of this file.
1// Copyright 2021 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_CONTAINER_H_
6#define INCLUDE_V8_CONTAINER_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include <functional>
12
13#include "v8-local-handle.h" // NOLINT(build/include_directory)
14#include "v8-object.h" // NOLINT(build/include_directory)
15#include "v8config.h" // NOLINT(build/include_directory)
16
17namespace v8 {
18
19class Context;
20class Isolate;
21
25class V8_EXPORT Array : public Object {
26 public:
27 uint32_t Length() const;
28
33 static Local<Array> New(Isolate* isolate, int length = 0);
34
39 static Local<Array> New(Isolate* isolate, Local<Value>* elements,
40 size_t length);
41 V8_INLINE static Array* Cast(Value* value) {
42#ifdef V8_ENABLE_CHECKS
43 CheckCast(value);
44#endif
45 return static_cast<Array*>(value);
46 }
47
61 Local<Context> context, size_t length,
62 std::function<MaybeLocal<v8::Value>()> next_value_callback);
63
64 enum class CallbackResult {
65 kException,
66 kBreak,
67 kContinue,
68 };
69 using IterationCallback = CallbackResult (*)(uint32_t index,
70 Local<Value> element,
71 void* data);
72
98 void* callback_data);
99
100 private:
101 Array();
102 static void CheckCast(Value* obj);
103};
104
108class V8_EXPORT Map : public Object {
109 public:
110 size_t Size() const;
111 void Clear();
113 Local<Value> key);
115 Local<Value> key,
116 Local<Value> value);
118 Local<Value> key);
120 Local<Value> key);
121
127
131 static Local<Map> New(Isolate* isolate);
132
133 V8_INLINE static Map* Cast(Value* value) {
134#ifdef V8_ENABLE_CHECKS
135 CheckCast(value);
136#endif
137 return static_cast<Map*>(value);
138 }
139
140 private:
141 Map();
142 static void CheckCast(Value* obj);
143};
144
148class V8_EXPORT Set : public Object {
149 public:
150 size_t Size() const;
151 void Clear();
153 Local<Value> key);
155 Local<Value> key);
157 Local<Value> key);
158
163
167 static Local<Set> New(Isolate* isolate);
168
169 V8_INLINE static Set* Cast(Value* value) {
170#ifdef V8_ENABLE_CHECKS
171 CheckCast(value);
172#endif
173 return static_cast<Set*>(value);
174 }
175
176 private:
177 Set();
178 static void CheckCast(Value* obj);
179};
180
181} // namespace v8
182
183#endif // INCLUDE_V8_CONTAINER_H_
static Local< Array > New(Isolate *isolate, Local< Value > *elements, size_t length)
static Local< Array > New(Isolate *isolate, int length=0)
uint32_t Length() const
CallbackResult(*)(uint32_t index, Local< Value > element, void *data) IterationCallback
static V8_INLINE Array * Cast(Value *value)
Maybe< void > Iterate(Local< Context > context, IterationCallback callback, void *callback_data)
static MaybeLocal< Array > New(Local< Context > context, size_t length, std::function< MaybeLocal< v8::Value >()> next_value_callback)
Local< Array > AsArray() const
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, Local< Value > key)
size_t Size() const
static V8_INLINE Map * Cast(Value *value)
void Clear()
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
static Local< Map > New(Isolate *isolate)
V8_WARN_UNUSED_RESULT MaybeLocal< Map > Set(Local< Context > context, Local< Value > key, Local< Value > value)
Local< Array > AsArray() const
static Local< Set > New(Isolate *isolate)
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, Local< Value > key)
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, Local< Value > key)
size_t Size() const
static V8_INLINE Set * Cast(Value *value)
void Clear()
V8_WARN_UNUSED_RESULT MaybeLocal< Set > Add(Local< Context > context, Local< Value > key)
#define V8_EXPORT
Definition v8config.h:753
#define V8_INLINE
Definition v8config.h:477
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:628