v8x 149.4.0-rc.1

Engine agnostic JavaScript
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
#![allow(non_snake_case, unused)]

use crate::jsc::core::{
  ctx_of, current_ctx, current_iso, intern, intern_ctx, iso_state, jsval,
};
use crate::jsc::jsc_sys::*;
use crate::support::{Maybe, MaybeBool, int};
use crate::{
  Array, Context, IndexFilter, IntegrityLevel, KeyCollectionMode,
  KeyConversionMode, Map, Name, Object, Private, PropertyAttribute,
  PropertyDescriptor, PropertyFilter, RealIsolate, Set, String, Value,
};
use std::os::raw::{c_char, c_void};
use std::ptr;

#[inline]
fn obj_of(ctx: JSContextRef, p: *const Object) -> JSObjectRef {
  let v = jsval(p);
  if v.is_null() {
    return ptr::null_mut();
  }
  let mut exc: JSValueRef = ptr::null();
  unsafe { JSValueToObject(ctx, v, &mut exc) }
}

#[inline]
fn just_bool(b: bool) -> MaybeBool {
  if b {
    MaybeBool::JustTrue
  } else {
    MaybeBool::JustFalse
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__New(isolate: *mut RealIsolate) -> *const Object {
  let st = iso_state(isolate);
  let ctx =
    st.contexts.last().copied().unwrap_or(ptr::null_mut()) as JSContextRef;
  if ctx.is_null() {
    return ptr::null();
  }
  let o = unsafe { JSObjectMake(ctx, ptr::null_mut(), ptr::null_mut()) };
  intern_ctx::<Object>(ctx, o as JSValueRef)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__New__with_prototype_and_properties(
  isolate: *mut RealIsolate,
  prototype_or_null: *const Value,
  names: *const *const Name,
  values: *const *const Value,
  length: usize,
) -> *const Object {
  let st = iso_state(isolate);
  let ctx =
    st.contexts.last().copied().unwrap_or(ptr::null_mut()) as JSContextRef;
  if ctx.is_null() {
    return ptr::null();
  }
  let o = unsafe { JSObjectMake(ctx, ptr::null_mut(), ptr::null_mut()) };
  if !prototype_or_null.is_null() {
    let proto = jsval(prototype_or_null);
    unsafe { JSObjectSetPrototype(ctx, o, proto) };
  }
  unsafe {
    for i in 0..length {
      let key = *names.add(i);
      let val = *values.add(i);
      let mut exc: JSValueRef = ptr::null();
      JSObjectSetPropertyForKey(ctx, o, jsval(key), jsval(val), 0, &mut exc);
    }
  }
  intern_ctx::<Object>(ctx, o as JSValueRef)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__Get(
  this: *const Object,
  context: *const Context,
  key: *const Value,
) -> *const Value {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return ptr::null();
  }
  let mut exc: JSValueRef = ptr::null();
  let v = unsafe { JSObjectGetPropertyForKey(ctx, o, jsval(key), &mut exc) };
  if !exc.is_null() {
    return ptr::null();
  }
  intern_ctx::<Value>(ctx, v)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetIndex(
  this: *const Object,
  context: *const Context,
  index: u32,
) -> *const Value {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return ptr::null();
  }
  let mut exc: JSValueRef = ptr::null();
  let v = unsafe { JSObjectGetPropertyAtIndex(ctx, o, index, &mut exc) };
  if !exc.is_null() {
    return ptr::null();
  }
  intern_ctx::<Value>(ctx, v)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetPrototype(
  this: *const Object,
) -> *const Value {
  let ctx = current_ctx();
  let o = obj_of(ctx, this);
  if o.is_null() {
    return ptr::null();
  }
  let v = unsafe { JSObjectGetPrototype(ctx, o) };
  intern_ctx::<Value>(ctx, v)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__Set(
  this: *const Object,
  context: *const Context,
  key: *const Value,
  value: *const Value,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  unsafe {
    JSObjectSetPropertyForKey(ctx, o, jsval(key), jsval(value), 0, &mut exc)
  };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  MaybeBool::JustTrue
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__SetIndex(
  this: *const Object,
  context: *const Context,
  index: u32,
  value: *const Value,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  unsafe { JSObjectSetPropertyAtIndex(ctx, o, index, jsval(value), &mut exc) };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  MaybeBool::JustTrue
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__SetPrototype(
  this: *const Object,
  context: *const Context,
  prototype: *const Value,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  unsafe { JSObjectSetPrototype(ctx, o, jsval(prototype)) };
  MaybeBool::JustTrue
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__CreateDataProperty(
  this: *const Object,
  context: *const Context,
  key: *const Name,
  value: *const Value,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  unsafe {
    JSObjectSetPropertyForKey(ctx, o, jsval(key), jsval(value), 0, &mut exc)
  };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  MaybeBool::JustTrue
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__DefineOwnProperty(
  this: *const Object,
  context: *const Context,
  key: *const Name,
  value: *const Value,
  attr: PropertyAttribute,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }

  let a = attr.as_u32();
  let mut jsc_attr: u32 = 0;
  if a & (1 << 0) != 0 {
    jsc_attr |= 1 << 1;
  }
  if a & (1 << 1) != 0 {
    jsc_attr |= 1 << 2;
  }
  if a & (1 << 2) != 0 {
    jsc_attr |= 1 << 3;
  }
  let mut exc: JSValueRef = ptr::null();
  unsafe {
    JSObjectSetPropertyForKey(
      ctx,
      o,
      jsval(key),
      jsval(value),
      jsc_attr,
      &mut exc,
    )
  };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  MaybeBool::JustTrue
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__DefineProperty(
  this: *const Object,
  context: *const Context,
  key: *const Name,
  desc: *const PropertyDescriptor,
) -> MaybeBool {
  MaybeBool::Nothing
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__Delete(
  this: *const Object,
  context: *const Context,
  key: *const Value,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  let r = unsafe { JSObjectDeletePropertyForKey(ctx, o, jsval(key), &mut exc) };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  just_bool(r)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__Has(
  this: *const Object,
  context: *const Context,
  key: *const Value,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  let r = unsafe { JSObjectHasPropertyForKey(ctx, o, jsval(key), &mut exc) };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  just_bool(r)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__HasOwnProperty(
  this: *const Object,
  context: *const Context,
  key: *const Name,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  let r = unsafe { JSObjectHasPropertyForKey(ctx, o, jsval(key), &mut exc) };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  just_bool(r)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetConstructorName(
  this: *const Object,
) -> *const String {
  let ctx = current_ctx();
  let o = obj_of(ctx, this);
  if o.is_null() {
    return ptr::null();
  }

  let cname = b"constructor\0";
  let nname = b"name\0";
  unsafe {
    let cs = JSStringCreateWithUTF8CString(cname.as_ptr() as *const c_char);
    let mut exc: JSValueRef = ptr::null();
    let ctor = JSObjectGetProperty(ctx, o, cs, &mut exc);
    JSStringRelease(cs);
    if exc.is_null() && JSValueIsObject(ctx, ctor) {
      let ctor_o = JSValueToObject(ctx, ctor, &mut exc);
      if !ctor_o.is_null() {
        let ns = JSStringCreateWithUTF8CString(nname.as_ptr() as *const c_char);
        let name = JSObjectGetProperty(ctx, ctor_o, ns, &mut exc);
        JSStringRelease(ns);
        if exc.is_null() && JSValueIsString(ctx, name) {
          return intern_ctx::<String>(ctx, name);
        }
      }
    }
  }
  ptr::null()
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetIdentityHash(this: *const Object) -> int {
  let p = jsval(this) as usize;
  let h = (p as u32) ^ ((p >> 32) as u32);
  (h & 0x7fff_ffff) as int
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetOwnPropertyNames(
  this: *const Object,
  context: *const Context,
  filter: PropertyFilter,
  key_conversion: KeyConversionMode,
) -> *const Array {
  let _ = (filter, key_conversion);
  property_names_array(this, context, false)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetPropertyNames(
  this: *const Object,
  context: *const Context,
  mode: KeyCollectionMode,
  property_filter: PropertyFilter,
  index_filter: IndexFilter,
  key_conversion: KeyConversionMode,
) -> *const Array {
  let _ = (mode, key_conversion);

  let filter =
    unsafe { *(&property_filter as *const PropertyFilter as *const u32) };

  if filter & 8 != 0 {
    return empty_array(this, context);
  }

  let skip_indices = index_filter as u32 == 1;
  property_names_array(this, context, skip_indices)
}

fn property_names_array(
  this: *const Object,
  context: *const Context,
  skip_indices: bool,
) -> *const Array {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return ptr::null();
  }
  unsafe {
    let names = JSObjectCopyPropertyNames(ctx, o);
    let count = JSPropertyNameArrayGetCount(names);
    let mut vals: Vec<JSValueRef> = Vec::with_capacity(count);
    for i in 0..count {
      let s = JSPropertyNameArrayGetNameAtIndex(names, i);
      if skip_indices && jsstr_is_array_index(s) {
        continue;
      }
      let v = JSValueMakeString(ctx, s);
      vals.push(v);
    }
    JSPropertyNameArrayRelease(names);
    let mut exc: JSValueRef = ptr::null();
    let arr = JSObjectMakeArray(ctx, vals.len(), vals.as_ptr(), &mut exc);
    if !exc.is_null() || arr.is_null() {
      return ptr::null();
    }
    intern_ctx::<Array>(ctx, arr as JSValueRef)
  }
}

fn empty_array(_this: *const Object, context: *const Context) -> *const Array {
  let ctx = ctx_of(context) as JSContextRef;
  if ctx.is_null() {
    return ptr::null();
  }
  unsafe {
    let mut exc: JSValueRef = ptr::null();
    let arr = JSObjectMakeArray(ctx, 0, ptr::null(), &mut exc);
    if !exc.is_null() || arr.is_null() {
      return ptr::null();
    }
    intern_ctx::<Array>(ctx, arr as JSValueRef)
  }
}

unsafe fn jsstr_is_array_index(s: JSStringRef) -> bool {
  let len = unsafe { JSStringGetLength(s) };
  if len == 0 || len > 10 {
    return false;
  }
  let chars = unsafe { JSStringGetCharactersPtr(s) };
  if chars.is_null() {
    return false;
  }
  let slice = unsafe { std::slice::from_raw_parts(chars, len) };

  if slice[0] == b'0' as u16 {
    return len == 1;
  }
  let mut val: u64 = 0;
  for &c in slice {
    if !(b'0' as u16..=b'9' as u16).contains(&c) {
      return false;
    }
    val = val * 10 + (c - b'0' as u16) as u64;
  }
  val <= u32::MAX as u64
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetPrivate(
  this: *const Object,
  context: *const Context,
  key: *const Private,
) -> *const Value {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return ptr::null();
  }
  let mut exc: JSValueRef = ptr::null();
  let v = unsafe { JSObjectGetPropertyForKey(ctx, o, jsval(key), &mut exc) };
  if !exc.is_null() {
    return ptr::null();
  }
  intern_ctx::<Value>(ctx, v)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__SetPrivate(
  this: *const Object,
  context: *const Context,
  key: *const Private,
  value: *const Value,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }

  let mut exc: JSValueRef = ptr::null();
  unsafe {
    JSObjectSetPropertyForKey(
      ctx,
      o,
      jsval(key),
      jsval(value),
      1 << 2,
      &mut exc,
    )
  };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  MaybeBool::JustTrue
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetPropertyAttributes(
  this: *const Object,
  context: *const Context,
  key: *const Value,
  out: *mut Maybe<PropertyAttribute>,
) {
  if out.is_null() {
    return;
  }
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  let mut exc: JSValueRef = ptr::null();
  let has = if o.is_null() {
    false
  } else {
    unsafe { JSObjectHasPropertyForKey(ctx, o, jsval(key), &mut exc) }
  };
  let m = if has && exc.is_null() {
    let mut tmp: Maybe<PropertyAttribute> = unsafe { std::mem::zeroed() };

    unsafe {
      *(&mut tmp as *mut Maybe<PropertyAttribute> as *mut bool) = true;
    }
    tmp
  } else {
    unsafe { std::mem::zeroed() }
  };
  unsafe {
    ptr::write(out, m);
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Array__New(
  isolate: *mut RealIsolate,
  length: int,
) -> *const Array {
  let st = iso_state(isolate);
  let ctx =
    st.contexts.last().copied().unwrap_or(ptr::null_mut()) as JSContextRef;
  if ctx.is_null() {
    return ptr::null();
  }
  let len = if length < 0 { 0usize } else { length as usize };
  unsafe {
    let mut exc: JSValueRef = ptr::null();
    let arr = if len == 0 {
      JSObjectMakeArray(ctx, 0, ptr::null(), &mut exc)
    } else {
      let undef = JSValueMakeUndefined(ctx);
      let vals = vec![undef; len];
      JSObjectMakeArray(ctx, vals.len(), vals.as_ptr(), &mut exc)
    };
    if !exc.is_null() || arr.is_null() {
      return ptr::null();
    }
    intern_ctx::<Array>(ctx, arr as JSValueRef)
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Array__New_with_elements(
  isolate: *mut RealIsolate,
  elements: *const *const Value,
  length: usize,
) -> *const Array {
  let st = iso_state(isolate);
  let ctx =
    st.contexts.last().copied().unwrap_or(ptr::null_mut()) as JSContextRef;
  if ctx.is_null() {
    return ptr::null();
  }
  unsafe {
    let mut vals: Vec<JSValueRef> = Vec::with_capacity(length);
    for i in 0..length {
      vals.push(jsval(*elements.add(i)));
    }
    let mut exc: JSValueRef = ptr::null();
    let arr = JSObjectMakeArray(ctx, vals.len(), vals.as_ptr(), &mut exc);
    if !exc.is_null() || arr.is_null() {
      return ptr::null();
    }
    intern_ctx::<Array>(ctx, arr as JSValueRef)
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Array__Length(array: *const Array) -> u32 {
  let ctx = current_ctx();
  if ctx.is_null() {
    return 0;
  }
  let o = obj_of(ctx, array as *const Object);
  if o.is_null() {
    return 0;
  }
  unsafe {
    let ls =
      JSStringCreateWithUTF8CString(b"length\0".as_ptr() as *const c_char);
    let mut exc: JSValueRef = ptr::null();
    let lv = JSObjectGetProperty(ctx, o, ls, &mut exc);
    JSStringRelease(ls);
    if !exc.is_null() {
      return 0;
    }
    let n = JSValueToNumber(ctx, lv, &mut exc);
    if !exc.is_null() || n.is_nan() || n < 0.0 {
      return 0;
    }
    n as u32
  }
}

thread_local! {
    static WRAP_TABLE: std::cell::RefCell<
        std::collections::HashMap<(usize, u16), usize>,
    > = std::cell::RefCell::new(std::collections::HashMap::new());
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__Wrap(
  _isolate: *const RealIsolate,
  wrapper: *const Object,
  value: *const crate::binding::RustObj,
  tag: u16,
) {
  if wrapper.is_null() {
    return;
  }
  WRAP_TABLE.with(|t| {
    t.borrow_mut()
      .insert((wrapper as usize, tag), value as usize);
  });
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__Unwrap(
  _isolate: *const RealIsolate,
  wrapper: *const Object,
  tag: u16,
) -> *mut crate::binding::RustObj {
  if wrapper.is_null() {
    return ptr::null_mut();
  }
  WRAP_TABLE.with(|t| {
    t.borrow()
      .get(&(wrapper as usize, tag))
      .map(|&p| p as *mut crate::binding::RustObj)
      .unwrap_or(ptr::null_mut())
  })
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__IsApiWrapper(this: *const Object) -> bool {
  if this.is_null() {
    return false;
  }
  WRAP_TABLE.with(|t| {
    let map = t.borrow();
    map.keys().any(|(w, _)| *w == this as usize)
  })
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetOwnPropertyDescriptor(
  this: *const Object,
  context: *const Context,
  key: *const Name,
) -> *const Value {
  if this.is_null() {
    return ptr::null();
  }
  let ctx = ctx_of(context) as JSContextRef;
  if ctx.is_null() {
    return ptr::null();
  }
  let obj = obj_of(ctx, this);
  if obj.is_null() {
    return ptr::null();
  }
  unsafe {
    let global = JSContextGetGlobalObject(ctx);
    let object_key = JSStringCreateWithUTF8CString(c"Object".as_ptr());
    let mut exc: JSValueRef = ptr::null();
    let object_ctor = JSObjectGetProperty(ctx, global, object_key, &mut exc);
    JSStringRelease(object_key);
    if object_ctor.is_null() || !JSValueIsObject(ctx, object_ctor) {
      return ptr::null();
    }
    let gopd_key =
      JSStringCreateWithUTF8CString(c"getOwnPropertyDescriptor".as_ptr());
    let gopd =
      JSObjectGetProperty(ctx, object_ctor as JSObjectRef, gopd_key, &mut exc);
    JSStringRelease(gopd_key);
    if gopd.is_null() || !JSValueIsObject(ctx, gopd) {
      return ptr::null();
    }
    let args = [obj as JSValueRef, jsval(key)];
    let r = JSObjectCallAsFunction(
      ctx,
      gopd as JSObjectRef,
      object_ctor as JSObjectRef,
      2,
      args.as_ptr(),
      &mut exc,
    );
    if r.is_null() {
      if !exc.is_null() {
        crate::jsc::core::record_pending_exception(ctx, exc);
      }
      return ptr::null();
    }

    intern_ctx::<Value>(ctx, r)
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__HasIndex(
  this: *const Object,
  context: *const Context,
  index: u32,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  let v = unsafe { JSObjectGetPropertyAtIndex(ctx, o, index, &mut exc) };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }

  just_bool(!unsafe { JSValueIsUndefined(ctx, v) })
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__DeleteIndex(
  this: *const Object,
  context: *const Context,
  index: u32,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }

  let key = unsafe { JSValueMakeNumber(ctx, index as f64) };
  let mut exc: JSValueRef = ptr::null();
  let r = unsafe { JSObjectDeletePropertyForKey(ctx, o, key, &mut exc) };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  just_bool(r)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetRealNamedProperty(
  this: *const Object,
  context: *const Context,
  key: *const Name,
) -> *const Value {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return ptr::null();
  }
  let mut exc: JSValueRef = ptr::null();
  let v = unsafe { JSObjectGetPropertyForKey(ctx, o, jsval(key), &mut exc) };
  if !exc.is_null() {
    return ptr::null();
  }
  intern_ctx::<Value>(ctx, v)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__HasRealNamedProperty(
  this: *const Object,
  context: *const Context,
  key: *const Name,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  let r = unsafe { JSObjectHasPropertyForKey(ctx, o, jsval(key), &mut exc) };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  just_bool(r)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetRealNamedPropertyAttributes(
  this: *const Object,
  context: *const Context,
  key: *const Name,
  out: *mut Maybe<PropertyAttribute>,
) {
  if out.is_null() {
    return;
  }
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  let mut exc: JSValueRef = ptr::null();
  let has = if o.is_null() {
    false
  } else {
    unsafe { JSObjectHasPropertyForKey(ctx, o, jsval(key), &mut exc) }
  };
  let m = if has && exc.is_null() {
    let mut tmp: Maybe<PropertyAttribute> = unsafe { std::mem::zeroed() };
    unsafe {
      *(&mut tmp as *mut Maybe<PropertyAttribute> as *mut bool) = true;
    }
    tmp
  } else {
    unsafe { std::mem::zeroed() }
  };
  unsafe {
    ptr::write(out, m);
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__HasPrivate(
  this: *const Object,
  context: *const Context,
  key: *const Private,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  let r = unsafe { JSObjectHasPropertyForKey(ctx, o, jsval(key), &mut exc) };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  just_bool(r)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__DeletePrivate(
  this: *const Object,
  context: *const Context,
  key: *const Private,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }
  let mut exc: JSValueRef = ptr::null();
  let r = unsafe { JSObjectDeletePropertyForKey(ctx, o, jsval(key), &mut exc) };
  if !exc.is_null() {
    return MaybeBool::Nothing;
  }
  just_bool(r)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetCreationContext(
  this: *const Object,
) -> *const Context {
  let iso = current_iso();
  if iso.is_null() {
    return ptr::null();
  }
  iso_state(iso)
    .contexts
    .last()
    .copied()
    .unwrap_or(ptr::null_mut()) as *const Context
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__SetIntegrityLevel(
  this: *const Object,
  context: *const Context,
  level: IntegrityLevel,
) -> MaybeBool {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this);
  if o.is_null() {
    return MaybeBool::Nothing;
  }

  let fname = match level {
    IntegrityLevel::Frozen => b"freeze\0".as_ref(),
    IntegrityLevel::Sealed => b"seal\0".as_ref(),
  };
  unsafe {
    let global = JSContextGetGlobalObject(ctx);
    let mut exc: JSValueRef = ptr::null();
    let oname =
      JSStringCreateWithUTF8CString(b"Object\0".as_ptr() as *const c_char);
    let object_ctor = JSObjectGetProperty(ctx, global, oname, &mut exc);
    JSStringRelease(oname);
    if !exc.is_null() || !JSValueIsObject(ctx, object_ctor) {
      return MaybeBool::Nothing;
    }
    let object_obj = JSValueToObject(ctx, object_ctor, &mut exc);
    let fs = JSStringCreateWithUTF8CString(fname.as_ptr() as *const c_char);
    let func = JSObjectGetProperty(ctx, object_obj, fs, &mut exc);
    JSStringRelease(fs);
    if !exc.is_null() {
      return MaybeBool::Nothing;
    }
    let func_obj = JSValueToObject(ctx, func, &mut exc);
    if func_obj.is_null() {
      return MaybeBool::Nothing;
    }
    let args = [o as JSValueRef];
    JSObjectCallAsFunction(
      ctx,
      func_obj,
      ptr::null_mut(),
      1,
      args.as_ptr(),
      &mut exc,
    );
    if !exc.is_null() {
      return MaybeBool::Nothing;
    }
  }
  MaybeBool::JustTrue
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__PreviewEntries(
  this: *const Object,
  is_key_value: *mut bool,
) -> *const Array {
  let ctx = current_ctx();
  let o = obj_of(ctx, this);
  if ctx.is_null() || o.is_null() {
    return ptr::null();
  }
  // A Map/Set ITERATOR has no `.entries()`/`.values()` of its own; previewing
  // it means peeking the remaining backing entries without consuming. Do that
  // natively (introspect.cpp). Collections fall through to the iterator-method
  // path below.
  {
    let mut kv = false;
    let arr = unsafe {
      crate::jsc::introspect::v82jsc_iterator_preview(
        ctx,
        o as JSValueRef,
        &mut kv,
      )
    };
    if !arr.is_null() {
      if !is_key_value.is_null() {
        unsafe { *is_key_value = kv };
      }
      return intern::<Array>(arr);
    }
  }
  unsafe {
    let mut exc: JSValueRef = ptr::null();

    let try_iter = |name: &[u8]| -> JSValueRef {
      let mut e: JSValueRef = ptr::null();
      let ns = JSStringCreateWithUTF8CString(name.as_ptr() as *const c_char);
      let m = JSObjectGetProperty(ctx, o, ns, &mut e);
      JSStringRelease(ns);
      if !e.is_null() || !JSValueIsObject(ctx, m) {
        return ptr::null();
      }
      let mo = JSValueToObject(ctx, m, &mut e);
      if mo.is_null() || !JSObjectIsFunction(ctx, mo) {
        return ptr::null();
      }
      JSObjectCallAsFunction(ctx, mo, o, 0, ptr::null(), &mut e)
    };
    let (iter, kv) = {
      let it = try_iter(b"entries\0");
      if !it.is_null() {
        (it, true)
      } else {
        (try_iter(b"values\0"), false)
      }
    };
    if iter.is_null() {
      if !is_key_value.is_null() {
        *is_key_value = false;
      }
      return ptr::null();
    }
    if !is_key_value.is_null() {
      *is_key_value = kv;
    }

    let global = JSContextGetGlobalObject(ctx);
    let an =
      JSStringCreateWithUTF8CString(b"Array\0".as_ptr() as *const c_char);
    let array_ctor = JSObjectGetProperty(ctx, global, an, &mut exc);
    JSStringRelease(an);
    let array_obj = JSValueToObject(ctx, array_ctor, &mut exc);
    let fr = JSStringCreateWithUTF8CString(b"from\0".as_ptr() as *const c_char);
    let from = JSObjectGetProperty(ctx, array_obj, fr, &mut exc);
    JSStringRelease(fr);
    let from_obj = JSValueToObject(ctx, from, &mut exc);
    if from_obj.is_null() {
      return ptr::null();
    }
    let args = [iter];
    let arr = JSObjectCallAsFunction(
      ctx,
      from_obj,
      ptr::null_mut(),
      1,
      args.as_ptr(),
      &mut exc,
    );
    if !exc.is_null() || arr.is_null() {
      return ptr::null();
    }

    if kv {
      let flat = b"(function(pairs){var r=[];for(var i=0;i<pairs.length;i++){r.push(pairs[i][0]);r.push(pairs[i][1]);}return r;})\0";
      let fs = JSStringCreateWithUTF8CString(flat.as_ptr() as *const c_char);
      let fnv = JSEvaluateScript(
        ctx,
        fs,
        ptr::null_mut(),
        ptr::null_mut(),
        1,
        &mut exc,
      );
      JSStringRelease(fs);
      let fnobj = JSValueToObject(ctx, fnv, &mut exc);
      if !fnobj.is_null() {
        let a2 = [arr];
        let flat_arr = JSObjectCallAsFunction(
          ctx,
          fnobj,
          ptr::null_mut(),
          1,
          a2.as_ptr(),
          &mut exc,
        );
        if exc.is_null() && !flat_arr.is_null() {
          return intern_ctx::<Array>(ctx, flat_arr);
        }
      }
    }
    intern_ctx::<Array>(ctx, arr)
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Map__Size(map: *const Map) -> usize {
  map_set_size(jsval(map))
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Set__Size(map: *const Set) -> usize {
  map_set_size(jsval(map))
}

fn map_set_size(v: JSValueRef) -> usize {
  let ctx = current_ctx();
  if ctx.is_null() || v.is_null() {
    return 0;
  }
  unsafe {
    let mut exc: JSValueRef = ptr::null();
    let o = JSValueToObject(ctx, v, &mut exc);
    if o.is_null() {
      return 0;
    }
    let ss = JSStringCreateWithUTF8CString(b"size\0".as_ptr() as *const c_char);
    let sz = JSObjectGetProperty(ctx, o, ss, &mut exc);
    JSStringRelease(ss);
    if !exc.is_null() {
      return 0;
    }
    JSValueToNumber(ctx, sz, &mut exc) as usize
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Map__As__Array(this: *const Map) -> *const Array {
  map_set_as_array(jsval(this), true)
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Set__As__Array(this: *const Set) -> *const Array {
  map_set_as_array(jsval(this), false)
}

fn map_set_as_array(v: JSValueRef, is_map: bool) -> *const Array {
  let ctx = current_ctx();
  if ctx.is_null() || v.is_null() {
    return ptr::null();
  }
  unsafe {
    let src = if is_map {
      b"(function(m){var r=[];m.forEach(function(val,key){r.push(key);r.push(val);});return r;})\0".as_ref()
    } else {
      b"(function(s){var r=[];s.forEach(function(val){r.push(val);});return r;})\0".as_ref()
    };
    let mut exc: JSValueRef = ptr::null();
    let fs = JSStringCreateWithUTF8CString(src.as_ptr() as *const c_char);
    let fnv =
      JSEvaluateScript(ctx, fs, ptr::null_mut(), ptr::null_mut(), 1, &mut exc);
    JSStringRelease(fs);
    let fnobj = JSValueToObject(ctx, fnv, &mut exc);
    if fnobj.is_null() {
      return ptr::null();
    }
    let args = [v];
    let arr = JSObjectCallAsFunction(
      ctx,
      fnobj,
      ptr::null_mut(),
      1,
      args.as_ptr(),
      &mut exc,
    );
    if !exc.is_null() || arr.is_null() {
      return ptr::null();
    }
    intern_ctx::<Array>(ctx, arr)
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Set__New(isolate: *mut RealIsolate) -> *const Set {
  let st = iso_state(isolate);
  let ctx =
    st.contexts.last().copied().unwrap_or(ptr::null_mut()) as JSContextRef;
  if ctx.is_null() {
    return ptr::null();
  }
  unsafe {
    let mut exc: JSValueRef = ptr::null();
    let fs =
      JSStringCreateWithUTF8CString(b"(new Set())\0".as_ptr() as *const c_char);
    let v =
      JSEvaluateScript(ctx, fs, ptr::null_mut(), ptr::null_mut(), 1, &mut exc);
    JSStringRelease(fs);
    if !exc.is_null() {
      return ptr::null();
    }
    intern_ctx::<Set>(ctx, v)
  }
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Set__Add(
  this: *const Set,
  context: *const Context,
  key: *const Value,
) -> *const Set {
  let ctx = ctx_of(context) as JSContextRef;
  let o = obj_of(ctx, this as *const Object);
  if o.is_null() {
    return ptr::null();
  }
  unsafe {
    let mut exc: JSValueRef = ptr::null();
    let as_ = JSStringCreateWithUTF8CString(b"add\0".as_ptr() as *const c_char);
    let add = JSObjectGetProperty(ctx, o, as_, &mut exc);
    JSStringRelease(as_);
    let add_obj = JSValueToObject(ctx, add, &mut exc);
    if add_obj.is_null() {
      return ptr::null();
    }
    let args = [jsval(key)];
    JSObjectCallAsFunction(ctx, add_obj, o, 1, args.as_ptr(), &mut exc);
    if !exc.is_null() {
      return ptr::null();
    }
  }

  this
}

// ---------------------------------------------------------------------------
// Link-stubs for v8 C-ABI symbols that `test_api.rs` references but this
// backend doesn't implement yet. Each returns a benign default
// (null / 0 / false / `Nothing`) so the target LINKS and the many tests that
// don't touch these paths run; tests that do exercise them fail gracefully
// without crashing. Promote individual stubs to real implementations over time.
// ---------------------------------------------------------------------------

#[unsafe(no_mangle)]
pub extern "C" fn v8__Map__Clear(_this: *const std::os::raw::c_void) {}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Map__Delete(
  _this: *const std::os::raw::c_void,
  _context: *const std::os::raw::c_void,
  _key: *const std::os::raw::c_void,
) -> crate::support::MaybeBool {
  crate::support::MaybeBool::Nothing
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Map__Get(
  _this: *const std::os::raw::c_void,
  _context: *const std::os::raw::c_void,
  _key: *const std::os::raw::c_void,
) -> *const std::os::raw::c_void {
  std::ptr::null()
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Map__Has(
  _this: *const std::os::raw::c_void,
  _context: *const std::os::raw::c_void,
  _key: *const std::os::raw::c_void,
) -> crate::support::MaybeBool {
  crate::support::MaybeBool::Nothing
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Map__New(
  _isolate: *mut std::os::raw::c_void,
) -> *const std::os::raw::c_void {
  std::ptr::null()
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Map__Set(
  _this: *const std::os::raw::c_void,
  _context: *const std::os::raw::c_void,
  _key: *const std::os::raw::c_void,
  _value: *const std::os::raw::c_void,
) -> *const std::os::raw::c_void {
  std::ptr::null()
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetAlignedPointerFromInternalField(
  _this: *const std::os::raw::c_void,
  _index: crate::support::int,
  _tag: u16,
) -> *const std::os::raw::c_void {
  std::ptr::null()
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__GetInternalField(
  _this: *const std::os::raw::c_void,
  _index: crate::support::int,
) -> *const std::os::raw::c_void {
  std::ptr::null()
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__InternalFieldCount(
  _this: *const std::os::raw::c_void,
) -> crate::support::int {
  0
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__SetAccessor(
  _this: *const std::os::raw::c_void,
  _context: *const std::os::raw::c_void,
  _key: *const std::os::raw::c_void,
  _getter: *const std::os::raw::c_void,
  _setter: *const std::os::raw::c_void,
  _data_or_null: *const std::os::raw::c_void,
  _attr: crate::PropertyAttribute,
) -> crate::support::MaybeBool {
  crate::support::MaybeBool::Nothing
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__SetAlignedPointerInInternalField(
  _this: *const std::os::raw::c_void,
  _index: crate::support::int,
  _value: *const std::os::raw::c_void,
  _tag: u16,
) {
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__SetInternalField(
  _this: *const std::os::raw::c_void,
  _index: crate::support::int,
  _data: *const std::os::raw::c_void,
) {
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Object__SetLazyDataProperty(
  _this: *const std::os::raw::c_void,
  _context: *const std::os::raw::c_void,
  _key: *const std::os::raw::c_void,
  _getter: *const std::os::raw::c_void,
  _data_or_null: *const std::os::raw::c_void,
  _attr: crate::PropertyAttribute,
  _getter_side_effect_type: crate::SideEffectType,
  _setter_side_effect_type: crate::SideEffectType,
) -> crate::support::MaybeBool {
  crate::support::MaybeBool::Nothing
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__RegExp__Exec(
  _this: *const std::os::raw::c_void,
  _context: *const std::os::raw::c_void,
  _subject: *const std::os::raw::c_void,
) -> *const std::os::raw::c_void {
  std::ptr::null()
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__RegExp__GetSource(
  _this: *const std::os::raw::c_void,
) -> *const std::os::raw::c_void {
  std::ptr::null()
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__RegExp__New(
  _context: *const std::os::raw::c_void,
  _pattern: *const std::os::raw::c_void,
  _flags: crate::RegExpCreationFlags,
) -> *const std::os::raw::c_void {
  std::ptr::null()
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Set__Clear(_this: *const std::os::raw::c_void) {}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Set__Delete(
  _this: *const std::os::raw::c_void,
  _context: *const std::os::raw::c_void,
  _key: *const std::os::raw::c_void,
) -> crate::support::MaybeBool {
  crate::support::MaybeBool::Nothing
}

#[unsafe(no_mangle)]
pub extern "C" fn v8__Set__Has(
  _this: *const std::os::raw::c_void,
  _context: *const std::os::raw::c_void,
  _key: *const std::os::raw::c_void,
) -> crate::support::MaybeBool {
  crate::support::MaybeBool::Nothing
}