@@ -173,32 +173,32 @@ pub fn defineClass(
173
173
comptime options : DefineClassOptions (Instance ),
174
174
) fn () callconv (.C ) gobject.Type {
175
175
const instance_info = @typeInfo (Instance );
176
- if (instance_info != .Struct or instance_info .Struct .layout != .@"extern" ) {
176
+ if (instance_info != .@"struct" or instance_info .@ "struct" .layout != .@"extern" ) {
177
177
@compileError ("an instance type must be an extern struct" );
178
178
}
179
179
180
180
if (! @hasDecl (Instance , "Parent" )) {
181
181
@compileError ("a class type must have a declaration named Parent pointing to the parent type" );
182
182
}
183
183
const parent_info = @typeInfo (Instance .Parent );
184
- if (parent_info != .Struct or parent_info .Struct .layout != .@"extern" or ! @hasDecl (Instance .Parent , "getGObjectType" )) {
184
+ if (parent_info != .@"struct" or parent_info .@ "struct" .layout != .@"extern" or ! @hasDecl (Instance .Parent , "getGObjectType" )) {
185
185
@compileError ("the defined parent type " ++ @typeName (Instance .Parent ) ++ " does not appear to be a GObject class type" );
186
186
}
187
- if (instance_info .Struct .fields .len == 0 or instance_info .Struct .fields [0 ].type != Instance .Parent ) {
187
+ if (instance_info .@ "struct" .fields .len == 0 or instance_info .@ "struct" .fields [0 ].type != Instance .Parent ) {
188
188
@compileError ("the first field of the instance struct must have type " ++ @typeName (Instance .Parent ));
189
189
}
190
190
191
191
if (! @hasDecl (Instance , "Class" )) {
192
192
@compileError ("a class type must have a member named Class pointing to the class record" );
193
193
}
194
194
const class_info = @typeInfo (Instance .Class );
195
- if (class_info != .Struct or class_info .Struct .layout != .@"extern" ) {
195
+ if (class_info != .@"struct" or class_info .@ "struct" .layout != .@"extern" ) {
196
196
@compileError ("a class type must be an extern struct" );
197
197
}
198
198
if (! @hasDecl (Instance .Class , "Instance" ) or Instance .Class .Instance != Instance ) {
199
199
@compileError ("a class type must have a declaration named Instance pointing to the instance type" );
200
200
}
201
- if (class_info .Struct .fields .len == 0 or class_info .Struct .fields [0 ].type != Instance .Parent .Class ) {
201
+ if (class_info .@ "struct" .fields .len == 0 or class_info .@ "struct" .fields [0 ].type != Instance .Parent .Class ) {
202
202
@compileError ("the first field of the class struct must have type " ++ @typeName (Instance .Parent .Class ));
203
203
}
204
204
@@ -338,16 +338,16 @@ pub fn defineEnum(
338
338
comptime options : DefineEnumOptions ,
339
339
) fn () callconv (.C ) gobject.Type {
340
340
const enum_info = @typeInfo (Enum );
341
- if (enum_info != .Enum or enum_info .Enum .tag_type != c_int ) {
341
+ if (enum_info != .@"enum" or enum_info .@ "enum" .tag_type != c_int ) {
342
342
@compileError ("an enum type must have a tag type of c_int" );
343
343
}
344
- if (! enum_info .Enum .is_exhaustive ) {
344
+ if (! enum_info .@ "enum" .is_exhaustive ) {
345
345
@compileError ("an enum type must be exhaustive" );
346
346
}
347
347
348
- const n_values = enum_info .Enum .fields .len ;
349
- var enum_values : [n_values + 1 ]gobject.EnumValue = undefined ;
350
- for (enum_info .Enum .fields , enum_values [0.. n_values ]) | field , * value | {
348
+ const n_values = enum_info .@ "enum" .fields .len ;
349
+ var enum_values : [n_values + 1 ]gobject.enum_value = undefined ;
350
+ for (enum_info .@ "enum" .fields , enum_values [0.. n_values ]) | field , * value | {
351
351
value .* = .{
352
352
.value = field .value ,
353
353
.value_name = field .name ,
@@ -394,12 +394,12 @@ pub fn defineFlags(
394
394
comptime options : DefineFlagsOptions ,
395
395
) fn () callconv (.C ) gobject.Type {
396
396
const flags_info = @typeInfo (Flags );
397
- if (flags_info != .Struct or flags_info .Struct .layout != .@"packed" or flags_info .Struct .backing_integer != c_uint ) {
397
+ if (flags_info != .@"struct" or flags_info .@ "struct" .layout != .@"packed" or flags_info .@ "struct" .backing_integer != c_uint ) {
398
398
@compileError ("a flags type must have a backing integer type of c_uint" );
399
399
}
400
400
401
401
comptime var n_values = 0 ;
402
- for (flags_info .Struct .fields ) | field | {
402
+ for (flags_info .@ "struct" .fields ) | field | {
403
403
if (! std .mem .startsWith (u8 , field .name , "_" )) {
404
404
if (@bitSizeOf (field .type ) != 1 ) {
405
405
@compileError ("non-padding flags field " ++ field .name ++ " must be 1 bit" );
@@ -409,7 +409,7 @@ pub fn defineFlags(
409
409
}
410
410
comptime var flags_values : [n_values + 1 ]gobject.FlagsValue = undefined ;
411
411
var current_value = 0 ;
412
- for (flags_info .Struct .fields ) | field | {
412
+ for (flags_info .@ "struct" .fields ) | field | {
413
413
if (! std .mem .startsWith (u8 , field .name , "_" )) {
414
414
flags_values [current_value ] = .{
415
415
.value = 1 << @bitOffsetOf (Flags , field .name ),
@@ -458,7 +458,7 @@ pub fn Accessor(comptime Owner: type, comptime Data: type) type {
458
458
}
459
459
460
460
fn FieldType (comptime T : type , comptime name : []const u8 ) type {
461
- return for (@typeInfo (T ).Struct .fields ) | field | {
461
+ return for (@typeInfo (T ).@ "struct" .fields ) | field | {
462
462
if (std .mem .eql (u8 , field .name , name )) break field .type ;
463
463
} else @compileError ("no field named " ++ name ++ " in " ++ @typeName (T ));
464
464
}
@@ -698,15 +698,15 @@ pub fn defineProperty(
698
698
);
699
699
} else if (std .meta .hasFn (Data , "getGObjectType" )) {
700
700
return switch (@typeInfo (Data )) {
701
- .Enum = > gobject .paramSpecEnum (
701
+ .@"enum" = > gobject .paramSpecEnum (
702
702
name ,
703
703
options .nick orelse null ,
704
704
options .blurb orelse null ,
705
705
Data .getGObjectType (),
706
706
@intFromEnum (options .default ),
707
707
flags ,
708
708
),
709
- .Struct = > gobject .paramSpecFlags (
709
+ .@"struct" = > gobject .paramSpecFlags (
710
710
name ,
711
711
options .nick orelse null ,
712
712
options .blurb orelse null ,
@@ -752,7 +752,7 @@ pub fn defineProperty(
752
752
/// The properties passed in `properties` should be the structs returned by
753
753
/// `defineProperty`.
754
754
pub fn registerProperties (class : anytype , properties : []const type ) void {
755
- const Instance = @typeInfo (@TypeOf (class )).Pointer .child .Instance ;
755
+ const Instance = @typeInfo (@TypeOf (class )).pointer .child .Instance ;
756
756
gobject .Object .virtual_methods .get_property .implement (class , struct {
757
757
fn getProperty (object : * Instance , id : c_uint , value : * gobject.Value , _ : * gobject.ParamSpec ) callconv (.C ) void {
758
758
inline for (properties , 1.. ) | property , i | {
@@ -810,10 +810,10 @@ pub fn defineSignal(
810
810
comptime param_types : []const type ,
811
811
comptime ReturnType : type ,
812
812
) type {
813
- const EmitParams = @Type (.{ .Struct = .{
813
+ const EmitParams = @Type (.{ .@ "struct" = .{
814
814
.layout = .auto ,
815
815
.fields = fields : {
816
- var fields : [param_types .len ]std.builtin.Type.StructField = undefined ;
816
+ var fields : [param_types .len ]std.builtin.Type.struct_field = undefined ;
817
817
for (param_types , & fields , 0.. ) | ParamType , * field , i | {
818
818
field .* = .{
819
819
.name = std .fmt .comptimePrint ("{}" , .{i }),
@@ -878,7 +878,7 @@ pub fn defineSignal(
878
878
pub fn connect (
879
879
target : anytype ,
880
880
comptime T : type ,
881
- callback : SignalHandler (@typeInfo (@TypeOf (target )).Pointer .child , param_types , T , ReturnType ),
881
+ callback : SignalHandler (@typeInfo (@TypeOf (target )).pointer .child , param_types , T , ReturnType ),
882
882
data : T ,
883
883
options : struct {
884
884
after : bool = false ,
@@ -917,10 +917,10 @@ pub const impl_helpers = struct {
917
917
/// guaranteed.
918
918
pub inline fn as (comptime T : type , self : anytype ) * T {
919
919
const self_info = @typeInfo (@TypeOf (self ));
920
- if (self_info != .Pointer or self_info .Pointer .size != .One ) {
920
+ if (self_info != .pointer or self_info .pointer .size != .One ) {
921
921
@compileError ("cannot cast a non-pointer type" );
922
922
}
923
- const Self = self_info .Pointer .child ;
923
+ const Self = self_info .pointer .child ;
924
924
925
925
if (isAssignableFrom (T , Self )) {
926
926
return @ptrCast (@alignCast (self ));
@@ -979,7 +979,7 @@ pub fn isA(self: anytype, comptime T: type) bool {
979
979
980
980
/// Creates a new instance of an object type with the given properties.
981
981
pub fn newInstance (comptime T : type , properties : anytype ) * T {
982
- const typeInfo = @typeInfo (@TypeOf (properties )).Struct ;
982
+ const typeInfo = @typeInfo (@TypeOf (properties )).@ "struct" ;
983
983
const n_props = typeInfo .fields .len ;
984
984
var names : [n_props ][* :0 ]const u8 = undefined ;
985
985
var values : [n_props ]gobject.Value = undefined ;
@@ -1085,10 +1085,10 @@ pub const Value = struct {
1085
1085
} else if (T == f64 ) {
1086
1086
return value .getDouble ();
1087
1087
} else if (isCString (T )) {
1088
- if (@typeInfo (T ) != .Optional ) {
1088
+ if (@typeInfo (T ) != .optional ) {
1089
1089
@compileError ("cannot guarantee value is non-null" );
1090
1090
}
1091
- const Pointer = @typeInfo (@typeInfo (T ).Optional .child ).Pointer ;
1091
+ const Pointer = @typeInfo (@typeInfo (T ).optional .child ).pointer ;
1092
1092
if (! Pointer .is_const ) {
1093
1093
@compileError ("get does not take ownership; can only return const strings" );
1094
1094
}
@@ -1099,12 +1099,12 @@ pub const Value = struct {
1099
1099
};
1100
1100
} else if (std .meta .hasFn (T , "getGObjectType" )) {
1101
1101
return switch (@typeInfo (T )) {
1102
- .Enum = > @enumFromInt (value .getEnum ()),
1103
- .Struct = > @bitCast (value .getFlags ()),
1102
+ .@"enum" = > @enumFromInt (value .getEnum ()),
1103
+ .@"struct" = > @bitCast (value .getFlags ()),
1104
1104
else = > @compileError ("cannot extract " ++ @typeName (T ) ++ " from Value" ),
1105
1105
};
1106
1106
} else if (singlePointerChild (T )) | Child | {
1107
- if (@typeInfo (T ) != .Optional ) {
1107
+ if (@typeInfo (T ) != .optional ) {
1108
1108
@compileError ("cannot guarantee value is non-null" );
1109
1109
}
1110
1110
if (Child == gobject .ParamSpec ) {
@@ -1156,14 +1156,14 @@ pub const Value = struct {
1156
1156
} else if (comptime isCString (T )) {
1157
1157
// orelse null as temporary workaround for https://github.com/ziglang/zig/issues/12523
1158
1158
switch (@typeInfo (T )) {
1159
- .Pointer = > value .setString (contents ),
1160
- .Optional = > value .setString (contents orelse null ),
1159
+ .pointer = > value .setString (contents ),
1160
+ .optional = > value .setString (contents orelse null ),
1161
1161
else = > unreachable ,
1162
1162
}
1163
1163
} else if (std .meta .hasFn (T , "getGObjectType" )) {
1164
1164
switch (@typeInfo (T )) {
1165
- .Enum = > value .setEnum (@intFromEnum (contents )),
1166
- .Struct = > value .setFlags (@bitCast (contents )),
1165
+ .@"enum" = > value .setEnum (@intFromEnum (contents )),
1166
+ .@"struct" = > value .setFlags (@bitCast (contents )),
1167
1167
else = > @compileError ("cannot construct Value from " ++ @typeName (T )),
1168
1168
}
1169
1169
} else if (singlePointerChild (T )) | Child | {
@@ -1192,18 +1192,18 @@ inline fn isObject(comptime T: type) bool {
1192
1192
1193
1193
inline fn isCString (comptime T : type ) bool {
1194
1194
return switch (@typeInfo (T )) {
1195
- .Pointer = > | pointer | switch (pointer .size ) {
1195
+ .pointer = > | pointer | switch (pointer .size ) {
1196
1196
.One = > switch (@typeInfo (pointer .child )) {
1197
- .Array = > | child | child .child == u8 and std .meta .sentinel (pointer .child ) == @as (u8 , 0 ),
1197
+ .array = > | child | child .child == u8 and std .meta .sentinel (pointer .child ) == @as (u8 , 0 ),
1198
1198
else = > false ,
1199
1199
},
1200
1200
.Many , .Slice = > pointer .child == u8 and std .meta .sentinel (T ) == @as (u8 , 0 ),
1201
1201
.C = > pointer .child == u8 ,
1202
1202
},
1203
- .Optional = > | optional | switch (@typeInfo (optional .child )) {
1204
- .Pointer = > | pointer | switch (pointer .size ) {
1203
+ .optional = > | optional | switch (@typeInfo (optional .child )) {
1204
+ .pointer = > | pointer | switch (pointer .size ) {
1205
1205
.One = > switch (@typeInfo (pointer .child )) {
1206
- .Array = > | child | child .child == u8 and std .meta .sentinel (pointer .child ) == @as (u8 , 0 ),
1206
+ .array = > | child | child .child == u8 and std .meta .sentinel (pointer .child ) == @as (u8 , 0 ),
1207
1207
else = > false ,
1208
1208
},
1209
1209
.Many , .Slice = > pointer .child == u8 and std .meta .sentinel (optional .child ) == @as (u8 , 0 ),
@@ -1217,13 +1217,13 @@ inline fn isCString(comptime T: type) bool {
1217
1217
1218
1218
inline fn singlePointerChild (comptime T : type ) ? type {
1219
1219
return switch (@typeInfo (T )) {
1220
- .Pointer = > | pointer | switch (pointer .size ) {
1220
+ .pointer = > | pointer | switch (pointer .size ) {
1221
1221
.One , .C = > pointer .child ,
1222
1222
else = > null ,
1223
1223
},
1224
- .Optional = > | optional | switch (@typeInfo (optional .child )) {
1225
- .Pointer = > | pointer | switch (pointer .size ) {
1226
- .One = > pointer .child ,
1224
+ .optional = > | optional | switch (@typeInfo (optional .child )) {
1225
+ .pointer = > | pointer | switch (pointer .size ) {
1226
+ .one = > pointer .child ,
1227
1227
else = > null ,
1228
1228
},
1229
1229
else = > null ,
0 commit comments