@@ -241,7 +241,7 @@ pub const Type = struct {
241
241
}
242
242
243
243
// check that user-defined types have been provided as an API
244
- pub fn lookup (comptime self : * Type , comptime structs : []Struct ) Error ! void {
244
+ pub fn lookup (comptime self : * Type , comptime structs : []const Struct ) Error ! void {
245
245
std .debug .assert (@inComptime ());
246
246
247
247
// lookup unecessary
@@ -462,7 +462,7 @@ pub const Func = struct {
462
462
463
463
setter_index : ? u8 , // TODO: not ideal, is there a cleaner solution?
464
464
465
- fn lookupTypes (comptime self : * Func , comptime structs : []Struct ) Error ! void {
465
+ fn lookupTypes (comptime self : * const Func , comptime structs : []const Struct ) Error ! void {
466
466
inline for (self .args ) | * arg | {
467
467
try arg .lookup (structs );
468
468
}
@@ -738,12 +738,12 @@ pub const Struct = struct {
738
738
has_constructor : bool ,
739
739
constructor : Func ,
740
740
741
- getters : []Func ,
742
- setters : []Func ,
743
- methods : []Func ,
741
+ getters : []const Func ,
742
+ setters : []const Func ,
743
+ methods : []const Func ,
744
744
745
745
// nested types
746
- nested : []StructNested ,
746
+ nested : []const StructNested ,
747
747
748
748
pub fn Self (comptime self : Struct ) type {
749
749
comptime {
@@ -784,7 +784,7 @@ pub const Struct = struct {
784
784
return @sizeOf (self .Self ()) == 0 ;
785
785
}
786
786
787
- fn lookupTypes (comptime self : * Struct , comptime structs : []Struct ) Error ! void {
787
+ fn lookupTypes (comptime self : * Struct , comptime structs : []const Struct ) Error ! void {
788
788
try self .value .lookup (structs );
789
789
if (self .has_constructor ) {
790
790
try self .constructor .lookupTypes (structs );
@@ -1323,6 +1323,11 @@ pub const Struct = struct {
1323
1323
}
1324
1324
}
1325
1325
1326
+ const final_getters = getters ;
1327
+ const final_setters = setters ;
1328
+ const final_methods = methods ;
1329
+ const final_nested = nested ;
1330
+
1326
1331
return Struct {
1327
1332
// struct info
1328
1333
.name = struct_name ,
@@ -1343,12 +1348,12 @@ pub const Struct = struct {
1343
1348
// struct functions
1344
1349
.has_constructor = has_constructor ,
1345
1350
.constructor = constructor ,
1346
- .getters = getters [0 .. ] ,
1347
- .setters = setters [0 .. ] ,
1348
- .methods = methods [0 .. ] ,
1351
+ .getters = & final_getters ,
1352
+ .setters = & final_setters ,
1353
+ .methods = & final_methods ,
1349
1354
1350
1355
// nested types
1351
- .nested = nested [0 .. ] ,
1356
+ .nested = & final_nested ,
1352
1357
};
1353
1358
}
1354
1359
};
@@ -1432,7 +1437,7 @@ fn lookupException(comptime all: []Struct) Error!void {
1432
1437
}
1433
1438
}
1434
1439
1435
- pub fn do (comptime types : anytype ) Error ! []Struct {
1440
+ pub fn do (comptime types : anytype ) Error ! []const Struct {
1436
1441
comptime {
1437
1442
1438
1443
// check types provided
@@ -1475,7 +1480,8 @@ pub fn do(comptime types: anytype) Error![]Struct {
1475
1480
try s .lookupTypes (& all );
1476
1481
}
1477
1482
1478
- return & all ;
1483
+ const final = all ;
1484
+ return & final ;
1479
1485
}
1480
1486
}
1481
1487
0 commit comments