-
Notifications
You must be signed in to change notification settings - Fork 321
/
binding.cc
4028 lines (3261 loc) · 142 KB
/
binding.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <memory>
#include "cppgc/platform.h"
#include "support.h"
#include "unicode/locid.h"
#include "v8-callbacks.h"
#include "v8/include/cppgc/persistent.h"
#include "v8/include/libplatform/libplatform.h"
#include "v8/include/v8-cppgc.h"
#include "v8/include/v8-fast-api-calls.h"
#include "v8/include/v8-inspector.h"
#include "v8/include/v8-internal.h"
#include "v8/include/v8-platform.h"
#include "v8/include/v8-profiler.h"
#include "v8/include/v8.h"
#include "v8/src/api/api-inl.h"
#include "v8/src/api/api.h"
#include "v8/src/base/debug/stack_trace.h"
#include "v8/src/base/sys-info.h"
#include "v8/src/execution/isolate-utils-inl.h"
#include "v8/src/execution/isolate-utils.h"
#include "v8/src/flags/flags.h"
#include "v8/src/libplatform/default-platform.h"
#include "v8/src/objects/objects-inl.h"
#include "v8/src/objects/objects.h"
#include "v8/src/objects/smi.h"
using namespace support;
template <typename T>
constexpr size_t align_to(size_t size) {
return (size + sizeof(T) - 1) & ~(sizeof(T) - 1);
}
static_assert(sizeof(two_pointers_t) ==
sizeof(std::shared_ptr<v8::BackingStore>),
"std::shared_ptr<v8::BackingStore> size mismatch");
static_assert(sizeof(v8::HandleScope) == sizeof(size_t) * 3,
"HandleScope size mismatch");
static_assert(sizeof(v8::EscapableHandleScope) == sizeof(size_t) * 4,
"EscapableHandleScope size mismatch");
static_assert(sizeof(v8::PromiseRejectMessage) == sizeof(size_t) * 3,
"PromiseRejectMessage size mismatch");
static_assert(sizeof(v8::Locker) == sizeof(size_t) * 2, "Locker size mismatch");
static_assert(sizeof(v8::ScriptCompiler::CompilationDetails) ==
sizeof(int64_t) * 3,
"CompilationDetails size mismatch");
static_assert(
sizeof(v8::ScriptCompiler::Source) ==
align_to<size_t>(sizeof(size_t) * 8 + sizeof(int) * 2 +
// the last field before CompilationDetails on 32-bit
// systems will have a padding
align_to<int64_t>(sizeof(size_t)) +
sizeof(v8::ScriptCompiler::CompilationDetails)),
"Source size mismatch");
static_assert(sizeof(v8::FunctionCallbackInfo<v8::Value>) == sizeof(size_t) * 3,
"FunctionCallbackInfo size mismatch");
static_assert(sizeof(v8::ReturnValue<v8::Value>) == sizeof(size_t) * 1,
"ReturnValue size mismatch");
static_assert(sizeof(v8::TryCatch) == sizeof(size_t) * 6,
"TryCatch size mismatch");
static_assert(sizeof(v8::Isolate::AllowJavascriptExecutionScope) ==
sizeof(size_t) * 2,
"AllowJavascriptExecutionScope size mismatch");
static_assert(sizeof(v8::Location) == sizeof(int) * 2,
"Location size mismatch");
static_assert(sizeof(v8::SnapshotCreator) == sizeof(size_t) * 1,
"SnapshotCreator size mismatch");
static_assert(sizeof(v8::CFunction) == sizeof(size_t) * 2,
"CFunction size mismatch");
static_assert(sizeof(three_pointers_t) == sizeof(v8_inspector::StringView),
"StringView size mismatch");
#if INTPTR_MAX == INT64_MAX // 64-bit platforms
static_assert(sizeof(v8::ScriptCompiler::CachedData) == 24,
"CachedData size mismatch");
static_assert(offsetof(v8::ScriptCompiler::CachedData, data) == 0,
"CachedData.data offset mismatch");
static_assert(offsetof(v8::ScriptCompiler::CachedData, length) == 8,
"CachedData.length offset mismatch");
static_assert(offsetof(v8::ScriptCompiler::CachedData, rejected) == 12,
"CachedData.rejected offset mismatch");
static_assert(offsetof(v8::ScriptCompiler::CachedData, buffer_policy) == 16,
"CachedData.buffer_policy offset mismatch");
static_assert(sizeof(v8::Isolate::DisallowJavascriptExecutionScope) == 16,
"DisallowJavascriptExecutionScope size mismatch");
#else
static_assert(sizeof(v8::ScriptCompiler::CachedData) == 16,
"CachedData size mismatch");
static_assert(offsetof(v8::ScriptCompiler::CachedData, data) == 0,
"CachedData.data offset mismatch");
static_assert(offsetof(v8::ScriptCompiler::CachedData, length) == 4,
"CachedData.length offset mismatch");
static_assert(offsetof(v8::ScriptCompiler::CachedData, rejected) == 8,
"CachedData.rejected offset mismatch");
static_assert(offsetof(v8::ScriptCompiler::CachedData, buffer_policy) == 12,
"CachedData.buffer_policy offset mismatch");
static_assert(sizeof(v8::Isolate::DisallowJavascriptExecutionScope) == 12,
"DisallowJavascriptExecutionScope size mismatch");
#endif
extern "C" {
const extern int v8__internal__Internals__kIsolateEmbedderDataOffset =
v8::internal::Internals::kIsolateEmbedderDataOffset;
void v8__V8__SetFlagsFromCommandLine(int* argc, char** argv,
const char* usage) {
namespace i = v8::internal;
using HelpOptions = i::FlagList::HelpOptions;
HelpOptions help_options = HelpOptions(HelpOptions::kExit, usage);
i::FlagList::SetFlagsFromCommandLine(argc, argv, true, help_options);
}
void v8__V8__SetFlagsFromString(const char* flags, size_t length) {
v8::V8::SetFlagsFromString(flags, length);
}
void v8__V8__SetEntropySource(v8::EntropySource callback) {
v8::V8::SetEntropySource(callback);
}
const char* v8__V8__GetVersion() { return v8::V8::GetVersion(); }
void v8__V8__InitializePlatform(v8::Platform* platform) {
v8::V8::InitializePlatform(platform);
}
void v8__V8__Initialize() { v8::V8::Initialize(); }
bool v8__V8__Dispose() { return v8::V8::Dispose(); }
void v8__V8__DisposePlatform() { v8::V8::DisposePlatform(); }
v8::Isolate* v8__Isolate__New(const v8::Isolate::CreateParams& params) {
return v8::Isolate::New(params);
}
void v8__Isolate__Dispose(v8::Isolate* isolate) { isolate->Dispose(); }
void v8__Isolate__Enter(v8::Isolate* isolate) { isolate->Enter(); }
void v8__Isolate__Exit(v8::Isolate* isolate) { isolate->Exit(); }
v8::Isolate* v8__Isolate__GetCurrent() { return v8::Isolate::GetCurrent(); }
const v8::Data* v8__Isolate__GetCurrentHostDefinedOptions(
v8::Isolate* isolate) {
return maybe_local_to_ptr(isolate->GetCurrentHostDefinedOptions());
}
void v8__Isolate__MemoryPressureNotification(v8::Isolate* isolate,
v8::MemoryPressureLevel level) {
isolate->MemoryPressureNotification(level);
}
void v8__Isolate__ClearKeptObjects(v8::Isolate* isolate) {
isolate->ClearKeptObjects();
}
void v8__Isolate__LowMemoryNotification(v8::Isolate* isolate) {
isolate->LowMemoryNotification();
}
void v8__Isolate__GetHeapStatistics(v8::Isolate* isolate,
v8::HeapStatistics* s) {
isolate->GetHeapStatistics(s);
}
const v8::Context* v8__Isolate__GetCurrentContext(v8::Isolate* isolate) {
return local_to_ptr(isolate->GetCurrentContext());
}
const v8::Context* v8__Isolate__GetEnteredOrMicrotaskContext(
v8::Isolate* isolate) {
return local_to_ptr(isolate->GetEnteredOrMicrotaskContext());
}
uint32_t v8__Isolate__GetNumberOfDataSlots(v8::Isolate* isolate) {
return isolate->GetNumberOfDataSlots();
}
const v8::Data* v8__Isolate__GetDataFromSnapshotOnce(v8::Isolate* isolate,
size_t index) {
return maybe_local_to_ptr(isolate->GetDataFromSnapshotOnce<v8::Data>(index));
}
v8::MicrotasksPolicy v8__Isolate__GetMicrotasksPolicy(
const v8::Isolate* isolate) {
return isolate->GetMicrotasksPolicy();
}
void v8__Isolate__SetMicrotasksPolicy(v8::Isolate* isolate,
v8::MicrotasksPolicy policy) {
static_assert(0 == static_cast<uint32_t>(v8::MicrotasksPolicy::kExplicit),
"v8::MicrotasksPolicy::kExplicit mismatch");
static_assert(1 == static_cast<uint32_t>(v8::MicrotasksPolicy::kScoped),
"v8::MicrotasksPolicy::kScoped mismatch");
static_assert(2 == static_cast<uint32_t>(v8::MicrotasksPolicy::kAuto),
"v8::MicrotasksPolicy::kAuto mismatch");
isolate->SetMicrotasksPolicy(policy);
}
void v8__Isolate__PerformMicrotaskCheckpoint(v8::Isolate* isolate) {
isolate->PerformMicrotaskCheckpoint();
}
void v8__Isolate__EnqueueMicrotask(v8::Isolate* isolate,
const v8::Function& function) {
isolate->EnqueueMicrotask(ptr_to_local(&function));
}
void v8__Isolate__RequestInterrupt(v8::Isolate* isolate,
v8::InterruptCallback callback, void* data) {
isolate->RequestInterrupt(callback, data);
}
void v8__Isolate__SetPrepareStackTraceCallback(
v8::Isolate* isolate, v8::PrepareStackTraceCallback callback) {
isolate->SetPrepareStackTraceCallback(callback);
}
void v8__Isolate__SetPromiseHook(v8::Isolate* isolate, v8::PromiseHook hook) {
isolate->SetPromiseHook(hook);
}
void v8__Isolate__SetPromiseRejectCallback(v8::Isolate* isolate,
v8::PromiseRejectCallback callback) {
isolate->SetPromiseRejectCallback(callback);
}
void v8__Isolate__SetWasmAsyncResolvePromiseCallback(
v8::Isolate* isolate, v8::WasmAsyncResolvePromiseCallback callback) {
isolate->SetWasmAsyncResolvePromiseCallback(callback);
}
void v8__Isolate__SetCaptureStackTraceForUncaughtExceptions(
v8::Isolate* isolate, bool capture, int frame_limit) {
isolate->SetCaptureStackTraceForUncaughtExceptions(capture, frame_limit);
}
void v8__Isolate__SetHostInitializeImportMetaObjectCallback(
v8::Isolate* isolate, v8::HostInitializeImportMetaObjectCallback callback) {
isolate->SetHostInitializeImportMetaObjectCallback(callback);
}
void v8__Isolate__SetHostImportModuleDynamicallyCallback(
v8::Isolate* isolate, v8::HostImportModuleDynamicallyCallback callback) {
isolate->SetHostImportModuleDynamicallyCallback(callback);
}
void v8__Isolate__SetHostCreateShadowRealmContextCallback(
v8::Isolate* isolate, v8::HostCreateShadowRealmContextCallback callback) {
isolate->SetHostCreateShadowRealmContextCallback(callback);
}
void v8__Isolate__SetUseCounterCallback(
v8::Isolate* isolate, v8::Isolate::UseCounterCallback callback) {
isolate->SetUseCounterCallback(callback);
}
bool v8__Isolate__AddMessageListener(v8::Isolate* isolate,
v8::MessageCallback callback) {
return isolate->AddMessageListener(callback);
}
bool v8__Isolate__AddMessageListenerWithErrorLevel(v8::Isolate* isolate,
v8::MessageCallback callback,
int error_level) {
return isolate->AddMessageListenerWithErrorLevel(callback, error_level);
}
void v8__Isolate__AddGCPrologueCallback(
v8::Isolate* isolate, v8::Isolate::GCCallbackWithData callback, void* data,
v8::GCType gc_type_filter) {
isolate->AddGCPrologueCallback(callback, data, gc_type_filter);
}
void v8__Isolate__RemoveGCPrologueCallback(
v8::Isolate* isolate, v8::Isolate::GCCallbackWithData callback,
void* data) {
isolate->RemoveGCPrologueCallback(callback, data);
}
void v8__Isolate__AddNearHeapLimitCallback(v8::Isolate* isolate,
v8::NearHeapLimitCallback callback,
void* data) {
isolate->AddNearHeapLimitCallback(callback, data);
}
void v8__Isolate__RemoveNearHeapLimitCallback(
v8::Isolate* isolate, v8::NearHeapLimitCallback callback,
size_t heap_limit) {
isolate->RemoveNearHeapLimitCallback(callback, heap_limit);
}
int64_t v8__Isolate__AdjustAmountOfExternalAllocatedMemory(
v8::Isolate* isolate, int64_t change_in_bytes) {
return isolate->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
}
void v8__Isolate__SetOOMErrorHandler(v8::Isolate* isolate,
v8::OOMErrorCallback callback) {
isolate->SetOOMErrorHandler(callback);
}
const v8::Value* v8__Isolate__ThrowException(v8::Isolate* isolate,
const v8::Value& exception) {
return local_to_ptr(isolate->ThrowException(ptr_to_local(&exception)));
}
void v8__Isolate__TerminateExecution(v8::Isolate* isolate) {
isolate->TerminateExecution();
}
bool v8__Isolate__IsExecutionTerminating(v8::Isolate* isolate) {
return isolate->IsExecutionTerminating();
}
void v8__Isolate__CancelTerminateExecution(v8::Isolate* isolate) {
isolate->CancelTerminateExecution();
}
void v8__Isolate__SetAllowAtomicsWait(v8::Isolate* isolate, bool allow) {
isolate->SetAllowAtomicsWait(allow);
}
void v8__Isolate__SetWasmStreamingCallback(v8::Isolate* isolate,
v8::WasmStreamingCallback callback) {
isolate->SetWasmStreamingCallback(callback);
}
void v8__Isolate__SetAllowWasmCodeGenerationCallback(
v8::Isolate* isolate, v8::AllowWasmCodeGenerationCallback callback) {
isolate->SetAllowWasmCodeGenerationCallback(callback);
}
bool v8__Isolate__HasPendingBackgroundTasks(v8::Isolate* isolate) {
return isolate->HasPendingBackgroundTasks();
}
void v8__Isolate__RequestGarbageCollectionForTesting(
v8::Isolate* isolate, v8::Isolate::GarbageCollectionType type) {
isolate->RequestGarbageCollectionForTesting(type);
}
void v8__Isolate__CreateParams__CONSTRUCT(
uninit_t<v8::Isolate::CreateParams>* buf) {
construct_in_place<v8::Isolate::CreateParams>(buf);
}
size_t v8__Isolate__CreateParams__SIZEOF() {
return sizeof(v8::Isolate::CreateParams);
}
void v8__Isolate__DateTimeConfigurationChangeNotification(
v8::Isolate* isolate, v8::Isolate::TimeZoneDetection time_zone_detection) {
isolate->DateTimeConfigurationChangeNotification(time_zone_detection);
}
void v8__ResourceConstraints__ConfigureDefaultsFromHeapSize(
v8::ResourceConstraints* constraints, size_t initial_heap_size_in_bytes,
size_t maximum_heap_size_in_bytes) {
constraints->ConfigureDefaultsFromHeapSize(initial_heap_size_in_bytes,
maximum_heap_size_in_bytes);
}
void v8__ResourceConstraints__ConfigureDefaults(
v8::ResourceConstraints* constraints, uint64_t physical_memory,
uint64_t virtual_memory_limit) {
constraints->ConfigureDefaults(physical_memory, virtual_memory_limit);
}
void v8__HandleScope__CONSTRUCT(uninit_t<v8::HandleScope>* buf,
v8::Isolate* isolate) {
construct_in_place<v8::HandleScope>(buf, isolate);
}
void v8__HandleScope__DESTRUCT(v8::HandleScope* self) { self->~HandleScope(); }
const v8::Data* v8__Local__New(v8::Isolate* isolate, const v8::Data& other) {
return local_to_ptr(v8::Local<v8::Data>::New(isolate, ptr_to_local(&other)));
}
const v8::Data* v8__Global__New(v8::Isolate* isolate, const v8::Data& other) {
// We have to use `std::move()` here because v8 disables the copy constructor
// for class `v8::Global`.
auto global = v8::Global<v8::Data>(isolate, ptr_to_local(&other));
return make_pod<v8::Data*>(std::move(global));
}
const v8::Data* v8__Global__NewWeak(
v8::Isolate* isolate, const v8::Data& other, void* parameter,
v8::WeakCallbackInfo<void>::Callback callback) {
auto global = v8::Global<v8::Data>(isolate, ptr_to_local(&other));
global.SetWeak(parameter, callback, v8::WeakCallbackType::kParameter);
return make_pod<v8::Data*>(std::move(global));
}
void v8__Global__Reset(const v8::Data* data) {
auto global = ptr_to_global(data);
global.Reset();
}
void v8__TracedReference__CONSTRUCT(
uninit_t<v8::TracedReference<v8::Data>>* buf) {
construct_in_place<v8::TracedReference<v8::Data>>(buf);
}
void v8__TracedReference__DESTRUCT(v8::TracedReference<v8::Data>* self) {
self->~TracedReference();
}
void v8__TracedReference__Reset(v8::TracedReference<v8::Data>* self,
v8::Isolate* isolate, const v8::Data* other) {
self->Reset(isolate, ptr_to_local(other));
}
const v8::Data* v8__TracedReference__Get(v8::TracedReference<v8::Data>* self,
v8::Isolate* isolate) {
return local_to_ptr(self->Get(isolate));
}
v8::Isolate* v8__WeakCallbackInfo__GetIsolate(
const v8::WeakCallbackInfo<void>* self) {
return self->GetIsolate();
}
void* v8__WeakCallbackInfo__GetParameter(
const v8::WeakCallbackInfo<void>* self) {
return self->GetParameter();
}
void v8__WeakCallbackInfo__SetSecondPassCallback(
const v8::WeakCallbackInfo<void>* self,
v8::WeakCallbackInfo<void>::Callback callback) {
self->SetSecondPassCallback(callback);
}
void v8__ScriptCompiler__Source__CONSTRUCT(
uninit_t<v8::ScriptCompiler::Source>* buf, const v8::String& source_string,
const v8::ScriptOrigin* origin,
v8::ScriptCompiler::CachedData* cached_data) {
if (origin) {
construct_in_place<v8::ScriptCompiler::Source>(
buf, ptr_to_local(&source_string), *origin, cached_data);
} else {
construct_in_place<v8::ScriptCompiler::Source>(
buf, ptr_to_local(&source_string), cached_data);
}
}
void v8__ScriptCompiler__Source__DESTRUCT(v8::ScriptCompiler::Source* self) {
self->~Source();
}
v8::ScriptCompiler::CachedData* v8__ScriptCompiler__CachedData__NEW(
const uint8_t* data, int length) {
return new v8::ScriptCompiler::CachedData(
data, length, v8::ScriptCompiler::CachedData::BufferNotOwned);
}
void v8__ScriptCompiler__CachedData__DELETE(
v8::ScriptCompiler::CachedData* self) {
delete self;
}
const v8::ScriptCompiler::CachedData* v8__ScriptCompiler__Source__GetCachedData(
const v8::ScriptCompiler::Source* source) {
return source->GetCachedData();
}
const v8::Module* v8__ScriptCompiler__CompileModule(
v8::Isolate* isolate, v8::ScriptCompiler::Source* source,
v8::ScriptCompiler::CompileOptions options,
v8::ScriptCompiler::NoCacheReason no_cache_reason) {
v8::MaybeLocal<v8::Module> maybe_local = v8::ScriptCompiler::CompileModule(
isolate, source, options, no_cache_reason);
return maybe_local_to_ptr(maybe_local);
}
const v8::Script* v8__ScriptCompiler__Compile(
const v8::Context* context, v8::ScriptCompiler::Source* source,
v8::ScriptCompiler::CompileOptions options,
v8::ScriptCompiler::NoCacheReason no_cache_reason) {
v8::MaybeLocal<v8::Script> maybe_local = v8::ScriptCompiler::Compile(
ptr_to_local(context), source, options, no_cache_reason);
return maybe_local_to_ptr(maybe_local);
}
const v8::Function* v8__ScriptCompiler__CompileFunction(
const v8::Context* context, v8::ScriptCompiler::Source* source,
size_t arguments_count, const v8::String** arguments,
size_t context_extensions_count, const v8::Object** context_extensions,
v8::ScriptCompiler::CompileOptions options,
v8::ScriptCompiler::NoCacheReason no_cache_reason) {
return maybe_local_to_ptr(v8::ScriptCompiler::CompileFunction(
ptr_to_local(context), source, arguments_count,
reinterpret_cast<v8::Local<v8::String>*>(arguments),
context_extensions_count,
reinterpret_cast<v8::Local<v8::Object>*>(context_extensions), options,
no_cache_reason));
}
const v8::UnboundScript* v8__ScriptCompiler__CompileUnboundScript(
v8::Isolate* isolate, v8::ScriptCompiler::Source* source,
v8::ScriptCompiler::CompileOptions options,
v8::ScriptCompiler::NoCacheReason no_cache_reason) {
v8::MaybeLocal<v8::UnboundScript> maybe_local =
v8::ScriptCompiler::CompileUnboundScript(isolate, source, options,
no_cache_reason);
return maybe_local_to_ptr(maybe_local);
}
uint32_t v8__ScriptCompiler__CachedDataVersionTag() {
return v8::ScriptCompiler::CachedDataVersionTag();
}
size_t v8__TypedArray__Length(const v8::TypedArray* self) {
return ptr_to_local(self)->Length();
}
bool v8__Data__EQ(const v8::Data& self, const v8::Data& other) {
return ptr_to_local(&self) == ptr_to_local(&other);
}
bool v8__Data__IsBigInt(const v8::Data& self) {
return IsBigInt(*v8::Utils::OpenHandle(&self));
}
bool v8__Data__IsBoolean(const v8::Data& self) {
return IsBoolean(*v8::Utils::OpenHandle(&self));
}
bool v8__Data__IsContext(const v8::Data& self) { return self.IsContext(); }
bool v8__Data__IsFixedArray(const v8::Data& self) {
return IsFixedArray(*v8::Utils::OpenHandle(&self));
}
bool v8__Data__IsFunctionTemplate(const v8::Data& self) {
return self.IsFunctionTemplate();
}
bool v8__Data__IsModule(const v8::Data& self) { return self.IsModule(); }
bool v8__Data__IsModuleRequest(const v8::Data& self) {
return IsModuleRequest(*v8::Utils::OpenHandle(&self));
}
bool v8__Data__IsName(const v8::Data& self) {
return IsName(*v8::Utils::OpenHandle(&self));
}
bool v8__Data__IsNumber(const v8::Data& self) {
return IsNumber(*v8::Utils::OpenHandle(&self));
}
bool v8__Data__IsObjectTemplate(const v8::Data& self) {
return self.IsObjectTemplate();
}
bool v8__Data__IsPrimitive(const v8::Data& self) {
return IsPrimitive(*v8::Utils::OpenHandle(&self)) && !self.IsPrivate();
}
bool v8__Data__IsPrivate(const v8::Data& self) { return self.IsPrivate(); }
bool v8__Data__IsString(const v8::Data& self) {
return IsString(*v8::Utils::OpenHandle(&self));
}
bool v8__Data__IsSymbol(const v8::Data& self) {
return IsPublicSymbol(*v8::Utils::OpenHandle(&self));
}
bool v8__Data__IsValue(const v8::Data& self) { return self.IsValue(); }
bool v8__Value__IsUndefined(const v8::Value& self) {
return self.IsUndefined();
}
bool v8__Value__IsNull(const v8::Value& self) { return self.IsNull(); }
bool v8__Value__IsNullOrUndefined(const v8::Value& self) {
return self.IsNullOrUndefined();
}
bool v8__Value__IsTrue(const v8::Value& self) { return self.IsTrue(); }
bool v8__Value__IsFalse(const v8::Value& self) { return self.IsFalse(); }
bool v8__Value__IsName(const v8::Value& self) { return self.IsName(); }
bool v8__Value__IsString(const v8::Value& self) { return self.IsString(); }
bool v8__Value__IsSymbol(const v8::Value& self) { return self.IsSymbol(); }
bool v8__Value__IsFunction(const v8::Value& self) { return self.IsFunction(); }
bool v8__Value__IsArray(const v8::Value& self) { return self.IsArray(); }
bool v8__Value__IsObject(const v8::Value& self) { return self.IsObject(); }
bool v8__Value__IsBigInt(const v8::Value& self) { return self.IsBigInt(); }
bool v8__Value__IsBoolean(const v8::Value& self) { return self.IsBoolean(); }
bool v8__Value__IsNumber(const v8::Value& self) { return self.IsNumber(); }
bool v8__Value__IsExternal(const v8::Value& self) { return self.IsExternal(); }
bool v8__Value__IsInt32(const v8::Value& self) { return self.IsInt32(); }
bool v8__Value__IsUint32(const v8::Value& self) { return self.IsUint32(); }
bool v8__Value__IsDate(const v8::Value& self) { return self.IsDate(); }
bool v8__Value__IsArgumentsObject(const v8::Value& self) {
return self.IsArgumentsObject();
}
bool v8__Value__IsBigIntObject(const v8::Value& self) {
return self.IsBigIntObject();
}
bool v8__Value__IsBooleanObject(const v8::Value& self) {
return self.IsBooleanObject();
}
bool v8__Value__IsNumberObject(const v8::Value& self) {
return self.IsNumberObject();
}
bool v8__Value__IsStringObject(const v8::Value& self) {
return self.IsStringObject();
}
bool v8__Value__IsSymbolObject(const v8::Value& self) {
return self.IsSymbolObject();
}
bool v8__Value__IsNativeError(const v8::Value& self) {
return self.IsNativeError();
}
bool v8__Value__IsRegExp(const v8::Value& self) { return self.IsRegExp(); }
bool v8__Value__IsAsyncFunction(const v8::Value& self) {
return self.IsAsyncFunction();
}
bool v8__Value__IsGeneratorFunction(const v8::Value& self) {
return self.IsGeneratorFunction();
}
bool v8__Value__IsGeneratorObject(const v8::Value& self) {
return self.IsGeneratorObject();
}
bool v8__Value__IsPromise(const v8::Value& self) { return self.IsPromise(); }
bool v8__Value__IsMap(const v8::Value& self) { return self.IsMap(); }
bool v8__Value__IsSet(const v8::Value& self) { return self.IsSet(); }
bool v8__Value__IsMapIterator(const v8::Value& self) {
return self.IsMapIterator();
}
bool v8__Value__IsSetIterator(const v8::Value& self) {
return self.IsSetIterator();
}
bool v8__Value__IsSetGeneratorObject(const v8::Value& self) {
return self.IsGeneratorObject();
}
bool v8__Value__IsWeakMap(const v8::Value& self) { return self.IsWeakMap(); }
bool v8__Value__IsWeakSet(const v8::Value& self) { return self.IsWeakSet(); }
bool v8__Value__IsArrayBuffer(const v8::Value& self) {
return self.IsArrayBuffer();
}
bool v8__Value__IsArrayBufferView(const v8::Value& self) {
return self.IsArrayBufferView();
}
bool v8__Value__IsTypedArray(const v8::Value& self) {
return self.IsTypedArray();
}
bool v8__Value__IsUint8Array(const v8::Value& self) {
return self.IsUint8Array();
}
bool v8__Value__IsUint8ClampedArray(const v8::Value& self) {
return self.IsUint8ClampedArray();
}
bool v8__Value__IsInt8Array(const v8::Value& self) {
return self.IsInt8Array();
}
bool v8__Value__IsUint16Array(const v8::Value& self) {
return self.IsUint16Array();
}
bool v8__Value__IsInt16Array(const v8::Value& self) {
return self.IsInt16Array();
}
bool v8__Value__IsUint32Array(const v8::Value& self) {
return self.IsUint32Array();
}
bool v8__Value__IsInt32Array(const v8::Value& self) {
return self.IsInt32Array();
}
bool v8__Value__IsFloat32Array(const v8::Value& self) {
return self.IsFloat32Array();
}
bool v8__Value__IsFloat64Array(const v8::Value& self) {
return self.IsFloat64Array();
}
bool v8__Value__IsBigInt64Array(const v8::Value& self) {
return self.IsBigInt64Array();
}
bool v8__Value__IsBigUint64Array(const v8::Value& self) {
return self.IsBigUint64Array();
}
bool v8__Value__IsDataView(const v8::Value& self) { return self.IsDataView(); }
bool v8__Value__IsSharedArrayBuffer(const v8::Value& self) {
return self.IsSharedArrayBuffer();
}
bool v8__Value__IsProxy(const v8::Value& self) { return self.IsProxy(); }
bool v8__Value__IsWasmModuleObject(const v8::Value& self) {
return self.IsWasmModuleObject();
}
bool v8__Value__IsWasmMemoryObject(const v8::Value& self) {
return self.IsWasmMemoryObject();
}
bool v8__Value__IsModuleNamespaceObject(const v8::Value& self) {
return self.IsModuleNamespaceObject();
}
bool v8__Value__StrictEquals(const v8::Value& self, const v8::Value& that) {
return self.StrictEquals(ptr_to_local(&that));
}
bool v8__Value__SameValue(const v8::Value& self, const v8::Value& that) {
return self.SameValue(ptr_to_local(&that));
}
const v8::Uint32* v8__Value__ToUint32(const v8::Value& self,
const v8::Context& context) {
return maybe_local_to_ptr(self.ToUint32(ptr_to_local(&context)));
}
const v8::Int32* v8__Value__ToInt32(const v8::Value& self,
const v8::Context& context) {
return maybe_local_to_ptr(self.ToInt32(ptr_to_local(&context)));
}
const v8::Integer* v8__Value__ToInteger(const v8::Value& self,
const v8::Context& context) {
return maybe_local_to_ptr(self.ToInteger(ptr_to_local(&context)));
}
const v8::BigInt* v8__Value__ToBigInt(const v8::Value& self,
const v8::Context& context) {
return maybe_local_to_ptr(self.ToBigInt(ptr_to_local(&context)));
}
const v8::String* v8__Value__ToString(const v8::Value& self,
const v8::Context& context) {
return maybe_local_to_ptr(self.ToString(ptr_to_local(&context)));
}
const v8::String* v8__Value__ToDetailString(const v8::Value& self,
const v8::Context& context) {
return maybe_local_to_ptr(self.ToDetailString(ptr_to_local(&context)));
}
const v8::Number* v8__Value__ToNumber(const v8::Value& self,
const v8::Context& context) {
return maybe_local_to_ptr(self.ToNumber(ptr_to_local(&context)));
}
const v8::Object* v8__Value__ToObject(const v8::Value& self,
const v8::Context& context) {
return maybe_local_to_ptr(self.ToObject(ptr_to_local(&context)));
}
const v8::Boolean* v8__Value__ToBoolean(const v8::Value& self,
v8::Isolate* isolate) {
return local_to_ptr(self.ToBoolean(isolate));
}
void v8__Value__InstanceOf(const v8::Value& self, const v8::Context& context,
const v8::Object& object, v8::Maybe<bool>* out) {
v8::Value* self_non_const = const_cast<v8::Value*>(&self);
*out =
self_non_const->InstanceOf(ptr_to_local(&context), ptr_to_local(&object));
}
void v8__Value__NumberValue(const v8::Value& self, const v8::Context& context,
v8::Maybe<double>* out) {
*out = self.NumberValue(ptr_to_local(&context));
}
void v8__Value__IntegerValue(const v8::Value& self, const v8::Context& context,
v8::Maybe<int64_t>* out) {
*out = self.IntegerValue(ptr_to_local(&context));
}
void v8__Value__Uint32Value(const v8::Value& self, const v8::Context& context,
v8::Maybe<uint32_t>* out) {
*out = self.Uint32Value(ptr_to_local(&context));
}
void v8__Value__Int32Value(const v8::Value& self, const v8::Context& context,
v8::Maybe<int32_t>* out) {
*out = self.Int32Value(ptr_to_local(&context));
}
bool v8__Value__BooleanValue(const v8::Value& self, v8::Isolate* isolate) {
return self.BooleanValue(isolate);
}
const v8::String* v8__Value__TypeOf(v8::Value& self, v8::Isolate* isolate) {
return local_to_ptr(self.TypeOf(isolate));
}
const v8::Primitive* v8__Null(v8::Isolate* isolate) {
return local_to_ptr(v8::Null(isolate));
}
const v8::Primitive* v8__Undefined(v8::Isolate* isolate) {
return local_to_ptr(v8::Undefined(isolate));
}
const v8::Boolean* v8__Boolean__New(v8::Isolate* isolate, bool value) {
return local_to_ptr(v8::Boolean::New(isolate, value));
}
int v8__FixedArray__Length(const v8::FixedArray& self) { return self.Length(); }
const v8::Data* v8__FixedArray__Get(const v8::FixedArray& self,
const v8::Context& context, int index) {
return local_to_ptr(ptr_to_local(&self)->Get(ptr_to_local(&context), index));
}
const v8::PrimitiveArray* v8__PrimitiveArray__New(v8::Isolate* isolate,
int length) {
return local_to_ptr(v8::PrimitiveArray::New(isolate, length));
}
int v8__PrimitiveArray__Length(const v8::PrimitiveArray& self) {
return self.Length();
}
void v8__PrimitiveArray__Set(const v8::PrimitiveArray& self,
v8::Isolate* isolate, int index,
const v8::Primitive& item) {
ptr_to_local(&self)->Set(isolate, index, ptr_to_local(&item));
}
const v8::Primitive* v8__PrimitiveArray__Get(const v8::PrimitiveArray& self,
v8::Isolate* isolate, int index) {
return local_to_ptr(ptr_to_local(&self)->Get(isolate, index));
}
v8::BackingStore* v8__ArrayBuffer__NewBackingStore__with_byte_length(
v8::Isolate* isolate, size_t byte_length) {
std::unique_ptr<v8::BackingStore> u =
v8::ArrayBuffer::NewBackingStore(isolate, byte_length);
return u.release();
}
v8::BackingStore* v8__ArrayBuffer__NewBackingStore__with_data(
void* data, size_t byte_length, v8::BackingStore::DeleterCallback deleter,
void* deleter_data) {
std::unique_ptr<v8::BackingStore> u = v8::ArrayBuffer::NewBackingStore(
data, byte_length, deleter, deleter_data);
return u.release();
}
two_pointers_t v8__ArrayBuffer__GetBackingStore(const v8::ArrayBuffer& self) {
return make_pod<two_pointers_t>(ptr_to_local(&self)->GetBackingStore());
}
v8::BackingStore* v8__BackingStore__EmptyBackingStore(bool shared) {
std::unique_ptr<i::BackingStoreBase> u = i::BackingStore::EmptyBackingStore(
shared ? i::SharedFlag::kShared : i::SharedFlag::kNotShared);
return static_cast<v8::BackingStore*>(u.release());
}
bool v8__BackingStore__IsResizableByUserJavaScript(
const v8::BackingStore& self) {
return ptr_to_local(&self)->IsResizableByUserJavaScript();
}
void* v8__ArrayBuffer__Data(const v8::ArrayBuffer& self) {
return ptr_to_local(&self)->Data();
}
MaybeBool v8__ArrayBuffer__Detach(const v8::ArrayBuffer& self,
const v8::Value* key) {
return maybe_to_maybe_bool(ptr_to_local(&self)->Detach(ptr_to_local(key)));
}
bool v8__ArrayBuffer__IsDetachable(const v8::ArrayBuffer& self) {
return ptr_to_local(&self)->IsDetachable();
}
bool v8__ArrayBuffer__WasDetached(const v8::ArrayBuffer& self) {
return ptr_to_local(&self)->WasDetached();
}
void v8__ArrayBuffer__SetDetachKey(const v8::ArrayBuffer& self,
const v8::Value* key) {
return ptr_to_local(&self)->SetDetachKey(ptr_to_local(key));
}
void* v8__BackingStore__Data(const v8::BackingStore& self) {
return self.Data();
}
size_t v8__BackingStore__ByteLength(const v8::BackingStore& self) {
return self.ByteLength();
}
bool v8__BackingStore__IsShared(const v8::BackingStore& self) {
return self.IsShared();
}
void v8__BackingStore__DELETE(v8::BackingStore* self) { delete self; }
two_pointers_t std__shared_ptr__v8__BackingStore__COPY(
const std::shared_ptr<v8::BackingStore>& ptr) {
return make_pod<two_pointers_t>(ptr);
}
two_pointers_t std__shared_ptr__v8__BackingStore__CONVERT__std__unique_ptr(
v8::BackingStore* unique_ptr) {
return make_pod<two_pointers_t>(
std::shared_ptr<v8::BackingStore>(unique_ptr));
}
v8::BackingStore* std__shared_ptr__v8__BackingStore__get(
const std::shared_ptr<v8::BackingStore>& ptr) {
return ptr.get();
}
void std__shared_ptr__v8__BackingStore__reset(
std::shared_ptr<v8::BackingStore>* ptr) {
ptr->reset();
}
long std__shared_ptr__v8__BackingStore__use_count(
const std::shared_ptr<v8::BackingStore>& ptr) {
return ptr.use_count();
}
two_pointers_t std__shared_ptr__v8__ArrayBuffer__Allocator__COPY(
const std::shared_ptr<v8::ArrayBuffer::Allocator>& ptr) {
return make_pod<two_pointers_t>(ptr);