mirror of
https://github.com/zoriya/zig-wayland.git
synced 2025-12-06 07:06:12 +00:00
Track xToY() renamed to yFromX() breaking changes
This commit is contained in:
@@ -45,19 +45,19 @@ pub const Fixed = enum(i32) {
|
||||
_,
|
||||
|
||||
pub fn toInt(f: Fixed) i24 {
|
||||
return @truncate(i24, @enumToInt(f) >> 8);
|
||||
return @truncate(i24, @intFromEnum(f) >> 8);
|
||||
}
|
||||
|
||||
pub fn fromInt(i: i24) Fixed {
|
||||
return @intToEnum(Fixed, @as(i32, i) << 8);
|
||||
return @enumFromInt(Fixed, @as(i32, i) << 8);
|
||||
}
|
||||
|
||||
pub fn toDouble(f: Fixed) f64 {
|
||||
return @intToFloat(f64, @enumToInt(f)) / 256;
|
||||
return @floatFromInt(f64, @intFromEnum(f)) / 256;
|
||||
}
|
||||
|
||||
pub fn fromDouble(d: f64) Fixed {
|
||||
return @intToEnum(Fixed, @floatToInt(i32, d * 256));
|
||||
return @enumFromInt(Fixed, @intFromFloat(i32, d * 256));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -92,9 +92,9 @@ pub fn Dispatcher(comptime Obj: type, comptime Data: type) type {
|
||||
// signed/unsigned ints, fds, new_ids, bitfield enums
|
||||
.Int, .Struct => @field(payload_data, f.name) = @bitCast(f.type, args[i].u),
|
||||
// objects, strings, arrays
|
||||
.Pointer, .Optional => @field(payload_data, f.name) = @intToPtr(f.type, @ptrToInt(args[i].o)),
|
||||
.Pointer, .Optional => @field(payload_data, f.name) = @ptrFromInt(f.type, @intFromPtr(args[i].o)),
|
||||
// non-bitfield enums
|
||||
.Enum => @field(payload_data, f.name) = @intToEnum(f.type, args[i].i),
|
||||
.Enum => @field(payload_data, f.name) = @enumFromInt(f.type, args[i].i),
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ pub fn Dispatcher(comptime Obj: type, comptime Data: type) type {
|
||||
@ptrCast(*const HandlerFn, @alignCast(@alignOf(HandlerFn), implementation))(
|
||||
@ptrCast(*Obj, object),
|
||||
@unionInit(Payload, payload_field.name, payload_data),
|
||||
@intToPtr(Data, @ptrToInt(object.getUserData())),
|
||||
@ptrFromInt(Data, @intFromPtr(object.getUserData())),
|
||||
);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -635,7 +635,7 @@ const Interface = struct {
|
||||
\\ _data: T,
|
||||
\\) void {{
|
||||
\\ const _proxy = @ptrCast(*client.wl.Proxy, _{[interface]});
|
||||
\\ const _mut_data = @intToPtr(?*anyopaque, @ptrToInt(_data));
|
||||
\\ const _mut_data = @ptrFromInt(?*anyopaque, @intFromPtr(_data));
|
||||
\\ _proxy.addDispatcher(common.Dispatcher({[type]}, T).dispatcher, _listener, _mut_data);
|
||||
\\}}
|
||||
, .{
|
||||
@@ -703,7 +703,7 @@ const Interface = struct {
|
||||
if (has_error) {
|
||||
try writer.print(
|
||||
\\pub fn postError({[interface]}: *{[type]}, _err: Error, _message: [*:0]const u8) void {{
|
||||
\\ return @ptrCast(*server.wl.Resource, {[interface]}).postError(@intCast(u32, @enumToInt(_err)), _message);
|
||||
\\ return @ptrCast(*server.wl.Resource, {[interface]}).postError(@intCast(u32, @intFromEnum(_err)), _message);
|
||||
\\}}
|
||||
, .{
|
||||
.interface = fmtId(trimPrefix(interface.name)),
|
||||
@@ -736,12 +736,12 @@ const Interface = struct {
|
||||
\\ _resource.setDispatcher(
|
||||
\\ common.Dispatcher({[type]}, T).dispatcher,
|
||||
\\ handle_request,
|
||||
\\ @intToPtr(?*anyopaque, @ptrToInt(_data)),
|
||||
\\ @ptrFromInt(?*anyopaque, @intFromPtr(_data)),
|
||||
\\ if (handle_destroy) |_handler| struct {{
|
||||
\\ fn _wrapper(__resource: *server.wl.Resource) callconv(.C) void {{
|
||||
\\ @call(.always_inline, _handler, .{{
|
||||
\\ @ptrCast(*{[type]}, __resource),
|
||||
\\ @intToPtr(T, @ptrToInt(__resource.getUserData())),
|
||||
\\ @ptrFromInt(T, @intFromPtr(__resource.getUserData())),
|
||||
\\ }});
|
||||
\\ }}
|
||||
\\ }}._wrapper else null,
|
||||
@@ -763,12 +763,12 @@ const Interface = struct {
|
||||
\\ _resource.setDispatcher(
|
||||
\\ null,
|
||||
\\ null,
|
||||
\\ @intToPtr(?*anyopaque, @ptrToInt(_data)),
|
||||
\\ @ptrFromInt(?*anyopaque, @intFromPtr(_data)),
|
||||
\\ if (handle_destroy) |_handler| struct {{
|
||||
\\ fn _wrapper(__resource: *server.wl.Resource) callconv(.C) void {{
|
||||
\\ @call(.always_inline, _handler, .{{
|
||||
\\ @ptrCast(*{[type]}, __resource),
|
||||
\\ @intToPtr(T, @ptrToInt(__resource.getUserData())),
|
||||
\\ @ptrFromInt(T, @intFromPtr(__resource.getUserData())),
|
||||
\\ }});
|
||||
\\ }}
|
||||
\\ }}._wrapper else null,
|
||||
@@ -964,7 +964,7 @@ const Message = struct {
|
||||
const c_type = if (arg.kind == .uint) "u32" else "i32";
|
||||
try writer.print(
|
||||
\\ )) {{
|
||||
\\ .Enum => @intCast({[ct]s}, @enumToInt(_{[an]})),
|
||||
\\ .Enum => @intCast({[ct]s}, @intFromEnum(_{[an]})),
|
||||
\\ .Struct => @bitCast(u32, _{[an]}),
|
||||
\\ else => unreachable,
|
||||
\\ }}
|
||||
|
||||
@@ -556,7 +556,7 @@ pub fn Listener(comptime T: type) type {
|
||||
else
|
||||
struct {
|
||||
fn wrapper(listener: *Self, data: ?*anyopaque) callconv(.C) void {
|
||||
@call(.always_inline, notify, .{ listener, @intToPtr(T, @ptrToInt(data)) });
|
||||
@call(.always_inline, notify, .{ listener, @ptrFromInt(T, @intFromPtr(data)) });
|
||||
}
|
||||
}.wrapper;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user