interoptopus_backend_csharp 0.14.25

Generates C# bindings.
Documentation
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
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
// Automatically generated by Interoptopus.

#pragma warning disable 0105
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
#if UNITY_2018_1_OR_NEWER
using Unity.Collections.LowLevel.Unsafe;
using Unity.Collections;
#endif
using My.Company;
using My.Company.Common;
#pragma warning restore 0105

namespace My.Company
{
    public static partial class Interop
    {
        public const string NativeLib = "interoptopus_reference_project";

        static Interop()
        {
            var api_version = Interop.pattern_api_guard();
            if (api_version != 16012698009278542425ul)
            {
                throw new TypeLoadException($"API reports hash {api_version} which differs from hash in bindings (16012698009278542425). You probably forgot to update / copy either the bindings or the library.");
            }
        }

        public const byte U8 = (byte) 255;

        public const float F32_MIN_POSITIVE = (float) 0.000000000000000000000000000000000000011754944;

        public const int COMPUTED_I32 = (int) -2147483647;


        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_void")]
        public static extern void primitive_void();

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_void2")]
        public static extern void primitive_void2();

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_bool")]
        public static extern bool primitive_bool(bool x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_u8")]
        public static extern byte primitive_u8(byte x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_u16")]
        public static extern ushort primitive_u16(ushort x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_u32")]
        public static extern uint primitive_u32(uint x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_u64")]
        public static extern ulong primitive_u64(ulong x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_i8")]
        public static extern sbyte primitive_i8(sbyte x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_i16")]
        public static extern short primitive_i16(short x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_i32")]
        public static extern int primitive_i32(int x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "primitive_i64")]
        public static extern long primitive_i64(long x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "boolean_alignment")]
        public static extern BooleanAlignment boolean_alignment(BooleanAlignment x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "boolean_alignment2")]
        public static extern BooleanAlignment boolean_alignment2(bool rval);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "aligned_to_packed1")]
        public static extern Packed1 aligned_to_packed1(Aligned1 a);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "aligned_to_packed2")]
        public static extern Packed2 aligned_to_packed2(Aligned2 a);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "many_args_5")]
        public static extern long many_args_5(long x0, long x1, long x2, long x3, long x4);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "many_args_10")]
        public static extern long many_args_10(long x0, long x1, long x2, long x3, long x4, long x5, long x6, long x7, long x8, long x9);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ptr")]
        public static extern IntPtr ptr(ref long x);

        /// # Safety
        ///
        /// Parameter x must point to valid data.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ptr_mut")]
        public static extern IntPtr ptr_mut(out long x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ptr_ptr")]
        public static extern IntPtr ptr_ptr(ref IntPtr x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ref_simple")]
        public static extern IntPtr ref_simple(ref long x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ref_mut_simple")]
        public static extern IntPtr ref_mut_simple(out long x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ref_option")]
        public static extern bool ref_option(ref long x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ref_mut_option")]
        public static extern bool ref_mut_option(out long x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "tupled")]
        public static extern Tupled tupled(Tupled x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "complex_args_1")]
        public static extern FFIError complex_args_1(Vec3f32 a, ref Tupled b);

        public static void complex_args_1_checked(Vec3f32 a, ref Tupled b)
        {
            var rval = complex_args_1(a, ref b);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "complex_args_2")]
        public static extern IntPtr complex_args_2(SomeForeignType cmplx);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "callback")]
        public static extern byte callback(InteropDelegate_fn_u8_rval_u8 callback, byte value);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "callback")]
        public static extern byte callback(IntPtr callback, byte value);


        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "generic_1a")]
        public static extern uint generic_1a(Genericu32 x, Phantomu8 y);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "generic_1b")]
        public static extern byte generic_1b(Genericu8 x, Phantomu8 y);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "generic_1c")]
        public static extern byte generic_1c(ref Genericu8 x, ref Genericu8 y);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "generic_2")]
        public static extern byte generic_2(IntPtr x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "generic_3")]
        public static extern byte generic_3(IntPtr x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "generic_4")]
        public static extern byte generic_4(IntPtr x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "array_1")]
        public static extern byte array_1(Array x);

        /// This function has documentation.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "documented")]
        public static extern EnumDocumented documented(StructDocumented x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ambiguous_1")]
        public static extern Vec1 ambiguous_1(Vec1 x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ambiguous_2")]
        public static extern Vec2 ambiguous_2(Vec2 x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ambiguous_3")]
        public static extern bool ambiguous_3(Vec1 x, Vec2 y);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "namespaced_type")]
        public static extern Vec namespaced_type(Vec x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "namespaced_inner_option")]
        public static extern OptionVec namespaced_inner_option(OptionVec x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "namespaced_inner_slice")]
        public static extern SliceVec namespaced_inner_slice(SliceVec x);

        public static SliceVec namespaced_inner_slice(Vec[] x)
        {
            unsafe
            {
                fixed (void* ptr_x = x)
                {
                    var x_slice = new SliceVec(new IntPtr(ptr_x), (ulong) x.Length);
                    return namespaced_inner_slice(x_slice);;
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static SliceVec namespaced_inner_slice(NativeArray<Vec> x)
        {
            var x_slice = new SliceVec(x);
            return namespaced_inner_slice(x_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "namespaced_inner_slice_mut")]
        public static extern SliceMutVec namespaced_inner_slice_mut(SliceMutVec x);

        public static SliceMutVec namespaced_inner_slice_mut(Vec[] x)
        {
            unsafe
            {
                fixed (void* ptr_x = x)
                {
                    var x_slice = new SliceMutVec(new IntPtr(ptr_x), (ulong) x.Length);
                    return namespaced_inner_slice_mut(x_slice);;
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static SliceMutVec namespaced_inner_slice_mut(NativeArray<Vec> x)
        {
            var x_slice = new SliceMutVec(x);
            return namespaced_inner_slice_mut(x_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "panics")]
        public static extern FFIError panics();

        public static void panics_checked()
        {
            var rval = panics();;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "renamed")]
        public static extern EnumRenamed renamed(StructRenamed x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "sleep")]
        public static extern void sleep(ulong millis);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "weird_1")]
        public static extern bool weird_1(Weird1u32 x, Weird2u8 y);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "visibility")]
        public static extern void visibility(Visibility1 x, Visibility2 y);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "repr_transparent")]
        public static extern Tupled repr_transparent(Tupled x, ref Tupled r);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ascii_pointer_1")]
        public static extern uint pattern_ascii_pointer_1(string x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ascii_pointer_2")]
        public static extern IntPtr pattern_ascii_pointer_2();

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ascii_pointer_len")]
        public static extern uint pattern_ascii_pointer_len(string x, UseAsciiStringPattern y);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ascii_pointer_return_slice")]
        public static extern SliceUseAsciiStringPattern pattern_ascii_pointer_return_slice();

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_1")]
        public static extern uint pattern_ffi_slice_1(Sliceu32 ffi_slice);

        public static uint pattern_ffi_slice_1(uint[] ffi_slice)
        {
            unsafe
            {
                fixed (void* ptr_ffi_slice = ffi_slice)
                {
                    var ffi_slice_slice = new Sliceu32(new IntPtr(ptr_ffi_slice), (ulong) ffi_slice.Length);
                    return pattern_ffi_slice_1(ffi_slice_slice);;
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static uint pattern_ffi_slice_1(NativeArray<uint> ffi_slice)
        {
            var ffi_slice_slice = new Sliceu32(ffi_slice);
            return pattern_ffi_slice_1(ffi_slice_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_1b")]
        public static extern uint pattern_ffi_slice_1b(SliceMutu32 ffi_slice);

        public static uint pattern_ffi_slice_1b(uint[] ffi_slice)
        {
            unsafe
            {
                fixed (void* ptr_ffi_slice = ffi_slice)
                {
                    var ffi_slice_slice = new SliceMutu32(new IntPtr(ptr_ffi_slice), (ulong) ffi_slice.Length);
                    return pattern_ffi_slice_1b(ffi_slice_slice);;
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static uint pattern_ffi_slice_1b(NativeArray<uint> ffi_slice)
        {
            var ffi_slice_slice = new SliceMutu32(ffi_slice);
            return pattern_ffi_slice_1b(ffi_slice_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_2")]
        public static extern Vec3f32 pattern_ffi_slice_2(SliceVec3f32 ffi_slice, int i);

        public static Vec3f32 pattern_ffi_slice_2(Vec3f32[] ffi_slice, int i)
        {
            unsafe
            {
                fixed (void* ptr_ffi_slice = ffi_slice)
                {
                    var ffi_slice_slice = new SliceVec3f32(new IntPtr(ptr_ffi_slice), (ulong) ffi_slice.Length);
                    return pattern_ffi_slice_2(ffi_slice_slice, i);;
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static Vec3f32 pattern_ffi_slice_2(NativeArray<Vec3f32> ffi_slice, int i)
        {
            var ffi_slice_slice = new SliceVec3f32(ffi_slice);
            return pattern_ffi_slice_2(ffi_slice_slice, i);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_3")]
        public static extern void pattern_ffi_slice_3(SliceMutu8 slice, CallbackSliceMut callback);

        public static void pattern_ffi_slice_3(byte[] slice, CallbackSliceMut callback)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new SliceMutu8(new IntPtr(ptr_slice), (ulong) slice.Length);
                    pattern_ffi_slice_3(slice_slice, callback);;
                }
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_3")]
        public static extern void pattern_ffi_slice_3(SliceMutu8 slice, IntPtr callback);

        #if UNITY_2018_1_OR_NEWER
        public static void pattern_ffi_slice_3(NativeArray<byte> slice, IntPtr callback)
        {
            var slice_slice = new SliceMutu8(slice);
            pattern_ffi_slice_3(slice_slice, callback);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_4")]
        public static extern void pattern_ffi_slice_4(Sliceu8 slice, SliceMutu8 slice2);

        public static void pattern_ffi_slice_4(byte[] slice, byte[] slice2)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new Sliceu8(new IntPtr(ptr_slice), (ulong) slice.Length);
                    fixed (void* ptr_slice2 = slice2)
                    {
                        var slice2_slice = new SliceMutu8(new IntPtr(ptr_slice2), (ulong) slice2.Length);
                        pattern_ffi_slice_4(slice_slice, slice2_slice);;
                    }
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static void pattern_ffi_slice_4(NativeArray<byte> slice, NativeArray<byte> slice2)
        {
            var slice_slice = new Sliceu8(slice);
            var slice2_slice = new SliceMutu8(slice2);
            pattern_ffi_slice_4(slice_slice, slice2_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_5")]
        public static extern void pattern_ffi_slice_5(ref Sliceu8 slice, ref SliceMutu8 slice2);

        public static void pattern_ffi_slice_5(byte[] slice, byte[] slice2)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new Sliceu8(new IntPtr(ptr_slice), (ulong) slice.Length);
                    fixed (void* ptr_slice2 = slice2)
                    {
                        var slice2_slice = new SliceMutu8(new IntPtr(ptr_slice2), (ulong) slice2.Length);
                        pattern_ffi_slice_5(ref slice_slice, ref slice2_slice);;
                    }
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static void pattern_ffi_slice_5(NativeArray<byte> slice, NativeArray<byte> slice2)
        {
            var slice_slice = new Sliceu8(slice);
            var slice2_slice = new SliceMutu8(slice2);
            pattern_ffi_slice_5(ref slice_slice, ref slice2_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_6")]
        public static extern void pattern_ffi_slice_6(ref SliceMutu8 slice, CallbackU8 callback);

        public static void pattern_ffi_slice_6(byte[] slice, CallbackU8 callback)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new SliceMutu8(new IntPtr(ptr_slice), (ulong) slice.Length);
                    pattern_ffi_slice_6(ref slice_slice, callback);;
                }
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_6")]
        public static extern void pattern_ffi_slice_6(ref SliceMutu8 slice, IntPtr callback);

        #if UNITY_2018_1_OR_NEWER
        public static void pattern_ffi_slice_6(NativeArray<byte> slice, IntPtr callback)
        {
            var slice_slice = new SliceMutu8(slice);
            pattern_ffi_slice_6(ref slice_slice, callback);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_delegate")]
        public static extern byte pattern_ffi_slice_delegate(CallbackFFISlice callback);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_delegate")]
        public static extern byte pattern_ffi_slice_delegate(IntPtr callback);


        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_delegate_huge")]
        public static extern Vec3f32 pattern_ffi_slice_delegate_huge(CallbackHugeVecSlice callback);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_slice_delegate_huge")]
        public static extern Vec3f32 pattern_ffi_slice_delegate_huge(IntPtr callback);


        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_option_1")]
        public static extern OptionInner pattern_ffi_option_1(OptionInner ffi_slice);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_option_2")]
        public static extern Inner pattern_ffi_option_2(OptionInner ffi_slice);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_bool")]
        public static extern Bool pattern_ffi_bool(Bool ffi_bool);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_cchar")]
        public static extern sbyte pattern_ffi_cchar(sbyte ffi_cchar);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_cchar_const_pointer")]
        public static extern IntPtr pattern_ffi_cchar_const_pointer(IntPtr ffi_cchar);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_ffi_cchar_mut_pointer")]
        public static extern IntPtr pattern_ffi_cchar_mut_pointer(IntPtr ffi_cchar);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_api_guard")]
        public static extern ulong pattern_api_guard();

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_callback_1")]
        public static extern uint pattern_callback_1(MyCallback callback, uint x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_callback_1")]
        public static extern uint pattern_callback_1(IntPtr callback, uint x);


        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_callback_2")]
        public static extern MyCallbackVoid pattern_callback_2(MyCallbackVoid callback);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_callback_2")]
        public static extern MyCallbackVoid pattern_callback_2(IntPtr callback);


        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_callback_3")]
        public static extern void pattern_callback_3(DelegateCallbackMyCallbackContextual callback, uint x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_callback_4")]
        public static extern uint pattern_callback_4(MyCallbackNamespaced callback, uint x);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "pattern_callback_4")]
        public static extern uint pattern_callback_4(IntPtr callback, uint x);


        /// Destroys the given instance.
        ///
        /// # Safety
        ///
        /// The passed parameter MUST have been created with the corresponding init function;
        /// passing any other value results in undefined behavior.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_destroy")]
        public static extern FFIError simple_service_destroy(ref IntPtr context);

        /// Destroys the given instance.
        ///
        /// # Safety
        ///
        /// The passed parameter MUST have been created with the corresponding init function;
        /// passing any other value results in undefined behavior.
        public static void simple_service_destroy_checked(ref IntPtr context)
        {
            var rval = simple_service_destroy(ref context);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        /// The constructor must return a `Result<Self, Error>`.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_new_with")]
        public static extern FFIError simple_service_new_with(ref IntPtr context, uint some_value);

        /// The constructor must return a `Result<Self, Error>`.
        public static void simple_service_new_with_checked(ref IntPtr context, uint some_value)
        {
            var rval = simple_service_new_with(ref context, some_value);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_new_without")]
        public static extern FFIError simple_service_new_without(ref IntPtr context);

        public static void simple_service_new_without_checked(ref IntPtr context)
        {
            var rval = simple_service_new_without(ref context);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_new_with_string")]
        public static extern FFIError simple_service_new_with_string(ref IntPtr context, string ascii);

        public static void simple_service_new_with_string_checked(ref IntPtr context, string ascii)
        {
            var rval = simple_service_new_with_string(ref context, ascii);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_new_failing")]
        public static extern FFIError simple_service_new_failing(ref IntPtr context, byte some_value);

        public static void simple_service_new_failing_checked(ref IntPtr context, byte some_value)
        {
            var rval = simple_service_new_failing(ref context, some_value);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        /// Methods returning a Result<(), _> are the default and do not
        /// need annotations.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_result")]
        public static extern FFIError simple_service_method_result(IntPtr context, uint anon1);

        /// Methods returning a Result<(), _> are the default and do not
        /// need annotations.
        public static void simple_service_method_result_checked(IntPtr context, uint anon1)
        {
            var rval = simple_service_method_result(context, anon1);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_value")]
        public static extern uint simple_service_method_value(IntPtr context, uint x);

        /// This method should be documented.
        ///
        /// Multiple lines.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_void")]
        public static extern void simple_service_method_void(IntPtr context);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_mut_self")]
        public static extern byte simple_service_method_mut_self(IntPtr context, Sliceu8 slice);

        public static byte simple_service_method_mut_self(IntPtr context, byte[] slice)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new Sliceu8(new IntPtr(ptr_slice), (ulong) slice.Length);
                    return simple_service_method_mut_self(context, slice_slice);;
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static byte simple_service_method_mut_self(IntPtr context, NativeArray<byte> slice)
        {
            var slice_slice = new Sliceu8(slice);
            return simple_service_method_mut_self(context, slice_slice);;
        }
        #endif

        /// Single line.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_mut_self_void")]
        public static extern void simple_service_method_mut_self_void(IntPtr context, SliceBool slice);

        /// Single line.
        public static void simple_service_method_mut_self_void(IntPtr context, Bool[] slice)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new SliceBool(new IntPtr(ptr_slice), (ulong) slice.Length);
                    simple_service_method_mut_self_void(context, slice_slice);;
                }
            }
        }

        /// Single line.
        #if UNITY_2018_1_OR_NEWER
        public static void simple_service_method_mut_self_void(IntPtr context, NativeArray<Bool> slice)
        {
            var slice_slice = new SliceBool(slice);
            simple_service_method_mut_self_void(context, slice_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_mut_self_ref")]
        public static extern byte simple_service_method_mut_self_ref(IntPtr context, ref byte x, out byte y);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_mut_self_ref_slice")]
        public static extern byte simple_service_method_mut_self_ref_slice(IntPtr context, ref byte x, out byte y, Sliceu8 slice);

        public static byte simple_service_method_mut_self_ref_slice(IntPtr context, ref byte x, out byte y, byte[] slice)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new Sliceu8(new IntPtr(ptr_slice), (ulong) slice.Length);
                    return simple_service_method_mut_self_ref_slice(context, ref x, out y, slice_slice);;
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static byte simple_service_method_mut_self_ref_slice(IntPtr context, ref byte x, out byte y, NativeArray<byte> slice)
        {
            var slice_slice = new Sliceu8(slice);
            return simple_service_method_mut_self_ref_slice(context, ref x, out y, slice_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_mut_self_ref_slice_limited")]
        public static extern byte simple_service_method_mut_self_ref_slice_limited(IntPtr context, ref byte x, out byte y, Sliceu8 slice, Sliceu8 slice2);

        public static byte simple_service_method_mut_self_ref_slice_limited(IntPtr context, ref byte x, out byte y, byte[] slice, byte[] slice2)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new Sliceu8(new IntPtr(ptr_slice), (ulong) slice.Length);
                    fixed (void* ptr_slice2 = slice2)
                    {
                        var slice2_slice = new Sliceu8(new IntPtr(ptr_slice2), (ulong) slice2.Length);
                        return simple_service_method_mut_self_ref_slice_limited(context, ref x, out y, slice_slice, slice2_slice);;
                    }
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static byte simple_service_method_mut_self_ref_slice_limited(IntPtr context, ref byte x, out byte y, NativeArray<byte> slice, NativeArray<byte> slice2)
        {
            var slice_slice = new Sliceu8(slice);
            var slice2_slice = new Sliceu8(slice2);
            return simple_service_method_mut_self_ref_slice_limited(context, ref x, out y, slice_slice, slice2_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_mut_self_ffi_error")]
        public static extern FFIError simple_service_method_mut_self_ffi_error(IntPtr context, SliceMutu8 slice);

        public static void simple_service_method_mut_self_ffi_error(IntPtr context, byte[] slice)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new SliceMutu8(new IntPtr(ptr_slice), (ulong) slice.Length);
                    var rval = simple_service_method_mut_self_ffi_error(context, slice_slice);;
                    if (rval != FFIError.Ok)
                    {
                        throw new InteropException<FFIError>(rval);
                    }
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static void simple_service_method_mut_self_ffi_error(IntPtr context, NativeArray<byte> slice)
        {
            var slice_slice = new SliceMutu8(slice);
            var rval = simple_service_method_mut_self_ffi_error(context, slice_slice);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_mut_self_no_error")]
        public static extern FFIError simple_service_method_mut_self_no_error(IntPtr context, SliceMutu8 slice);

        public static void simple_service_method_mut_self_no_error(IntPtr context, byte[] slice)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new SliceMutu8(new IntPtr(ptr_slice), (ulong) slice.Length);
                    var rval = simple_service_method_mut_self_no_error(context, slice_slice);;
                    if (rval != FFIError.Ok)
                    {
                        throw new InteropException<FFIError>(rval);
                    }
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static void simple_service_method_mut_self_no_error(IntPtr context, NativeArray<byte> slice)
        {
            var slice_slice = new SliceMutu8(slice);
            var rval = simple_service_method_mut_self_no_error(context, slice_slice);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }
        #endif

        /// Warning, you _must_ discard the returned slice object before calling into this service
        /// again, as otherwise undefined behavior might happen.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_return_slice")]
        public static extern Sliceu32 simple_service_return_slice(IntPtr context);

        /// Warning, you _must_ discard the returned slice object before calling into this service
        /// again, as otherwise undefined behavior might happen.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_return_slice_mut")]
        public static extern SliceMutu32 simple_service_return_slice_mut(IntPtr context);

        /// This function has no panic safeguards. If it panics your host app will be in an undefined state.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_return_string")]
        public static extern IntPtr simple_service_return_string(IntPtr context);

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_void_ffi_error")]
        public static extern FFIError simple_service_method_void_ffi_error(IntPtr context);

        public static void simple_service_method_void_ffi_error_checked(IntPtr context)
        {
            var rval = simple_service_method_void_ffi_error(context);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_callback")]
        public static extern FFIError simple_service_method_callback(IntPtr context, MyCallback callback);

        public static void simple_service_method_callback_checked(IntPtr context, MyCallback callback)
        {
            var rval = simple_service_method_callback(context, callback);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_method_callback")]
        public static extern FFIError simple_service_method_callback(IntPtr context, IntPtr callback);


        /// Destroys the given instance.
        ///
        /// # Safety
        ///
        /// The passed parameter MUST have been created with the corresponding init function;
        /// passing any other value results in undefined behavior.
        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_lt_destroy")]
        public static extern FFIError simple_service_lt_destroy(ref IntPtr context);

        /// Destroys the given instance.
        ///
        /// # Safety
        ///
        /// The passed parameter MUST have been created with the corresponding init function;
        /// passing any other value results in undefined behavior.
        public static void simple_service_lt_destroy_checked(ref IntPtr context)
        {
            var rval = simple_service_lt_destroy(ref context);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_lt_new_with")]
        public static extern FFIError simple_service_lt_new_with(ref IntPtr context, ref uint some_value);

        public static void simple_service_lt_new_with_checked(ref IntPtr context, ref uint some_value)
        {
            var rval = simple_service_lt_new_with(ref context, ref some_value);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_lt_method_lt")]
        public static extern void simple_service_lt_method_lt(IntPtr context, SliceBool slice);

        public static void simple_service_lt_method_lt(IntPtr context, Bool[] slice)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new SliceBool(new IntPtr(ptr_slice), (ulong) slice.Length);
                    simple_service_lt_method_lt(context, slice_slice);;
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static void simple_service_lt_method_lt(IntPtr context, NativeArray<Bool> slice)
        {
            var slice_slice = new SliceBool(slice);
            simple_service_lt_method_lt(context, slice_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_lt_method_lt2")]
        public static extern void simple_service_lt_method_lt2(IntPtr context, SliceBool slice);

        public static void simple_service_lt_method_lt2(IntPtr context, Bool[] slice)
        {
            unsafe
            {
                fixed (void* ptr_slice = slice)
                {
                    var slice_slice = new SliceBool(new IntPtr(ptr_slice), (ulong) slice.Length);
                    simple_service_lt_method_lt2(context, slice_slice);;
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static void simple_service_lt_method_lt2(IntPtr context, NativeArray<Bool> slice)
        {
            var slice_slice = new SliceBool(slice);
            simple_service_lt_method_lt2(context, slice_slice);;
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_lt_return_string_accept_slice")]
        public static extern IntPtr simple_service_lt_return_string_accept_slice(IntPtr anon0, Sliceu8 anon1);

        public static string simple_service_lt_return_string_accept_slice(IntPtr anon0, byte[] anon1)
        {
            unsafe
            {
                fixed (void* ptr_anon1 = anon1)
                {
                    var anon1_slice = new Sliceu8(new IntPtr(ptr_anon1), (ulong) anon1.Length);
                    var s = simple_service_lt_return_string_accept_slice(anon0, anon1_slice);;
                    return Marshal.PtrToStringAnsi(s);
                }
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public static string simple_service_lt_return_string_accept_slice(IntPtr anon0, NativeArray<byte> anon1)
        {
            var anon1_slice = new Sliceu8(anon1);
            var s = simple_service_lt_return_string_accept_slice(anon0, anon1_slice);;
            return Marshal.PtrToStringAnsi(s);
        }
        #endif

        [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "simple_service_lt_method_void_ffi_error")]
        public static extern FFIError simple_service_lt_method_void_ffi_error(IntPtr context);

        public static void simple_service_lt_method_void_ffi_error_checked(IntPtr context)
        {
            var rval = simple_service_lt_method_void_ffi_error(context);;
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

    }

    /// Documented enum.
    public enum EnumDocumented
    {
        /// Variant A.
        A = 0,
        /// Variant B.
        B = 1,
        /// Variant B.
        C = 2,
    }

    public enum EnumRenamed
    {
        X = 0,
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential, Pack = 2)]
    public partial struct Aligned1
    {
        public byte x;
        public ushort y;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential, Pack = 64)]
    public partial struct Aligned2
    {
        public byte x;
        public ushort y;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Array
    {
        public byte data0;
        public byte data1;
        public byte data2;
        public byte data3;
        public byte data4;
        public byte data5;
        public byte data6;
        public byte data7;
        public byte data8;
        public byte data9;
        public byte data10;
        public byte data11;
        public byte data12;
        public byte data13;
        public byte data14;
        public byte data15;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct BooleanAlignment
    {
        public int a;
        public short b;
        public short c;
        public byte d;
        public byte e;
        public byte f;
        public byte g;
        public byte h;
        public byte i;
        public byte j;
        public byte k;
        public ulong id;
        [MarshalAs(UnmanagedType.I1)]
        public bool is_valid;
        public ulong datum;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct DelegateCallbackMyCallbackContextual
    {
        public MyCallbackContextual callback;
        #if UNITY_2018_1_OR_NEWER
        [NativeDisableUnsafePtrRestriction]
        #endif
        public IntPtr context;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct ExtraTypef32
    {
        public float x;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Genericu32
    {
        #if UNITY_2018_1_OR_NEWER
        [NativeDisableUnsafePtrRestriction]
        #endif
        public IntPtr x;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Genericu8
    {
        #if UNITY_2018_1_OR_NEWER
        [NativeDisableUnsafePtrRestriction]
        #endif
        public IntPtr x;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Inner
    {
        float x;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public partial struct Packed1
    {
        public byte x;
        public ushort y;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public partial struct Packed2
    {
        public byte x;
        public ushort y;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Phantomu8
    {
        public uint x;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct SomeForeignType
    {
        public uint x;
    }

    /// Documented struct.
    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct StructDocumented
    {
        /// Documented field.
        public float x;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct StructRenamed
    {
        public EnumRenamed e;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Tupled
    {
        public byte x0;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct UseAsciiStringPattern
    {
        public string ascii_string;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Vec1
    {
        public float x;
        public float y;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Vec2
    {
        public double x;
        public double z;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Vec3f32
    {
        public float x;
        public float y;
        public float z;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Visibility1
    {
        public byte pblc;
        byte prvt;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Visibility2
    {
        public byte pblc1;
        public byte pblc2;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Weird1u32
    {
        uint x;
    }

    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct Weird2u8
    {
        byte t;
        byte a0;
        byte a1;
        byte a2;
        byte a3;
        byte a4;
        #if UNITY_2018_1_OR_NEWER
        [NativeDisableUnsafePtrRestriction]
        #endif
        IntPtr r;
    }

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate byte InteropDelegate_fn_u8_rval_u8(byte x0);

    public enum FFIError
    {
        Ok = 0,
        Null = 100,
        Panic = 200,
        Fail = 300,
    }

    ///A pointer to an array of data someone else owns which may not be modified.
    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct SliceUseAsciiStringPattern
    {
        ///Pointer to start of immutable data.
        #if UNITY_2018_1_OR_NEWER
        [NativeDisableUnsafePtrRestriction]
        #endif
        IntPtr data;
        ///Number of elements.
        ulong len;
    }

    public partial struct SliceUseAsciiStringPattern : IEnumerable<UseAsciiStringPattern>
    {
        public SliceUseAsciiStringPattern(GCHandle handle, ulong count)
        {
            this.data = handle.AddrOfPinnedObject();
            this.len = count;
        }
        public SliceUseAsciiStringPattern(IntPtr handle, ulong count)
        {
            this.data = handle;
            this.len = count;
        }
        #if (NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER || NETCOREAPP2_1_OR_GREATER)
        public ReadOnlySpan<UseAsciiStringPattern> ReadOnlySpan
        {
            get
            {
                unsafe
                {
                    return new ReadOnlySpan<UseAsciiStringPattern>(this.data.ToPointer(), (int) this.len);
                }
            }
        }
        #endif
        #if UNITY_2018_1_OR_NEWER
        public SliceUseAsciiStringPattern(NativeArray<UseAsciiStringPattern> handle)
        {
            unsafe
            {
                this.data = new IntPtr(NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr(handle));
                this.len = (ulong) handle.Length;
            }
        }
        #endif
        public UseAsciiStringPattern this[int i]
        {
            get
            {
                if (i >= Count) throw new IndexOutOfRangeException();
                var size = Marshal.SizeOf(typeof(UseAsciiStringPattern));
                var ptr = new IntPtr(data.ToInt64() + i * size);
                return Marshal.PtrToStructure<UseAsciiStringPattern>(ptr);
            }
        }
        public UseAsciiStringPattern[] Copied
        {
            get
            {
                var rval = new UseAsciiStringPattern[len];
                for (var i = 0; i < (int) len; i++) {
                    rval[i] = this[i];
                }
                return rval;
            }
        }
        public int Count => (int) len;
        public IEnumerator<UseAsciiStringPattern> GetEnumerator()
        {
            for (var i = 0; i < (int)len; ++i)
            {
                yield return this[i];
            }
        }
        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }
    }


    ///A pointer to an array of data someone else owns which may not be modified.
    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct SliceVec3f32
    {
        ///Pointer to start of immutable data.
        #if UNITY_2018_1_OR_NEWER
        [NativeDisableUnsafePtrRestriction]
        #endif
        IntPtr data;
        ///Number of elements.
        ulong len;
    }

    public partial struct SliceVec3f32 : IEnumerable<Vec3f32>
    {
        public SliceVec3f32(GCHandle handle, ulong count)
        {
            this.data = handle.AddrOfPinnedObject();
            this.len = count;
        }
        public SliceVec3f32(IntPtr handle, ulong count)
        {
            this.data = handle;
            this.len = count;
        }
        #if (NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER || NETCOREAPP2_1_OR_GREATER)
        public ReadOnlySpan<Vec3f32> ReadOnlySpan
        {
            get
            {
                unsafe
                {
                    return new ReadOnlySpan<Vec3f32>(this.data.ToPointer(), (int) this.len);
                }
            }
        }
        #endif
        #if UNITY_2018_1_OR_NEWER
        public SliceVec3f32(NativeArray<Vec3f32> handle)
        {
            unsafe
            {
                this.data = new IntPtr(NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr(handle));
                this.len = (ulong) handle.Length;
            }
        }
        #endif
        public Vec3f32 this[int i]
        {
            get
            {
                if (i >= Count) throw new IndexOutOfRangeException();
                unsafe
                {
                    var d = (Vec3f32*) data.ToPointer();
                    return d[i];
                }
            }
        }
        public Vec3f32[] Copied
        {
            get
            {
                var rval = new Vec3f32[len];
                unsafe
                {
                    fixed (void* dst = rval)
                    {
                        #if __INTEROPTOPUS_NEVER
                        #elif NETCOREAPP
                        Unsafe.CopyBlock(dst, data.ToPointer(), (uint) len * (uint) sizeof(Vec3f32));
                        #elif UNITY_2018_1_OR_NEWER
                        UnsafeUtility.MemCpy(dst, data.ToPointer(), (long) (len * (ulong) sizeof(Vec3f32)));
                        #else
                        for (var i = 0; i < (int) len; i++) {
                            rval[i] = this[i];
                        }
                        #endif
                    }
                }
                return rval;
            }
        }
        public int Count => (int) len;
        public IEnumerator<Vec3f32> GetEnumerator()
        {
            for (var i = 0; i < (int)len; ++i)
            {
                yield return this[i];
            }
        }
        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }
    }


    ///Option type containing boolean flag and maybe valid data.
    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public partial struct OptionInner
    {
        ///Element that is maybe valid.
        Inner t;
        ///Byte where `1` means element `t` is valid.
        byte is_some;
    }

    public partial struct OptionInner
    {
        public static OptionInner FromNullable(Inner? nullable)
        {
            var result = new OptionInner();
            if (nullable.HasValue)
            {
                result.is_some = 1;
                result.t = nullable.Value;
            }

            return result;
        }

        public Inner? ToNullable()
        {
            return this.is_some == 1 ? this.t : (Inner?)null;
        }
    }


    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate byte CallbackFFISlice(Sliceu8 slice);

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate Vec3f32 CallbackHugeVecSlice(SliceVec3f32 slice);

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void CallbackSliceMut(SliceMutu8 slice);

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate byte CallbackU8(byte value);

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate uint MyCallback(uint value);

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void MyCallbackContextual(IntPtr context, uint value);

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate uint MyCallbackNamespaced(uint value);

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void MyCallbackVoid(IntPtr ptr);


    /// Some struct we want to expose as a class.
    public partial class SimpleService : IDisposable
    {
        private IntPtr _context;

        private SimpleService() {}

        /// The constructor must return a `Result<Self, Error>`.
        public static SimpleService NewWith(uint some_value)
        {
            var self = new SimpleService();
            var rval = Interop.simple_service_new_with(ref self._context, some_value);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
            return self;
        }

        public static SimpleService NewWithout()
        {
            var self = new SimpleService();
            var rval = Interop.simple_service_new_without(ref self._context);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
            return self;
        }

        public static SimpleService NewWithString(string ascii)
        {
            var self = new SimpleService();
            var rval = Interop.simple_service_new_with_string(ref self._context, ascii);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
            return self;
        }

        public static SimpleService NewFailing(byte some_value)
        {
            var self = new SimpleService();
            var rval = Interop.simple_service_new_failing(ref self._context, some_value);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
            return self;
        }

        public void Dispose()
        {
            var rval = Interop.simple_service_destroy(ref _context);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        /// Methods returning a Result<(), _> are the default and do not
        /// need annotations.
        public void MethodResult(uint anon1)
        {
            var rval = Interop.simple_service_method_result(_context, anon1);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        public uint MethodValue(uint x)
        {
            return Interop.simple_service_method_value(_context, x);
        }

        /// This method should be documented.
        ///
        /// Multiple lines.
        public void MethodVoid()
        {
            Interop.simple_service_method_void(_context);
        }

        public byte MethodMutSelf(Sliceu8 slice)
        {
            return Interop.simple_service_method_mut_self(_context, slice);
        }

        public byte MethodMutSelf(byte[] slice)
        {
            return Interop.simple_service_method_mut_self(_context, slice);
        }

        #if UNITY_2018_1_OR_NEWER
        public byte MethodMutSelf(NativeArray<byte> slice)
        {
            return Interop.simple_service_method_mut_self(_context, slice);
        }
        #endif

        /// Single line.
        public void MethodMutSelfVoid(SliceBool slice)
        {
            Interop.simple_service_method_mut_self_void(_context, slice);
        }

        /// Single line.
        public void MethodMutSelfVoid(Bool[] slice)
        {
            Interop.simple_service_method_mut_self_void(_context, slice);
        }

        #if UNITY_2018_1_OR_NEWER
        /// Single line.
        public void MethodMutSelfVoid(NativeArray<Bool> slice)
        {
            Interop.simple_service_method_mut_self_void(_context, slice);
        }
        #endif

        public byte MethodMutSelfRef(ref byte x, out byte y)
        {
            return Interop.simple_service_method_mut_self_ref(_context, ref x, out y);
        }

        public byte MethodMutSelfRefSlice(ref byte x, out byte y, Sliceu8 slice)
        {
            return Interop.simple_service_method_mut_self_ref_slice(_context, ref x, out y, slice);
        }

        public byte MethodMutSelfRefSlice(ref byte x, out byte y, byte[] slice)
        {
            return Interop.simple_service_method_mut_self_ref_slice(_context, ref x, out y, slice);
        }

        #if UNITY_2018_1_OR_NEWER
        public byte MethodMutSelfRefSlice(ref byte x, out byte y, NativeArray<byte> slice)
        {
            return Interop.simple_service_method_mut_self_ref_slice(_context, ref x, out y, slice);
        }
        #endif

        public byte MethodMutSelfRefSliceLimited(ref byte x, out byte y, Sliceu8 slice, Sliceu8 slice2)
        {
            return Interop.simple_service_method_mut_self_ref_slice_limited(_context, ref x, out y, slice, slice2);
        }

        public byte MethodMutSelfRefSliceLimited(ref byte x, out byte y, byte[] slice, byte[] slice2)
        {
            return Interop.simple_service_method_mut_self_ref_slice_limited(_context, ref x, out y, slice, slice2);
        }

        #if UNITY_2018_1_OR_NEWER
        public byte MethodMutSelfRefSliceLimited(ref byte x, out byte y, NativeArray<byte> slice, NativeArray<byte> slice2)
        {
            return Interop.simple_service_method_mut_self_ref_slice_limited(_context, ref x, out y, slice, slice2);
        }
        #endif

        public void MethodMutSelfFfiError(SliceMutu8 slice)
        {
            var rval = Interop.simple_service_method_mut_self_ffi_error(_context, slice);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        public void MethodMutSelfFfiError(byte[] slice)
        {
            Interop.simple_service_method_mut_self_ffi_error(_context, slice);
        }

        #if UNITY_2018_1_OR_NEWER
        public void MethodMutSelfFfiError(NativeArray<byte> slice)
        {
            Interop.simple_service_method_mut_self_ffi_error(_context, slice);
        }
        #endif

        public void MethodMutSelfNoError(SliceMutu8 slice)
        {
            var rval = Interop.simple_service_method_mut_self_no_error(_context, slice);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        public void MethodMutSelfNoError(byte[] slice)
        {
            Interop.simple_service_method_mut_self_no_error(_context, slice);
        }

        #if UNITY_2018_1_OR_NEWER
        public void MethodMutSelfNoError(NativeArray<byte> slice)
        {
            Interop.simple_service_method_mut_self_no_error(_context, slice);
        }
        #endif

        /// Warning, you _must_ discard the returned slice object before calling into this service
        /// again, as otherwise undefined behavior might happen.
        public Sliceu32 ReturnSlice()
        {
            return Interop.simple_service_return_slice(_context);
        }

        /// Warning, you _must_ discard the returned slice object before calling into this service
        /// again, as otherwise undefined behavior might happen.
        public SliceMutu32 ReturnSliceMut()
        {
            return Interop.simple_service_return_slice_mut(_context);
        }

        /// This function has no panic safeguards. If it panics your host app will be in an undefined state.
        public string ReturnString()
        {
            var s = Interop.simple_service_return_string(_context);
            return Marshal.PtrToStringAnsi(s);
        }

        public void MethodVoidFfiError()
        {
            var rval = Interop.simple_service_method_void_ffi_error(_context);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        public void MethodCallback(MyCallback callback)
        {
            var rval = Interop.simple_service_method_callback(_context, callback);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        #if UNITY_2018_1_OR_NEWER
        public void MethodCallback(IntPtr callback)
        {
            Interop.simple_service_method_callback(_context, callback);
        }
        #endif

        public IntPtr Context => _context;
    }


    public partial class SimpleServiceLifetime : IDisposable
    {
        private IntPtr _context;

        private SimpleServiceLifetime() {}

        public static SimpleServiceLifetime NewWith(ref uint some_value)
        {
            var self = new SimpleServiceLifetime();
            var rval = Interop.simple_service_lt_new_with(ref self._context, ref some_value);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
            return self;
        }

        public void Dispose()
        {
            var rval = Interop.simple_service_lt_destroy(ref _context);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        public void MethodLt(SliceBool slice)
        {
            Interop.simple_service_lt_method_lt(_context, slice);
        }

        public void MethodLt(Bool[] slice)
        {
            Interop.simple_service_lt_method_lt(_context, slice);
        }

        #if UNITY_2018_1_OR_NEWER
        public void MethodLt(NativeArray<Bool> slice)
        {
            Interop.simple_service_lt_method_lt(_context, slice);
        }
        #endif

        public void MethodLt2(SliceBool slice)
        {
            Interop.simple_service_lt_method_lt2(_context, slice);
        }

        public void MethodLt2(Bool[] slice)
        {
            Interop.simple_service_lt_method_lt2(_context, slice);
        }

        #if UNITY_2018_1_OR_NEWER
        public void MethodLt2(NativeArray<Bool> slice)
        {
            Interop.simple_service_lt_method_lt2(_context, slice);
        }
        #endif

        public string ReturnStringAcceptSlice(Sliceu8 anon1)
        {
            var s = Interop.simple_service_lt_return_string_accept_slice(_context, anon1);
            return Marshal.PtrToStringAnsi(s);
        }

        public string ReturnStringAcceptSlice(byte[] anon1)
        {
            return Interop.simple_service_lt_return_string_accept_slice(_context, anon1);
        }

        #if UNITY_2018_1_OR_NEWER
        public string ReturnStringAcceptSlice(NativeArray<byte> anon1)
        {
            return Interop.simple_service_lt_return_string_accept_slice(_context, anon1);
        }
        #endif

        public void MethodVoidFfiError()
        {
            var rval = Interop.simple_service_lt_method_void_ffi_error(_context);
            if (rval != FFIError.Ok)
            {
                throw new InteropException<FFIError>(rval);
            }
        }

        public IntPtr Context => _context;
    }



}