code
stringlengths
38
801k
repo_path
stringlengths
6
263
pub const std = @import("std"); pub const vk = @import("vk"); pub const vma = @import("vma"); pub const sdl = @import("sdl"); pub usingnamespace @import("simd.zig"); pub const assert = std.debug.assert; pub const GpuBuffer = struct { buffer: vk.Buffer, alloc: vma.Allocation, pub fn init( vma_alloc: vma.Allocator, size: vk.DeviceSize, mem_usage: vma.MemoryUsage, buf_usage: vk.BufferUsageFlags, ) !GpuBuffer { const results = try vma_alloc.createBuffer( .{ .size = size, .usage = buf_usage, .sharingMode = .EXCLUSIVE }, .{ .usage = mem_usage }, ); return GpuBuffer{ .buffer = results.buffer, .alloc = results.allocation, }; } pub fn deinit(self: GpuBuffer, vma_alloc: vma.Allocator) void { vma_alloc.destroyBuffer(self.buffer, self.alloc); } }; pub const GpuMesh = struct { uploaded: vk.Fence, idx_count: usize, idx_type: vk.IndexType, size: usize, host: GpuBuffer, gpu: GpuBuffer, pub fn init(device: vk.Device, vma_alloc: vma.Allocator, src: CpuMesh) !GpuMesh { const total_size = @intCast(usize, src.index_size + src.geom_size); const host_buffer = try GpuBuffer.init(vma_alloc, total_size, .cpuToGpu, .{ .transferSrc = true }); errdefer host_buffer.deinit(vma_alloc); const device_buffer = try GpuBuffer.init(vma_alloc, total_size, .gpuOnly, .{ .vertexBuffer = true, .indexBuffer = true, .transferDst = true, }); errdefer device_buffer.deinit(vma_alloc); const fence = try vk.CreateFence(device, .{}, null); errdefer vk.DestroyFence(device, fence, null); // Copy the data into the cpu buffer { const data = try vma_alloc.mapMemory(host_buffer.alloc, u8); defer vma_alloc.unmapMemory(host_buffer.alloc); var offset: usize = 0; // Copy Indices var size = src.index_size; @memcpy(data + offset, @ptrCast([*]const u8, src.indices), size); offset += size; // Copy Positions size = @sizeOf(Float3) * src.vertex_count; @memcpy(data + offset, @ptrCast([*]const u8, src.positions), size); offset += size; // Copy Colors @memcpy(data + offset, @ptrCast([*]const u8, src.colors), size); offset += size; // Copy Normals @memcpy(data + offset, @ptrCast([*]const u8, src.normals), size); offset += size; assert(offset == total_size); } return GpuMesh{ .uploaded = fence, .idx_count = src.index_count, .idx_type = .UINT16, .size = total_size, .host = host_buffer, .gpu = device_buffer, }; } pub fn deinit(self: GpuMesh, device: vk.Device, vma_alloc: vma.Allocator) void { self.host.deinit(vma_alloc); self.gpu.deinit(vma_alloc); vk.DestroyFence(device, self.uploaded, null); } }; pub const CpuMesh = struct { index_size: u64, geom_size: u64, index_count: u32, vertex_count: u32, indices: [*]const u16, positions: [*]const Float3, colors: [*]const Float3, normals: [*]const Float3, }; pub const PUSH_CONSTANT_BYTES = 256; pub const PushConstants = extern struct { time: Float4, resolution: Float2, mvp: Float4x4, m: Float4x4, }; comptime { if (@sizeOf(PushConstants) > PUSH_CONSTANT_BYTES) @compileError("Too Many Push Constants"); } /// Takes a pointer type like *T, *const T, *align(4)T, etc, /// returns the pointer type *[1]T, *const [1]T, *align(4) [1]T, etc. pub fn ArrayPtr(comptime ptrType: type) type { comptime { // Check that the input is of type *T var info = @typeInfo(ptrType); assert(info == .Pointer); assert(info.Pointer.size == .One); assert(info.Pointer.sentinel == null); // Create the new value type, [1]T const arrayInfo = std.builtin.TypeInfo{ .Array = .{ .len = 1, .child = info.Pointer.child, .sentinel = @as(?info.Pointer.child, null), }, }; // Patch the type to be *[1]T, preserving other modifiers const singleArrayType = @Type(arrayInfo); info.Pointer.child = singleArrayType; // also need to change the type of the sentinel // we checked that this is null above so no work needs to be done here. info.Pointer.sentinel = @as(?singleArrayType, null); return @Type(info); } } pub fn arrayPtr(ptr: anytype) callconv(.Inline) ArrayPtr(@TypeOf(ptr)) { return ptr; }
src/common.zig
const c = @import("std").c; usingnamespace @import("zamqp.zig"); pub extern fn amqp_version_number() u32; pub extern fn amqp_version() [*:0]const u8; pub extern fn amqp_error_string2(err: status_t) [*:0]const u8; pub extern fn amqp_cstring_bytes(cstr: [*:0]const u8) bytes_t; pub extern fn amqp_parse_url(url: [*:0]u8, parsed: *ConnectionInfo) status_t; // Connection pub const connection_state_t = opaque {}; pub extern fn amqp_new_connection() ?*connection_state_t; pub extern fn amqp_connection_close(state: *connection_state_t, code: c_int) RpcReply; pub extern fn amqp_destroy_connection(state: *connection_state_t) status_t; pub extern fn amqp_login(state: *connection_state_t, vhost: [*:0]const u8, channel_max: c_int, frame_max: c_int, heartbeat: c_int, sasl_method: sasl_method_t, ...) RpcReply; pub extern fn amqp_maybe_release_buffers(state: *connection_state_t) void; pub extern fn amqp_get_rpc_reply(state: *connection_state_t) RpcReply; pub extern fn amqp_simple_wait_frame_noblock(state: *connection_state_t, decoded_frame: *Frame, tv: ?*c.timeval) status_t; pub extern fn amqp_consume_message(state: *connection_state_t, envelope: *Envelope, timeout: ?*c.timeval, flags_t: c_int) RpcReply; // Socket pub const socket_t = opaque {}; pub extern fn amqp_socket_open_noblock(self: *socket_t, host: [*:0]const u8, port: c_int, timeout: ?*c.timeval) status_t; pub extern fn amqp_tcp_socket_new(state: *connection_state_t) ?*socket_t; pub extern fn amqp_tcp_socket_set_sockfd(self: *socket_t, sockfd: c_int) void; pub extern fn amqp_ssl_socket_new(state: *connection_state_t) ?*socket_t; pub extern fn amqp_ssl_socket_set_cacert(self: *socket_t, cacert: [*:0]const u8) status_t; pub extern fn amqp_ssl_socket_set_key(self: *socket_t, cert: [*:0]const u8, key: [*:0]const u8) status_t; pub extern fn amqp_ssl_socket_set_key_buffer(self: *socket_t, cert: [*:0]const u8, key: ?*const c_void, n: usize) status_t; pub extern fn amqp_ssl_socket_set_verify_peer(self: *socket_t, verify: boolean_t) void; pub extern fn amqp_ssl_socket_set_verify_hostname(self: *socket_t, verify: boolean_t) void; pub extern fn amqp_ssl_socket_set_ssl_versions(self: *socket_t, min: tls_version_t, max: tls_version_t) status_t; // Channel pub extern fn amqp_channel_open(state: *connection_state_t, channel: channel_t) ?*channel_open_ok_t; pub extern fn amqp_read_message(state: *connection_state_t, channel: channel_t, message: *Message, flags: c_int) RpcReply; pub extern fn amqp_basic_publish( state: *connection_state_t, channel: channel_t, exchange: bytes_t, routing_key: bytes_t, mandatory: boolean_t, immediate: boolean_t, properties: *const BasicProperties, body: bytes_t, ) status_t; pub extern fn amqp_basic_consume( state: *connection_state_t, channel: channel_t, queue: bytes_t, consumer_tag: bytes_t, no_local: boolean_t, no_ack: boolean_t, exclusive: boolean_t, arguments: table_t, ) ?*basic_consume_ok_t; pub extern fn amqp_exchange_declare( state: *connection_state_t, channel: channel_t, exchange: bytes_t, type_: bytes_t, passive: boolean_t, durable: boolean_t, auto_delete: boolean_t, internal: boolean_t, arguments: table_t, ) ?*exchange_declare_ok_t; pub extern fn amqp_queue_declare( state: *connection_state_t, channel: channel_t, queue: bytes_t, passive: boolean_t, durable: boolean_t, exclusive: boolean_t, auto_delete: boolean_t, arguments: table_t, ) ?*queue_declare_ok_t; pub extern fn amqp_queue_bind( state: *connection_state_t, channel: channel_t, queue: bytes_t, exchange: bytes_t, routing_key: bytes_t, arguments: table_t, ) ?*queue_bind_ok_t; pub extern fn amqp_basic_ack(state: *connection_state_t, channel: channel_t, delivery_tag: u64, multiple: boolean_t) status_t; pub extern fn amqp_basic_reject(state: *connection_state_t, channel: channel_t, delivery_tag: u64, requeue: boolean_t) status_t; pub extern fn amqp_basic_qos(state: *connection_state_t, channel: channel_t, prefetch_size: u32, prefetch_count: u16, global: boolean_t) ?*basic_qos_ok_t; pub extern fn amqp_channel_close(state: *connection_state_t, channel: channel_t, code: c_int) RpcReply; pub extern fn amqp_maybe_release_buffers_on_channel(state: *connection_state_t, channel: channel_t) void; pub extern fn amqp_destroy_message(message: *Message) void; pub extern fn amqp_destroy_envelope(envelope: *Envelope) void; pub extern const amqp_empty_bytes: bytes_t; pub extern const amqp_empty_table: table_t; pub extern const amqp_empty_array: array_t; pub const sasl_method_t = extern enum(c_int) { UNDEFINED = -1, PLAIN = 0, EXTERNAL = 1, _, }; pub const basic_qos_ok_t = extern struct { dummy: u8, }; pub const exchange_declare_ok_t = extern struct { dummy: u8, }; pub const queue_bind_ok_t = extern struct { dummy: u8, };
src/c_api.zig
//-------------------------------------------------------------------------------- // Section: Types (25) //-------------------------------------------------------------------------------- pub const HINTERACTIONCONTEXT = *opaque{}; pub const INTERACTION_ID = enum(i32) { NONE = 0, MANIPULATION = 1, TAP = 2, SECONDARY_TAP = 3, HOLD = 4, DRAG = 5, CROSS_SLIDE = 6, MAX = -1, }; pub const INTERACTION_ID_NONE = INTERACTION_ID.NONE; pub const INTERACTION_ID_MANIPULATION = INTERACTION_ID.MANIPULATION; pub const INTERACTION_ID_TAP = INTERACTION_ID.TAP; pub const INTERACTION_ID_SECONDARY_TAP = INTERACTION_ID.SECONDARY_TAP; pub const INTERACTION_ID_HOLD = INTERACTION_ID.HOLD; pub const INTERACTION_ID_DRAG = INTERACTION_ID.DRAG; pub const INTERACTION_ID_CROSS_SLIDE = INTERACTION_ID.CROSS_SLIDE; pub const INTERACTION_ID_MAX = INTERACTION_ID.MAX; pub const INTERACTION_FLAGS = enum(u32) { NONE = 0, BEGIN = 1, END = 2, CANCEL = 4, INERTIA = 8, MAX = 4294967295, _, pub fn initFlags(o: struct { NONE: u1 = 0, BEGIN: u1 = 0, END: u1 = 0, CANCEL: u1 = 0, INERTIA: u1 = 0, MAX: u1 = 0, }) INTERACTION_FLAGS { return @intToEnum(INTERACTION_FLAGS, (if (o.NONE == 1) @enumToInt(INTERACTION_FLAGS.NONE) else 0) | (if (o.BEGIN == 1) @enumToInt(INTERACTION_FLAGS.BEGIN) else 0) | (if (o.END == 1) @enumToInt(INTERACTION_FLAGS.END) else 0) | (if (o.CANCEL == 1) @enumToInt(INTERACTION_FLAGS.CANCEL) else 0) | (if (o.INERTIA == 1) @enumToInt(INTERACTION_FLAGS.INERTIA) else 0) | (if (o.MAX == 1) @enumToInt(INTERACTION_FLAGS.MAX) else 0) ); } }; pub const INTERACTION_FLAG_NONE = INTERACTION_FLAGS.NONE; pub const INTERACTION_FLAG_BEGIN = INTERACTION_FLAGS.BEGIN; pub const INTERACTION_FLAG_END = INTERACTION_FLAGS.END; pub const INTERACTION_FLAG_CANCEL = INTERACTION_FLAGS.CANCEL; pub const INTERACTION_FLAG_INERTIA = INTERACTION_FLAGS.INERTIA; pub const INTERACTION_FLAG_MAX = INTERACTION_FLAGS.MAX; pub const INTERACTION_CONFIGURATION_FLAGS = enum(u32) { NONE = 0, MANIPULATION = 1, MANIPULATION_TRANSLATION_X = 2, MANIPULATION_TRANSLATION_Y = 4, MANIPULATION_ROTATION = 8, MANIPULATION_SCALING = 16, MANIPULATION_TRANSLATION_INERTIA = 32, MANIPULATION_ROTATION_INERTIA = 64, MANIPULATION_SCALING_INERTIA = 128, MANIPULATION_RAILS_X = 256, MANIPULATION_RAILS_Y = 512, MANIPULATION_EXACT = 1024, MANIPULATION_MULTIPLE_FINGER_PANNING = 2048, // CROSS_SLIDE = 1, this enum value conflicts with MANIPULATION // CROSS_SLIDE_HORIZONTAL = 2, this enum value conflicts with MANIPULATION_TRANSLATION_X // CROSS_SLIDE_SELECT = 4, this enum value conflicts with MANIPULATION_TRANSLATION_Y // CROSS_SLIDE_SPEED_BUMP = 8, this enum value conflicts with MANIPULATION_ROTATION // CROSS_SLIDE_REARRANGE = 16, this enum value conflicts with MANIPULATION_SCALING // CROSS_SLIDE_EXACT = 32, this enum value conflicts with MANIPULATION_TRANSLATION_INERTIA // TAP = 1, this enum value conflicts with MANIPULATION // TAP_DOUBLE = 2, this enum value conflicts with MANIPULATION_TRANSLATION_X // TAP_MULTIPLE_FINGER = 4, this enum value conflicts with MANIPULATION_TRANSLATION_Y // SECONDARY_TAP = 1, this enum value conflicts with MANIPULATION // HOLD = 1, this enum value conflicts with MANIPULATION // HOLD_MOUSE = 2, this enum value conflicts with MANIPULATION_TRANSLATION_X // HOLD_MULTIPLE_FINGER = 4, this enum value conflicts with MANIPULATION_TRANSLATION_Y // DRAG = 1, this enum value conflicts with MANIPULATION MAX = 4294967295, _, pub fn initFlags(o: struct { NONE: u1 = 0, MANIPULATION: u1 = 0, MANIPULATION_TRANSLATION_X: u1 = 0, MANIPULATION_TRANSLATION_Y: u1 = 0, MANIPULATION_ROTATION: u1 = 0, MANIPULATION_SCALING: u1 = 0, MANIPULATION_TRANSLATION_INERTIA: u1 = 0, MANIPULATION_ROTATION_INERTIA: u1 = 0, MANIPULATION_SCALING_INERTIA: u1 = 0, MANIPULATION_RAILS_X: u1 = 0, MANIPULATION_RAILS_Y: u1 = 0, MANIPULATION_EXACT: u1 = 0, MANIPULATION_MULTIPLE_FINGER_PANNING: u1 = 0, MAX: u1 = 0, }) INTERACTION_CONFIGURATION_FLAGS { return @intToEnum(INTERACTION_CONFIGURATION_FLAGS, (if (o.NONE == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.NONE) else 0) | (if (o.MANIPULATION == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION) else 0) | (if (o.MANIPULATION_TRANSLATION_X == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_X) else 0) | (if (o.MANIPULATION_TRANSLATION_Y == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_Y) else 0) | (if (o.MANIPULATION_ROTATION == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_ROTATION) else 0) | (if (o.MANIPULATION_SCALING == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_SCALING) else 0) | (if (o.MANIPULATION_TRANSLATION_INERTIA == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_INERTIA) else 0) | (if (o.MANIPULATION_ROTATION_INERTIA == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_ROTATION_INERTIA) else 0) | (if (o.MANIPULATION_SCALING_INERTIA == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_SCALING_INERTIA) else 0) | (if (o.MANIPULATION_RAILS_X == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_RAILS_X) else 0) | (if (o.MANIPULATION_RAILS_Y == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_RAILS_Y) else 0) | (if (o.MANIPULATION_EXACT == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_EXACT) else 0) | (if (o.MANIPULATION_MULTIPLE_FINGER_PANNING == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_MULTIPLE_FINGER_PANNING) else 0) | (if (o.MAX == 1) @enumToInt(INTERACTION_CONFIGURATION_FLAGS.MAX) else 0) ); } }; pub const INTERACTION_CONFIGURATION_FLAG_NONE = INTERACTION_CONFIGURATION_FLAGS.NONE; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_TRANSLATION_X = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_X; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_TRANSLATION_Y = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_Y; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_ROTATION = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_ROTATION; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_SCALING = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_SCALING; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_TRANSLATION_INERTIA = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_INERTIA; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_ROTATION_INERTIA = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_ROTATION_INERTIA; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_SCALING_INERTIA = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_SCALING_INERTIA; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_RAILS_X = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_RAILS_X; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_RAILS_Y = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_RAILS_Y; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_EXACT = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_EXACT; pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_MULTIPLE_FINGER_PANNING = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_MULTIPLE_FINGER_PANNING; pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION; pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_HORIZONTAL = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_X; pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_SELECT = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_Y; pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_SPEED_BUMP = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_ROTATION; pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_REARRANGE = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_SCALING; pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_EXACT = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_INERTIA; pub const INTERACTION_CONFIGURATION_FLAG_TAP = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION; pub const INTERACTION_CONFIGURATION_FLAG_TAP_DOUBLE = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_X; pub const INTERACTION_CONFIGURATION_FLAG_TAP_MULTIPLE_FINGER = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_Y; pub const INTERACTION_CONFIGURATION_FLAG_SECONDARY_TAP = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION; pub const INTERACTION_CONFIGURATION_FLAG_HOLD = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION; pub const INTERACTION_CONFIGURATION_FLAG_HOLD_MOUSE = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_X; pub const INTERACTION_CONFIGURATION_FLAG_HOLD_MULTIPLE_FINGER = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_Y; pub const INTERACTION_CONFIGURATION_FLAG_DRAG = INTERACTION_CONFIGURATION_FLAGS.MANIPULATION; pub const INTERACTION_CONFIGURATION_FLAG_MAX = INTERACTION_CONFIGURATION_FLAGS.MAX; pub const INERTIA_PARAMETER = enum(i32) { TRANSLATION_DECELERATION = 1, TRANSLATION_DISPLACEMENT = 2, ROTATION_DECELERATION = 3, ROTATION_ANGLE = 4, EXPANSION_DECELERATION = 5, EXPANSION_EXPANSION = 6, MAX = -1, }; pub const INERTIA_PARAMETER_TRANSLATION_DECELERATION = INERTIA_PARAMETER.TRANSLATION_DECELERATION; pub const INERTIA_PARAMETER_TRANSLATION_DISPLACEMENT = INERTIA_PARAMETER.TRANSLATION_DISPLACEMENT; pub const INERTIA_PARAMETER_ROTATION_DECELERATION = INERTIA_PARAMETER.ROTATION_DECELERATION; pub const INERTIA_PARAMETER_ROTATION_ANGLE = INERTIA_PARAMETER.ROTATION_ANGLE; pub const INERTIA_PARAMETER_EXPANSION_DECELERATION = INERTIA_PARAMETER.EXPANSION_DECELERATION; pub const INERTIA_PARAMETER_EXPANSION_EXPANSION = INERTIA_PARAMETER.EXPANSION_EXPANSION; pub const INERTIA_PARAMETER_MAX = INERTIA_PARAMETER.MAX; pub const INTERACTION_STATE = enum(i32) { IDLE = 0, IN_INTERACTION = 1, POSSIBLE_DOUBLE_TAP = 2, MAX = -1, }; pub const INTERACTION_STATE_IDLE = INTERACTION_STATE.IDLE; pub const INTERACTION_STATE_IN_INTERACTION = INTERACTION_STATE.IN_INTERACTION; pub const INTERACTION_STATE_POSSIBLE_DOUBLE_TAP = INTERACTION_STATE.POSSIBLE_DOUBLE_TAP; pub const INTERACTION_STATE_MAX = INTERACTION_STATE.MAX; pub const INTERACTION_CONTEXT_PROPERTY = enum(i32) { MEASUREMENT_UNITS = 1, INTERACTION_UI_FEEDBACK = 2, FILTER_POINTERS = 3, MAX = -1, }; pub const INTERACTION_CONTEXT_PROPERTY_MEASUREMENT_UNITS = INTERACTION_CONTEXT_PROPERTY.MEASUREMENT_UNITS; pub const INTERACTION_CONTEXT_PROPERTY_INTERACTION_UI_FEEDBACK = INTERACTION_CONTEXT_PROPERTY.INTERACTION_UI_FEEDBACK; pub const INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS = INTERACTION_CONTEXT_PROPERTY.FILTER_POINTERS; pub const INTERACTION_CONTEXT_PROPERTY_MAX = INTERACTION_CONTEXT_PROPERTY.MAX; pub const CROSS_SLIDE_THRESHOLD = enum(i32) { SELECT_START = 0, SPEED_BUMP_START = 1, SPEED_BUMP_END = 2, REARRANGE_START = 3, COUNT = 4, MAX = -1, }; pub const CROSS_SLIDE_THRESHOLD_SELECT_START = CROSS_SLIDE_THRESHOLD.SELECT_START; pub const CROSS_SLIDE_THRESHOLD_SPEED_BUMP_START = CROSS_SLIDE_THRESHOLD.SPEED_BUMP_START; pub const CROSS_SLIDE_THRESHOLD_SPEED_BUMP_END = CROSS_SLIDE_THRESHOLD.SPEED_BUMP_END; pub const CROSS_SLIDE_THRESHOLD_REARRANGE_START = CROSS_SLIDE_THRESHOLD.REARRANGE_START; pub const CROSS_SLIDE_THRESHOLD_COUNT = CROSS_SLIDE_THRESHOLD.COUNT; pub const CROSS_SLIDE_THRESHOLD_MAX = CROSS_SLIDE_THRESHOLD.MAX; pub const CROSS_SLIDE_FLAGS = enum(u32) { NONE = 0, SELECT = 1, SPEED_BUMP = 2, REARRANGE = 4, MAX = 4294967295, _, pub fn initFlags(o: struct { NONE: u1 = 0, SELECT: u1 = 0, SPEED_BUMP: u1 = 0, REARRANGE: u1 = 0, MAX: u1 = 0, }) CROSS_SLIDE_FLAGS { return @intToEnum(CROSS_SLIDE_FLAGS, (if (o.NONE == 1) @enumToInt(CROSS_SLIDE_FLAGS.NONE) else 0) | (if (o.SELECT == 1) @enumToInt(CROSS_SLIDE_FLAGS.SELECT) else 0) | (if (o.SPEED_BUMP == 1) @enumToInt(CROSS_SLIDE_FLAGS.SPEED_BUMP) else 0) | (if (o.REARRANGE == 1) @enumToInt(CROSS_SLIDE_FLAGS.REARRANGE) else 0) | (if (o.MAX == 1) @enumToInt(CROSS_SLIDE_FLAGS.MAX) else 0) ); } }; pub const CROSS_SLIDE_FLAGS_NONE = CROSS_SLIDE_FLAGS.NONE; pub const CROSS_SLIDE_FLAGS_SELECT = CROSS_SLIDE_FLAGS.SELECT; pub const CROSS_SLIDE_FLAGS_SPEED_BUMP = CROSS_SLIDE_FLAGS.SPEED_BUMP; pub const CROSS_SLIDE_FLAGS_REARRANGE = CROSS_SLIDE_FLAGS.REARRANGE; pub const CROSS_SLIDE_FLAGS_MAX = CROSS_SLIDE_FLAGS.MAX; pub const MOUSE_WHEEL_PARAMETER = enum(i32) { CHAR_TRANSLATION_X = 1, CHAR_TRANSLATION_Y = 2, DELTA_SCALE = 3, DELTA_ROTATION = 4, PAGE_TRANSLATION_X = 5, PAGE_TRANSLATION_Y = 6, MAX = -1, }; pub const MOUSE_WHEEL_PARAMETER_CHAR_TRANSLATION_X = MOUSE_WHEEL_PARAMETER.CHAR_TRANSLATION_X; pub const MOUSE_WHEEL_PARAMETER_CHAR_TRANSLATION_Y = MOUSE_WHEEL_PARAMETER.CHAR_TRANSLATION_Y; pub const MOUSE_WHEEL_PARAMETER_DELTA_SCALE = MOUSE_WHEEL_PARAMETER.DELTA_SCALE; pub const MOUSE_WHEEL_PARAMETER_DELTA_ROTATION = MOUSE_WHEEL_PARAMETER.DELTA_ROTATION; pub const MOUSE_WHEEL_PARAMETER_PAGE_TRANSLATION_X = MOUSE_WHEEL_PARAMETER.PAGE_TRANSLATION_X; pub const MOUSE_WHEEL_PARAMETER_PAGE_TRANSLATION_Y = MOUSE_WHEEL_PARAMETER.PAGE_TRANSLATION_Y; pub const MOUSE_WHEEL_PARAMETER_MAX = MOUSE_WHEEL_PARAMETER.MAX; pub const TAP_PARAMETER = enum(i32) { IN_CONTACT_COUNT = 0, AX_CONTACT_COUNT = 1, AX = -1, }; pub const TAP_PARAMETER_MIN_CONTACT_COUNT = TAP_PARAMETER.IN_CONTACT_COUNT; pub const TAP_PARAMETER_MAX_CONTACT_COUNT = TAP_PARAMETER.AX_CONTACT_COUNT; pub const TAP_PARAMETER_MAX = TAP_PARAMETER.AX; pub const HOLD_PARAMETER = enum(i32) { MIN_CONTACT_COUNT = 0, MAX_CONTACT_COUNT = 1, THRESHOLD_RADIUS = 2, THRESHOLD_START_DELAY = 3, MAX = -1, }; pub const HOLD_PARAMETER_MIN_CONTACT_COUNT = HOLD_PARAMETER.MIN_CONTACT_COUNT; pub const HOLD_PARAMETER_MAX_CONTACT_COUNT = HOLD_PARAMETER.MAX_CONTACT_COUNT; pub const HOLD_PARAMETER_THRESHOLD_RADIUS = HOLD_PARAMETER.THRESHOLD_RADIUS; pub const HOLD_PARAMETER_THRESHOLD_START_DELAY = HOLD_PARAMETER.THRESHOLD_START_DELAY; pub const HOLD_PARAMETER_MAX = HOLD_PARAMETER.MAX; pub const TRANSLATION_PARAMETER = enum(i32) { IN_CONTACT_COUNT = 0, AX_CONTACT_COUNT = 1, AX = -1, }; pub const TRANSLATION_PARAMETER_MIN_CONTACT_COUNT = TRANSLATION_PARAMETER.IN_CONTACT_COUNT; pub const TRANSLATION_PARAMETER_MAX_CONTACT_COUNT = TRANSLATION_PARAMETER.AX_CONTACT_COUNT; pub const TRANSLATION_PARAMETER_MAX = TRANSLATION_PARAMETER.AX; pub const MANIPULATION_RAILS_STATE = enum(i32) { UNDECIDED = 0, FREE = 1, RAILED = 2, MAX = -1, }; pub const MANIPULATION_RAILS_STATE_UNDECIDED = MANIPULATION_RAILS_STATE.UNDECIDED; pub const MANIPULATION_RAILS_STATE_FREE = MANIPULATION_RAILS_STATE.FREE; pub const MANIPULATION_RAILS_STATE_RAILED = MANIPULATION_RAILS_STATE.RAILED; pub const MANIPULATION_RAILS_STATE_MAX = MANIPULATION_RAILS_STATE.MAX; pub const MANIPULATION_TRANSFORM = extern struct { translationX: f32, translationY: f32, scale: f32, expansion: f32, rotation: f32, }; pub const MANIPULATION_VELOCITY = extern struct { velocityX: f32, velocityY: f32, velocityExpansion: f32, velocityAngular: f32, }; pub const INTERACTION_ARGUMENTS_MANIPULATION = extern struct { delta: MANIPULATION_TRANSFORM, cumulative: MANIPULATION_TRANSFORM, velocity: MANIPULATION_VELOCITY, railsState: MANIPULATION_RAILS_STATE, }; pub const INTERACTION_ARGUMENTS_TAP = extern struct { count: u32, }; pub const INTERACTION_ARGUMENTS_CROSS_SLIDE = extern struct { flags: CROSS_SLIDE_FLAGS, }; pub const INTERACTION_CONTEXT_OUTPUT = extern struct { interactionId: INTERACTION_ID, interactionFlags: INTERACTION_FLAGS, inputType: POINTER_INPUT_TYPE, x: f32, y: f32, arguments: extern union { manipulation: INTERACTION_ARGUMENTS_MANIPULATION, tap: INTERACTION_ARGUMENTS_TAP, crossSlide: INTERACTION_ARGUMENTS_CROSS_SLIDE, }, }; pub const INTERACTION_CONTEXT_OUTPUT2 = extern struct { interactionId: INTERACTION_ID, interactionFlags: INTERACTION_FLAGS, inputType: POINTER_INPUT_TYPE, contactCount: u32, currentContactCount: u32, x: f32, y: f32, arguments: extern union { manipulation: INTERACTION_ARGUMENTS_MANIPULATION, tap: INTERACTION_ARGUMENTS_TAP, crossSlide: INTERACTION_ARGUMENTS_CROSS_SLIDE, }, }; pub const INTERACTION_CONTEXT_CONFIGURATION = extern struct { interactionId: INTERACTION_ID, enable: INTERACTION_CONFIGURATION_FLAGS, }; pub const CROSS_SLIDE_PARAMETER = extern struct { threshold: CROSS_SLIDE_THRESHOLD, distance: f32, }; pub const INTERACTION_CONTEXT_OUTPUT_CALLBACK = fn( clientData: ?*anyopaque, output: ?*const INTERACTION_CONTEXT_OUTPUT, ) callconv(@import("std").os.windows.WINAPI) void; pub const INTERACTION_CONTEXT_OUTPUT_CALLBACK2 = fn( clientData: ?*anyopaque, output: ?*const INTERACTION_CONTEXT_OUTPUT2, ) callconv(@import("std").os.windows.WINAPI) void; //-------------------------------------------------------------------------------- // Section: Functions (30) //-------------------------------------------------------------------------------- // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn CreateInteractionContext( interactionContext: ?*?HINTERACTIONCONTEXT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn DestroyInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn RegisterOutputCallbackInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, outputCallback: ?INTERACTION_CONTEXT_OUTPUT_CALLBACK, clientData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "NInput" fn RegisterOutputCallbackInteractionContext2( interactionContext: ?HINTERACTIONCONTEXT, outputCallback: ?INTERACTION_CONTEXT_OUTPUT_CALLBACK2, clientData: ?*anyopaque, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn SetInteractionConfigurationInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, configurationCount: u32, configuration: [*]const INTERACTION_CONTEXT_CONFIGURATION, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn GetInteractionConfigurationInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, configurationCount: u32, configuration: [*]INTERACTION_CONTEXT_CONFIGURATION, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn SetPropertyInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, contextProperty: INTERACTION_CONTEXT_PROPERTY, value: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn GetPropertyInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, contextProperty: INTERACTION_CONTEXT_PROPERTY, value: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn SetInertiaParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, inertiaParameter: INERTIA_PARAMETER, value: f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn GetInertiaParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, inertiaParameter: INERTIA_PARAMETER, value: ?*f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn SetCrossSlideParametersInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, parameterCount: u32, crossSlideParameters: [*]CROSS_SLIDE_PARAMETER, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn GetCrossSlideParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, threshold: CROSS_SLIDE_THRESHOLD, distance: ?*f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "NInput" fn SetTapParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, parameter: TAP_PARAMETER, value: f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "NInput" fn GetTapParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, parameter: TAP_PARAMETER, value: ?*f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "NInput" fn SetHoldParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, parameter: HOLD_PARAMETER, value: f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "NInput" fn GetHoldParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, parameter: HOLD_PARAMETER, value: ?*f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "NInput" fn SetTranslationParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, parameter: TRANSLATION_PARAMETER, value: f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; pub extern "NInput" fn GetTranslationParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, parameter: TRANSLATION_PARAMETER, value: ?*f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn SetMouseWheelParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, parameter: MOUSE_WHEEL_PARAMETER, value: f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn GetMouseWheelParameterInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, parameter: MOUSE_WHEEL_PARAMETER, value: ?*f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn ResetInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn GetStateInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, pointerInfo: ?*const POINTER_INFO, state: ?*INTERACTION_STATE, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn AddPointerInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, pointerId: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn RemovePointerInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, pointerId: u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn ProcessPointerFramesInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, entriesCount: u32, pointerCount: u32, pointerInfo: ?*const POINTER_INFO, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn BufferPointerPacketsInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, entriesCount: u32, pointerInfo: [*]const POINTER_INFO, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn ProcessBufferedPacketsInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn ProcessInertiaInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn StopInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, ) callconv(@import("std").os.windows.WINAPI) HRESULT; // TODO: this type is limited to platform 'windows8.0' pub extern "NInput" fn SetPivotInteractionContext( interactionContext: ?HINTERACTIONCONTEXT, x: f32, y: f32, radius: f32, ) callconv(@import("std").os.windows.WINAPI) HRESULT; //-------------------------------------------------------------------------------- // Section: Unicode Aliases (0) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { }, .wide => struct { }, .unspecified => if (@import("builtin").is_test) struct { } else struct { }, }; //-------------------------------------------------------------------------------- // Section: Imports (3) //-------------------------------------------------------------------------------- const HRESULT = @import("../foundation.zig").HRESULT; const POINTER_INFO = @import("../ui/input/pointer.zig").POINTER_INFO; const POINTER_INPUT_TYPE = @import("../ui/windows_and_messaging.zig").POINTER_INPUT_TYPE; test { // The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476 if (@hasDecl(@This(), "INTERACTION_CONTEXT_OUTPUT_CALLBACK")) { _ = INTERACTION_CONTEXT_OUTPUT_CALLBACK; } if (@hasDecl(@This(), "INTERACTION_CONTEXT_OUTPUT_CALLBACK2")) { _ = INTERACTION_CONTEXT_OUTPUT_CALLBACK2; } @setEvalBranchQuota( @import("std").meta.declarations(@This()).len * 3 ); // reference all the pub declarations if (!@import("builtin").is_test) return; inline for (@import("std").meta.declarations(@This())) |decl| { if (decl.is_pub) { _ = decl; } } }
win32/ui/interaction_context.zig
const std = @import("std"); const debug = std.debug; const mem = std.mem; const log = std.log; const testing = std.testing; const Allocator = mem.Allocator; const AutoHashMap = std.AutoHashMap; const TailQueue = std.TailQueue; const ArrayList = std.ArrayList; const intcode = @import("intcode"); const IntcodeProgram = intcode.IntcodeProgram; const Address = u16; const Packet = struct { src: Address, dest: Address, x: i64, y: i64 }; const MessageQueue = ArrayList(i64); const file_content = @embedFile("../input.txt"); pub const NIC = struct { const Self = @This(); allocator: Allocator, address: Address, nic: IntcodeProgram, incoming: MessageQueue, outgoing: ArrayList(Packet), buf: ArrayList(i64), pub fn init(allocator: Allocator, code: []const i64, address: Address) !Self { var self = Self{ .allocator = allocator, .address = address, .nic = try IntcodeProgram.init(allocator, code), .incoming = try MessageQueue.initCapacity(allocator, 16), .outgoing = try ArrayList(Packet).initCapacity(allocator, 6), .buf = try ArrayList(i64).initCapacity(allocator, 18), }; // when each computer boots up, it will request its network address via a single input instruction self.incoming.appendAssumeCapacity(address); return self; } pub fn deinit(self: *Self) void { self.nic.deinit(); self.incoming.deinit(); self.outgoing.deinit(); self.buf.deinit(); } const no_data = [_]i64{-1}; /// Result can be picked up in self.outgoing. pub fn run(self: *Self) !void { // reset lists for outgoing messages self.outgoing.items.len = 0; self.buf.items.len = 0; const input = blk: { if (self.incoming.items.len > 0) { break :blk self.incoming.items; } else { // If the incoming packet queue is *empty*, provide `-1` break :blk no_data[0..]; } }; log.debug("NIC {d} starts running with input {d}", .{ self.address, input }); const status = try self.nic.run(i64, input, i64, &self.buf); debug.assert(status == .blocked); log.debug("NIC {d} finished with output {d}", .{ self.address, self.buf.items }); // reset incoming self.incoming.items.len = 0; // three i64 (addr, x, y) fit into a single packet try self.outgoing.ensureTotalCapacity(self.buf.items.len / 3); var i: usize = 0; const src = @intCast(u16, self.address); while (i < self.buf.items.len) : (i += 3) { const packet = Packet{ .src = src, .dest = @intCast(u16, self.buf.items[i]), .x = self.buf.items[i + 1], .y = self.buf.items[i + 2], }; self.outgoing.appendAssumeCapacity(packet); } log.debug("> NIC {d} sending: {s}", .{ self.address, self.outgoing.items }); } pub fn enqueue(self: *Self, packet: Packet) !void { if (packet.dest != self.address) { return error.PacketMismatch; } log.debug("> NIC {d}: adding {s} to queue", .{ self.address, packet }); try self.incoming.append(packet.x); try self.incoming.append(packet.y); } }; pub fn part1(allocator: Allocator) !i64 { var arena = std.heap.ArenaAllocator.init(allocator); defer arena.deinit(); var input = try intcode.parseInput(arena.allocator(), file_content); var network = AutoHashMap(Address, NIC).init(arena.allocator()); const computerCount = 50; var i: u16 = 0; while (i < computerCount) : (i += 1) { try network.put(i, try NIC.init(arena.allocator(), input, i)); } while (true) { var it = network.iterator(); while (it.next()) |kv| { var nic = kv.value_ptr; try nic.run(); for (nic.outgoing.items) |packet| { if (packet.dest == 255) { return packet.y; } if (network.getEntry(packet.dest)) |entry| { try entry.value_ptr.enqueue(packet); } } } } unreachable; } pub fn part2(allocator: Allocator) !i64 { var arena = std.heap.ArenaAllocator.init(allocator); defer arena.deinit(); var input = try intcode.parseInput(arena.allocator(), file_content); var network = AutoHashMap(Address, NIC).init(arena.allocator()); const computerCount = 50; var i: u16 = 0; while (i < computerCount) : (i += 1) { try network.put(i, try NIC.init(arena.allocator(), input, i)); } // addr 255 var nat: ?Packet = null; var last_packet_for_0: ?Packet = null; var is_idle: bool = undefined; var idle_counter: usize = 0; while (true) { is_idle = true; var it = network.iterator(); while (it.next()) |kv| { var nic = kv.value_ptr; try nic.run(); if (nic.outgoing.items.len > 0) { is_idle = false; } for (nic.outgoing.items) |packet| { if (packet.dest == 255) { nat = packet; } if (network.getEntry(packet.dest)) |entry| { try entry.value_ptr.enqueue(packet); } } } if (is_idle) { idle_counter += 1; log.debug("network is idle for {d} rounds. nat: {s}", .{ idle_counter, nat }); } if (idle_counter > 0) { if (nat) |packet| { log.debug("NAT delivering packet to 0: {s}", .{packet}); var packetCopy = packet; // do the NAT'ing packetCopy.src = 255; packetCopy.dest = 0; if (last_packet_for_0) |pk_for_0| { if (pk_for_0.x == packetCopy.x and pk_for_0.y == packetCopy.y) { return packetCopy.y; } } try network.getEntry(0).?.value_ptr.enqueue(packetCopy); last_packet_for_0 = packetCopy; nat = null; idle_counter = 0; } } } unreachable; } test "2019 Day 23, Part 1" { const answer = try part1(testing.allocator); try testing.expectEqual(@as(i64, 15662), answer); } test "2019 Day 23, Part 2" { const answer = try part2(testing.allocator); try testing.expectEqual(@as(i64, 10854), answer); }
day23/src/solve.zig
const std = @import("std"); const georgios = @import("georgios"); const utils = @import("utils"); const kernel = @import("kernel.zig"); const print = @import("print.zig"); const BuddyAllocator = @import("buddy_allocator.zig").BuddyAllocator; const platform = @import("platform.zig"); pub const AllocError = georgios.memory.AllocError; pub const FreeError = georgios.memory.FreeError; pub const MemoryError = georgios.memory.MemoryError; pub const Range = struct { start: usize = 0, size: usize = 0, pub fn from_bytes(bytes: []const u8) Range { return .{.start = @ptrToInt(bytes.ptr), .size = bytes.len}; } pub fn end(self: *const Range) usize { return self.start + self.size; } pub fn to_ptr(self: *const Range, comptime PtrType: type) PtrType { return @intToPtr(PtrType, self.start); } pub fn to_slice(self: *const Range, comptime Type: type) []Type { return utils.make_slice(Type, self.to_ptr([*]Type), self.size / @sizeOf(Type)); } }; /// Used by the platform to provide what real memory can be used for the real /// memory allocator. pub const RealMemoryMap = struct { const FrameGroup = struct { start: usize, frame_count: usize, }; frame_groups: [64]FrameGroup = undefined, frame_group_count: usize = 0, total_frame_count: usize = 0, fn invalid(self: *RealMemoryMap) bool { return self.frame_group_count == 0 or self.total_frame_count == 0; } /// Directly add a frame group. fn add_frame_group_impl(self: *RealMemoryMap, start: usize, frame_count: usize) void { if ((self.frame_group_count + 1) >= self.frame_groups.len) { @panic("Too many frame groups!"); } self.frame_groups[self.frame_group_count] = FrameGroup{ .start = start, .frame_count = frame_count, }; self.frame_group_count += 1; self.total_frame_count += frame_count; } /// Given a memory range, add a frame group if there are frames that can /// fit in it. pub fn add_frame_group(self: *RealMemoryMap, start: usize, end: usize) void { const aligned_start = utils.align_up(start, platform.frame_size); const aligned_end = utils.align_down(end, platform.frame_size); if (aligned_start < aligned_end) { self.add_frame_group_impl(aligned_start, (aligned_end - aligned_start) / platform.frame_size); } } }; var alloc_debug = false; pub const Allocator = struct { alloc_impl: fn(*Allocator, usize, usize) AllocError![]u8, free_impl: fn(*Allocator, []const u8, usize) FreeError!void, pub fn alloc(self: *Allocator, comptime Type: type) AllocError!*Type { if (alloc_debug) print.string( "Allocator.alloc: " ++ @typeName(Type) ++ "\n"); const rv = @ptrCast(*Type, @alignCast( @alignOf(Type), (try self.alloc_impl(self, @sizeOf(Type), @alignOf(Type))).ptr)); if (alloc_debug) print.format( "Allocator.alloc: " ++ @typeName(Type) ++ ": {:a}\n", .{@ptrToInt(rv)}); return rv; } pub fn free(self: *Allocator, value: anytype) FreeError!void { const traits = @typeInfo(@TypeOf(value)).Pointer; const bytes = utils.to_bytes(value); if (alloc_debug) print.format("Allocator.free: " ++ @typeName(@TypeOf(value)) ++ ": {:a}\n", .{@ptrToInt(bytes.ptr)}); try self.free_impl(self, bytes, traits.alignment); } pub fn alloc_array( self: *Allocator, comptime Type: type, count: usize) AllocError![]Type { if (alloc_debug) print.format( "Allocator.alloc_array: [{}]" ++ @typeName(Type) ++ "\n", .{count}); if (count == 0) { return AllocError.ZeroSizedAlloc; } const rv = @ptrCast([*]Type, @alignCast(@alignOf(Type), (try self.alloc_impl(self, @sizeOf(Type) * count, @alignOf(Type))).ptr))[0..count]; if (alloc_debug) print.format("Allocator.alloc_array: [{}]" ++ @typeName(Type) ++ ": {:a}\n", .{count, @ptrToInt(rv.ptr)}); return rv; } pub fn free_array(self: *Allocator, array: anytype) FreeError!void { const traits = @typeInfo(@TypeOf(array)).Pointer; if (alloc_debug) print.format( "Allocator.free_array: [{}]" ++ @typeName(traits.child) ++ ": {:a}\n", .{array.len, @ptrToInt(array.ptr)}); try self.free_impl(self, utils.to_const_bytes(array), traits.alignment); } pub fn alloc_range(self: *Allocator, size: usize) AllocError!Range { if (alloc_debug) print.format("Allocator.alloc_range: {}\n", .{size}); if (size == 0) { return AllocError.ZeroSizedAlloc; } const rv = Range{ .start = @ptrToInt((try self.alloc_impl(self, size, 1)).ptr), .size = size}; if (alloc_debug) print.format("Allocator.alloc_range: {}: {:a}\n", .{size, rv.start}); return rv; } pub fn free_range(self: *Allocator, range: Range) FreeError!void { if (alloc_debug) print.format( "Allocator.free_range: {}: {:a}\n", .{range.size, range.start}); try self.free_impl(self, range.to_slice(u8), 1); } }; pub const UnitTestAllocator = struct { const Self = @This(); const Impl = std.heap.ArenaAllocator; allocator: Allocator = undefined, impl: Impl = undefined, allocated: usize = undefined, pub fn init(self: *Self) void { self.impl = Impl.init(std.heap.page_allocator); self.allocator.alloc_impl = Self.alloc; self.allocator.free_impl = Self.free; self.allocated = 0; } pub fn done(self: *Self) void { std.testing.expectEqual(@as(usize, 0), self.allocated) catch @panic("outstanding allocations or wrong sizes"); self.impl.deinit(); } pub fn alloc(allocator: *Allocator, size: usize, align_to: usize) AllocError![]u8 { const self = @fieldParentPtr(Self, "allocator", allocator); self.allocated += size; const align_u29 = @truncate(u29, align_to); const rv = self.impl.allocator().allocBytes(align_u29, size, align_u29, @returnAddress()) catch return AllocError.OutOfMemory; return rv; } pub fn free(allocator: *Allocator, value: []const u8, aligned_to: usize) FreeError!void { const self = @fieldParentPtr(Self, "allocator", allocator); std.testing.expectEqual(true, self.allocated >= value.len) catch @panic("free arg is bigger than allocated sum"); self.allocated -= value.len; _ = self.impl.allocator().rawFree( @intToPtr([*]u8, @ptrToInt(value.ptr))[0..value.len], @truncate(u29, aligned_to), @returnAddress()); } }; /// Used by the kernel to manage system memory pub const Manager = struct { const alloc_size = utils.Mi(1); const AllocImplType = BuddyAllocator(alloc_size); impl: platform.MemoryMgrImpl = .{}, free_frame_count: usize = 0, alloc_range: Range = undefined, alloc_impl_range: Range = undefined, alloc_impl: *AllocImplType = undefined, alloc: *Allocator = undefined, big_alloc: *Allocator = undefined, /// To be called by the platform after it can give "map". pub fn init(self: *Manager, map: *RealMemoryMap) !void { print.debug_format( \\ - Initializing Memory System \\ - Start of kernel: \\ - Real: {:a} \\ - Virtual: {:a} \\ - End of kernel: \\ - Real: {:a} \\ - Virtual: {:a} \\ - Size of kernel is {} B ({} KiB) \\ - Frame Size: {} B ({} KiB) \\ , .{ platform.kernel_real_start(), platform.kernel_virtual_start(), platform.kernel_real_end(), platform.kernel_virtual_end(), platform.kernel_size(), platform.kernel_size() >> 10, platform.frame_size, platform.frame_size >> 10}); // Process RealMemoryMap if (map.invalid()) { @panic("RealMemoryMap is invalid!"); } print.debug_string(" - Frame Groups:\n"); for (map.frame_groups[0..map.frame_group_count]) |*i| { print.debug_format(" - {} Frames starting at {:a} \n", .{i.frame_count, i.start}); } // Initialize Platform Implementation // After this we should be able to manage all the memory on the system. self.impl.init(self, map); // List Memory const total_memory: usize = map.total_frame_count * platform.frame_size; const indent = if (print.debug_print) " - " else ""; print.format( "{}Total Available Memory: {} B ({} KiB/{} MiB/{} GiB)\n", .{ indent, total_memory, total_memory >> 10, total_memory >> 20, total_memory >> 30}); self.alloc_impl = try self.big_alloc.alloc(AllocImplType); try self.alloc_impl.init(try self.big_alloc.alloc([alloc_size]u8)); self.alloc = &self.alloc_impl.allocator; kernel.alloc = self.alloc; kernel.big_alloc = self.big_alloc; } pub fn free_pmem(self: *Manager, frame: usize) void { self.impl.push_frame(frame); self.free_frame_count += 1; } pub fn alloc_pmem(self: *Manager) AllocError!usize { const frame = try self.impl.pop_frame(); self.free_frame_count -= 1; return frame; } };
kernel/memory.zig
const std = @import("std"); const fs = @import("fs.zig"); const debug = std.debug; const heap = std.heap; const mem = std.mem; const fmt = std.fmt; const os = std.os; const rand = std.rand; fn countParents(comptime Folder: type, folder: *Folder) usize { var res: usize = 0; var tmp = folder; while (tmp.parent) |par| { tmp = par; res += 1; } return res; } fn randomFs(allocator: *mem.Allocator, random: *rand.Random, comptime Folder: type) !*Folder { comptime debug.assert(Folder == fs.Nitro or Folder == fs.Narc); const root = try Folder.create(allocator); var unique: u64 = 0; var curr: ?*Folder = root; while (curr) |folder| { const parents = countParents(Folder, folder); const choice = random.range(usize, 0, 255); if (choice < parents + folder.nodes.len) { curr = folder.parent; break; } const is_file = random.scalar(bool); var name_buf: [50]u8 = undefined; const name = try fmt.bufPrint(name_buf[0..], "{}", unique); unique += 1; if (is_file) { switch (Folder) { fs.Nitro => { _ = try folder.createFile(name, blk: { const is_narc = random.scalar(bool); if (is_narc) { break :blk fs.Nitro.File{ .Narc = try randomFs(allocator, random, fs.Narc) }; } const data = try allocator.alloc(u8, random.range(usize, 10, 100)); random.bytes(data); break :blk fs.Nitro.File{ .Binary = fs.Nitro.File.Binary{ .allocator = allocator, .data = data, }, }; }); }, fs.Narc => { const data = try allocator.alloc(u8, random.range(usize, 10, 100)); random.bytes(data); _ = try folder.createFile(name, fs.Narc.File{ .allocator = allocator, .data = data, }); }, else => comptime unreachable, } } else { curr = try folder.createFolder(name); } } return root; } fn fsEqual(allocator: *mem.Allocator, comptime Folder: type, fs1: *Folder, fs2: *Folder) !bool { comptime debug.assert(Folder == fs.Nitro or Folder == fs.Narc); const FolderPair = struct { f1: *Folder, f2: *Folder, }; var folders_to_compare = std.ArrayList(FolderPair).init(allocator); defer folders_to_compare.deinit(); try folders_to_compare.append(FolderPair{ .f1 = fs1, .f2 = fs2, }); while (folders_to_compare.popOrNull()) |pair| { for (pair.f1.nodes.toSliceConst()) |n1| { switch (n1.kind) { Folder.Node.Kind.File => |f1| { const f2 = pair.f2.getFile(n1.name) orelse return false; switch (Folder) { fs.Nitro => { const Tag = @TagType(fs.Nitro.File); switch (f1.*) { Tag.Binary => { if (f2.* != Tag.Binary) return false; if (!mem.eql(u8, f1.Binary.data, f2.Binary.data)) return false; }, Tag.Narc => { if (f2.* != Tag.Narc) return false; if (!try fsEqual(allocator, fs.Narc, f1.Narc, f2.Narc)) return false; }, } }, fs.Narc => { if (!mem.eql(u8, f1.data, f2.data)) return false; }, else => comptime unreachable, } }, Folder.Node.Kind.Folder => |f1| { const f2 = pair.f2.getFolder(n1.name) orelse return false; try folders_to_compare.append(FolderPair{ .f1 = f1, .f2 = f2, }); }, } } } return true; } const TestFolder = fs.Folder(struct { // TODO: We cannot compare pointers to zero sized types, so this field have to exist. a: u8, fn deinit(file: *this) void {} }); fn assertError(res: var, expected: anyerror) void { if (res) |_| { unreachable; } else |actual| { debug.assert(expected == actual); } } test "nds.fs.Folder.deinit" { // TODO: To test deinit, we need a leak detector. } test "nds.fs.Folder.createFile" { var buf: [2 * 1024]u8 = undefined; var fix_buf_alloc = heap.FixedBufferAllocator.init(buf[0..]); const allocator = &fix_buf_alloc.allocator; const root = try TestFolder.create(allocator); const a = try root.createFile("a", undefined); const b = root.getFile("a") orelse unreachable; debug.assert(@ptrToInt(a) == @ptrToInt(b)); assertError(root.createFile("a", undefined), error.NameExists); assertError(root.createFile("/", undefined), error.InvalidName); } test "nds.fs.Folder.createFolder" { var buf: [2 * 1024]u8 = undefined; var fix_buf_alloc = heap.FixedBufferAllocator.init(buf[0..]); const allocator = &fix_buf_alloc.allocator; const root = try TestFolder.create(allocator); const a = try root.createFolder("a"); const b = root.getFolder("a") orelse unreachable; debug.assert(@ptrToInt(a) == @ptrToInt(b)); assertError(root.createFolder("a"), error.NameExists); assertError(root.createFolder("/"), error.InvalidName); } test "nds.fs.Folder.createPath" { var buf: [3 * 1024]u8 = undefined; var fix_buf_alloc = heap.FixedBufferAllocator.init(buf[0..]); const allocator = &fix_buf_alloc.allocator; const root = try TestFolder.create(allocator); const a = try root.createPath("b/a"); const b = root.getFolder("b/a") orelse unreachable; debug.assert(@ptrToInt(a) == @ptrToInt(b)); _ = try root.createFile("a", undefined); assertError(root.createPath("a"), error.FileInPath); } test "nds.fs.Folder.getFile" { var buf: [2 * 1024]u8 = undefined; var fix_buf_alloc = heap.FixedBufferAllocator.init(buf[0..]); const allocator = &fix_buf_alloc.allocator; const root = try TestFolder.create(allocator); const a = try root.createFolder("a"); _ = try root.createFile("a1", undefined); _ = try a.createFile("a2", undefined); const a1 = root.getFile("a1") orelse unreachable; const a2 = a.getFile("a2") orelse unreachable; const a1_root = a.getFile("/a1") orelse unreachable; debug.assert(root.getFile("a2") == null); debug.assert(a.getFile("a1") == null); const a2_path = root.getFile("a/a2") orelse unreachable; debug.assert(@ptrToInt(a1) == @ptrToInt(a1_root)); debug.assert(@ptrToInt(a2) == @ptrToInt(a2_path)); } test "nds.fs.Folder.getFolder" { var buf: [3 * 1024]u8 = undefined; var fix_buf_alloc = heap.FixedBufferAllocator.init(buf[0..]); const allocator = &fix_buf_alloc.allocator; const root = try TestFolder.create(allocator); const a = try root.createFolder("a"); _ = try root.createFolder("a1"); _ = try a.createFolder("a2"); const a1 = root.getFolder("a1") orelse unreachable; const a2 = a.getFolder("a2") orelse unreachable; const a1_root = a.getFolder("/a1") orelse unreachable; debug.assert(root.getFolder("a2") == null); debug.assert(a.getFolder("a1") == null); const a2_path = root.getFolder("a/a2") orelse unreachable; debug.assert(@ptrToInt(a1) == @ptrToInt(a1_root)); debug.assert(@ptrToInt(a2) == @ptrToInt(a2_path)); } test "nds.fs.Folder.exists" { var buf: [2 * 1024]u8 = undefined; var fix_buf_alloc = heap.FixedBufferAllocator.init(buf[0..]); const allocator = &fix_buf_alloc.allocator; const root = try TestFolder.create(allocator); _ = try root.createFolder("a"); _ = try root.createFile("b", undefined); debug.assert(root.exists("a")); debug.assert(root.exists("b")); debug.assert(!root.exists("c")); } test "nds.fs.Folder.root" { var buf: [7 * 1024]u8 = undefined; var fix_buf_alloc = heap.FixedBufferAllocator.init(buf[0..]); const allocator = &fix_buf_alloc.allocator; const root = try TestFolder.create(allocator); const a = try root.createPath("a"); const b = try root.createPath("a/b"); const c = try root.createPath("a/b/c"); const d = try root.createPath("c/b/d"); debug.assert(@ptrToInt(root) == @ptrToInt(root.root())); debug.assert(@ptrToInt(root) == @ptrToInt(a.root())); debug.assert(@ptrToInt(root) == @ptrToInt(b.root())); debug.assert(@ptrToInt(root) == @ptrToInt(c.root())); debug.assert(@ptrToInt(root) == @ptrToInt(d.root())); } test "nds.fs.read/writeNitro" { var buf: [400 * 1024]u8 = undefined; var fix_buf_alloc = heap.FixedBufferAllocator.init(buf[0..]); var random = rand.DefaultPrng.init(0); const allocator = &fix_buf_alloc.allocator; const root = try randomFs(allocator, &random.random, fs.Nitro); const fntAndFiles = try fs.getFntAndFiles(fs.Nitro, root, allocator); const files = fntAndFiles.files; const main_fnt = fntAndFiles.main_fnt; const sub_fnt = fntAndFiles.sub_fnt; const fnt_buff_size = @sliceToBytes(main_fnt).len + sub_fnt.len; const fnt_buff = try allocator.alloc(u8, fnt_buff_size); const fnt = try fmt.bufPrint(fnt_buff, "{}{}", @sliceToBytes(main_fnt), sub_fnt); var fat = std.ArrayList(fs.FatEntry).init(allocator); const test_file = "__nds.fs.test.read.write__"; defer os.deleteFile(test_file) catch unreachable; { var file = try os.File.openWrite(test_file); defer file.close(); for (files) |f| { const pos = @intCast(u32, try file.getPos()); try fs.writeNitroFile(file, allocator, f.*); fat.append(fs.FatEntry.init(pos, @intCast(u32, try file.getPos()) - pos)) catch unreachable; } } const fs2 = blk: { var file = try os.File.openRead(test_file); defer file.close(); break :blk try fs.readNitro(file, allocator, fnt, fat.toSlice()); }; debug.assert(try fsEqual(allocator, fs.Nitro, root, fs2)); }
src/nds/test.zig
const std = @import("std"); const warn = std.debug.warn; const assert = std.debug.assert; const types = @import("types.zig"); /// Class file loader type. pub const Loader = struct { file: std.fs.File, fn primitive(self: Loader, comptime T: type) !T { const size = @sizeOf(T); var buffer: [size]u8 = undefined; const n = try self.file.read(buffer[0..size]); assert(n == size); return std.mem.bigToNative(T, @bitCast(T, buffer)); } fn bytes(self: Loader, len: usize) ![]u8 { const buf = try types.allocator.alloc(u8, len); const n = try self.file.read(buf); assert(n == len); return buf; } fn constant(self: Loader) !types.Const { return switch (@intToEnum(types.ConstTag, try self.primitive(u8))) { types.ConstTag.class => types.Const{ .class = try self.primitive(u16), }, types.ConstTag.string => types.Const{ .string = try self.primitive(u16), }, types.ConstTag.utf8 => types.Const{ .utf8 = try self.bytes(try self.primitive(u16)), }, types.ConstTag.field => types.Const{ .field = types.FieldRef{ .class = try self.primitive(u16), .name_and_type = try self.primitive(u16), }, }, types.ConstTag.method => types.Const{ .method = types.FieldRef{ .class = try self.primitive(u16), .name_and_type = try self.primitive(u16), }, }, types.ConstTag.name_and_type => types.Const{ .name_and_type = types.NameAndType{ .name = try self.primitive(u16), .t = try self.primitive(u16), }, }, types.ConstTag.unused => types.Const{ .unused = true }, }; } fn constPool(self: Loader) ![]types.Const { const len = try self.primitive(u16); warn("Class.constant_pool length: {}\n", .{len}); const ret = try types.allocator.alloc(types.Const, len); warn("Class.constant_pool [\n", .{}); for (ret) |*v, i| { // The constant_pool table is indexed from 1 to constant_pool_count - 1. // https://docs.oracle.com/javase/specs/jvms/se14/html/jvms-4.html#jvms-4.1 v.* = if (i == 0) types.Const{ .unused = true } else try self.constant(); warn(" {}: {}\n", .{ i, v }); } warn("]\n", .{}); return ret; } fn interfaces(self: Loader, cls: types.Class) ![]([]const u8) { const n = try self.primitive(u16); const ret = try types.allocator.alloc([]const u8, n); for (ret) |*intf, i| { intf.* = cls.utf8(try self.primitive(u16)); warn("Class.interfaces[{}]: {}", .{ i, intf }); } return ret; } fn attributes(self: Loader, cls: types.Class) ![]types.Attribute { const n = try self.primitive(u16); const ret = try types.allocator.alloc(types.Attribute, n); for (ret) |*a, i| { a.* = types.Attribute{ .name = cls.utf8(try self.primitive(u16)), .data = try self.bytes(try self.primitive(u32)), }; warn("attribute {}, name: {s}, len: {}\n", .{ i, a.name, a.data.len, }); } return ret; } fn fields(self: Loader, cls: types.Class) ![]types.Field { const n = try self.primitive(u16); const ret = try types.allocator.alloc(types.Field, n); for (ret) |*f, i| { f.* = types.Field{ .flags = try self.primitive(u16), .name = cls.utf8(try self.primitive(u16)), .t = cls.utf8(try self.primitive(u16)), .attributes = try self.attributes(cls), }; warn("field {}: {}\n", .{ i, f }); } return ret; } /// ClassFile { /// u4 magic; /// u2 minor_version; /// u2 major_version; /// u2 constant_pool_count; /// cp_info constant_pool[constant_pool_count-1]; /// u2 access_flags; /// u2 this_class; /// u2 super_class; /// u2 interfaces_count; /// u2 interfaces[interfaces_count]; /// u2 fields_count; /// field_info fields[fields_count]; /// u2 methods_count; /// method_info methods[methods_count]; /// u2 attributes_count; /// attribute_info attributes[attributes_count]; /// } pub fn class(self: Loader) !types.Class { var ret: types.Class = undefined; // Loads header. var buffer: [4]u8 = undefined; const n = try self.file.read(buffer[0..buffer.len]); assert(n == 4); assert(buffer[0] == 0xca); assert(buffer[1] == 0xfe); assert(buffer[2] == 0xba); assert(buffer[3] == 0xbe); ret.minor_version = try self.primitive(u16); ret.major_version = try self.primitive(u16); warn("class version {}.{}\n", .{ ret.major_version, ret.minor_version }); assert(ret.major_version >= 45); // Loads constants. ret.constant_pool = try self.constPool(); // Loads class fields. ret.flags = try self.primitive(u16); ret.name = ret.utf8(try self.primitive(u16)); warn("Class.name: {s}\n", .{ret.name}); ret.super = ret.utf8(try self.primitive(u16)); warn("Class.super: {s}\n", .{ret.super}); ret.interfaces = try self.interfaces(ret); warn("Class.fields:\n", .{}); ret.fields = try self.fields(ret); warn("Class.methods:\n", .{}); ret.methods = try self.fields(ret); warn("Class.attributes:\n", .{}); ret.attributes = try self.attributes(ret); return ret; } }; test "load test/Add.class" { const file = try std.fs.cwd().openFile("test/Add.class", .{}); defer file.close(); const loader = Loader{ .file = file }; const c = try loader.class(); defer c.deinit(); // version assert(c.major_version == 55); assert(c.minor_version == 0); // const pool assert(c.constant_pool.len == 15); assert(c.constant_pool[0].unused); assert(c.constant_pool[1].method.class == 3); assert(c.constant_pool[1].method.name_and_type == 12); assert(c.constant_pool[2].class == 13); assert(c.constant_pool[3].class == 14); assert(std.mem.eql(u8, c.constant_pool[4].utf8, "<init>")); assert(std.mem.eql(u8, c.constant_pool[5].utf8, "()V")); assert(std.mem.eql(u8, c.constant_pool[6].utf8, "Code")); assert(std.mem.eql(u8, c.constant_pool[7].utf8, "LineNumberTable")); assert(std.mem.eql(u8, c.constant_pool[8].utf8, "add")); assert(std.mem.eql(u8, c.constant_pool[9].utf8, "(II)I")); assert(std.mem.eql(u8, c.constant_pool[10].utf8, "SourceFile")); assert(std.mem.eql(u8, c.constant_pool[11].utf8, "Add.java")); assert(c.constant_pool[12].name_and_type.name == 4); assert(c.constant_pool[12].name_and_type.t == 5); assert(std.mem.eql(u8, c.constant_pool[13].utf8, "Add")); assert(std.mem.eql(u8, c.constant_pool[14].utf8, "java/lang/Object")); // other fields assert(std.mem.eql(u8, c.name, "Add")); assert(std.mem.eql(u8, c.super, "java/lang/Object")); assert(c.fields.len == 0); assert(c.methods.len == 2); assert(std.mem.eql(u8, c.methods[0].name, "<init>")); assert(std.mem.eql(u8, c.methods[1].name, "add")); assert(c.attributes.len == 1); assert(std.mem.eql(u8, c.attributes[0].name, "SourceFile")); }
src/loader.zig
const uefi = @import("std").os.uefi; const Guid = uefi.Guid; pub const ConfigurationTable = extern struct { vendor_guid: Guid, vendor_table: *c_void, pub const acpi_20_table_guid align(8) = Guid{ .time_low = 0x8868e871, .time_mid = 0xe4f1, .time_high_and_version = 0x11d3, .clock_seq_high_and_reserved = 0xbc, .clock_seq_low = 0x22, .node = [_]u8{ 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81 }, }; pub const acpi_10_table_guid align(8) = Guid{ .time_low = 0xeb9d2d30, .time_mid = 0x2d88, .time_high_and_version = 0x11d3, .clock_seq_high_and_reserved = 0x9a, .clock_seq_low = 0x16, .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }, }; pub const sal_system_table_guid align(8) = Guid{ .time_low = 0xeb9d2d32, .time_mid = 0x2d88, .time_high_and_version = 0x113d, .clock_seq_high_and_reserved = 0x9a, .clock_seq_low = 0x16, .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }, }; pub const smbios_table_guid align(8) = Guid{ .time_low = 0xeb9d2d31, .time_mid = 0x2d88, .time_high_and_version = 0x11d3, .clock_seq_high_and_reserved = 0x9a, .clock_seq_low = 0x16, .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }, }; pub const smbios3_table_guid align(8) = Guid{ .time_low = 0xf2fd1544, .time_mid = 0x9794, .time_high_and_version = 0x4a2c, .clock_seq_high_and_reserved = 0x99, .clock_seq_low = 0x2e, .node = [_]u8{ 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 }, }; pub const mps_table_guid align(8) = Guid{ .time_low = 0xeb9d2d2f, .time_mid = 0x2d88, .time_high_and_version = 0x11d3, .clock_seq_high_and_reserved = 0x9a, .clock_seq_low = 0x16, .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }, }; pub const json_config_data_table_guid align(8) = Guid{ .time_low = 0x87367f87, .time_mid = 0x1119, .time_high_and_version = 0x41ce, .clock_seq_high_and_reserved = 0xaa, .clock_seq_low = 0xec, .node = [_]u8{ 0x8b, 0xe0, 0x11, 0x1f, 0x55, 0x8a }, }; pub const json_capsule_data_table_guid align(8) = Guid{ .time_low = 0x35e7a725, .time_mid = 0x8dd2, .time_high_and_version = 0x4cac, .clock_seq_high_and_reserved = 0x80, .clock_seq_low = 0x11, .node = [_]u8{ 0x33, 0xcd, 0xa8, 0x10, 0x90, 0x56 }, }; pub const json_capsule_result_table_guid align(8) = Guid{ .time_low = 0xdbc461c3, .time_mid = 0xb3de, .time_high_and_version = 0x422a, .clock_seq_high_and_reserved = 0xb9, .clock_seq_low = 0xb4, .node = [_]u8{ 0x98, 0x86, 0xfd, 0x49, 0xa1, 0xe5 }, }; };
lib/std/os/uefi/tables/configuration_table.zig
// SPDX-License-Identifier: MIT // This file is part of the `termcon` project under the MIT license. const c = @cImport({ @cInclude("termios.h"); @cInclude("sys/ioctl.h"); }); const std = @import("std"); const stdin = std.io.getStdIn(); const stdout = std.io.getStdOut(); const cursor = @import("cursor.zig"); const view = @import("../../view.zig"); pub const Size = view.Size; pub const Rune = view.Rune; pub const Style = view.Style; const Color = view.Color; const ColorType = view.ColorType; const ColorNamed8 = view.ColorNamed8; const ColorNamed16 = view.ColorNamed16; const ColorBit8 = view.ColorBit8; const ColorBit24 = view.ColorBit24; const Position = view.Position; /// Get the size of the screen in terms of rows and columns. pub fn getSize() !Size { var ws: c.winsize = undefined; var filehandle = stdout.handle; // TODO: Set to "/dev/tty" raw filehandle if available if (c.ioctl(filehandle, c.TIOCGWINSZ, &ws) < 0 or ws.ws_col == 0 or ws.ws_row == 0) { _ = try stdout.writer().write("\x1b[65535C\x1b[65535B"); const position: Position = try cursor.getPosition(); return Size{ .rows = position.row, .cols = position.col, }; } else { return Size{ .rows = ws.ws_row, .cols = ws.ws_col, }; } } fn writeStyle(style: Style) !void { const writer = stdout.writer(); _ = try writer.write("\x1b[0m"); if (style.text_decorations.italic) { _ = try writer.write("\x1b[3m"); } if (style.text_decorations.bold) { _ = try writer.write("\x1b[1m"); } if (style.text_decorations.underline) { _ = try writer.write("\x1b[4m"); } switch (style.fg_color) { ColorType.Default => { _ = try writer.write("\x1b[39m"); }, ColorType.Named8 => |v| switch (v) { ColorNamed8.Black => { _ = try writer.write("\x1b[30m"); }, ColorNamed8.Red => { _ = try writer.write("\x1b[31m"); }, ColorNamed8.Green => { _ = try writer.write("\x1b[32m"); }, ColorNamed8.Yellow => { _ = try writer.write("\x1b[33m"); }, ColorNamed8.Blue => { _ = try writer.write("\x1b[34m"); }, ColorNamed8.Magenta => { _ = try writer.write("\x1b[35m"); }, ColorNamed8.Cyan => { _ = try writer.write("\x1b36m"); }, ColorNamed8.White => { _ = try writer.write("\x1b37m"); }, }, ColorType.Named16 => |v| switch (v) { ColorNamed16.Black => { _ = try writer.write("\x1b[30m"); }, ColorNamed16.Red => { _ = try writer.write("\x1b[31m"); }, ColorNamed16.Green => { _ = try writer.write("\x1b[32m"); }, ColorNamed16.Yellow => { _ = try writer.write("\x1b[33m"); }, ColorNamed16.Blue => { _ = try writer.write("\x1b[34m"); }, ColorNamed16.Magenta => { _ = try writer.write("\x1b[35m"); }, ColorNamed16.Cyan => { _ = try writer.write("\x1b36m"); }, ColorNamed16.White => { _ = try writer.write("\x1b37m"); }, ColorNamed16.BrightBlack => { _ = try writer.write("\x1b[90m"); }, ColorNamed16.BrightRed => { _ = try writer.write("\x1b[91m"); }, ColorNamed16.BrightGreen => { _ = try writer.write("\x1b[92m"); }, ColorNamed16.BrightYellow => { _ = try writer.write("\x1b[93m"); }, ColorNamed16.BrightBlue => { _ = try writer.write("\x1b[94m"); }, ColorNamed16.BrightMagenta => { _ = try writer.write("\x1b[95m"); }, ColorNamed16.BrightCyan => { _ = try writer.write("\x1b96m"); }, ColorNamed16.BrightWhite => { _ = try writer.write("\x1b97m"); }, }, ColorType.Bit8 => |v| { _ = try writer.print("\x1b[38;5;{}m", .{v.code}); }, ColorType.Bit24 => |v| { _ = try writer.print( "\x1b[38;2;{};{};{}m", .{ v.code >> 16, (v.code & 255) >> 8, v.code & 255, }, ); }, } switch (style.bg_color) { ColorType.Default => { _ = try writer.write("\x1b[49m"); }, ColorType.Named8 => |v| switch (v) { ColorNamed8.Black => { _ = try writer.write("\x1b[40m"); }, ColorNamed8.Red => { _ = try writer.write("\x1b[41m"); }, ColorNamed8.Green => { _ = try writer.write("\x1b[42m"); }, ColorNamed8.Yellow => { _ = try writer.write("\x1b[44m"); }, ColorNamed8.Blue => { _ = try writer.write("\x1b[44m"); }, ColorNamed8.Magenta => { _ = try writer.write("\x1b[45m"); }, ColorNamed8.Cyan => { _ = try writer.write("\x1b46m"); }, ColorNamed8.White => { _ = try writer.write("\x1b47m"); }, }, ColorType.Named16 => |v| switch (v) { ColorNamed16.Black => { _ = try writer.write("\x1b[40m"); }, ColorNamed16.Red => { _ = try writer.write("\x1b[41m"); }, ColorNamed16.Green => { _ = try writer.write("\x1b[42m"); }, ColorNamed16.Yellow => { _ = try writer.write("\x1b[44m"); }, ColorNamed16.Blue => { _ = try writer.write("\x1b[44m"); }, ColorNamed16.Magenta => { _ = try writer.write("\x1b[45m"); }, ColorNamed16.Cyan => { _ = try writer.write("\x1b46m"); }, ColorNamed16.White => { _ = try writer.write("\x1b47m"); }, ColorNamed16.BrightBlack => { _ = try writer.write("\x1b[100m"); }, ColorNamed16.BrightRed => { _ = try writer.write("\x1b[101m"); }, ColorNamed16.BrightGreen => { _ = try writer.write("\x1b[102m"); }, ColorNamed16.BrightYellow => { _ = try writer.write("\x1b[103m"); }, ColorNamed16.BrightBlue => { _ = try writer.write("\x1b[104m"); }, ColorNamed16.BrightMagenta => { _ = try writer.write("\x1b[105m"); }, ColorNamed16.BrightCyan => { _ = try writer.write("\x1b106m"); }, ColorNamed16.BrightWhite => { _ = try writer.write("\x1b107m"); }, }, ColorType.Bit8 => |v| { _ = try writer.print("\x1b[48;5;{}m", .{v.code}); }, ColorType.Bit24 => |v| { _ = try writer.print( "\x1b[48;2;{};{};{}m", .{ v.code >> 16, (v.code & 255) >> 8, v.code & 255, }, ); }, } } /// Write styled text to the screen at the cursor's position, /// moving the cursor accordingly. pub fn write(runes: []const Rune, styles: []const Style) !void { if (runes.len != styles.len) return error.BackendError; if (runes.len == 0) return; var orig_style_index: usize = 0; try writeStyle(styles[0]); for (styles) |style, index| { if (!styles[orig_style_index].equal(style)) { _ = try stdout.writer().write(runes[orig_style_index..index]); orig_style_index = index; try writeStyle(style); } } _ = try stdout.writer().write(runes[orig_style_index..]); _ = try stdout.writer().write("\x1b[0m"); } /// Clear all runes and styles at the cursor's row. pub fn clearLine() !void { _ = try stdout.writer().write("\x1b[2K"); } /// Clear all runes and styles on the screen. pub fn clearScreen() !void { _ = try stdout.writer().write("\x1b[2J"); }
src/backend/termios/screen.zig
const os = @import("root").os; const std = @import("std"); const interrupts = @import("interrupts.zig"); const idt = @import("idt.zig"); const gdt = @import("gdt.zig"); const serial = @import("serial.zig"); const ports = @import("ports.zig"); const regs = @import("regs.zig"); const apic = @import("apic.zig"); const pci = os.platform.pci; const Tss = @import("tss.zig").Tss; pub const paging = @import("paging.zig"); pub const pci_space = @import("pci_space.zig"); pub const thread = @import("thread.zig"); pub const PagingRoot = u64; pub const InterruptFrame = interrupts.InterruptFrame; pub const InterruptState = interrupts.InterruptState; pub const irq_eoi = apic.eoi; fn setup_syscall_instr() void { if(comptime !os.config.kernel.x86_64.allow_syscall_instr) return; regs.IA32_LSTAR.write(@ptrToInt(interrupts.syscall_handler)); // Clear everything but the res1 bit (bit 1) regs.IA32_FMASK.write(@truncate(u22, ~@as(u64, 1 << 1))); comptime { if(gdt.selector.data64 != gdt.selector.code64 + 8) @compileError("syscall instruction assumes this"); } regs.IA32_STAR.write(@as(u64, gdt.selector.code64) << 32); // Allow syscall instructions regs.IA32_EFER.write(regs.IA32_EFER.read() | (1 << 0)); } pub fn get_and_disable_interrupts() InterruptState { return regs.eflags() & 0x200 == 0x200; } pub fn set_interrupts(s: InterruptState) void { if(s) { asm volatile( \\sti ); } else { asm volatile( \\cli ); } } pub fn platform_init() !void { try os.platform.acpi.init_acpi(); apic.enable(); set_interrupts(true); if(comptime(os.config.kernel.x86_64.ps2.enable_keyboard)) { const ps2 = @import("ps2.zig"); ps2.kb_interrupt_vector = interrupts.allocate_vector(); os.log("PS2 keyboard: vector 0x{X}\n", .{ps2.kb_interrupt_vector}); interrupts.add_handler(ps2.kb_interrupt_vector, ps2.kb_handler, true, 3, 1); ps2.kb_interrupt_gsi = apic.route_irq(0, 1, ps2.kb_interrupt_vector); os.log("PS2 keyboard: gsi 0x{X}\n", .{ps2.kb_interrupt_gsi}); ps2.kb_init(); } try os.platform.pci.init_pci(); } pub fn platform_early_init() void { os.platform.smp.prepare(); serial.init(); interrupts.init_interrupts(); os.platform.smp.cpus[0].platform_data.gdt.load(); os.memory.paging.init(); } pub fn bsp_pre_scheduler_init() void { idt.load_idt(); apic.enable(); setup_syscall_instr(); const cpu = os.platform.thread.get_current_cpu(); thread.bsp_task.platform_data.tss = os.vital(os.memory.vmm.backed(.Eternal).create(Tss), "alloc bsp tss"); thread.bsp_task.platform_data.tss.* = .{}; thread.bsp_task.platform_data.tss.set_interrupt_stack(cpu.int_stack); thread.bsp_task.platform_data.tss.set_scheduler_stack(cpu.sched_stack); thread.bsp_task.platform_data.load_state(); } pub fn ap_init() noreturn { os.memory.paging.kernel_context.apply(); idt.load_idt(); setup_syscall_instr(); const cpu = os.platform.thread.get_current_cpu(); cpu.platform_data.gdt.load(); asm volatile( \\mov %[stack], %%rsp \\jmp *%[dest] : : [stack] "rm" (cpu.sched_stack) , [_] "{rdi}" (cpu) , [dest] "r" (ap_init_stage2) ); unreachable; } fn ap_init_stage2() noreturn { _ = @atomicRmw(usize, &os.platform.smp.cpus_left, .Sub, 1, .AcqRel); // Wait for tasks asm volatile( \\int %[boostrap_vector] \\ : : [boostrap_vector] "i" (interrupts.boostrap_vector) ); unreachable; } pub fn spin_hint() void { asm volatile("pause"); } pub fn await_interrupt() void { asm volatile( \\sti \\hlt \\cli : : : "memory" ); } pub fn debugputch(ch: u8) void { ports.outb(0xe9, ch); serial.port(1).write(ch); serial.port(2).write(ch); serial.port(3).write(ch); serial.port(4).write(ch); } pub fn clock() usize { var eax: u32 = undefined; var edx: u32 = undefined; asm volatile ("rdtsc" : [_] "={eax}" (eax), [_] "={edx}" (edx), ); return @as(usize, eax) + (@as(usize, edx) << 32); }
src/platform/x86_64/x86_64.zig
const std = @import("std"); const zt = @import("../zt.zig"); usingnamespace @import("gl"); const Self = @This(); pub const VertShaderSource = @embedFile("shader/renderer.vertex"); pub const FragShaderSource = @embedFile("shader/renderer.fragment"); pub const Vertex = extern struct { pos: zt.math.Vec3, col: zt.math.Vec4, tex: zt.math.Vec2 }; internal: zt.gl.GenerateBuffer(Vertex, 4086) = undefined, viewMatrix: zt.math.Mat4 = zt.math.Mat4.identity, inverseViewMatrix: zt.math.Mat4 = zt.math.Mat4.identity, projectionMatrix: zt.math.Mat4 = zt.math.Mat4.identity, currentTexture: ?zt.gl.Texture = null, defaultShader: zt.gl.Shader = undefined, /// Internal render size, do not edit. Is set by `updateRenderSize`. buildSize: zt.math.Vec2 = .{}, resolution: i32 = 2, pub fn createShader(fragment:[*:0]const u8) zt.gl.Shader { return zt.gl.Shader.init(VertShaderSource, fragment); } pub fn init() @This() { var renderer = Self{ .defaultShader = zt.gl.Shader.init(VertShaderSource, FragShaderSource), .projectionMatrix = zt.math.Mat4.createOrthogonal(0, 1280, 720, 0, -128, 128), .viewMatrix = zt.math.Mat4.identity, }; renderer.internal = zt.gl.GenerateBuffer(Vertex, 4086).init(renderer.defaultShader); return renderer; } pub fn deinit(self: *Self) void { self.internal.deinit(); } /// Sets the render size, perfect to modify if you need to render into a differently sized frame buffer. Otherwise call /// this every frame to your `zt.App.width, height` pub fn updateRenderSize(self: *Self, size: zt.math.Vec2) void { self.projectionMatrix = zt.math.Mat4.createOrthogonal(0, size.x, size.y, 0, -128, 128); self.buildSize = size; } /// Given a position, zoom, and rotation, this function emulates a traditional 2d camera by directly modifying /// the view matrix. pub fn updateCamera(self: *Self, position: zt.math.Vec2, zoom: f32, rotation: f32) void { self.viewMatrix = zt.math.Mat4.batchMul(&.{ zt.math.Mat4.createTranslationXYZ(position.x, position.y, 0), // translate zt.math.Mat4.createZRotation(rotation), // Rotation zt.math.Mat4.createScale(zoom, zoom, 1.0), // Scale zt.math.Mat4.createTranslationXYZ(self.buildSize.x * 0.5, self.buildSize.y * 0.5, 0), // center }); self.inverseViewMatrix = self.viewMatrix.invert().?; } /// Resets the camera back to screenspace. pub fn updateCameraScreenSpace(self: *Self) void { self.viewMatrix = zt.math.Mat4.identity; self.inverseViewMatrix = self.viewMatrix.invert().?; } /// Sets the shader used by the internal buffer. Pass in null to revert to the default shader. pub fn updateShader(self:*Self, shader:?*zt.gl.Shader) void { self.flush(); if(shader) |realShader| { self.internal.shader = realShader.*; } else { self.internal.shader = self.defaultShader; } } /// The simplest sprite method. Passing null to normalized origin will draw top-left based. Passing null to source will /// draw the whole texture. Note; normalized origin is multiplicative. 1,1 will draw the texture from bottom right, providing /// beyond 0 and 1 is supported if the anchor needs to be pub inline fn sprite(self: *Self, texture: zt.gl.Texture, pos: zt.math.Vec2, z: f32, size: zt.math.Vec2, color: zt.math.Vec4, normOrigin: ?zt.math.Vec2, src: ?zt.math.Rect) void { const offset: zt.math.Vec2 = if (normOrigin) |no| .{ .x = -(size.x * no.x), .y = -(size.y * no.y) } else .{}; const source: zt.math.Rect = if (src) |s| zt.math.rect(s.position.x / texture.width, s.position.y / texture.height, s.size.x / texture.width, s.size.y / texture.height) else zt.math.rect(0, 0, 1, 1); self.spriteEx(texture, pos.x + offset.x, pos.y + offset.y, z, size.x, size.y, source.position.x, source.position.y, source.size.x, source.size.y, color, color, color, color); } /// If you want to submit the vertices yourself, this is the way to do it. Submit them in order: Top Left, Top Right, /// Bottom Left, Bottom Right. pub fn spriteManual(self: *Self, texture: zt.gl.Texture, tl: Vertex, tr: Vertex, bl: Vertex, br: Vertex) void { if (self.currentTexture == null) { self.currentTexture = texture; } else if (self.currentTexture.?.id != texture.id) { self.flush(); self.currentTexture = texture; } self.internal.addQuad(bl, tl, tr, br) catch |err| { if (err == error.NeedsFlush) { self.flush(); self.internal.addQuad(bl, tl, tr, br) catch unreachable; return; } std.debug.panic("Rendering error: {s}", .{@errorName(err)}); }; } /// Use this method if you want to avoid using zt math types such as Vec2, and would prefer to just input raw floats. pub fn spriteEx(self: *Self, texture: zt.gl.Texture, x: f32, y: f32, z: f32, w: f32, h: f32, sx: f32, sy: f32, sw: f32, sh: f32, colTl: zt.math.Vec4, colTr: zt.math.Vec4, colBl: zt.math.Vec4, colBr: zt.math.Vec4) void { if (self.currentTexture == null) { self.currentTexture = texture; } else if (self.currentTexture.?.id != texture.id) { self.flush(); self.currentTexture = texture; } var start: zt.math.Vec3 = zt.math.Vec3.new(x, y, z); var end: zt.math.Vec3 = zt.math.Vec3.new(x + w, y + h, z); var tl = Vertex{ .pos = .{ .x = start.x, .y = start.y, .z = start.z }, .col = colTl, .tex = .{ .x = sx, .y = sy }, }; var tr = Vertex{ .pos = .{ .x = end.x, .y = start.y, .z = start.z }, .col = colTr, .tex = .{ .x = sx + sw, .y = sy }, }; var bl = Vertex{ .pos = .{ .x = start.x, .y = end.y, .z = start.z }, .col = colBl, .tex = .{ .x = sx, .y = sy + sh }, }; var br = Vertex{ .pos = .{ .x = end.x, .y = end.y, .z = start.z }, .col = colBr, .tex = .{ .x = sx + sw, .y = sy + sh }, }; self.internal.addQuad(bl, tl, tr, br) catch |err| { if (err == error.NeedsFlush) { self.flush(); self.internal.addQuad(bl, tl, tr, br) catch unreachable; return; } std.debug.panic("Rendering error: {s}", .{@errorName(err)}); }; } /// For expected blank line behaviour, sourceRect should point to a spot on the sheet that is pure white. /// Otherwise you can point wherever you want for a textured line. pub fn line(self: *Self, texture: zt.gl.Texture, sourceRect: ?zt.math.Rect, start: zt.math.Vec2, end: zt.math.Vec2, z: f32, width: f32, colStarT: zt.math.Vec4, colEnd: zt.math.Vec4) void { if (self.currentTexture == null) { self.currentTexture = texture; } else if (self.currentTexture.?.id != texture.id) { self.flush(); self.currentTexture = texture; } const source: zt.math.Rect = if (sourceRect) |s| zt.math.rect(s.position.x / texture.width, s.position.y / texture.height, s.size.x / texture.width, s.size.y / texture.height) else zt.math.rect(0, 0, 1, 1); const direction: zt.math.Vec2 = end.sub(start).normalize(); var leftOffset: zt.math.Vec3 = zt.math.vec3(direction.y, -direction.x, 0).scale(width * 0.5); var rightOffset: zt.math.Vec3 = leftOffset.scale(-1); var tl = Vertex{ .pos = zt.math.vec3(start.x, start.y, z).add(leftOffset), .col = colStarT, .tex = .{ .x = source.position.x, .y = source.position.y }, }; var tr = Vertex{ .pos = zt.math.vec3(start.x, start.y, z).add(rightOffset), .col = colStarT, .tex = .{ .x = source.position.x + source.size.x, .y = source.position.y }, }; var bl = Vertex{ .pos = zt.math.vec3(end.x, end.y, z).add(leftOffset), .col = colEnd, .tex = .{ .x = source.position.x, .y = source.position.y + source.size.y }, }; var br = Vertex{ .pos = zt.math.vec3(end.x, end.y, z).add(rightOffset), .col = colEnd, .tex = .{ .x = source.position.x + source.size.x, .y = source.position.y + source.size.y }, }; self.internal.addQuad(bl, tl, tr, br) catch |err| { if (err == error.NeedsFlush) { self.flush(); self.internal.addQuad(bl, tl, tr, br) catch unreachable; return; } std.debug.panic("Rendering error: {s}", .{@errorName(err)}); }; } pub fn circle(self: *Self, texture: zt.gl.Texture, sourceRect: ?zt.math.Rect, target: zt.math.Vec2, radius: f32, z: f32, col: zt.math.Vec4) void { const twoPi: f32 = 2.0 * std.math.pi; const addition: i32 = std.math.clamp(@floatToInt(i32, std.math.round(radius / 100.0)) * 10, 0, 20); const triCount: i32 = (@floatToInt(i32, twoPi) * self.resolution) + addition; var i: i32 = 0; const source: zt.math.Rect = if (sourceRect) |s| zt.math.rect(s.position.x / texture.width, s.position.y / texture.height, s.size.x / texture.width, s.size.y / texture.height) else zt.math.rect(0, 0, 1, 1); while (i < triCount) : (i += 1) { var c = Vertex{ .pos = zt.math.vec3(target.x, target.y, z), .col = col, .tex = .{ .x = source.position.x, .y = source.position.y }, }; var l = Vertex{ .pos = zt.math.vec3(target.x + (radius * @cos(@intToFloat(f32, i) * twoPi / @intToFloat(f32, triCount))), target.y + (radius * @sin(@intToFloat(f32, i) * twoPi / @intToFloat(f32, triCount))), z), .col = col, .tex = .{ .x = source.position.x + source.size.x, .y = source.position.y }, }; var r = Vertex{ .pos = zt.math.vec3(target.x + (radius * @cos(@intToFloat(f32, i + 1) * twoPi / @intToFloat(f32, triCount))), target.y + (radius * @sin(@intToFloat(f32, i + 1) * twoPi / @intToFloat(f32, triCount))), z), .col = col, .tex = .{ .x = source.position.x, .y = source.position.y + source.size.y }, }; self.internal.addTri(c, l, r) catch |err| { if (err == error.NeedsFlush) { self.flush(); self.internal.addTri(c, l, r) catch unreachable; return; } std.debug.panic("Rendering error: {s}", .{@errorName(err)}); }; } } /// For expected blank line behaviour, sourceRect should point to a spot on the sheet that is pure white. /// It is not recommended to use this textured. pub fn rectangleHollow(self: *Self, texture: zt.gl.Texture, sourceRect: ?zt.math.Rect, target: zt.math.Rect, z: f32, thickness: f32, col: zt.math.Vec4) void { var tl = target.position; var tr = target.position.add(.{ .x = target.size.x }); var bl = target.position.add(.{ .y = target.size.y }); var br = target.position.add(target.size); self.line(texture, sourceRect, tl, tr.add(.{ .x = thickness * 0.5 }), z, thickness, col, col); self.line(texture, sourceRect, tr, br.add(.{ .y = thickness * 0.5 }), z, thickness, col, col); self.line(texture, sourceRect, br, bl.add(.{ .x = -thickness * 0.5 }), z, thickness, col, col); self.line(texture, sourceRect, bl, tl.add(.{ .y = -thickness * 0.5 }), z, thickness, col, col); } pub fn text(self: *Self, pos: zt.math.Vec2, string: []const u8, col: zt.math.Vec4) void { _ = self; const ig = @import("imgui"); var drawlist = ig.igGetBackgroundDrawList_Nil(); var colCast: [4]u8 = .{ @floatToInt(u8, 255 * col.x), @floatToInt(u8, 255 * col.y), @floatToInt(u8, 255 * col.z), @floatToInt(u8, 255 * col.w), }; ig.ImDrawList_AddText_Vec2(drawlist, pos, @bitCast(ig.ImU32, colCast), string.ptr, null); } pub fn clear(self: *Self) void { self.internal.clear(); } /// If there is nothing to draw, nothing will happen, so make sure to call this at the end of every render phase that might /// have dangling sprites to blit! pub fn flush(self: *Self) void { if (self.currentTexture == null or self.internal.indCount == 0) { return; } glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); self.internal.setUniform("View", self.viewMatrix); self.internal.setUniform("Projection", self.projectionMatrix); self.internal.pushStream(); self.currentTexture.?.bind(); self.internal.flush(); self.internal.clear(); self.currentTexture.?.unbind(); } pub fn worldToScreen(self: *Self, point: zt.math.Vec2) zt.math.Vec2 { return point.transform4(self.viewMatrix); } pub fn screenToWorld(self: *Self, point: zt.math.Vec2) zt.math.Vec2 { return point.transform4(self.inverseViewMatrix); }
src/zt/renderer.zig
const std = @import("std"); pub const PrivilegeLevel = enum(u2) { User = 0, Supervisor = 1, Machine = 3, pub fn getPrivilegeLevel(value: u2) !PrivilegeLevel { return std.meta.intToEnum(PrivilegeLevel, value) catch { std.log.emerg("invalid privlege mode {b}", .{value}); return error.InvalidPrivilegeLevel; }; } }; pub const IntegerRegister = enum(u5) { zero = 0, // return address ra = 1, // stack pointer sp = 2, // global pointer gp = 3, // thread pointer tp = 4, // temporaries t0 = 5, t1 = 6, t2 = 7, // saved register / frame pointer @"s0/fp" = 8, // saved register s1 = 9, // function arguments / return values a0 = 10, a1 = 11, // function arguments a2 = 12, a3 = 13, a4 = 14, a5 = 15, a6 = 16, a7 = 17, // saved registers s2 = 18, s3 = 19, s4 = 20, s5 = 21, s6 = 22, s7 = 23, s8 = 24, s9 = 25, s10 = 26, s11 = 27, // temporaries t3 = 28, t4 = 29, t5 = 30, t6 = 31, pub fn getIntegerRegister(value: usize) IntegerRegister { return std.meta.intToEnum(IntegerRegister, value) catch unreachable; } pub fn format(value: IntegerRegister, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { _ = fmt; _ = options; try writer.writeAll(value.getString()); } pub fn getString(register: IntegerRegister) []const u8 { return switch (register) { .zero => "zero(x0)", .ra => "ra(x1)", .sp => "sp(x2)", .gp => "gp(x3)", .tp => "tp(x4)", .t0 => "t0(x5)", .t1 => "t1(x6)", .t2 => "t2(x7)", .@"s0/fp" => "s0/fp(x8)", .s1 => "s1(x9)", .a0 => "a0(x10)", .a1 => "a1(x11)", .a2 => "a2(x12)", .a3 => "a3(x13)", .a4 => "a4(x14)", .a5 => "a5(x15)", .a6 => "a6(x16)", .a7 => "a7(x17)", .s2 => "s2(x18)", .s3 => "s3(x19)", .s4 => "s4(x20)", .s5 => "s5(x21)", .s6 => "s6(x22)", .s7 => "s7(x23)", .s8 => "s8(x24)", .s9 => "s9(x25)", .s10 => "s10(x26)", .s11 => "s11(x27)", .t3 => "t3(x28)", .t4 => "t4(x29)", .t5 => "t5(x30)", .t6 => "t6(31)", }; } }; pub const ExceptionCode = enum(u63) { InstructionAddressMisaligned = 0, InstructionAccessFault = 1, IllegalInstruction = 2, Breakpoint = 3, LoadAddressMisaligned = 4, LoadAccessFault = 5, @"Store/AMOAddressMisaligned" = 6, @"Store/AMOAccessFault" = 7, EnvironmentCallFromUMode = 8, EnvironmentCallFromSMode = 9, EnvironmentCallFromMMode = 11, InstructionPageFault = 12, LoadPageFault = 13, Store_AMOPageFault = 15, }; pub const ContextStatus = enum(u2) { Off = 0, Initial = 1, Clean = 2, Dirty = 3, pub fn getContextStatus(value: u2) !ContextStatus { return std.meta.intToEnum(ContextStatus, value) catch { std.log.emerg("invalid context status {b}", .{value}); return error.InvalidContextStatus; }; } }; pub const VectorMode = enum(u2) { Direct, Vectored, pub fn getVectorMode(value: u2) !VectorMode { return std.meta.intToEnum(VectorMode, value) catch { std.log.emerg("invalid vector mode {b}", .{value}); return error.InvalidVectorMode; }; } }; pub const AddressTranslationMode = enum(u4) { Bare = 0, Sv39 = 8, Sv48 = 9, pub fn getAddressTranslationMode(value: u4) !AddressTranslationMode { return std.meta.intToEnum(AddressTranslationMode, value) catch { std.log.emerg("invalid address translation mode {b}", .{value}); return error.InvalidAddressTranslationMode; }; } }; comptime { std.testing.refAllDecls(@This()); }
lib/types.zig
const std = @import("std"); const zalgebra = @import("zalgebra"); usingnamespace @import("didot-graphics"); usingnamespace @import("didot-objects"); usingnamespace @import("didot-app"); const Vec3 = zalgebra.vec3; const Quat = zalgebra.quat; const rad = zalgebra.to_radians; const Allocator = std.mem.Allocator; var scene: *Scene = undefined; const App = comptime blk: { comptime var systems = Systems {}; systems.addSystem(cameraSystem); break :blk Application(systems); }; const CameraController = struct {}; pub fn cameraSystem(controller: *Camera, transform: *Transform) !void { if (scene.findChild("Planet")) |planet| { const planetPosition = planet.getComponent(Transform).?.position; transform.lookAt(planetPosition); } } pub fn init(allocator: *Allocator, app: *App) !void { scene = app.scene; const asset = &scene.assetManager; try asset.autoLoad(allocator); var shader = try ShaderProgram.createFromFile(allocator, "assets/shaders/vert.glsl", "assets/shaders/frag.glsl"); var camera = try GameObject.createObject(allocator, null); camera.getComponent(Transform).?.position = Vec3.new(1.5, 1.5, -0.5); camera.getComponent(Transform).?.rotation = Quat.from_euler_angle(Vec3.new(300, -15, 0)); try camera.addComponent(Camera { .shader = shader }); try camera.addComponent(CameraController {}); try app.scene.add(camera); var sphere = try GameObject.createObject(allocator, asset.get("sphere.obj")); sphere.name = "Planet"; sphere.getComponent(Transform).?.position = Vec3.new(5, 0.75, -5); try app.scene.add(sphere); var light = try GameObject.createObject(allocator, null); light.getComponent(Transform).?.position = Vec3.new(1, 5, -5); light.material.ambient = Vec3.one(); try light.addComponent(PointLight {}); try scene.add(light); } pub fn main() !void { var gp = std.heap.GeneralPurposeAllocator(.{}) {}; const allocator = &gp.allocator; var app = App { .title = "Planets", .initFn = init }; try app.run(allocator, try Scene.create(allocator, null)); }
examples/planet-test/example-scene.zig
const clap = @import("clap"); const format = @import("format"); const it = @import("ziter"); const std = @import("std"); const ston = @import("ston"); const util = @import("util"); const debug = std.debug; const fmt = std.fmt; const fs = std.fs; const heap = std.heap; const io = std.io; const math = std.math; const mem = std.mem; const meta = std.meta; const os = std.os; const rand = std.rand; const testing = std.testing; const Program = @This(); allocator: mem.Allocator, options: struct { seed: u64, simular_total_stats: bool, }, pokedex: Set = Set{}, pokemons: Pokemons = Pokemons{}, wild_pokemons: Zones = Zones{}, pub const main = util.generateMain(Program); pub const version = "0.0.0"; pub const description = \\Randomizes wild Pokémon encounters. \\ ; pub const params = &[_]clap.Param(clap.Help){ clap.parseParam("-h, --help Display this help text and exit. ") catch unreachable, clap.parseParam("-s, --seed <INT> The seed to use for random numbers. A random seed will be picked if this is not specified.") catch unreachable, clap.parseParam("-t, --simular-total-stats Replaced wild Pokémons should have simular total stats. ") catch unreachable, clap.parseParam("-v, --version Output version information and exit. ") catch unreachable, }; pub fn init(allocator: mem.Allocator, args: anytype) !Program { return Program{ .allocator = allocator, .options = .{ .seed = try util.getSeed(args), .simular_total_stats = args.flag("--simular-total-stats"), }, }; } pub fn run( program: *Program, comptime Reader: type, comptime Writer: type, stdio: util.CustomStdIoStreams(Reader, Writer), ) !void { try format.io(program.allocator, stdio.in, stdio.out, program, useGame); try program.randomize(); try program.output(stdio.out); } fn output(program: *Program, writer: anytype) !void { for (program.wild_pokemons.values()) |zone, i| { const zone_id = program.wild_pokemons.keys()[i]; for (zone.wild_areas) |area, j| { const aid = @intToEnum(meta.Tag(format.WildPokemons), @intCast(u5, j)); try ston.serialize(writer, .{ .wild_pokemons = ston.index(zone_id, ston.field(@tagName(aid), .{ .pokemons = area.pokemons, })), }); } } } fn useGame(program: *Program, parsed: format.Game) !void { const allocator = program.allocator; switch (parsed) { .pokedex => |pokedex| { _ = try program.pokedex.put(allocator, pokedex.index, {}); return error.DidNotConsumeData; }, .pokemons => |pokemons| { const pokemon = (try program.pokemons.getOrPutValue(allocator, pokemons.index, .{})) .value_ptr; switch (pokemons.value) { .catch_rate => |catch_rate| pokemon.catch_rate = catch_rate, .pokedex_entry => |pokedex_entry| pokemon.pokedex_entry = pokedex_entry, .stats => |stats| pokemon.stats[@enumToInt(stats)] = stats.value(), .types, .base_exp_yield, .ev_yield, .items, .gender_ratio, .egg_cycles, .base_friendship, .growth_rate, .egg_groups, .abilities, .color, .evos, .moves, .tms, .hms, .name, => return error.DidNotConsumeData, } return error.DidNotConsumeData; }, .wild_pokemons => |wild_areas| { const zone = (try program.wild_pokemons.getOrPutValue( allocator, wild_areas.index, .{}, )).value_ptr; const area = &zone.wild_areas[@enumToInt(wild_areas.value)]; const wild_area = wild_areas.value.value(); switch (wild_area) { .pokemons => |pokemons| { const pokemon = (try area.pokemons.getOrPutValue( allocator, pokemons.index, .{}, )).value_ptr; // TODO: We're not using min/max level for anything yet switch (pokemons.value) { .min_level => |min_level| pokemon.min_level = min_level, .max_level => |max_level| pokemon.max_level = max_level, .species => |species| pokemon.species = species, } return; }, .encounter_rate => return error.DidNotConsumeData, } }, .version, .game_title, .gamecode, .instant_text, .starters, .text_delays, .trainers, .moves, .abilities, .types, .tms, .hms, .items, .maps, .static_pokemons, .given_pokemons, .pokeball_items, .hidden_hollows, .text, => return error.DidNotConsumeData, } unreachable; } fn randomize(program: *Program) !void { const allocator = program.allocator; const random = rand.DefaultPrng.init(program.options.seed).random(); var simular = std.ArrayList(u16).init(allocator); const species = try pokedexPokemons(allocator, program.pokemons, program.pokedex); for (program.wild_pokemons.values()) |zone| { for (zone.wild_areas) |area| { for (area.pokemons.values()) |*wild_pokemon| { const old_species = wild_pokemon.species orelse continue; if (program.options.simular_total_stats) blk: { // If we don't know what the old Pokemon was, then we can't do simular_total_stats. // We therefor just pick a random pokemon and continue. const pokemon = program.pokemons.get(old_species) orelse { wild_pokemon.species = util.random.item(random, species.keys()).?.*; break :blk; }; var min = @intCast(i64, it.fold(&pokemon.stats, @as(usize, 0), foldu8)); var max = min; simular.shrinkRetainingCapacity(0); while (simular.items.len < 5) { min -= 5; max += 5; for (species.keys()) |s| { const p = program.pokemons.get(s).?; const total = @intCast(i64, it.fold(&p.stats, @as(usize, 0), foldu8)); if (min <= total and total <= max) try simular.append(s); } } wild_pokemon.species = util.random.item(random, simular.items).?.*; } else { wild_pokemon.species = util.random.item(random, species.keys()).?.*; } } } } } fn foldu8(a: usize, b: u8) usize { return a + b; } const number_of_areas = @typeInfo(format.WildPokemons).Union.fields.len; const Pokemons = std.AutoArrayHashMapUnmanaged(u16, Pokemon); const Set = std.AutoArrayHashMapUnmanaged(u16, void); const WildAreas = [number_of_areas]WildArea; const WildPokemons = std.AutoArrayHashMapUnmanaged(u8, WildPokemon); const Zones = std.AutoArrayHashMapUnmanaged(u16, Zone); fn pokedexPokemons(allocator: mem.Allocator, pokemons: Pokemons, pokedex: Set) !Set { var res = Set{}; errdefer res.deinit(allocator); for (pokemons.values()) |pokemon, i| { if (pokemon.catch_rate == 0) continue; if (pokedex.get(pokemon.pokedex_entry) == null) continue; _ = try res.put(allocator, pokemons.keys()[i], {}); } return res; } const Zone = struct { wild_areas: WildAreas = [_]WildArea{WildArea{}} ** number_of_areas, }; const WildArea = struct { pokemons: WildPokemons = WildPokemons{}, }; const WildPokemon = struct { min_level: ?u8 = null, max_level: ?u8 = null, species: ?u16 = null, }; const Pokemon = struct { stats: [6]u8 = [_]u8{0} ** 6, catch_rate: usize = 1, pokedex_entry: u16 = math.maxInt(u16), }; test "tm35-rand-wild" { const result_prefix = \\.pokemons[0].pokedex_entry=0 \\.pokemons[0].stats.hp=10 \\.pokemons[0].stats.attack=10 \\.pokemons[0].stats.defense=10 \\.pokemons[0].stats.speed=10 \\.pokemons[0].stats.sp_attack=10 \\.pokemons[0].stats.sp_defense=10 \\.pokemons[0].catch_rate=10 \\.pokemons[1].pokedex_entry=1 \\.pokemons[1].stats.hp=12 \\.pokemons[1].stats.attack=12 \\.pokemons[1].stats.defense=12 \\.pokemons[1].stats.speed=12 \\.pokemons[1].stats.sp_attack=12 \\.pokemons[1].stats.sp_defense=12 \\.pokemons[1].catch_rate=10 \\.pokemons[2].pokedex_entry=2 \\.pokemons[2].stats.hp=14 \\.pokemons[2].stats.attack=14 \\.pokemons[2].stats.defense=14 \\.pokemons[2].stats.speed=14 \\.pokemons[2].stats.sp_attack=14 \\.pokemons[2].stats.sp_defense=14 \\.pokemons[2].catch_rate=10 \\.pokemons[3].pokedex_entry=3 \\.pokemons[3].stats.hp=16 \\.pokemons[3].stats.attack=16 \\.pokemons[3].stats.defense=16 \\.pokemons[3].stats.speed=16 \\.pokemons[3].stats.sp_attack=16 \\.pokemons[3].stats.sp_defense=16 \\.pokemons[3].catch_rate=10 \\.pokemons[4].pokedex_entry=4 \\.pokemons[4].stats.hp=18 \\.pokemons[4].stats.attack=18 \\.pokemons[4].stats.defense=18 \\.pokemons[4].stats.speed=18 \\.pokemons[4].stats.sp_attack=18 \\.pokemons[4].stats.sp_defense=18 \\.pokemons[4].catch_rate=10 \\.pokemons[5].pokedex_entry=5 \\.pokemons[5].stats.hp=20 \\.pokemons[5].stats.attack=20 \\.pokemons[5].stats.defense=20 \\.pokemons[5].stats.speed=20 \\.pokemons[5].stats.sp_attack=20 \\.pokemons[5].stats.sp_defense=20 \\.pokemons[5].catch_rate=10 \\.pokemons[6].pokedex_entry=6 \\.pokemons[6].stats.hp=22 \\.pokemons[6].stats.attack=22 \\.pokemons[6].stats.defense=22 \\.pokemons[6].stats.speed=22 \\.pokemons[6].stats.sp_attack=22 \\.pokemons[6].stats.sp_defense=22 \\.pokemons[6].catch_rate=10 \\.pokemons[7].pokedex_entry=7 \\.pokemons[7].stats.hp=24 \\.pokemons[7].stats.attack=24 \\.pokemons[7].stats.defense=24 \\.pokemons[7].stats.speed=24 \\.pokemons[7].stats.sp_attack=24 \\.pokemons[7].stats.sp_defense=24 \\.pokemons[7].catch_rate=10 \\.pokemons[8].pokedex_entry=8 \\.pokemons[8].stats.hp=28 \\.pokemons[8].stats.attack=28 \\.pokemons[8].stats.defense=28 \\.pokemons[8].stats.speed=28 \\.pokemons[8].stats.sp_attack=28 \\.pokemons[8].stats.sp_defense=28 \\.pokemons[8].catch_rate=10 \\.pokemons[9].pokedex_entry=9 \\.pokemons[9].stats.hp=28 \\.pokemons[9].stats.attack=28 \\.pokemons[9].stats.defense=28 \\.pokemons[9].stats.speed=28 \\.pokemons[9].stats.sp_attack=28 \\.pokemons[9].stats.sp_defense=28 \\.pokemons[9].catch_rate=0 \\.pokedex[0].height=0 \\.pokedex[1].height=0 \\.pokedex[2].height=0 \\.pokedex[3].height=0 \\.pokedex[4].height=0 \\.pokedex[5].height=0 \\.pokedex[6].height=0 \\.pokedex[7].height=0 \\.pokedex[8].height=0 \\.pokedex[9].height=0 \\ ; const test_string = result_prefix ++ \\.wild_pokemons[0].grass_0.pokemons[0].species=0 \\.wild_pokemons[0].grass_0.pokemons[1].species=0 \\.wild_pokemons[0].grass_0.pokemons[2].species=0 \\.wild_pokemons[0].grass_0.pokemons[3].species=0 \\.wild_pokemons[1].grass_0.pokemons[0].species=0 \\.wild_pokemons[1].grass_0.pokemons[1].species=0 \\.wild_pokemons[1].grass_0.pokemons[2].species=0 \\.wild_pokemons[1].grass_0.pokemons[3].species=0 \\.wild_pokemons[2].grass_0.pokemons[0].species=0 \\.wild_pokemons[2].grass_0.pokemons[1].species=0 \\.wild_pokemons[2].grass_0.pokemons[2].species=0 \\.wild_pokemons[2].grass_0.pokemons[3].species=0 \\.wild_pokemons[3].grass_0.pokemons[0].species=0 \\.wild_pokemons[3].grass_0.pokemons[1].species=0 \\.wild_pokemons[3].grass_0.pokemons[2].species=0 \\.wild_pokemons[3].grass_0.pokemons[3].species=0 \\ ; try util.testing.testProgram(Program, &[_][]const u8{"--seed=0"}, test_string, result_prefix ++ \\.wild_pokemons[0].grass_0.pokemons[0].species=2 \\.wild_pokemons[0].grass_0.pokemons[1].species=3 \\.wild_pokemons[0].grass_0.pokemons[2].species=3 \\.wild_pokemons[0].grass_0.pokemons[3].species=0 \\.wild_pokemons[1].grass_0.pokemons[0].species=4 \\.wild_pokemons[1].grass_0.pokemons[1].species=0 \\.wild_pokemons[1].grass_0.pokemons[2].species=7 \\.wild_pokemons[1].grass_0.pokemons[3].species=7 \\.wild_pokemons[2].grass_0.pokemons[0].species=2 \\.wild_pokemons[2].grass_0.pokemons[1].species=0 \\.wild_pokemons[2].grass_0.pokemons[2].species=2 \\.wild_pokemons[2].grass_0.pokemons[3].species=0 \\.wild_pokemons[3].grass_0.pokemons[0].species=0 \\.wild_pokemons[3].grass_0.pokemons[1].species=0 \\.wild_pokemons[3].grass_0.pokemons[2].species=0 \\.wild_pokemons[3].grass_0.pokemons[3].species=3 \\ ); try util.testing.testProgram(Program, &[_][]const u8{ "--seed=0", "--simular-total-stats" }, test_string, result_prefix ++ \\.wild_pokemons[0].grass_0.pokemons[0].species=0 \\.wild_pokemons[0].grass_0.pokemons[1].species=0 \\.wild_pokemons[0].grass_0.pokemons[2].species=0 \\.wild_pokemons[0].grass_0.pokemons[3].species=0 \\.wild_pokemons[1].grass_0.pokemons[0].species=0 \\.wild_pokemons[1].grass_0.pokemons[1].species=0 \\.wild_pokemons[1].grass_0.pokemons[2].species=1 \\.wild_pokemons[1].grass_0.pokemons[3].species=1 \\.wild_pokemons[2].grass_0.pokemons[0].species=0 \\.wild_pokemons[2].grass_0.pokemons[1].species=0 \\.wild_pokemons[2].grass_0.pokemons[2].species=0 \\.wild_pokemons[2].grass_0.pokemons[3].species=0 \\.wild_pokemons[3].grass_0.pokemons[0].species=0 \\.wild_pokemons[3].grass_0.pokemons[1].species=0 \\.wild_pokemons[3].grass_0.pokemons[2].species=0 \\.wild_pokemons[3].grass_0.pokemons[3].species=0 \\ ); }
src/randomizers/tm35-rand-wild.zig
const std = @import("std"); const interop = @import("../interop.zig"); const iup = @import("../iup.zig"); const Impl = @import("../impl.zig").Impl; const CallbackHandler = @import("../callback_handler.zig").CallbackHandler; const debug = std.debug; const trait = std.meta.trait; const Element = iup.Element; const Handle = iup.Handle; const Error = iup.Error; const ChildrenIterator = iup.ChildrenIterator; const Size = iup.Size; const Margin = iup.Margin; /// /// Creates an item of the menu interface element. /// When selected, it generates an action. pub const Item = opaque { pub const CLASS_NAME = "item"; pub const NATIVE_TYPE = iup.NativeType.Menu; const Self = @This(); pub const OnLDestroyFn = fn (self: *Self) anyerror!void; /// /// ACTION ACTION Action generated when the element is activated. /// Affects each element differently. /// Callback int function(Ihandle *ih); [in C] ih:action() -> (ret: number) [in /// Lua] ih: identifier of the element that activated the event. /// In some elements, this callback may receive more parameters, apart from ih. /// Please refer to each element's documentation. /// Affects IupButton, IupItem, IupList, IupText, IupCanvas, IupMultiline, /// IupToggle pub const OnActionFn = fn (self: *Self) anyerror!void; /// /// DESTROY_CB DESTROY_CB Called right before an element is destroyed. /// Callback int function(Ihandle *ih); [in C] ih:destroy_cb() -> (ret: number) /// [in Lua] ih: identifier of the element that activated the event. /// Notes If the dialog is visible then it is hidden before it is destroyed. /// The callback will be called right after it is hidden. /// The callback will be called before all other destroy procedures. /// For instance, if the element has children then it is called before the /// children are destroyed. /// For language binding implementations use the callback name "LDESTROY_CB" to /// release memory allocated by the binding for the element. /// Also the callback will be called before the language callback. /// Affects All. pub const OnDestroyFn = fn (self: *Self) anyerror!void; /// /// HIGHLIGHT_CB HIGHLIGHT_CB Callback triggered every time the user selects an /// IupItem or IupSubmenu. /// Callback int function(Ihandle *ih); [in C] elem:highlight_cb() -> (ret: /// number) [in Lua] ih: identifier of the element that activated the event. /// Affects IupItem, IupSubmenu pub const OnHighlightFn = fn (self: *Self) anyerror!void; /// /// MAP_CB MAP_CB Called right after an element is mapped and its attributes /// updated in IupMap. /// When the element is a dialog, it is called after the layout is updated. /// For all other elements is called before the layout is updated, so the /// element current size will still be 0x0 during MAP_CB (since 3.14). /// Callback int function(Ihandle *ih); [in C] ih:map_cb() -> (ret: number) [in /// Lua] ih: identifier of the element that activated the event. /// Affects All that have a native representation. pub const OnMapFn = fn (self: *Self) anyerror!void; pub const OnPostMessageFn = fn (self: *Self, arg0: [:0]const u8, arg1: i32, arg2: f64, arg3: *iup.Unknow) anyerror!void; /// /// UNMAP_CB UNMAP_CB Called right before an element is unmapped. /// Callback int function(Ihandle *ih); [in C] ih:unmap_cb() -> (ret: number) /// [in Lua] ih: identifier of the element that activated the event. /// Affects All that have a native representation. pub const OnUnmapFn = fn (self: *Self) anyerror!void; /// /// HELP_CB HELP_CB Action generated when the user press F1 at a control. /// In Motif is also activated by the Help button in some workstations keyboard. /// Callback void function(Ihandle *ih); [in C] ih:help_cb() -> (ret: number) /// [in Lua] ih: identifier of the element that activated the event. /// Returns: IUP_CLOSE will be processed. /// Affects All elements with user interaction. pub const OnHelpFn = fn (self: *Self) anyerror!void; /// /// VALUE (non inheritable): Indicates the item's state. /// When the value is ON, a mark will be displayed to the left of the item. /// Default: OFF. /// An item in a menu bar cannot have a check mark. /// When IMAGE is used, the checkmark is not shown. /// See the item AUTOTOGGLE attribute and the menu RADIO attribute. /// Since GTK 2.14 to have a menu item that can be marked you must set the /// VALUE attribute to ON or OFF, or set HIDEMARK=NO, before mapping the control. pub const Value = enum { On, Off, }; /// /// FLOATING (non inheritable) (at children only): If a child has FLOATING=YES /// then its size and position will be ignored by the layout processing. /// Default: "NO". /// (since 3.0) pub const Floating = enum { Yes, Ignore, No, }; pub const Initializer = struct { last_error: ?anyerror = null, ref: *Self, /// /// Returns a pointer to IUP element or an error. /// Only top-level or detached elements needs to be unwraped, pub fn unwrap(self: Initializer) !*Self { if (self.last_error) |e| { return e; } else { return self.ref; } } /// /// Captures a reference into a external variable /// Allows to capture some references even using full declarative API pub fn capture(self: *Initializer, ref: **Self) Initializer { ref.* = self.ref; return self.*; } pub fn setStrAttribute(self: *Initializer, attributeName: [:0]const u8, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; Self.setStrAttribute(self.ref, attributeName, arg); return self.*; } pub fn setIntAttribute(self: *Initializer, attributeName: [:0]const u8, arg: i32) Initializer { if (self.last_error) |_| return self.*; Self.setIntAttribute(self.ref, attributeName, arg); return self.*; } pub fn setBoolAttribute(self: *Initializer, attributeName: [:0]const u8, arg: bool) Initializer { if (self.last_error) |_| return self.*; Self.setBoolAttribute(self.ref, attributeName, arg); return self.*; } pub fn setPtrAttribute(self: *Initializer, comptime T: type, attributeName: [:0]const u8, value: ?*T) Initializer { if (self.last_error) |_| return self.*; Self.setPtrAttribute(self.ref, T, attributeName, value); return self.*; } pub fn setHandle(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setHandle(self.ref, arg); return self.*; } /// /// ACTIVE, THEME: also accepted. pub fn setActive(self: *Initializer, arg: bool) Initializer { if (self.last_error) |_| return self.*; interop.setBoolAttribute(self.ref, "ACTIVE", .{}, arg); return self.*; } /// /// TITLE (non inheritable): Item text. /// The "&" character can be used to define a mnemonic, the next character will /// be used as key. /// Use "&&" to show the "&" character instead on defining a mnemonic. /// When in a menu bar an item that has a mnemonic can be activated from any /// control in the dialog using the "Alt+key" combination. pub fn setTitle(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "TITLE", .{}, arg); return self.*; } /// /// IMPRESS [Windows and GTK Only] (non inheritable): Image name of the check /// mark image when VALUE=ON. pub fn setImPress(self: *Initializer, arg: anytype) Initializer { if (self.last_error) |_| return self.*; if (interop.validateHandle(.Image, arg)) { interop.setHandleAttribute(self.ref, "IMPRESS", .{}, arg); } else |err| { self.last_error = err; } return self.*; } pub fn setImPressHandleName(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "IMPRESS", .{}, arg); return self.*; } /// /// HIDEMARK [Motif and GTK Only]: If enabled the item cannot be checked, since /// the check box will not be shown. /// If all items in a menu enable it, then no empty space will be shown in /// front of the items. /// Normally the unmarked check box will not be shown, but since GTK 2.14 the /// unmarked check box is always shown. /// If your item will not be marked you must set HIDEMARK=YES, since this is /// the most common case we changed the default value to YES for this version /// of GTK, but if VALUE is defined the default goes back to NO. /// Default: NO. /// (since 3.0) pub fn setHideMark(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "HIDEMARK", .{}, arg); return self.*; } /// /// IMAGE [Windows and GTK Only] (non inheritable): Image name of the check /// mark image when VALUE=OFF. /// In Windows, an item in a menu bar cannot have a check mark. /// Ignored if item in a menu bar. /// A recommended size would be 16x16 to fit the image in the menu item. /// In Windows, if larger than the check mark area it will be cropped. pub fn setImage(self: *Initializer, arg: anytype) Initializer { if (self.last_error) |_| return self.*; if (interop.validateHandle(.Image, arg)) { interop.setHandleAttribute(self.ref, "IMAGE", .{}, arg); } else |err| { self.last_error = err; } return self.*; } pub fn setImageHandleName(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "IMAGE", .{}, arg); return self.*; } pub fn setHandleName(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "HANDLENAME", .{}, arg); return self.*; } pub fn setBgColor(self: *Initializer, rgb: iup.Rgb) Initializer { if (self.last_error) |_| return self.*; interop.setRgb(self.ref, "BGCOLOR", .{}, rgb); return self.*; } /// /// TITLEIMAGE (non inheritable): Image name of the title image. /// In Windows, it appears before of the title text and after the check mark /// area (so both title and title image can be visible). /// In Motif, it must be at least defined during map, it replaces the text, and /// only images will be possible to set (TITLE will be hidden). /// In GTK, it will appear on the check mark area. /// (since 3.0) pub fn setTitleImage(self: *Initializer, arg: anytype) Initializer { if (self.last_error) |_| return self.*; if (interop.validateHandle(.Image, arg)) { interop.setHandleAttribute(self.ref, "TITLEIMAGE", .{}, arg); } else |err| { self.last_error = err; } return self.*; } pub fn setTitleImageHandleName(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "TITLEIMAGE", .{}, arg); return self.*; } /// /// KEY (non inheritable): Underlines a key character in the submenu title. /// It is updated only when TITLE is updated. /// Deprecated (since 3.0), use the mnemonic support directly in the TITLE attribute. pub fn setKey(self: *Initializer, arg: i32) Initializer { if (self.last_error) |_| return self.*; interop.setIntAttribute(self.ref, "KEY", .{}, arg); return self.*; } pub fn setFont(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "FONT", .{}, arg); return self.*; } pub fn setName(self: *Initializer, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "NAME", .{}, arg); return self.*; } /// /// VALUE (non inheritable): Indicates the item's state. /// When the value is ON, a mark will be displayed to the left of the item. /// Default: OFF. /// An item in a menu bar cannot have a check mark. /// When IMAGE is used, the checkmark is not shown. /// See the item AUTOTOGGLE attribute and the menu RADIO attribute. /// Since GTK 2.14 to have a menu item that can be marked you must set the /// VALUE attribute to ON or OFF, or set HIDEMARK=NO, before mapping the control. pub fn setValue(self: *Initializer, arg: ?Value) Initializer { if (self.last_error) |_| return self.*; if (arg) |value| switch (value) { .On => interop.setStrAttribute(self.ref, "VALUE", .{}, "ON"), .Off => interop.setStrAttribute(self.ref, "VALUE", .{}, "OFF"), } else { interop.clearAttribute(self.ref, "VALUE", .{}); } return self.*; } /// /// AUTOTOGGLE (non inheritable): enables the automatic toggle of VALUE state /// when the item is activated. /// Default: NO. /// (since 3.0) pub fn setAutoToggle(self: *Initializer, arg: bool) Initializer { if (self.last_error) |_| return self.*; interop.setBoolAttribute(self.ref, "AUTOTOGGLE", .{}, arg); return self.*; } /// /// EXPANDWEIGHT (non inheritable) (at children only): If a child defines the /// expand weight, then it is used to multiply the free space used for expansion. /// (since 3.1) pub fn setExpandWeight(self: *Initializer, arg: f64) Initializer { if (self.last_error) |_| return self.*; interop.setDoubleAttribute(self.ref, "EXPANDWEIGHT", .{}, arg); return self.*; } /// /// FLOATING (non inheritable) (at children only): If a child has FLOATING=YES /// then its size and position will be ignored by the layout processing. /// Default: "NO". /// (since 3.0) pub fn setFloating(self: *Initializer, arg: ?Floating) Initializer { if (self.last_error) |_| return self.*; if (arg) |value| switch (value) { .Yes => interop.setStrAttribute(self.ref, "FLOATING", .{}, "YES"), .Ignore => interop.setStrAttribute(self.ref, "FLOATING", .{}, "IGNORE"), .No => interop.setStrAttribute(self.ref, "FLOATING", .{}, "NO"), } else { interop.clearAttribute(self.ref, "FLOATING", .{}); } return self.*; } /// /// TABIMAGEn (non inheritable): image name to be used in the respective tab. /// Use IupSetHandle or IupSetAttributeHandle to associate an image to a name. /// n starts at 0. /// See also IupImage. /// In Motif, the image is shown only if TABTITLEn is NULL. /// In Windows and Motif set the BGCOLOR attribute before setting the image. /// When set after map will update the TABIMAGE attribute on the respective /// child (since 3.10). /// (since 3.0). /// TABIMAGE (non inheritable) (at children only): Same as TABIMAGEn but set in /// each child. /// Works only if set before the child is added to the tabs. pub fn setTabImage(self: *Initializer, index: i32, arg: anytype) Initializer { if (self.last_error) |_| return self.*; if (interop.validateHandle(.Image, arg)) { interop.setHandleAttribute(self.ref, "TABIMAGE", .{index}, arg); } else |err| { self.last_error = err; } return self.*; } pub fn setTabImageHandleName(self: *Initializer, index: i32, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "TABIMAGE", .{index}, arg); return self.*; } /// /// TABTITLEn (non inheritable): Contains the text to be shown in the /// respective tab title. /// n starts at 0. /// If this value is NULL, it will remain empty. /// The "&" character can be used to define a mnemonic, the next character will /// be used as key. /// Use "&&" to show the "&" character instead on defining a mnemonic. /// The button can be activated from any control in the dialog using the /// "Alt+key" combination. /// (mnemonic support since 3.3). /// When set after map will update the TABTITLE attribute on the respective /// child (since 3.10). /// (since 3.0). /// TABTITLE (non inheritable) (at children only): Same as TABTITLEn but set in /// each child. /// Works only if set before the child is added to the tabs. pub fn setTabTitle(self: *Initializer, index: i32, arg: [:0]const u8) Initializer { if (self.last_error) |_| return self.*; interop.setStrAttribute(self.ref, "TABTITLE", .{index}, arg); return self.*; } pub fn setLDestroyCallback(self: *Initializer, callback: ?OnLDestroyFn) Initializer { const Handler = CallbackHandler(Self, OnLDestroyFn, "LDESTROY_CB"); Handler.setCallback(self.ref, callback); return self.*; } /// /// ACTION ACTION Action generated when the element is activated. /// Affects each element differently. /// Callback int function(Ihandle *ih); [in C] ih:action() -> (ret: number) [in /// Lua] ih: identifier of the element that activated the event. /// In some elements, this callback may receive more parameters, apart from ih. /// Please refer to each element's documentation. /// Affects IupButton, IupItem, IupList, IupText, IupCanvas, IupMultiline, /// IupToggle pub fn setActionCallback(self: *Initializer, callback: ?OnActionFn) Initializer { const Handler = CallbackHandler(Self, OnActionFn, "ACTION"); Handler.setCallback(self.ref, callback); return self.*; } /// /// DESTROY_CB DESTROY_CB Called right before an element is destroyed. /// Callback int function(Ihandle *ih); [in C] ih:destroy_cb() -> (ret: number) /// [in Lua] ih: identifier of the element that activated the event. /// Notes If the dialog is visible then it is hidden before it is destroyed. /// The callback will be called right after it is hidden. /// The callback will be called before all other destroy procedures. /// For instance, if the element has children then it is called before the /// children are destroyed. /// For language binding implementations use the callback name "LDESTROY_CB" to /// release memory allocated by the binding for the element. /// Also the callback will be called before the language callback. /// Affects All. pub fn setDestroyCallback(self: *Initializer, callback: ?OnDestroyFn) Initializer { const Handler = CallbackHandler(Self, OnDestroyFn, "DESTROY_CB"); Handler.setCallback(self.ref, callback); return self.*; } /// /// HIGHLIGHT_CB HIGHLIGHT_CB Callback triggered every time the user selects an /// IupItem or IupSubmenu. /// Callback int function(Ihandle *ih); [in C] elem:highlight_cb() -> (ret: /// number) [in Lua] ih: identifier of the element that activated the event. /// Affects IupItem, IupSubmenu pub fn setHighlightCallback(self: *Initializer, callback: ?OnHighlightFn) Initializer { const Handler = CallbackHandler(Self, OnHighlightFn, "HIGHLIGHT_CB"); Handler.setCallback(self.ref, callback); return self.*; } /// /// MAP_CB MAP_CB Called right after an element is mapped and its attributes /// updated in IupMap. /// When the element is a dialog, it is called after the layout is updated. /// For all other elements is called before the layout is updated, so the /// element current size will still be 0x0 during MAP_CB (since 3.14). /// Callback int function(Ihandle *ih); [in C] ih:map_cb() -> (ret: number) [in /// Lua] ih: identifier of the element that activated the event. /// Affects All that have a native representation. pub fn setMapCallback(self: *Initializer, callback: ?OnMapFn) Initializer { const Handler = CallbackHandler(Self, OnMapFn, "MAP_CB"); Handler.setCallback(self.ref, callback); return self.*; } pub fn setPostMessageCallback(self: *Initializer, callback: ?OnPostMessageFn) Initializer { const Handler = CallbackHandler(Self, OnPostMessageFn, "POSTMESSAGE_CB"); Handler.setCallback(self.ref, callback); return self.*; } /// /// UNMAP_CB UNMAP_CB Called right before an element is unmapped. /// Callback int function(Ihandle *ih); [in C] ih:unmap_cb() -> (ret: number) /// [in Lua] ih: identifier of the element that activated the event. /// Affects All that have a native representation. pub fn setUnmapCallback(self: *Initializer, callback: ?OnUnmapFn) Initializer { const Handler = CallbackHandler(Self, OnUnmapFn, "UNMAP_CB"); Handler.setCallback(self.ref, callback); return self.*; } /// /// HELP_CB HELP_CB Action generated when the user press F1 at a control. /// In Motif is also activated by the Help button in some workstations keyboard. /// Callback void function(Ihandle *ih); [in C] ih:help_cb() -> (ret: number) /// [in Lua] ih: identifier of the element that activated the event. /// Returns: IUP_CLOSE will be processed. /// Affects All elements with user interaction. pub fn setHelpCallback(self: *Initializer, callback: ?OnHelpFn) Initializer { const Handler = CallbackHandler(Self, OnHelpFn, "HELP_CB"); Handler.setCallback(self.ref, callback); return self.*; } }; pub fn setStrAttribute(self: *Self, attribute: [:0]const u8, arg: [:0]const u8) void { interop.setStrAttribute(self, attribute, .{}, arg); } pub fn getStrAttribute(self: *Self, attribute: [:0]const u8) [:0]const u8 { return interop.getStrAttribute(self, attribute, .{}); } pub fn setIntAttribute(self: *Self, attribute: [:0]const u8, arg: i32) void { interop.setIntAttribute(self, attribute, .{}, arg); } pub fn getIntAttribute(self: *Self, attribute: [:0]const u8) i32 { return interop.getIntAttribute(self, attribute, .{}); } pub fn setBoolAttribute(self: *Self, attribute: [:0]const u8, arg: bool) void { interop.setBoolAttribute(self, attribute, .{}, arg); } pub fn getBoolAttribute(self: *Self, attribute: [:0]const u8) bool { return interop.getBoolAttribute(self, attribute, .{}); } pub fn getPtrAttribute(self: *Self, comptime T: type, attribute: [:0]const u8) ?*T { return interop.getPtrAttribute(T, self, attribute, .{}); } pub fn setPtrAttribute(self: *Self, comptime T: type, attribute: [:0]const u8, value: ?*T) void { interop.setPtrAttribute(T, self, attribute, .{}, value); } pub fn setHandle(self: *Self, arg: [:0]const u8) void { interop.setHandle(self, arg); } pub fn fromHandleName(handle_name: [:0]const u8) ?*Self { return interop.fromHandleName(Self, handle_name); } /// /// Creates an interface element given its class name and parameters. /// After creation the element still needs to be attached to a container and mapped to the native system so it can be visible. pub fn init() Initializer { var handle = interop.create(Self); if (handle) |valid| { return .{ .ref = @ptrCast(*Self, valid), }; } else { return .{ .ref = undefined, .last_error = Error.NotInitialized }; } } /// /// Destroys an interface element and all its children. /// Only dialogs, timers, popup menus and images should be normally destroyed, but detached elements can also be destroyed. pub fn deinit(self: *Self) void { interop.destroy(self); } /// /// Creates (maps) the native interface objects corresponding to the given IUP interface elements. /// It will also called recursively to create the native element of all the children in the element's tree. /// The element must be already attached to a mapped container, except the dialog. A child can only be mapped if its parent is already mapped. /// This function is automatically called before the dialog is shown in IupShow, IupShowXY or IupPopup. /// If the element is a dialog then the abstract layout will be updated even if the dialog is already mapped. If the dialog is visible the elements will be immediately repositioned. Calling IupMap for an already mapped dialog is the same as only calling IupRefresh for the dialog. /// Calling IupMap for an already mapped element that is not a dialog does nothing. /// If you add new elements to an already mapped dialog you must call IupMap for that elements. And then call IupRefresh to update the dialog layout. /// If the WID attribute of an element is NULL, it means the element was not already mapped. Some containers do not have a native element associated, like VBOX and HBOX. In this case their WID is a fake value (void*)(-1). /// It is useful for the application to call IupMap when the value of the WID attribute must be known, i.e. the native element must exist, before a dialog is made visible. /// The MAP_CB callback is called at the end of the IupMap function, after all processing, so it can also be used to create other things that depend on the WID attribute. But notice that for non dialog elements it will be called before the dialog layout has been updated, so the element current size will still be 0x0 (since 3.14). pub fn map(self: *Self) !void { try interop.map(self); } /// /// pub fn getDialog(self: *Self) ?*iup.Dialog { return interop.getDialog(self); } /// /// Returns the the child element that has the NAME attribute equals to the given value on the same dialog hierarchy. /// Works also for children of a menu that is associated with a dialog. pub fn getDialogChild(self: *Self, byName: [:0]const u8) ?Element { return interop.getDialogChild(self, byName); } /// /// Updates the size and layout of all controls in the same dialog. /// To be used after changing size attributes, or attributes that affect the size of the control. Can be used for any element inside a dialog, but the layout of the dialog and all controls will be updated. It can change the layout of all the controls inside the dialog because of the dynamic layout positioning. pub fn refresh(self: *Self) void { Impl(Self).refresh(self); } /// /// ACTIVE, THEME: also accepted. pub fn getActive(self: *Self) bool { return interop.getBoolAttribute(self, "ACTIVE", .{}); } /// /// ACTIVE, THEME: also accepted. pub fn setActive(self: *Self, arg: bool) void { interop.setBoolAttribute(self, "ACTIVE", .{}, arg); } /// /// TITLE (non inheritable): Item text. /// The "&" character can be used to define a mnemonic, the next character will /// be used as key. /// Use "&&" to show the "&" character instead on defining a mnemonic. /// When in a menu bar an item that has a mnemonic can be activated from any /// control in the dialog using the "Alt+key" combination. pub fn getTitle(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "TITLE", .{}); } /// /// TITLE (non inheritable): Item text. /// The "&" character can be used to define a mnemonic, the next character will /// be used as key. /// Use "&&" to show the "&" character instead on defining a mnemonic. /// When in a menu bar an item that has a mnemonic can be activated from any /// control in the dialog using the "Alt+key" combination. pub fn setTitle(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "TITLE", .{}, arg); } /// /// IMPRESS [Windows and GTK Only] (non inheritable): Image name of the check /// mark image when VALUE=ON. pub fn getImPress(self: *Self) ?iup.Element { if (interop.getHandleAttribute(self, "IMPRESS", .{})) |handle| { return iup.Element.fromHandle(handle); } else { return null; } } /// /// IMPRESS [Windows and GTK Only] (non inheritable): Image name of the check /// mark image when VALUE=ON. pub fn setImPress(self: *Self, arg: anytype) !void { try interop.validateHandle(.Image, arg); interop.setHandleAttribute(self, "IMPRESS", .{}, arg); } pub fn setImPressHandleName(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "IMPRESS", .{}, arg); } /// /// HIDEMARK [Motif and GTK Only]: If enabled the item cannot be checked, since /// the check box will not be shown. /// If all items in a menu enable it, then no empty space will be shown in /// front of the items. /// Normally the unmarked check box will not be shown, but since GTK 2.14 the /// unmarked check box is always shown. /// If your item will not be marked you must set HIDEMARK=YES, since this is /// the most common case we changed the default value to YES for this version /// of GTK, but if VALUE is defined the default goes back to NO. /// Default: NO. /// (since 3.0) pub fn getHideMark(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "HIDEMARK", .{}); } /// /// HIDEMARK [Motif and GTK Only]: If enabled the item cannot be checked, since /// the check box will not be shown. /// If all items in a menu enable it, then no empty space will be shown in /// front of the items. /// Normally the unmarked check box will not be shown, but since GTK 2.14 the /// unmarked check box is always shown. /// If your item will not be marked you must set HIDEMARK=YES, since this is /// the most common case we changed the default value to YES for this version /// of GTK, but if VALUE is defined the default goes back to NO. /// Default: NO. /// (since 3.0) pub fn setHideMark(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "HIDEMARK", .{}, arg); } /// /// IMAGE [Windows and GTK Only] (non inheritable): Image name of the check /// mark image when VALUE=OFF. /// In Windows, an item in a menu bar cannot have a check mark. /// Ignored if item in a menu bar. /// A recommended size would be 16x16 to fit the image in the menu item. /// In Windows, if larger than the check mark area it will be cropped. pub fn getImage(self: *Self) ?iup.Element { if (interop.getHandleAttribute(self, "IMAGE", .{})) |handle| { return iup.Element.fromHandle(handle); } else { return null; } } /// /// IMAGE [Windows and GTK Only] (non inheritable): Image name of the check /// mark image when VALUE=OFF. /// In Windows, an item in a menu bar cannot have a check mark. /// Ignored if item in a menu bar. /// A recommended size would be 16x16 to fit the image in the menu item. /// In Windows, if larger than the check mark area it will be cropped. pub fn setImage(self: *Self, arg: anytype) !void { try interop.validateHandle(.Image, arg); interop.setHandleAttribute(self, "IMAGE", .{}, arg); } pub fn setImageHandleName(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "IMAGE", .{}, arg); } pub fn getHandleName(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "HANDLENAME", .{}); } pub fn setHandleName(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "HANDLENAME", .{}, arg); } pub fn getBgColor(self: *Self) ?iup.Rgb { return interop.getRgb(self, "BGCOLOR", .{}); } pub fn setBgColor(self: *Self, rgb: iup.Rgb) void { interop.setRgb(self, "BGCOLOR", .{}, rgb); } /// /// TITLEIMAGE (non inheritable): Image name of the title image. /// In Windows, it appears before of the title text and after the check mark /// area (so both title and title image can be visible). /// In Motif, it must be at least defined during map, it replaces the text, and /// only images will be possible to set (TITLE will be hidden). /// In GTK, it will appear on the check mark area. /// (since 3.0) pub fn getTitleImage(self: *Self) ?iup.Element { if (interop.getHandleAttribute(self, "TITLEIMAGE", .{})) |handle| { return iup.Element.fromHandle(handle); } else { return null; } } /// /// TITLEIMAGE (non inheritable): Image name of the title image. /// In Windows, it appears before of the title text and after the check mark /// area (so both title and title image can be visible). /// In Motif, it must be at least defined during map, it replaces the text, and /// only images will be possible to set (TITLE will be hidden). /// In GTK, it will appear on the check mark area. /// (since 3.0) pub fn setTitleImage(self: *Self, arg: anytype) !void { try interop.validateHandle(.Image, arg); interop.setHandleAttribute(self, "TITLEIMAGE", .{}, arg); } pub fn setTitleImageHandleName(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "TITLEIMAGE", .{}, arg); } /// /// KEY (non inheritable): Underlines a key character in the submenu title. /// It is updated only when TITLE is updated. /// Deprecated (since 3.0), use the mnemonic support directly in the TITLE attribute. pub fn getKey(self: *Self) i32 { return interop.getIntAttribute(self, "KEY", .{}); } /// /// KEY (non inheritable): Underlines a key character in the submenu title. /// It is updated only when TITLE is updated. /// Deprecated (since 3.0), use the mnemonic support directly in the TITLE attribute. pub fn setKey(self: *Self, arg: i32) void { interop.setIntAttribute(self, "KEY", .{}, arg); } pub fn getFont(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "FONT", .{}); } pub fn setFont(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "FONT", .{}, arg); } pub fn getName(self: *Self) [:0]const u8 { return interop.getStrAttribute(self, "NAME", .{}); } pub fn setName(self: *Self, arg: [:0]const u8) void { interop.setStrAttribute(self, "NAME", .{}, arg); } /// /// VALUE (non inheritable): Indicates the item's state. /// When the value is ON, a mark will be displayed to the left of the item. /// Default: OFF. /// An item in a menu bar cannot have a check mark. /// When IMAGE is used, the checkmark is not shown. /// See the item AUTOTOGGLE attribute and the menu RADIO attribute. /// Since GTK 2.14 to have a menu item that can be marked you must set the /// VALUE attribute to ON or OFF, or set HIDEMARK=NO, before mapping the control. pub fn getValue(self: *Self) ?Value { var ret = interop.getStrAttribute(self, "VALUE", .{}); if (std.ascii.eqlIgnoreCase("ON", ret)) return .On; if (std.ascii.eqlIgnoreCase("OFF", ret)) return .Off; return null; } /// /// VALUE (non inheritable): Indicates the item's state. /// When the value is ON, a mark will be displayed to the left of the item. /// Default: OFF. /// An item in a menu bar cannot have a check mark. /// When IMAGE is used, the checkmark is not shown. /// See the item AUTOTOGGLE attribute and the menu RADIO attribute. /// Since GTK 2.14 to have a menu item that can be marked you must set the /// VALUE attribute to ON or OFF, or set HIDEMARK=NO, before mapping the control. pub fn setValue(self: *Self, arg: ?Value) void { if (arg) |value| switch (value) { .On => interop.setStrAttribute(self, "VALUE", .{}, "ON"), .Off => interop.setStrAttribute(self, "VALUE", .{}, "OFF"), } else { interop.clearAttribute(self, "VALUE", .{}); } } /// /// WID (non inheritable): In Windows, returns the HMENU of the parent menu. pub fn getWId(self: *Self) i32 { return interop.getIntAttribute(self, "WID", .{}); } /// /// AUTOTOGGLE (non inheritable): enables the automatic toggle of VALUE state /// when the item is activated. /// Default: NO. /// (since 3.0) pub fn getAutoToggle(self: *Self) bool { return interop.getBoolAttribute(self, "AUTOTOGGLE", .{}); } /// /// AUTOTOGGLE (non inheritable): enables the automatic toggle of VALUE state /// when the item is activated. /// Default: NO. /// (since 3.0) pub fn setAutoToggle(self: *Self, arg: bool) void { interop.setBoolAttribute(self, "AUTOTOGGLE", .{}, arg); } /// /// EXPANDWEIGHT (non inheritable) (at children only): If a child defines the /// expand weight, then it is used to multiply the free space used for expansion. /// (since 3.1) pub fn getExpandWeight(self: *Self) f64 { return interop.getDoubleAttribute(self, "EXPANDWEIGHT", .{}); } /// /// EXPANDWEIGHT (non inheritable) (at children only): If a child defines the /// expand weight, then it is used to multiply the free space used for expansion. /// (since 3.1) pub fn setExpandWeight(self: *Self, arg: f64) void { interop.setDoubleAttribute(self, "EXPANDWEIGHT", .{}, arg); } /// /// FLOATING (non inheritable) (at children only): If a child has FLOATING=YES /// then its size and position will be ignored by the layout processing. /// Default: "NO". /// (since 3.0) pub fn getFloating(self: *Self) ?Floating { var ret = interop.getStrAttribute(self, "FLOATING", .{}); if (std.ascii.eqlIgnoreCase("YES", ret)) return .Yes; if (std.ascii.eqlIgnoreCase("IGNORE", ret)) return .Ignore; if (std.ascii.eqlIgnoreCase("NO", ret)) return .No; return null; } /// /// FLOATING (non inheritable) (at children only): If a child has FLOATING=YES /// then its size and position will be ignored by the layout processing. /// Default: "NO". /// (since 3.0) pub fn setFloating(self: *Self, arg: ?Floating) void { if (arg) |value| switch (value) { .Yes => interop.setStrAttribute(self, "FLOATING", .{}, "YES"), .Ignore => interop.setStrAttribute(self, "FLOATING", .{}, "IGNORE"), .No => interop.setStrAttribute(self, "FLOATING", .{}, "NO"), } else { interop.clearAttribute(self, "FLOATING", .{}); } } /// /// TABIMAGEn (non inheritable): image name to be used in the respective tab. /// Use IupSetHandle or IupSetAttributeHandle to associate an image to a name. /// n starts at 0. /// See also IupImage. /// In Motif, the image is shown only if TABTITLEn is NULL. /// In Windows and Motif set the BGCOLOR attribute before setting the image. /// When set after map will update the TABIMAGE attribute on the respective /// child (since 3.10). /// (since 3.0). /// TABIMAGE (non inheritable) (at children only): Same as TABIMAGEn but set in /// each child. /// Works only if set before the child is added to the tabs. pub fn getTabImage(self: *Self, index: i32) ?iup.Element { if (interop.getHandleAttribute(self, "TABIMAGE", .{index})) |handle| { return iup.Element.fromHandle(handle); } else { return null; } } /// /// TABIMAGEn (non inheritable): image name to be used in the respective tab. /// Use IupSetHandle or IupSetAttributeHandle to associate an image to a name. /// n starts at 0. /// See also IupImage. /// In Motif, the image is shown only if TABTITLEn is NULL. /// In Windows and Motif set the BGCOLOR attribute before setting the image. /// When set after map will update the TABIMAGE attribute on the respective /// child (since 3.10). /// (since 3.0). /// TABIMAGE (non inheritable) (at children only): Same as TABIMAGEn but set in /// each child. /// Works only if set before the child is added to the tabs. pub fn setTabImage(self: *Self, index: i32, arg: anytype) !void { try interop.validateHandle(.Image, arg); interop.setHandleAttribute(self, "TABIMAGE", .{index}, arg); } pub fn setTabImageHandleName(self: *Self, index: i32, arg: [:0]const u8) void { interop.setStrAttribute(self, "TABIMAGE", .{index}, arg); } /// /// TABTITLEn (non inheritable): Contains the text to be shown in the /// respective tab title. /// n starts at 0. /// If this value is NULL, it will remain empty. /// The "&" character can be used to define a mnemonic, the next character will /// be used as key. /// Use "&&" to show the "&" character instead on defining a mnemonic. /// The button can be activated from any control in the dialog using the /// "Alt+key" combination. /// (mnemonic support since 3.3). /// When set after map will update the TABTITLE attribute on the respective /// child (since 3.10). /// (since 3.0). /// TABTITLE (non inheritable) (at children only): Same as TABTITLEn but set in /// each child. /// Works only if set before the child is added to the tabs. pub fn getTabTitle(self: *Self, index: i32) [:0]const u8 { return interop.getStrAttribute(self, "TABTITLE", .{index}); } /// /// TABTITLEn (non inheritable): Contains the text to be shown in the /// respective tab title. /// n starts at 0. /// If this value is NULL, it will remain empty. /// The "&" character can be used to define a mnemonic, the next character will /// be used as key. /// Use "&&" to show the "&" character instead on defining a mnemonic. /// The button can be activated from any control in the dialog using the /// "Alt+key" combination. /// (mnemonic support since 3.3). /// When set after map will update the TABTITLE attribute on the respective /// child (since 3.10). /// (since 3.0). /// TABTITLE (non inheritable) (at children only): Same as TABTITLEn but set in /// each child. /// Works only if set before the child is added to the tabs. pub fn setTabTitle(self: *Self, index: i32, arg: [:0]const u8) void { interop.setStrAttribute(self, "TABTITLE", .{index}, arg); } pub fn setLDestroyCallback(self: *Self, callback: ?OnLDestroyFn) void { const Handler = CallbackHandler(Self, OnLDestroyFn, "LDESTROY_CB"); Handler.setCallback(self, callback); } /// /// ACTION ACTION Action generated when the element is activated. /// Affects each element differently. /// Callback int function(Ihandle *ih); [in C] ih:action() -> (ret: number) [in /// Lua] ih: identifier of the element that activated the event. /// In some elements, this callback may receive more parameters, apart from ih. /// Please refer to each element's documentation. /// Affects IupButton, IupItem, IupList, IupText, IupCanvas, IupMultiline, /// IupToggle pub fn setActionCallback(self: *Self, callback: ?OnActionFn) void { const Handler = CallbackHandler(Self, OnActionFn, "ACTION"); Handler.setCallback(self, callback); } /// /// DESTROY_CB DESTROY_CB Called right before an element is destroyed. /// Callback int function(Ihandle *ih); [in C] ih:destroy_cb() -> (ret: number) /// [in Lua] ih: identifier of the element that activated the event. /// Notes If the dialog is visible then it is hidden before it is destroyed. /// The callback will be called right after it is hidden. /// The callback will be called before all other destroy procedures. /// For instance, if the element has children then it is called before the /// children are destroyed. /// For language binding implementations use the callback name "LDESTROY_CB" to /// release memory allocated by the binding for the element. /// Also the callback will be called before the language callback. /// Affects All. pub fn setDestroyCallback(self: *Self, callback: ?OnDestroyFn) void { const Handler = CallbackHandler(Self, OnDestroyFn, "DESTROY_CB"); Handler.setCallback(self, callback); } /// /// HIGHLIGHT_CB HIGHLIGHT_CB Callback triggered every time the user selects an /// IupItem or IupSubmenu. /// Callback int function(Ihandle *ih); [in C] elem:highlight_cb() -> (ret: /// number) [in Lua] ih: identifier of the element that activated the event. /// Affects IupItem, IupSubmenu pub fn setHighlightCallback(self: *Self, callback: ?OnHighlightFn) void { const Handler = CallbackHandler(Self, OnHighlightFn, "HIGHLIGHT_CB"); Handler.setCallback(self, callback); } /// /// MAP_CB MAP_CB Called right after an element is mapped and its attributes /// updated in IupMap. /// When the element is a dialog, it is called after the layout is updated. /// For all other elements is called before the layout is updated, so the /// element current size will still be 0x0 during MAP_CB (since 3.14). /// Callback int function(Ihandle *ih); [in C] ih:map_cb() -> (ret: number) [in /// Lua] ih: identifier of the element that activated the event. /// Affects All that have a native representation. pub fn setMapCallback(self: *Self, callback: ?OnMapFn) void { const Handler = CallbackHandler(Self, OnMapFn, "MAP_CB"); Handler.setCallback(self, callback); } pub fn setPostMessageCallback(self: *Self, callback: ?OnPostMessageFn) void { const Handler = CallbackHandler(Self, OnPostMessageFn, "POSTMESSAGE_CB"); Handler.setCallback(self, callback); } /// /// UNMAP_CB UNMAP_CB Called right before an element is unmapped. /// Callback int function(Ihandle *ih); [in C] ih:unmap_cb() -> (ret: number) /// [in Lua] ih: identifier of the element that activated the event. /// Affects All that have a native representation. pub fn setUnmapCallback(self: *Self, callback: ?OnUnmapFn) void { const Handler = CallbackHandler(Self, OnUnmapFn, "UNMAP_CB"); Handler.setCallback(self, callback); } /// /// HELP_CB HELP_CB Action generated when the user press F1 at a control. /// In Motif is also activated by the Help button in some workstations keyboard. /// Callback void function(Ihandle *ih); [in C] ih:help_cb() -> (ret: number) /// [in Lua] ih: identifier of the element that activated the event. /// Returns: IUP_CLOSE will be processed. /// Affects All elements with user interaction. pub fn setHelpCallback(self: *Self, callback: ?OnHelpFn) void { const Handler = CallbackHandler(Self, OnHelpFn, "HELP_CB"); Handler.setCallback(self, callback); } }; test "Item Active" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setActive(true).unwrap()); defer item.deinit(); var ret = item.getActive(); try std.testing.expect(ret == true); } test "Item Title" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setTitle("Hello").unwrap()); defer item.deinit(); var ret = item.getTitle(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "Item HideMark" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setHideMark("Hello").unwrap()); defer item.deinit(); var ret = item.getHideMark(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "Item HandleName" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setHandleName("Hello").unwrap()); defer item.deinit(); var ret = item.getHandleName(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "Item BgColor" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setBgColor(.{ .r = 9, .g = 10, .b = 11 }).unwrap()); defer item.deinit(); var ret = item.getBgColor(); try std.testing.expect(ret != null and ret.?.r == 9 and ret.?.g == 10 and ret.?.b == 11); } test "Item Key" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setKey(42).unwrap()); defer item.deinit(); var ret = item.getKey(); try std.testing.expect(ret == 42); } test "Item Font" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setFont("Hello").unwrap()); defer item.deinit(); var ret = item.getFont(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "Item Name" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setName("Hello").unwrap()); defer item.deinit(); var ret = item.getName(); try std.testing.expect(std.mem.eql(u8, ret, "Hello")); } test "Item Value" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setValue(.On).unwrap()); defer item.deinit(); var ret = item.getValue(); try std.testing.expect(ret != null and ret.? == .On); } test "Item AutoToggle" { try iup.MainLoop.open(); defer iup.MainLoop.close(); var item = try (iup.Item.init().setAutoToggle(true).unwrap()); defer item.deinit(); var ret = item.getAutoToggle(); try std.testing.expect(ret == true); }
src/elements/item.zig
pub var OUTPUT: *CompositorOutput = undefined; pub fn main() anyerror!void { try epoll.init(); var detected_type = backends.detect(); var backend: Backend = try Backend.new(detected_type); try backend.init(); defer backend.deinit(); try compositor.COMPOSITOR.init(); var o1 = try out.newOutput(&backend, 640, 480); defer { o1.deinit() catch |err| {}; } try o1.addToEpoll(); OUTPUT = o1; // var o2 = try out.newOutput(&backend, 300, 300); views.CURRENT_VIEW = &o1.data.views[0]; std.debug.warn("==> backend: {s}\n", .{backend.name()}); var server = try Server.init(); defer { server.deinit(); } try server.addToEpoll(); try render.init(); defer render.deinit(); var cursor = try Cursor.init(); defer cursor.deinit(); var frames: u32 = 0; var now = std.time.milliTimestamp(); var then = now; while (compositor.COMPOSITOR.running) { var i: usize = 0; var n = epoll.wait(backend.wait()); while (i < n) { try epoll.dispatch(i); i = i + 1; } var out_it = out.OUTPUTS.iterator(); while (out_it.next()) |output| { if (output.isPageFlipScheduled() == false) { try output.begin(); try render.clear(); try render.render(output); for (output.data.views) |*view| { if (view.visible() == false) { continue; } var it = view.back(); while (it) |window| : (it = window.toplevel.next) { try window.render(0, 0); } } if (views.CURRENT_VIEW.output == output) { try cursor.render( @floatToInt(i32, compositor.COMPOSITOR.pointer_x), @floatToInt(i32, compositor.COMPOSITOR.pointer_y), ); } try output.swap(); frames += 1; now = std.time.milliTimestamp(); output.end(); if ((now - then) > 5000) { std.debug.warn("fps: {}\n", .{frames / 5}); then = now; frames = 0; } for (windows.WINDOWS) |*window| { if (window.in_use) { try window.frameCallback(); } } if (output.shouldClose()) { try output.deinit(); } } } } } const std = @import("std"); const epoll = @import("epoll.zig"); const backends = @import("backend/backend.zig"); const render = @import("renderer.zig"); const out = @import("output.zig"); const views = @import("view.zig"); const windows = @import("window.zig"); const compositor = @import("compositor.zig"); const Context = @import("client.zig").Context; const Server = @import("server.zig").Server; const Cursor = @import("cursor.zig").Cursor; const Output = @import("output.zig").Output; const CompositorOutput = @import("output.zig").CompositorOutput; const Backend = backends.Backend(Output);
src/main.zig
const std = @import("std"); const builtin = @import("builtin"); const known_folders = @import("known-folders"); /// Caller must free memory. pub fn askString(allocator: std.mem.Allocator, prompt: []const u8, max_size: usize) ![]u8 { const in = std.io.getStdIn().reader(); const out = std.io.getStdOut().writer(); try out.print("? {s}", .{prompt}); const result = try in.readUntilDelimiterAlloc(allocator, '\n', max_size); return if (std.mem.endsWith(u8, result, "\r")) result[0..(result.len - 1)] else result; } /// Caller must free memory. Max size is recommended to be a high value, like 512. pub fn askDirPath(allocator: std.mem.Allocator, prompt: []const u8, max_size: usize) ![]u8 { const out = std.io.getStdOut().writer(); while (true) { const path = try askString(allocator, prompt, max_size); if (!std.fs.path.isAbsolute(path)) { try out.writeAll("Error: Invalid directory, please try again.\n\n"); allocator.free(path); continue; } var dir = std.fs.cwd().openDir(path, std.fs.Dir.OpenDirOptions{}) catch { try out.writeAll("Error: Invalid directory, please try again.\n\n"); allocator.free(path); continue; }; dir.close(); return path; } } pub fn askBool(prompt: []const u8) !bool { const in = std.io.getStdIn().reader(); const out = std.io.getStdOut().writer(); var buffer: [1]u8 = undefined; while (true) { try out.print("? {s} (y/n) > ", .{prompt}); const read = in.read(&buffer) catch continue; try in.skipUntilDelimiterOrEof('\n'); if (read == 0) return error.EndOfStream; switch (buffer[0]) { 'y' => return true, 'n' => return false, else => continue, } } } pub fn askSelectOne(prompt: []const u8, comptime Options: type) !Options { const in = std.io.getStdIn().reader(); const out = std.io.getStdOut().writer(); try out.print("? {s} (select one)\n\n", .{prompt}); comptime var max_size: usize = 0; inline for (@typeInfo(Options).Enum.fields) |option| { try out.print(" - {s}\n", .{option.name}); if (option.name.len > max_size) max_size = option.name.len; } while (true) { var buffer: [max_size + 1]u8 = undefined; try out.writeAll("\n> "); var result = (in.readUntilDelimiterOrEof(&buffer, '\n') catch { try in.skipUntilDelimiterOrEof('\n'); try out.writeAll("Error: Invalid option, please try again.\n"); continue; }) orelse return error.EndOfStream; result = if (std.mem.endsWith(u8, result, "\r")) result[0..(result.len - 1)] else result; inline for (@typeInfo(Options).Enum.fields) |option| if (std.ascii.eqlIgnoreCase(option.name, result)) return @intToEnum(Options, option.value); try out.writeAll("Error: Invalid option, please try again.\n"); } } fn print(comptime fmt: []const u8, args: anytype) void { const stdout = std.io.getStdOut().writer(); stdout.print(fmt, args) catch @panic("Could not write to stdout"); } fn write(text: []const u8) void { const stdout = std.io.getStdOut().writer(); stdout.writeAll(text) catch @panic("Could not write to stdout"); } pub fn wizard(allocator: std.mem.Allocator) !void { @setEvalBranchQuota(2500); write( \\Welcome to the ZLS configuration wizard! \\ * \\ |\ \\ /* \ \\ | *\ \\ _/_*___|_ x \\ | @ @ / \\ @ \ / \\ \__-/ / \\ \\ ); var local_path = known_folders.getPath(allocator, .local_configuration) catch null; var global_path = known_folders.getPath(allocator, .global_configuration) catch null; defer if (local_path) |d| allocator.free(d); defer if (global_path) |d| allocator.free(d); if (global_path == null and local_path == null) { write("Could not open a global or local config directory.\n"); return; } var config_path: []const u8 = undefined; if (try askBool("Should this configuration be system-wide?")) { if (global_path) |p| { config_path = p; } else { write("Could not find a global config directory.\n"); return; } } else { if (local_path) |p| { config_path = p; } else { write("Could not find a local config directory.\n"); return; } } var dir = std.fs.cwd().openDir(config_path, .{}) catch |err| { print("Could not open {s}: {}.\n", .{ config_path, err }); return; }; defer dir.close(); var file = dir.createFile("zls.json", .{}) catch |err| { print("Could not create {s}/zls.json: {}.\n", .{ config_path, err }); return; }; defer file.close(); const out = file.writer(); var zig_exe_path = try findZig(allocator); defer if (zig_exe_path) |p| allocator.free(p); if (zig_exe_path) |path| { print("Found zig executable '{s}' in PATH.\n", .{path}); } else { write("Could not find 'zig' in PATH\n"); zig_exe_path = try askString(allocator, if (builtin.os.tag == .windows) \\What is the path to the 'zig' executable you would like to use? \\Note that due to a bug in zig (https://github.com/ziglang/zig/issues/6044), \\your zig directory cannot contain the '/' character. else "What is the path to the 'zig' executable you would like to use?", std.fs.MAX_PATH_BYTES); } const editor = try askSelectOne("Which code editor do you use?", enum { VSCode, Sublime, Kate, Neovim, Vim8, Emacs, Doom, Spacemacs, Other }); const snippets = try askBool("Do you want to enable snippets?"); const style = try askBool("Do you want to enable style warnings?"); const semantic_tokens = try askBool("Do you want to enable semantic highlighting?"); const operator_completions = try askBool("Do you want to enable .* and .? completions?"); const include_at_in_builtins = switch (editor) { .Sublime => true, .VSCode, .Kate, .Neovim, .Vim8, .Emacs, .Doom, .Spacemacs => false, else => try askBool("Should the @ sign be included in completions of builtin functions?\nChange this later if `@inc` completes to `include` or `@@include`"), }; const max_detail_length: usize = switch (editor) { .Sublime => 256, else => 1024 * 1024, }; std.debug.print("Writing config to {s}/zls.json ... ", .{config_path}); try std.json.stringify(.{ .zig_exe_path = zig_exe_path, .enable_snippets = snippets, .warn_style = style, .enable_semantic_tokens = semantic_tokens, .operator_completions = operator_completions, .include_at_in_builtins = include_at_in_builtins, .max_detail_length = max_detail_length, }, .{}, out); write("successful.\n\n\n\n"); // Keep synced with README.md switch (editor) { .VSCode => { write( \\To use ZLS in Visual Studio Code, install the 'ZLS for VSCode' extension from \\'https://github.com/zigtools/zls-vscode/releases' or via the extensions menu. \\Then, open VSCode's 'settings.json' file, and add: \\ \\"zigLanguageClient.path": "[command_or_path_to_zls]" ); }, .Sublime => { write( \\To use ZLS in Sublime, install the `LSP` package from \\https://github.com/sublimelsp/LSP/releases or via Package Control. \\Then, add the following snippet to LSP's user settings: \\ \\For Sublime Text 3: \\ \\{ \\ "clients": { \\ "zig": { \\ "command": ["zls"], \\ "enabled": true, \\ "languageId": "zig", \\ "scopes": ["source.zig"], \\ "syntaxes": ["Packages/Zig Language/Syntaxes/Zig.tmLanguage"] \\ } \\ } \\} \\ \\For Sublime Text 4: \\ \\{ \\ "clients": { \\ "zig": { \\ "command": ["zls"], \\ "enabled": true, \\ "selector": "source.zig" \\ } \\ } \\} ); }, .Kate => { write( \\To use ZLS in Kate, enable `LSP client` plugin in Kate settings. \\Then, add the following snippet to `LSP client's` user settings: \\(or paste it in `LSP client's` GUI settings) \\ \\{ \\ "servers": { \\ "zig": { \\ "command": ["zls"], \\ "url": "https://github.com/zigtools/zls", \\ "highlightingModeRegex": "^Zig$" \\ } \\ } \\} ); }, .Neovim, .Vim8 => { write( \\To use ZLS in Neovim/Vim8, we recommend using CoC engine. \\You can get it from https://github.com/neoclide/coc.nvim. \\Then, simply issue cmd from Neovim/Vim8 `:CocConfig`, and add this to your CoC config: \\ \\{ \\ "languageserver": { \\ "zls" : { \\ "command": "command_or_path_to_zls", \\ "filetypes": ["zig"] \\ } \\ } \\} ); }, .Emacs => { write( \\To use ZLS in Emacs, install lsp-mode (https://github.com/emacs-lsp/lsp-mode) from melpa. \\Zig mode (https://github.com/ziglang/zig-mode) is also useful! \\Then, add the following to your emacs config: \\ \\(require 'lsp-mode) \\(setq lsp-zig-zls-executable "<path to zls>") ); }, .Doom => { write( \\To use ZLS in Doom Emacs, enable the lsp module \\And install the `zig-mode` (https://github.com/ziglang/zig-mode) \\package by adding `(package! zig-mode)` to your packages.el file. \\ \\(use-package! zig-mode \\ :hook ((zig-mode . lsp-deferred)) \\ :custom (zig-format-on-save nil) \\ :config \\ (after! lsp-mode \\ (add-to-list 'lsp-language-id-configuration '(zig-mode . "zig")) \\ (lsp-register-client \\ (make-lsp-client \\ :new-connection (lsp-stdio-connection "<path to zls>") \\ :major-modes '(zig-mode) \\ :server-id 'zls)))) ); }, .Spacemacs => { write( \\To use ZLS in Spacemacs, add the `lsp` and `zig` layers \\to `dotspacemacs-configuration-layers` in your .spacemacs file. \\Then, if you don't have `zls` in your PATH, add the following to \\`dotspacemacs/user-config` in your .spacemacs file: \\ \\(setq lsp-zig-zls-executable "<path to zls>") ); }, .Other => { write( \\We might not *officially* support your editor, but you can definitely still use ZLS! \\Simply configure your editor for use with language servers and point it to the ZLS executable! ); }, } write("\n\nThank you for choosing ZLS!\n"); } pub fn findZig(allocator: std.mem.Allocator) !?[]const u8 { const env_path = std.process.getEnvVarOwned(allocator, "PATH") catch |err| switch (err) { error.EnvironmentVariableNotFound => { return null; }, else => return err, }; defer allocator.free(env_path); const exe_extension = builtin.target.exeFileExt(); const zig_exe = try std.fmt.allocPrint(allocator, "zig{s}", .{exe_extension}); defer allocator.free(zig_exe); var it = std.mem.tokenize(u8, env_path, &[_]u8{std.fs.path.delimiter}); while (it.next()) |path| { if (builtin.os.tag == .windows) { if (std.mem.indexOfScalar(u8, path, '/') != null) continue; } const full_path = try std.fs.path.join(allocator, &[_][]const u8{ path, zig_exe }); defer allocator.free(full_path); if (!std.fs.path.isAbsolute(full_path)) continue; const file = std.fs.openFileAbsolute(full_path, .{}) catch continue; defer file.close(); const stat = file.stat() catch continue; if (stat.kind == .Directory) continue; return try allocator.dupe(u8, full_path); } return null; }
src/setup.zig
const std = @import("std"); const Type = @import("type.zig").Type; const log2 = std.math.log2; const assert = std.debug.assert; const BigInt = std.math.big.Int; const Target = std.Target; const Allocator = std.mem.Allocator; /// This is the raw data, with no bookkeeping, no memory awareness, /// no de-duplication, and no type system awareness. /// It's important for this struct to be small. /// This union takes advantage of the fact that the first page of memory /// is unmapped, giving us 4096 possible enum tags that have no payload. pub const Value = extern union { /// If the tag value is less than Tag.no_payload_count, then no pointer /// dereference is needed. tag_if_small_enough: usize, ptr_otherwise: *Payload, pub const Tag = enum { // The first section of this enum are tags that require no payload. u8_type, i8_type, isize_type, usize_type, c_short_type, c_ushort_type, c_int_type, c_uint_type, c_long_type, c_ulong_type, c_longlong_type, c_ulonglong_type, c_longdouble_type, f16_type, f32_type, f64_type, f128_type, c_void_type, bool_type, void_type, type_type, anyerror_type, comptime_int_type, comptime_float_type, noreturn_type, fn_naked_noreturn_no_args_type, single_const_pointer_to_comptime_int_type, const_slice_u8_type, zero, void_value, noreturn_value, bool_true, bool_false, // See last_no_payload_tag below. // After this, the tag requires a payload. ty, int_u64, int_i64, int_big, function, ref, ref_val, bytes, pub const last_no_payload_tag = Tag.bool_false; pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1; }; pub fn initTag(comptime small_tag: Tag) Value { comptime assert(@enumToInt(small_tag) < Tag.no_payload_count); return .{ .tag_if_small_enough = @enumToInt(small_tag) }; } pub fn initPayload(payload: *Payload) Value { assert(@enumToInt(payload.tag) >= Tag.no_payload_count); return .{ .ptr_otherwise = payload }; } pub fn tag(self: Value) Tag { if (self.tag_if_small_enough < Tag.no_payload_count) { return @intToEnum(Tag, @intCast(@TagType(Tag), self.tag_if_small_enough)); } else { return self.ptr_otherwise.tag; } } pub fn cast(self: Value, comptime T: type) ?*T { if (self.tag_if_small_enough < Tag.no_payload_count) return null; const expected_tag = std.meta.fieldInfo(T, "base").default_value.?.tag; if (self.ptr_otherwise.tag != expected_tag) return null; return @fieldParentPtr(T, "base", self.ptr_otherwise); } pub fn format( self: Value, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: var, ) !void { comptime assert(fmt.len == 0); var val = self; while (true) switch (val.tag()) { .u8_type => return out_stream.writeAll("u8"), .i8_type => return out_stream.writeAll("i8"), .isize_type => return out_stream.writeAll("isize"), .usize_type => return out_stream.writeAll("usize"), .c_short_type => return out_stream.writeAll("c_short"), .c_ushort_type => return out_stream.writeAll("c_ushort"), .c_int_type => return out_stream.writeAll("c_int"), .c_uint_type => return out_stream.writeAll("c_uint"), .c_long_type => return out_stream.writeAll("c_long"), .c_ulong_type => return out_stream.writeAll("c_ulong"), .c_longlong_type => return out_stream.writeAll("c_longlong"), .c_ulonglong_type => return out_stream.writeAll("c_ulonglong"), .c_longdouble_type => return out_stream.writeAll("c_longdouble"), .f16_type => return out_stream.writeAll("f16"), .f32_type => return out_stream.writeAll("f32"), .f64_type => return out_stream.writeAll("f64"), .f128_type => return out_stream.writeAll("f128"), .c_void_type => return out_stream.writeAll("c_void"), .bool_type => return out_stream.writeAll("bool"), .void_type => return out_stream.writeAll("void"), .type_type => return out_stream.writeAll("type"), .anyerror_type => return out_stream.writeAll("anyerror"), .comptime_int_type => return out_stream.writeAll("comptime_int"), .comptime_float_type => return out_stream.writeAll("comptime_float"), .noreturn_type => return out_stream.writeAll("noreturn"), .fn_naked_noreturn_no_args_type => return out_stream.writeAll("fn() callconv(.Naked) noreturn"), .single_const_pointer_to_comptime_int_type => return out_stream.writeAll("*const comptime_int"), .const_slice_u8_type => return out_stream.writeAll("[]const u8"), .zero => return out_stream.writeAll("0"), .void_value => return out_stream.writeAll("{}"), .noreturn_value => return out_stream.writeAll("unreachable"), .bool_true => return out_stream.writeAll("true"), .bool_false => return out_stream.writeAll("false"), .ty => return val.cast(Payload.Ty).?.ty.format("", options, out_stream), .int_u64 => return std.fmt.formatIntValue(val.cast(Payload.Int_u64).?.int, "", options, out_stream), .int_i64 => return std.fmt.formatIntValue(val.cast(Payload.Int_i64).?.int, "", options, out_stream), .int_big => return out_stream.print("{}", .{val.cast(Payload.IntBig).?.big_int}), .function => return out_stream.writeAll("(function)"), .ref => return out_stream.writeAll("(ref)"), .ref_val => { try out_stream.writeAll("*const "); val = val.cast(Payload.RefVal).?.val; continue; }, .bytes => return std.zig.renderStringLiteral(self.cast(Payload.Bytes).?.data, out_stream), }; } /// Asserts that the value is representable as an array of bytes. /// Copies the value into a freshly allocated slice of memory, which is owned by the caller. pub fn toAllocatedBytes(self: Value, allocator: *Allocator) Allocator.Error![]u8 { if (self.cast(Payload.Bytes)) |bytes| { return std.mem.dupe(allocator, u8, bytes.data); } unreachable; } /// Asserts that the value is representable as a type. pub fn toType(self: Value) Type { return switch (self.tag()) { .ty => self.cast(Payload.Ty).?.ty, .u8_type => Type.initTag(.@"u8"), .i8_type => Type.initTag(.@"i8"), .isize_type => Type.initTag(.@"isize"), .usize_type => Type.initTag(.@"usize"), .c_short_type => Type.initTag(.@"c_short"), .c_ushort_type => Type.initTag(.@"c_ushort"), .c_int_type => Type.initTag(.@"c_int"), .c_uint_type => Type.initTag(.@"c_uint"), .c_long_type => Type.initTag(.@"c_long"), .c_ulong_type => Type.initTag(.@"c_ulong"), .c_longlong_type => Type.initTag(.@"c_longlong"), .c_ulonglong_type => Type.initTag(.@"c_ulonglong"), .c_longdouble_type => Type.initTag(.@"c_longdouble"), .f16_type => Type.initTag(.@"f16"), .f32_type => Type.initTag(.@"f32"), .f64_type => Type.initTag(.@"f64"), .f128_type => Type.initTag(.@"f128"), .c_void_type => Type.initTag(.@"c_void"), .bool_type => Type.initTag(.@"bool"), .void_type => Type.initTag(.@"void"), .type_type => Type.initTag(.@"type"), .anyerror_type => Type.initTag(.@"anyerror"), .comptime_int_type => Type.initTag(.@"comptime_int"), .comptime_float_type => Type.initTag(.@"comptime_float"), .noreturn_type => Type.initTag(.@"noreturn"), .fn_naked_noreturn_no_args_type => Type.initTag(.fn_naked_noreturn_no_args), .single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int), .const_slice_u8_type => Type.initTag(.const_slice_u8), .zero, .void_value, .noreturn_value, .bool_true, .bool_false, .int_u64, .int_i64, .int_big, .function, .ref, .ref_val, .bytes, => unreachable, }; } /// Asserts the value is an integer. pub fn toBigInt(self: Value, allocator: *Allocator) Allocator.Error!BigInt { switch (self.tag()) { .ty, .u8_type, .i8_type, .isize_type, .usize_type, .c_short_type, .c_ushort_type, .c_int_type, .c_uint_type, .c_long_type, .c_ulong_type, .c_longlong_type, .c_ulonglong_type, .c_longdouble_type, .f16_type, .f32_type, .f64_type, .f128_type, .c_void_type, .bool_type, .void_type, .type_type, .anyerror_type, .comptime_int_type, .comptime_float_type, .noreturn_type, .fn_naked_noreturn_no_args_type, .single_const_pointer_to_comptime_int_type, .const_slice_u8_type, .void_value, .noreturn_value, .bool_true, .bool_false, .function, .ref, .ref_val, .bytes, => unreachable, .zero => return BigInt.initSet(allocator, 0), .int_u64 => return BigInt.initSet(allocator, self.cast(Payload.Int_u64).?.int), .int_i64 => return BigInt.initSet(allocator, self.cast(Payload.Int_i64).?.int), .int_big => return self.cast(Payload.IntBig).?.big_int, } } /// Asserts the value is an integer and it fits in a u64 pub fn toUnsignedInt(self: Value) u64 { switch (self.tag()) { .ty, .u8_type, .i8_type, .isize_type, .usize_type, .c_short_type, .c_ushort_type, .c_int_type, .c_uint_type, .c_long_type, .c_ulong_type, .c_longlong_type, .c_ulonglong_type, .c_longdouble_type, .f16_type, .f32_type, .f64_type, .f128_type, .c_void_type, .bool_type, .void_type, .type_type, .anyerror_type, .comptime_int_type, .comptime_float_type, .noreturn_type, .fn_naked_noreturn_no_args_type, .single_const_pointer_to_comptime_int_type, .const_slice_u8_type, .void_value, .noreturn_value, .bool_true, .bool_false, .function, .ref, .ref_val, .bytes, => unreachable, .zero => return 0, .int_u64 => return self.cast(Payload.Int_u64).?.int, .int_i64 => return @intCast(u64, self.cast(Payload.Int_u64).?.int), .int_big => return self.cast(Payload.IntBig).?.big_int.to(u64) catch unreachable, } } /// Asserts the value is an integer, and the destination type is ComptimeInt or Int. pub fn intFitsInType(self: Value, ty: Type, target: Target) bool { switch (self.tag()) { .ty, .u8_type, .i8_type, .isize_type, .usize_type, .c_short_type, .c_ushort_type, .c_int_type, .c_uint_type, .c_long_type, .c_ulong_type, .c_longlong_type, .c_ulonglong_type, .c_longdouble_type, .f16_type, .f32_type, .f64_type, .f128_type, .c_void_type, .bool_type, .void_type, .type_type, .anyerror_type, .comptime_int_type, .comptime_float_type, .noreturn_type, .fn_naked_noreturn_no_args_type, .single_const_pointer_to_comptime_int_type, .const_slice_u8_type, .void_value, .noreturn_value, .bool_true, .bool_false, .function, .ref, .ref_val, .bytes, => unreachable, .zero => return true, .int_u64 => switch (ty.zigTypeTag()) { .Int => { const x = self.cast(Payload.Int_u64).?.int; if (x == 0) return true; const info = ty.intInfo(target); const needed_bits = std.math.log2(x) + 1 + @boolToInt(info.signed); return info.bits >= needed_bits; }, .ComptimeInt => return true, else => unreachable, }, .int_i64 => switch (ty.zigTypeTag()) { .Int => { const x = self.cast(Payload.Int_i64).?.int; if (x == 0) return true; const info = ty.intInfo(target); if (!info.signed and x < 0) return false; @panic("TODO implement i64 intFitsInType"); }, .ComptimeInt => return true, else => unreachable, }, .int_big => switch (ty.zigTypeTag()) { .Int => { const info = ty.intInfo(target); return self.cast(Payload.IntBig).?.big_int.fitsInTwosComp(info.signed, info.bits); }, .ComptimeInt => return true, else => unreachable, }, } } /// Asserts the value is a pointer and dereferences it. pub fn pointerDeref(self: Value) Value { switch (self.tag()) { .ty, .u8_type, .i8_type, .isize_type, .usize_type, .c_short_type, .c_ushort_type, .c_int_type, .c_uint_type, .c_long_type, .c_ulong_type, .c_longlong_type, .c_ulonglong_type, .c_longdouble_type, .f16_type, .f32_type, .f64_type, .f128_type, .c_void_type, .bool_type, .void_type, .type_type, .anyerror_type, .comptime_int_type, .comptime_float_type, .noreturn_type, .fn_naked_noreturn_no_args_type, .single_const_pointer_to_comptime_int_type, .const_slice_u8_type, .zero, .void_value, .noreturn_value, .bool_true, .bool_false, .function, .int_u64, .int_i64, .int_big, .bytes, => unreachable, .ref => return self.cast(Payload.Ref).?.cell.contents, .ref_val => return self.cast(Payload.RefVal).?.val, } } /// This type is not copyable since it may contain pointers to its inner data. pub const Payload = struct { tag: Tag, pub const Int_u64 = struct { base: Payload = Payload{ .tag = .int_u64 }, int: u64, }; pub const Int_i64 = struct { base: Payload = Payload{ .tag = .int_i64 }, int: i64, }; pub const IntBig = struct { base: Payload = Payload{ .tag = .int_big }, big_int: BigInt, }; pub const Function = struct { base: Payload = Payload{ .tag = .function }, /// Index into the `fns` array of the `ir.Module` index: usize, }; pub const ArraySentinel0_u8_Type = struct { base: Payload = Payload{ .tag = .array_sentinel_0_u8_type }, len: u64, }; pub const SingleConstPtrType = struct { base: Payload = Payload{ .tag = .single_const_ptr_type }, elem_type: *Type, }; pub const Ref = struct { base: Payload = Payload{ .tag = .ref }, cell: *MemoryCell, }; pub const RefVal = struct { base: Payload = Payload{ .tag = .ref_val }, val: Value, }; pub const Bytes = struct { base: Payload = Payload{ .tag = .bytes }, data: []const u8, }; pub const Ty = struct { base: Payload = Payload{ .tag = .ty }, ty: Type, }; }; }; /// This is the heart of resource management of the Zig compiler. The Zig compiler uses /// stop-the-world mark-and-sweep garbage collection during compilation to manage the resources /// associated with evaluating compile-time code and semantic analysis. Each `MemoryCell` represents /// a root. pub const MemoryCell = struct { parent: Parent, contents: Value, pub const Parent = union(enum) { none, struct_field: struct { struct_base: *MemoryCell, field_index: usize, }, array_elem: struct { array_base: *MemoryCell, elem_index: usize, }, union_field: *MemoryCell, err_union_code: *MemoryCell, err_union_payload: *MemoryCell, optional_payload: *MemoryCell, optional_flag: *MemoryCell, }; };
src-self-hosted/value.zig
const std = @import("std"); const CloneError = error{ SystemResources, InvalidExe, AccessDenied, } || std.os.UnexpectedError; pub const clone_args = extern struct { flags: u64, // Flags bit mask pidfd: u64, // Where to store PID file descriptor (pid_t *) child_tid: u64, // Where to store child TID, in child's memory (pid_t *) parent_tid: u64, // Where to store child TID, in parent's memory (int *) exit_signal: u64, // Signal to deliver to parent on child termination stack: u64, // Pointer to lowest byte of stack stack_size: u64, // Size of stack tls: u64, // Location of new TLS set_tid: u64, // Pointer to a pid_t array (since Linux 5.5) set_tid_size: u64, // Number of elements in set_tid (since Linux 5.5) cgroup: u64, // File descriptor for target cgroup of child (since Linux 5.7) }; pub const CLONE = struct { pub const NEWTIME = 0x00000080; pub const VM = 0x00000100; pub const FS = 0x00000200; pub const FILES = 0x00000400; pub const SIGHAND = 0x00000800; pub const PIDFD = 0x00001000; pub const PTRACE = 0x00002000; pub const VFORK = 0x00004000; pub const PARENT = 0x00008000; pub const THREAD = 0x00010000; pub const NEWNS = 0x00020000; pub const SYSVSEM = 0x00040000; pub const SETTLS = 0x00080000; pub const PARENT_SETTID = 0x00100000; pub const CHILD_CLEARTID = 0x00200000; pub const DETACHED = 0x00400000; pub const UNTRACED = 0x00800000; pub const CHILD_SETTID = 0x01000000; pub const NEWCGROUP = 0x02000000; pub const NEWUTS = 0x04000000; pub const NEWIPC = 0x08000000; pub const NEWUSER = 0x10000000; pub const NEWPID = 0x20000000; pub const NEWNET = 0x40000000; pub const IO = 0x80000000; }; pub fn clone3(cl_args: *clone_args) CloneError!std.os.pid_t { const pid = std.os.linux.syscall2(.clone3, @ptrToInt(cl_args), @sizeOf(clone_args)); return switch (std.os.errno(pid)) { .SUCCESS => @intCast(std.os.pid_t, @bitCast(isize, pid)), .AGAIN => error.SystemResources, .BUSY => error.SystemResources, .EXIST => error.SystemResources, .INVAL => error.InvalidExe, .NOMEM => return error.SystemResources, .NOSPC => return error.SystemResources, .OPNOTSUPP => return error.SystemResources, .PERM => error.AccessDenied, .USERS => return error.SystemResources, else => |err| std.os.unexpectedErrno(err), }; } const PollError = error{ InvalidExe, SystemResources, } || std.os.UnexpectedError; pub fn poll(fds: []std.os.pollfd, n: std.os.nfds_t, timeout: i32) PollError!usize { while (true) { const events = std.os.linux.syscall3(.poll, @ptrToInt(fds.ptr), n, @bitCast(u32, timeout)); return switch (std.os.errno(events)) { .SUCCESS => events, .FAULT => unreachable, .INTR => continue, .INVAL => error.InvalidExe, .NOMEM => return error.SystemResources, else => |err| std.os.unexpectedErrno(err), }; } } const PidfdOpenError = error{ InvalidExe, ProcessFdQuotaExceeded, SystemFdQuotaExceeded, NoDevice, SystemResources, ProcessNotFound, } || std.os.UnexpectedError; pub fn pidfd_open(pid: std.os.pid_t, flags: u32) !i32 { const pidfd = std.os.linux.syscall2(.pidfd_open, @bitCast(u32, pid), flags); return switch (std.os.errno(pidfd)) { .SUCCESS => @intCast(i32, @bitCast(isize, pidfd)), .INVAL => error.InvalidExe, .MFILE => error.ProcessFdQuotaExceeded, .NFILE => error.SystemFdQuotaExceeded, .NODEV => error.NoDevice, .NOMEM => error.SystemResources, .SRCH => error.ProcessNotFound, else => |err| std.os.unexpectedErrno(err), }; } const SetnsError = error{ FileDescriptorInvalid, InvalidExe, SystemResources, AccessDenied, ProcessNotFound, } || std.os.UnexpectedError; pub fn setns(fd: std.os.fd_t, nstype: usize) SetnsError!void { return switch (std.os.errno(std.os.linux.syscall2(.setns, @bitCast(u32, fd), nstype))) { .SUCCESS => {}, .BADF => error.FileDescriptorInvalid, .INVAL => error.InvalidExe, .NOMEM => error.SystemResources, .PERM => error.AccessDenied, .SRCH => error.ProcessNotFound, else => |err| std.os.unexpectedErrno(err), }; } const UnshareError = error{ InvalidExe, SystemResources, AccessDenied, } || std.os.UnexpectedError; pub fn unshare(flags: usize) UnshareError!void { return switch (std.os.errno(std.os.linux.syscall1(.unshare, flags))) { .SUCCESS => {}, .INVAL => error.InvalidExe, .NOMEM => error.SystemResources, .NOSPC => error.SystemResources, .PERM => error.AccessDenied, .USERS => error.SystemResources, else => |err| std.os.unexpectedErrno(err), }; } const MountError = error{ AccessDenied, DeviceBusy, InvalidExe, FileSystem, SystemResources, NameTooLong, FileNotFound, NotBlockDevice, NotDir, ReadOnlyFileSystem, } || std.os.UnexpectedError; pub fn mount(special: ?[*:0]const u8, dir: [*:0]const u8, fstype: ?[*:0]const u8, flags: u32, data: ?*u8) MountError!void { return switch (std.os.errno(std.os.linux.syscall5(.mount, @ptrToInt(special), @ptrToInt(dir), @ptrToInt(fstype), flags, @ptrToInt(data)))) { .SUCCESS => {}, .ACCES => error.AccessDenied, .BUSY => error.DeviceBusy, .FAULT => unreachable, .INVAL => error.InvalidExe, .LOOP => error.FileSystem, .MFILE => error.SystemResources, .NAMETOOLONG => error.NameTooLong, .NODEV => error.SystemResources, .NOENT => error.FileNotFound, .NOMEM => error.SystemResources, .NOTBLK => error.NotBlockDevice, .NOTDIR => error.NotDir, .NXIO => error.InvalidExe, .PERM => error.AccessDenied, .ROFS => error.ReadOnlyFileSystem, else => |err| std.os.unexpectedErrno(err), }; } const UmountError = error{ WouldBlock, DeviceBusy, InvalidExe, NameTooLong, FileNotFound, SystemResources, AccessDenied, } || std.os.UnexpectedError; pub fn umount2(special: [*:0]const u8, flags: u32) UmountError!void { return switch (std.os.errno(std.os.linux.syscall2(.umount2, @ptrToInt(special), flags))) { .SUCCESS => {}, .AGAIN => error.WouldBlock, .BUSY => error.DeviceBusy, .FAULT => unreachable, .INVAL => error.InvalidExe, .NAMETOOLONG => error.NameTooLong, .NOENT => error.FileNotFound, .NOMEM => error.SystemResources, .PERM => error.AccessDenied, else => |err| std.os.unexpectedErrno(err), }; } const MknodError = error{ AccessDenied, DiskQuota, PathAlreadyExists, InvalidExe, FileSystem, NameTooLong, FileNotFound, SystemResources, NoSpaceLeft, NotDir, } || std.os.UnexpectedError; pub fn mknod(pathname: [*:0]const u8, mode: std.os.linux.mode_t, dev: std.os.linux.dev_t) MknodError!void { return switch (std.os.errno(std.os.linux.syscall3(.mknod, @ptrToInt(pathname), mode, dev))) { .SUCCESS => {}, .ACCES => error.AccessDenied, .DQUOT => error.DiskQuota, .EXIST => error.PathAlreadyExists, .FAULT => unreachable, .INVAL => error.InvalidExe, .LOOP => error.FileSystem, .NAMETOOLONG => error.NameTooLong, .NOENT => error.FileNotFound, .NOMEM => error.SystemResources, .NOSPC => error.NoSpaceLeft, .NOTDIR => error.NotDir, .PERM => error.AccessDenied, else => |err| std.os.unexpectedErrno(err), }; } const ChrootError = error{ AccessDenied, FileSystem, NameTooLong, FileNotFound, SystemResources, NotDir, } || std.os.UnexpectedError; pub fn chroot(pathname: [*:0]const u8) ChrootError!void { return switch (std.os.errno(std.os.linux.syscall1(.chroot, @ptrToInt(pathname)))) { .SUCCESS => {}, .ACCES => error.AccessDenied, .FAULT => unreachable, .IO => error.FileSystem, .LOOP => error.FileSystem, .NAMETOOLONG => error.NameTooLong, .NOENT => error.FileNotFound, .NOMEM => error.SystemResources, .NOTDIR => error.NotDir, .PERM => error.AccessDenied, else => |err| std.os.unexpectedErrno(err), }; } const ChownError = error{ AccessDenied, FileSystem, NameTooLong, FileNotFound, SystemResources, NotDir, ReadOnlyFileSystem, } || std.os.UnexpectedError; pub fn chown(pathname: [*:0]const u8, uid: std.os.linux.uid_t, gid: std.os.linux.gid_t) ChownError!void { return switch (std.os.errno(std.os.linux.syscall3(.chown, @ptrToInt(pathname), uid, gid))) { .SUCCESS => {}, .ACCES => error.AccessDenied, .FAULT => unreachable, .LOOP => error.FileSystem, .NAMETOOLONG => error.NameTooLong, .NOENT => error.FileNotFound, .NOMEM => error.SystemResources, .NOTDIR => error.NotDir, .PERM => error.AccessDenied, .ROFS => error.ReadOnlyFileSystem, else => |err| std.os.unexpectedErrno(err), }; } const SethostnameError = error{ InvalidExe, NameTooLong, AccessDenied, } || std.os.UnexpectedError; pub fn sethostname(name: []const u8) SethostnameError!void { return switch (std.os.errno(std.os.linux.syscall2(.sethostname, @ptrToInt(name.ptr), name.len))) { .SUCCESS => {}, .FAULT => unreachable, .INVAL => error.InvalidExe, .NAMETOOLONG => error.NameTooLong, .PERM => error.AccessDenied, else => |err| std.os.unexpectedErrno(err), }; } pub fn mkdev(major: u64, minor: u64) std.os.linux.dev_t { var dev: std.os.linux.dev_t = 0; dev |= (major & 0x00000fff) << 8; dev |= (major & 0xfffff000) << 32; dev |= (minor & 0x000000ff) << 0; dev |= (minor & 0xffffff00) << 12; return dev; } pub fn umask(mask: std.os.mode_t) std.os.mode_t { return std.os.linux.syscall1(.umask, mask); } const SetgroupsError = error{ InvalidExe, SystemResources, AccessDenied, } || std.os.UnexpectedError; pub fn setgroups(list: []std.os.gid_t) SetgroupsError!usize { const nums = std.os.linux.syscall2(.setgroups, list.len, @ptrToInt(list.ptr)); return switch (std.os.errno(nums)) { .SUCCESS => nums, .FAULT => unreachable, .INVAL => error.InvalidExe, .NOMEM => error.SystemResources, .PERM => error.AccessDenied, else => |err| std.os.unexpectedErrno(err), }; }
src/syscall.zig
usingnamespace @import("../engine/engine.zig"); const Literal = @import("../parser/literal.zig").Literal; const LiteralValue = @import("../parser/literal.zig").LiteralValue; const std = @import("std"); const testing = std.testing; const mem = std.mem; pub fn OneOfAmbiguousContext(comptime Payload: type, comptime Value: type) type { return []const *Parser(Payload, Value); } /// Represents values from one parse path. /// /// In the case of a non-ambiguous `OneOfAmbiguous` grammar of `Parser1 | Parser2`, the combinator will /// yield: /// /// ``` /// stream(OneOfAmbiguousValue(Parser1Value)) /// ``` /// /// Or: /// /// ``` /// stream(OneOfAmbiguousValue(Parser2Value)) /// ``` /// /// In the case of an ambiguous grammar `Parser1 | Parser2` where either parser can produce three /// different parse paths, it will yield: /// /// ``` /// stream( /// OneOfAmbiguousValue(Parser1Value1), /// OneOfAmbiguousValue(Parser1Value2), /// OneOfAmbiguousValue(Parser1Value3), /// OneOfAmbiguousValue(Parser2Value1), /// OneOfAmbiguousValue(Parser2Value2), /// OneOfAmbiguousValue(Parser2Value3), /// ) /// ``` /// pub fn OneOfAmbiguousValue(comptime Value: type) type { return Value; } /// Matches one of the given `input` parsers, supporting ambiguous and unambiguous grammars. /// /// The `input` parsers must remain alive for as long as the `OneOfAmbiguous` parser will be used. pub fn OneOfAmbiguous(comptime Payload: type, comptime Value: type) type { return struct { parser: Parser(Payload, OneOfAmbiguousValue(Value)) = Parser(Payload, OneOfAmbiguousValue(Value)).init(parse, nodeName, deinit), input: OneOfAmbiguousContext(Payload, Value), const Self = @This(); pub fn init(input: OneOfAmbiguousContext(Payload, Value)) Self { return Self{ .input = input }; } pub fn deinit(parser: *Parser(Payload, Value), allocator: *mem.Allocator) void { const self = @fieldParentPtr(Self, "parser", parser); for (self.input) |in_parser| { in_parser.deinit(allocator); } } pub fn nodeName(parser: *const Parser(Payload, Value), node_name_cache: *std.AutoHashMap(usize, ParserNodeName)) Error!u64 { const self = @fieldParentPtr(Self, "parser", parser); var v = std.hash_map.hashString("OneOfAmbiguous"); for (self.input) |in_parser| { v +%= try in_parser.nodeName(node_name_cache); } return v; } pub fn parse(parser: *const Parser(Payload, Value), in_ctx: *const Context(Payload, Value)) callconv(.Async) !void { const self = @fieldParentPtr(Self, "parser", parser); var ctx = in_ctx.with(self.input); defer ctx.results.close(); var buffer = try ResultStream(Result(OneOfAmbiguousValue(Value))).init(ctx.allocator, ctx.key); defer buffer.deinit(); for (self.input) |in_parser| { const child_node_name = try in_parser.nodeName(&in_ctx.memoizer.node_name_cache); var child_ctx = try in_ctx.initChild(Value, child_node_name, ctx.offset); defer child_ctx.deinitChild(); if (!child_ctx.existing_results) try in_parser.parse(&child_ctx); var sub = child_ctx.subscribe(); while (sub.next()) |next| { try buffer.add(next.toUnowned()); } } buffer.close(); var gotValues: usize = 0; var gotErrors: usize = 0; var sub = buffer.subscribe(ctx.key, ctx.path, Result(Value).initError(ctx.offset, "matches only the empty language")); while (sub.next()) |next| { switch (next.result) { .err => gotErrors += 1, else => gotValues += 1, } } if (gotValues > 0) { // At least one parse path succeeded, so discard all error'd parse paths. // // TODO(slimsag): would the client not want to enumerate error'd paths that made some // progress? var sub2 = buffer.subscribe(ctx.key, ctx.path, Result(Value).initError(ctx.offset, "matches only the empty language")); while (sub2.next()) |next| { switch (next.result) { .err => {}, else => try ctx.results.add(next), } } return; } // All parse paths failed, so return a nice error. // // TODO(slimsag): include names of expected input parsers // // TODO(slimsag): collect and return the furthest error if a parse path made // progress and failed. try ctx.results.add(Result(OneOfAmbiguousValue(Value)).initError(ctx.offset, "expected OneOfAmbiguous")); } }; } // Confirms that the following grammar works as expected: // // ```ebnf // Grammar = "ello" | "world" ; // ``` // test "oneof" { nosuspend { const allocator = testing.allocator; const Payload = void; const ctx = try Context(Payload, OneOfAmbiguousValue(LiteralValue)).init(allocator, "elloworld", {}); defer ctx.deinit(); const parsers: []*Parser(Payload, LiteralValue) = &.{ (&Literal(Payload).init("ello").parser).ref(), (&Literal(Payload).init("world").parser).ref(), }; var helloOrWorld = OneOfAmbiguous(Payload, LiteralValue).init(parsers); try helloOrWorld.parser.parse(&ctx); var sub = ctx.subscribe(); var first = sub.next().?; try testing.expectEqual(Result(OneOfAmbiguousValue(LiteralValue)).init(4, .{ .value = "ello" }).toUnowned(), first); try testing.expect(sub.next() == null); // stream closed } } // Confirms that the following grammar works as expected: // // ```ebnf // Grammar = "ello" | "elloworld" ; // ``` // test "oneof_ambiguous" { nosuspend { const allocator = testing.allocator; const Payload = void; const ctx = try Context(Payload, OneOfAmbiguousValue(LiteralValue)).init(allocator, "elloworld", {}); defer ctx.deinit(); const parsers: []*Parser(Payload, LiteralValue) = &.{ (&Literal(Payload).init("ello").parser).ref(), (&Literal(Payload).init("elloworld").parser).ref(), }; var helloOrWorld = OneOfAmbiguous(Payload, LiteralValue).init(parsers); try helloOrWorld.parser.parse(&ctx); var sub = ctx.subscribe(); var r1 = sub.next().?; try testing.expectEqual(@as(usize, 4), r1.offset); try testing.expectEqualStrings("ello", r1.result.value.value); var r2 = sub.next().?; try testing.expectEqual(@as(usize, 9), r2.offset); try testing.expectEqualStrings("elloworld", r2.result.value.value); try testing.expect(sub.next() == null); // stream closed } }
src/combn/combinator/oneof_ambiguous.zig
const std = @import("std"); const vec3 = @import("vec3.zig"); const Scene = @import("../scene.zig").Scene; const Shape = @import("shape.zig").Shape; const Material = @import("material.zig").Material; pub fn new_light_scene(alloc: *std.mem.Allocator) !Scene { var scene = Scene.new(alloc); const light = try scene.new_material(Material.new_light(1, 1, 1, 1)); try scene.shapes.append(Shape.new_sphere( .{ .x = 0, .y = 0, .z = 0 }, 0.2, light, )); return scene; } pub fn new_orb_scene(alloc: *std.mem.Allocator) !Scene { var scene = Scene.new(alloc); scene.camera.pos.y = 1; scene.camera.pos.z = 2; scene.camera.defocus = 0; const white = try scene.new_material(Material.new_diffuse(1, 1, 1)); const light = try scene.new_material(Material.new_light(1, 1, 1, 1)); try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 1, .z = 0 }, 0, white, )); // Centered glowing sphere try scene.shapes.append(Shape.new_sphere( .{ .x = 0, .y = 0.2, .z = 0 }, 0.5, light, )); // Fill light for the front face try scene.shapes.append(Shape.new_sphere( .{ .x = 2, .y = 2, .z = 3 }, 0.5, light, )); // Initialize the RNG var buf: [8]u8 = undefined; try std.os.getrandom(buf[0..]); const seed = std.mem.readIntLittle(u64, buf[0..8]); var r = std.rand.DefaultPrng.init(seed); const NUM: i32 = 4; const SCALE: f32 = 0.75; const SIZE: f32 = SCALE / @intToFloat(f32, NUM); var x: i32 = -NUM; try scene.shapes.append(Shape.new_sphere( .{ .x = SCALE, .y = 0.2, .z = SCALE }, 0.05, light, )); try scene.shapes.append(Shape.new_sphere( .{ .x = -SCALE, .y = 0.2, .z = SCALE }, 0.05, light, )); try scene.shapes.append(Shape.new_sphere( .{ .x = -SCALE, .y = 0.2, .z = -SCALE }, 0.05, light, )); try scene.shapes.append(Shape.new_sphere( .{ .x = SCALE, .y = 0.2, .z = -SCALE }, 0.05, light, )); while (x <= NUM) : (x += 1) { var z: i32 = -NUM; while (z <= NUM) : (z += 1) { const h = if (std.math.absCast(x) == NUM and std.math.absCast(z) == NUM) 0.1 else r.random.float(f32) * 0.1; try scene.add_cube( .{ .x = @intToFloat(f32, x) * SIZE, .y = h, .z = @intToFloat(f32, z) * SIZE, }, .{ .x = 1, .y = 0, .z = 0 }, // dx .{ .x = 0, .y = 1, .z = 0 }, // dy .{ .x = SIZE, .y = 0.2, .z = SIZE }, // size white, ); } } return scene; } pub fn new_simple_scene(alloc: *std.mem.Allocator) !Scene { var scene = Scene.new(alloc); const white = try scene.new_material(Material.new_diffuse(1, 1, 1)); const red = try scene.new_material(Material.new_diffuse(1, 0.2, 0.2)); const light = try scene.new_material(Material.new_light(1, 1, 1, 1)); try scene.shapes.append(Shape.new_sphere( .{ .x = 0, .y = 0, .z = 0 }, 0.1, light, )); try scene.shapes.append(Shape.new_sphere( .{ .x = 0.5, .y = 0.3, .z = 0 }, 0.5, white, )); try scene.shapes.append(Shape.new_sphere( .{ .x = -0.5, .y = 0.3, .z = 0 }, 0.3, red, )); return scene; } pub fn new_white_box(alloc: *std.mem.Allocator) !Scene { var scene = Scene.new(alloc); const white = try scene.new_material(Material.new_diffuse(1, 1, 1)); const light = try scene.new_material(Material.new_light(1, 1, 1, 7)); // Light try scene.shapes.append(Shape.new_finite_plane( .{ .x = 0, .y = 1, .z = 0 }, 1.04, .{ .x = 1, .y = 0, .z = 0 }, .{ .x = -0.25, .y = 0.25, .z = -1.0, .w = 0.25 }, light, )); // Back wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 0, .z = 1 }, -1, white, )); // Left wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 1, .y = 0, .z = 0 }, -1, white, )); // Right wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = -1, .y = 0, .z = 0 }, -1, white, )); // Top wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = -1, .z = 0 }, -1.05, white, )); // Bottom wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 1, .z = 0 }, -1, white, )); // Front wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 0, .z = -1 }, -1, white, )); return scene; } pub fn new_hex_box(alloc: *std.mem.Allocator) !Scene { var scene = try new_white_box(alloc); scene.camera.defocus = 0; scene.camera.scale = 0.4; scene.camera.perspective = 1; scene.camera.pos = .{ .x = 0, .y = -0.4, .z = 0.7 }; scene.camera.target = .{ .x = 0, .y = -0.6, .z = 0.3 }; scene.camera.defocus = 0.008; scene.camera.focal_distance = 0.5; const metal = try scene.new_material(Material.new_metal(1, 0.86, 0.45, 0.2)); const NUM: i32 = 4; const SCALE: f32 = 0.5; const SIZE: f32 = SCALE / @intToFloat(f32, NUM); var x = -NUM; while (x <= NUM) : (x += 1) { var z: i32 = -NUM; while (z <= NUM) : (z += 1) { // const dy = std.math.sin(@intToFloat(f32, x) / @intToFloat(f32, NUM) * std.math.pi); var dx: f32 = 0; if (@rem(z, 2) == 0) { dx = SIZE / 2; if (x == NUM) { continue; } } try scene.shapes.append(Shape.new_sphere( .{ .x = @intToFloat(f32, x) * SIZE + dx, .y = -1 + SCALE / 20, .z = @intToFloat(f32, z) * SIZE * 0.866, }, SCALE / 20, metal, )); } } return scene; } pub fn new_cornell_box(alloc: *std.mem.Allocator) !Scene { var scene = Scene.new(alloc); scene.camera.defocus = 0; const white = try scene.new_material(Material.new_diffuse(1, 1, 1)); const red = try scene.new_material(Material.new_diffuse(1, 0.1, 0.1)); const green = try scene.new_material(Material.new_diffuse(0.1, 1, 0.1)); const light = try scene.new_material(Material.new_light(1, 0.8, 0.6, 6)); // Light try scene.shapes.append(Shape.new_finite_plane( .{ .x = 0, .y = 1, .z = 0 }, 1.04, .{ .x = 1, .y = 0, .z = 0 }, .{ .x = -0.25, .y = 0.25, .z = -0.25, .w = 0.25 }, light, )); // Back wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 0, .z = 1 }, -1, white, )); // Left wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 1, .y = 0, .z = 0 }, -1, red, )); // Right wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = -1, .y = 0, .z = 0 }, -1, green, )); // Top wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = -1, .z = 0 }, -1.05, white, )); // Bottom wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 1, .z = 0 }, -1, white, )); var h: f32 = 1.3; try scene.add_cube( .{ .x = -0.35, .y = -1 + h / 2, .z = -0.3 }, vec3.normalize(.{ .x = 0.4, .y = 0, .z = 1 }), vec3.normalize(.{ .x = 0, .y = 1, .z = 0 }), .{ .x = 0.6, .y = h, .z = 0.6 }, white, ); h = 0.6; try scene.add_cube( .{ .x = 0.35, .y = -1 + h / 2, .z = 0.3 }, vec3.normalize(.{ .x = -0.4, .y = 0, .z = 1 }), vec3.normalize(.{ .x = 0, .y = 1, .z = 0 }), .{ .x = 0.55, .y = h, .z = 0.55 }, white, ); return scene; } pub fn new_cornell_balls(alloc: *std.mem.Allocator) !Scene { var scene = Scene.new(alloc); const white = try scene.new_material(Material.new_diffuse(1, 1, 1)); const red = try scene.new_material(Material.new_diffuse(1, 0.1, 0.1)); const blue = try scene.new_material(Material.new_diffuse(0.1, 0.1, 1)); const green = try scene.new_material(Material.new_diffuse(0.1, 1, 0.1)); const metal = try scene.new_material(Material.new_metal(1, 1, 0.5, 0.1)); const glass = try scene.new_material(Material.new_glass(1.3, 0.0003)); const light = try scene.new_material(Material.new_light(1, 1, 1, 4)); // Light try scene.shapes.append(Shape.new_sphere( .{ .x = 0, .y = 6.05, .z = 0 }, 5.02, light, )); // Back wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 0, .z = 1 }, -1, white, )); // Left wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 1, .y = 0, .z = 0 }, -1, red, )); // Right wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = -1, .y = 0, .z = 0 }, -1, green, )); // Top wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = -1, .z = 0 }, -1.05, white, )); // Bottom wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 1, .z = 0 }, -1, white, )); // Front wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 0, .z = -1 }, -1, white, )); // Blue sphere try scene.shapes.append(Shape.new_sphere( .{ .x = -0.3, .y = -0.6, .z = -0.2 }, 0.4, blue, )); // Metal sphere try scene.shapes.append(Shape.new_sphere( .{ .x = 0.5, .y = -0.7, .z = 0.3 }, 0.3, metal, )); // Glass sphere try scene.shapes.append(Shape.new_sphere( .{ .x = 0.1, .y = -0.8, .z = 0.5 }, 0.2, glass, )); return scene; } pub fn new_cornell_aberration(alloc: *std.mem.Allocator) !Scene { var scene = try new_cornell_balls(alloc); scene.camera.pos = .{ .x = 0, .y = -0.6, .z = 1 }; scene.camera.target = .{ .x = 0, .y = -0.6, .z = 0 }; scene.camera.defocus = 0; scene.camera.scale = 0.4; return scene; } pub fn new_rtiow(alloc: *std.mem.Allocator) !Scene { // Initialize the RNG var buf: [8]u8 = undefined; try std.os.getrandom(buf[0..]); const seed = std.mem.readIntLittle(u64, buf[0..8]); var r = std.rand.DefaultPrng.init(seed); var scene = Scene.new(alloc); scene.camera = .{ .pos = .{ .x = 8, .y = 1.5, .z = 2 }, .target = .{ .x = 0, .y = 0, .z = 0 }, .up = .{ .x = 0, .y = 1, .z = 0 }, .scale = 1, .defocus = 0.03, .perspective = 0.4, .focal_distance = 4.0, }; const ground_material = try scene.new_material( Material.new_diffuse(0.5, 0.5, 0.5), ); try scene.shapes.append(Shape.new_sphere( .{ .x = 0, .y = -1000, .z = 0 }, 1000, ground_material, )); const glass_mat = try scene.new_material(Material.new_glass(1.3, 0.0013)); var a: i32 = -11; while (a < 11) : (a += 1) { var b: i32 = -11; while (b < 11) : (b += 1) { const x = @intToFloat(f32, a) + 0.7 * r.random.float(f32); const y: f32 = 0.18; const z = @intToFloat(f32, b) + 0.7 * r.random.float(f32); const da = std.math.sqrt(std.math.pow(f32, x - 4, 2) + std.math.pow(f32, z, 2)); const db = std.math.sqrt(std.math.pow(f32, x, 2) + std.math.pow(f32, z, 2)); const dc = std.math.sqrt(std.math.pow(f32, x + 4, 2) + std.math.pow(f32, z, 2)); if (da > 1.1 and db > 1.1 and dc > 1.1) { const choose_mat = r.random.float(f32); var mat: u32 = undefined; if (choose_mat < 0.8) { const red = r.random.float(f32); const green = r.random.float(f32); const blue = r.random.float(f32); mat = try scene.new_material( Material.new_diffuse(red, green, blue), ); } else if (choose_mat < 0.95) { const red = r.random.float(f32) / 2 + 1; const green = r.random.float(f32) / 2 + 1; const blue = r.random.float(f32) / 2 + 1; const fuzz = r.random.float(f32) / 2; mat = try scene.new_material( Material.new_metal(red, green, blue, fuzz), ); } else { mat = glass_mat; } try scene.shapes.append(Shape.new_sphere(.{ .x = x, .y = y, .z = z }, 0.2, mat)); } } } try scene.shapes.append(Shape.new_sphere( .{ .x = 0, .y = 1, .z = 0 }, 1, glass_mat, )); const diffuse = try scene.new_material(Material.new_diffuse(0.4, 0.2, 0.1)); try scene.shapes.append(Shape.new_sphere( .{ .x = -4, .y = 1, .z = 0 }, 1, diffuse, )); const metal = try scene.new_material(Material.new_metal(0.7, 0.6, 0.5, 0.0)); try scene.shapes.append(Shape.new_sphere( .{ .x = 4, .y = 1, .z = 0 }, 1, metal, )); const light = try scene.new_material(Material.new_light(0.8, 0.95, 1, 1)); try scene.shapes.append(Shape.new_sphere( .{ .x = 0, .y = 0, .z = 0 }, 2000, light, )); return scene; } pub fn new_horizon(alloc: *std.mem.Allocator) !Scene { var scene = Scene.new(alloc); const blue = try scene.new_material(Material.new_diffuse(0.5, 0.5, 1)); const red = try scene.new_material(Material.new_diffuse(1, 0.5, 0.5)); const glass = try scene.new_material(Material.new_glass(1.3, 0.0013)); const light = try scene.new_material(Material.new_light(1, 1, 1, 1)); // Back wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 0, .z = 1 }, -100, light, )); try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 0, .z = -1 }, -100, light, )); try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = -1, .z = 0 }, -100, light, )); try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 1, .y = 0, .z = 0 }, -100, light, )); try scene.shapes.append(Shape.new_infinite_plane( .{ .x = -1, .y = 0, .z = 0 }, -100, light, )); // Bottom wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 1, .z = 0 }, -1, blue, )); // Red sphere try scene.shapes.append(Shape.new_sphere( .{ .x = 1.25, .y = -0.5, .z = -1 }, 0.5, red, )); // Glass sphere try scene.shapes.append(Shape.new_sphere( .{ .x = 0.0, .y = -0.5, .z = -1 }, 0.5, glass, )); return scene; } pub fn new_prism(alloc: *std.mem.Allocator) !Scene { var scene = Scene.new(alloc); scene.camera.perspective = 0; scene.camera.defocus = 0; scene.camera.up = .{ .x = -1, .y = 0, .z = 0 }; const light = try scene.new_material(Material.new_laser(1, 1, 1, 200, 0.999)); const glass = try scene.new_material(Material.new_glass(1.36, 0.001)); const white = try scene.new_material(Material.new_metaflat()); // Back wall try scene.shapes.append(Shape.new_infinite_plane( .{ .x = 0, .y = 0, .z = 1 }, -1, white, )); try scene.shapes.append(Shape.new_finite_plane( .{ .x = -0.259, .y = 0.966, .z = 0 }, -1, .{ .x = 0, .y = 0, .z = 1 }, .{ .x = -1, .y = 1, .z = -0.01, .w = 0.01 }, light, )); try scene.shapes.append(Shape.new_finite_plane( .{ .x = -0.5, .y = -0.8660254037, .z = 0 }, 0.3, .{ .x = 1, .y = 0, .z = 0 }, .{ .x = -0.6, .y = 0.35, .z = -1, .w = 1 }, glass, )); try scene.shapes.append(Shape.new_finite_plane( .{ .x = -0.5, .y = 0.8660254037, .z = 0 }, 0.3, .{ .x = 1, .y = 0, .z = 0 }, .{ .x = -0.6, .y = 0.35, .z = -1, .w = 1 }, glass, )); // Build a triangle try scene.shapes.append(Shape.new_finite_plane( .{ .x = 0, .y = 0, .z = 1 }, 0, .{ .x = 1, .y = 0, .z = 0 }, .{ .x = 0.6, .y = 0.605, .z = -0.7, .w = 0.7 }, light, )); try scene.shapes.append(Shape.new_finite_plane( .{ .x = 0, .y = 0, .z = 1 }, 0, .{ .x = -0.5, .y = 0.8660254037, .z = 0 }, .{ .x = 0.3, .y = 0.305, .z = -0.87, .w = 0.525 }, light, )); try scene.shapes.append(Shape.new_finite_plane( .{ .x = 0, .y = 0, .z = 1 }, 0, .{ .x = 0.5, .y = 0.8660254037, .z = 0 }, .{ .x = -0.305, .y = -0.3, .z = -0.87, .w = 0.525 }, light, )); return scene; } pub fn new_caffeine(alloc: *std.mem.Allocator) !Scene { var scene = try @import("mol.zig").from_mol_file(alloc, "data/caffeine.mol"); scene.camera.defocus = 0; scene.camera.pos.z = 2; scene.camera.perspective = 0.1; scene.camera.scale = 5; const light = try scene.new_material(Material.new_light(1, 1, 1, 5)); try scene.shapes.append( Shape.new_sphere(.{ .x = 3.5, .y = 4.5, .z = 10 }, 5, light), ); const backdrop = try scene.new_material(Material.new_light(0.79, 0.85, 0.89, 1)); try scene.shapes.append( Shape.new_infinite_plane(.{ .x = 0, .y = 0, .z = 1 }, -5, backdrop), ); return scene; } pub fn new_riboflavin(alloc: *std.mem.Allocator) !Scene { var scene = try @import("mol.zig").from_mol_file(alloc, "data/riboflavin.mol"); scene.camera.defocus = 0; scene.camera.pos = .{ .x = 1, .y = 2, .z = 5 }; scene.camera.target = .{ .x = 0.5, .y = 0, .z = 0 }; scene.camera.perspective = 0.1; scene.camera.scale = 5; const light = try scene.new_material(Material.new_light(1, 1, 1, 5)); try scene.shapes.append( Shape.new_sphere(.{ .x = 3.5, .y = 4.5, .z = 10 }, 5, light), ); return scene; }
src/scene/examples.zig
const std = @import("std"); const mem = std.mem; const Digit = @This(); allocator: *mem.Allocator, array: []bool, lo: u21 = 178, hi: u21 = 127242, pub fn init(allocator: *mem.Allocator) !Digit { var instance = Digit{ .allocator = allocator, .array = try allocator.alloc(bool, 127065), }; mem.set(bool, instance.array, false); var index: u21 = 0; index = 0; while (index <= 1) : (index += 1) { instance.array[index] = true; } instance.array[7] = true; index = 4791; while (index <= 4799) : (index += 1) { instance.array[index] = true; } instance.array[6440] = true; instance.array[8126] = true; index = 8130; while (index <= 8135) : (index += 1) { instance.array[index] = true; } index = 8142; while (index <= 8151) : (index += 1) { instance.array[index] = true; } index = 9134; while (index <= 9142) : (index += 1) { instance.array[index] = true; } index = 9154; while (index <= 9162) : (index += 1) { instance.array[index] = true; } index = 9174; while (index <= 9182) : (index += 1) { instance.array[index] = true; } instance.array[9272] = true; index = 9283; while (index <= 9291) : (index += 1) { instance.array[index] = true; } instance.array[9293] = true; index = 9924; while (index <= 9932) : (index += 1) { instance.array[index] = true; } index = 9934; while (index <= 9942) : (index += 1) { instance.array[index] = true; } index = 9944; while (index <= 9952) : (index += 1) { instance.array[index] = true; } index = 67982; while (index <= 67985) : (index += 1) { instance.array[index] = true; } index = 69038; while (index <= 69046) : (index += 1) { instance.array[index] = true; } index = 69536; while (index <= 69544) : (index += 1) { instance.array[index] = true; } index = 127054; while (index <= 127064) : (index += 1) { instance.array[index] = true; } // Placeholder: 0. Struct name, 1. Code point kind return instance; } pub fn deinit(self: *Digit) void { self.allocator.free(self.array); } // isDigit checks if cp is of the kind Digit. pub fn isDigit(self: Digit, cp: u21) bool { if (cp < self.lo or cp > self.hi) return false; const index = cp - self.lo; return if (index >= self.array.len) false else self.array[index]; }
src/components/autogen/DerivedNumericType/Digit.zig
const std = @import("std"); const pike = @import("pike"); const net = std.net; const Allocator = std.mem.Allocator; /// HTTP Status codes according to `rfc7231` /// https://tools.ietf.org/html/rfc7231#section-6 pub const StatusCode = enum(u16) { // Informational 1xx Continue = 100, // Successful 2xx SwitchingProtocols = 101, Ok = 200, Created = 201, Accepted = 202, NonAuthoritativeInformation = 203, NoContent = 204, ResetContent = 205, // Redirections 3xx PartialContent = 206, MultipleChoices = 300, MovedPermanently = 301, Found = 302, SeeOther = 303, NotModified = 304, UseProxy = 305, TemporaryRedirect = 307, // Client errors 4xx BadRequest = 400, /// reserved status code for future use Unauthorized = 401, PaymentRequired = 402, Forbidden = 403, NotFound = 404, MethodNotAllowed = 405, NotAcceptable = 406, ProxyAuthenticationRequired = 407, RequestTimeout = 408, Conflict = 409, Gone = 410, LengthRequired = 411, PreconditionFailed = 412, RequestEntityTooLarge = 413, RequestUriTooLong = 414, UnsupportedMediaType = 415, RequestedRangeNotSatisfiable = 416, ExpectationFailed = 417, /// Teapot is an extension Status Code and not required for clients to support Teapot = 418, UpgradeRequired = 426, /// Extra Status Code according to `https://tools.ietf.org/html/rfc6585#section-5` RequestHeaderFieldsTooLarge = 431, // server errors 5xx InternalServerError = 500, NotImplemented = 501, BadGateway = 502, ServiceUnavailable = 503, GatewayTimeout = 504, HttpVersionNotSupported = 505, /// Returns the string value of a `StatusCode` /// for example: .ResetContent returns "Returns Content". pub fn toString(self: StatusCode) []const u8 { return switch (self) { .Continue => "Continue", .SwitchingProtocols => "Switching Protocols", .Ok => "Ok", .Created => "Created", .Accepted => "Accepted", .NonAuthoritativeInformation => "Non Authoritative Information", .NoContent => "No Content", .ResetContent => "Reset Content", .PartialContent => "Partial Content", .MultipleChoices => "Multiple Choices", .MovedPermanently => "Moved Permanently", .Found => "Found", .SeeOther => "See Other", .NotModified => "Not Modified", .UseProxy => "Use Proxy", .TemporaryRedirect => "Temporary Redirect", .BadRequest => "Bad Request", .Unauthorized => "Unauthorized", .PaymentRequired => "Payment Required", .Forbidden => "Forbidden", .NotFound => "Not Found", .MethodNotAllowed => "Method Not Allowed", .NotAcceptable => "Not Acceptable", .ProxyAuthenticationRequired => "Proxy Authentication Required", .RequestTimeout => "Request Timeout", .Conflict => "Conflict", .Gone => "Gone", .LengthRequired => "Length Required", .PreconditionFailed => "Precondition Failed", .RequestEntityTooLarge => "Request Entity Too Large", .RequestUriTooLong => "Request-URI Too Long", .UnsupportedMediaType => "Unsupported Media Type", .RequestedRangeNotSatisfiable => "Requested Range Not Satisfiable", .Teapot => "I'm a Teapot", .UpgradeRequired => "Upgrade Required", .RequestHeaderFieldsTooLarge => "Request Header Fields Too Large", .ExpectationFailed => "Expectation Failed", .InternalServerError => "Internal Server Error", .NotImplemented => "Not Implemented", .BadGateway => "Bad Gateway", .ServiceUnavailable => "Service Unavailable", .GatewayTimeout => "Gateway Timeout", .HttpVersionNotSupported => "HTTP Version Not Supported", }; } }; /// Headers is an alias to `std.StringHashMap([]const u8)` pub const Headers = std.StringArrayHashMap([]const u8); /// SocketWriter writes to a socket and sets the /// MSG_NOSIGNAL flag to ignore BrokenPipe signals /// This is needed so the server does not get interrupted pub const SocketWriter = struct { handle: *pike.Socket, /// Alias for `std.os.SendError` /// Required constant for `std.io.BufferedWriter` pub const Error = error{ DiskQuota, FileTooBig, InputOutput, NoSpaceLeft, OperationAborted, NotOpenForWriting, OperationCancelled, } || std.os.SendError; /// Uses fmt to format the given bytes and writes to the socket pub fn print(self: SockerWriter, comptime format: []const u8, args: anytype) Error!usize { return std.fmt.format(self, format, args); } /// writes to the socket /// Note that this may not write all bytes, use writeAll for that pub fn write(self: SocketWriter, bytes: []const u8) Error!usize { return self.handle.send(bytes, std.os.MSG_NOSIGNAL); } /// Loops untill all bytes have been written to the socket pub fn writeAll(self: SocketWriter, bytes: []const u8) Error!void { var index: usize = 0; while (index != bytes.len) { index += try self.write(bytes[index..]); } } }; /// Response allows to set the status code and content of the response pub const Response = struct { /// status code of the response, 200 by default status_code: StatusCode = .Ok, /// StringHashMap([]const u8) with key and value of headers headers: Headers, /// Buffered writer that writes to our socket socket_writer: std.io.BufferedWriter(4096, SocketWriter), /// True when write() has been called is_flushed: bool, /// Response body, can be written to through the writer interface body: std.ArrayList(u8).Writer, pub const Error = SocketWriter.Error || error{OutOfMemory}; pub const Writer = std.io.Writer(*Response, Error, write); /// Returns a writer interface, any data written to the writer /// will be appended to the response's body pub fn writer(self: *Response) Writer { return .{ .context = self }; } /// Appends the buffer to the body of the response fn write(self: *Response, buffer: []const u8) Error!usize { return self.body.write(buffer); } /// Sends a status code with an empty body and the current headers to the client /// Note that this will complete the response and any further writes are illegal. pub fn writeHeader(self: *Response, status_code: StatusCode) Error!void { self.status_code = status_code; try self.flush(); } /// Sends the response to the client, can only be called once /// Any further calls is a panic pub fn flush(self: *Response) Error!void { std.debug.assert(!self.is_flushed); self.is_flushed = true; const body = self.body.context.items; var socket = self.socket_writer.writer(); // Print the status line, we only support HTTP/1.1 for now try socket.print("HTTP/1.1 {} {}\r\n", .{ @enumToInt(self.status_code), self.status_code.toString() }); // write headers for (self.headers.items()) |header| { try socket.print("{}: {}\r\n", .{ header.key, header.value }); } // If user has not set content-length, we add it calculated by the length of the body if (body.len > 0 and !self.headers.contains("Content-Length")) { try socket.print("Content-Length: {}\r\n", .{body.len}); } // set default Content-Type. // Adding headers is expensive so add it as default when we write to the socket if (!self.headers.contains("Content-Type")) { try socket.writeAll("Content-Type: text/plain; charset=utf-8\r\n"); } try socket.writeAll("Connection: keep-alive\r\n"); try socket.writeAll("\r\n"); if (body.len > 0) try socket.writeAll(body); try self.socket_writer.flush(); // ensure everything is written } /// Sends a `404 - Resource not found` response pub fn notFound(self: *Response) Error!void { self.status_code = .NotFound; try self.body.writeAll("Resource not found\n"); } };
src/response.zig
const std = @import("std"); const firm_abi = @import("firm-abi.zig"); /// Codegen helpers for a program pub const Codegen = struct { /// Enum with all the binary opcodes pub const BinaryOperations = enum { And, Or, Eor, Add, Sub, Mul, Mulh, Mod, Div, Cmp_Less, Cmp_Less_Equal, Cmp_Greater, Cmp_Greater_Equal, Cmp_Equal, Cmp_Not_Equal, Cmp_Less_Greater, Cmp_Not_Equal_Float, Cmp_Unordered, Cmp_Unordered_Less, Cmp_Unordered_Less_Equal, Cmp_Unordered_Greater, Cmp_Unordered_Greater_Equal, Cmp_False, Cmp_True, Error, }; // Handles the binary operations pub fn binaryOperation(op: BinaryOperations, lhs: *firm_abi.ir_node, rhs: *firm_abi.ir_node) *firm_abi.ir_node { var node_op : *firm_abi.ir_node = switch(op) { BinaryOperations.And => firm_abi.newAdd(lhs, rhs), BinaryOperations.Or => firm_abi.newOr(lhs, rhs), BinaryOperations.Eor => firm_abi.newEor(lhs, rhs), BinaryOperations.Add => firm_abi.newAdd(lhs, rhs), BinaryOperations.Sub => firm_abi.newSub(lhs, rhs), BinaryOperations.Mul => firm_abi.newMul(lhs, rhs), BinaryOperations.Mulh => firm_abi.newMulh(lhs, rhs), BinaryOperations.Mod => firm_abi.newMod(lhs, rhs), BinaryOperations.Div => firm_abi.newDiv(lhs, rhs), BinaryOperations.Cmp_Less => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.less), BinaryOperations.Cmp_Less_Equal => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.less_equal), BinaryOperations.Cmp_Greater => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.greater), BinaryOperations.Cmp_Greater_Equal => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.greater_equal), BinaryOperations.Cmp_Equal => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.equal), BinaryOperations.Cmp_Not_Equal => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.less_equal_greater), BinaryOperations.Cmp_Less_Greater => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.less_greater), BinaryOperations.Cmp_Not_Equal_Float => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.unordered_less_greater), BinaryOperations.Cmp_Unordered => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.unordered), BinaryOperations.Cmp_Unordered_Less => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.unordered_less), BinaryOperations.Cmp_Unordered_Less_Equal => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.unordered_less_equal), BinaryOperations.Cmp_Unordered_Greater => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.unordered_greater), BinaryOperations.Cmp_Unordered_Greater_Equal => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.unordered_greater_equal), BinaryOperations.Cmp_False => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.false), BinaryOperations.Cmp_True => firm_abi.newCmp(lhs, rhs, firm_abi.ir_relation.true), else => firm_abi.newBad(firm_abi.mode_ANY), } orelse firm_abi.newBad(firm_abi.mode_ANY); return node_op; } /// Enum with all the unary opcodes pub const UnaryOperations = enum { Not, Error, }; // Handles the unary operations pub fn unaryOperation(op: UnaryOperations, lhs: *firm_abi.ir_node) *firm_abi.ir_node { var node_op : *firm_abi.ir_node = switch(op) { UnaryOperations.Not => firm_abi.newNot(lhs), } orelse firm_abi.newBad(firm_abi.mode_ANY); return node_op; } // Get Number Tarval from a value pub fn getNumberTarval(comptime intType : type, value: intType) *firm_abi.ir_tarval { var typeInfo : std.builtin.TypeInfo = @typeInfo(intType); if(typeInfo == .Int) { if(typeInfo.Int.bits <= 32){ if(typeInfo.Int.Signedness == .signed) { return firm_abi.newTarvalFromLong(value, firm_abi.mode_I); } } } return firm_abi.newTarvalFromLong(value, firm_abi.mode_I); } // Create a function on the ir_graph with the given name and type signature, and appends the given graph to the main graph }; /// Program struct represents the main ir_graph pub const program = struct { /// The main ir_graph ir_graph: firm_abi.ir_graph, /// init the program pub fn init() void { firm_abi.irInit(); } };
src/codegen.zig
const std = @import("std"); const mem = std.mem; const StringHashMap = std.hash_map.StringHashMap; const ArrayList = std.ArrayList; /// Represents a token to be emitted by the {{Tokenizer}}. pub const Token = union(enum) { DOCTYPE: struct { name: ?[]const u8 = null, publicIdentifier: ?[]const u8 = null, systemIdentifier: ?[]const u8 = null, forceQuirks: bool = false, }, StartTag: struct { name: ?[]const u8 = null, selfClosing: bool = false, attributes: StringHashMap([]const u8), pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: var) !void { try writer.writeAll("{ "); try writer.print(".name = {}, .selfClosing = {}", .{ value.name, value.selfClosing }); if (value.attributes.items().len > 0) { try writer.writeAll(", attributes = .{ "); for (value.attributes.items()) |entry, i| { try writer.print("{}: \"{}\"", .{ entry.key, entry.value }); if (i + 1 < value.attributes.items().len) try writer.writeAll(", "); } try writer.writeAll(" }"); } try writer.writeAll(" }"); } }, EndTag: struct { name: ?[]const u8 = null, /// Ignored past tokenization, only used for errors selfClosing: bool = false, /// Ignored past tokenization, only used for errors attributes: StringHashMap([]const u8), pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: var) !void { try writer.writeAll("{ "); try writer.print(".name = {}, .selfClosing = {}", .{ value.name, value.selfClosing }); try writer.writeAll(" }"); } }, Comment: struct { data: ?[]const u8 = null, }, Character: struct { data: u21, pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: var) !void { var char: [4]u8 = undefined; var len = std.unicode.utf8Encode(value.data, char[0..]) catch unreachable; if (char[0] == '\n') { len = 2; std.mem.copy(u8, char[0..2], "\\n"); } try writer.print("\"{}\"", .{ char[0..len] }); } }, EndOfFile, };
src/token.zig
const std = @import("std"); const builtin = @import("builtin"); pub usingnamespace @import("ingble.zig"); pub usingnamespace @import("gatt_client_async.zig"); const print = platform_printf; const enable_print = print_info == 1; const rom_crc: f_crc_t = @intToPtr(f_crc_t, 0x00000f79); fn same_version(a: *const prog_ver_t, b: * const prog_ver_t) bool { return (a.*.major == b.*.major) and (a.*.minor == b.*.minor) and (a.*.patch == b.*.patch); } const PAGE_SIZE = 8192; const FullMeta = packed struct { cmd_id: u8, crc_value: u16, entry: u32, blocks: [MAX_UPDATE_BLOCKS]fota_update_block_t, }; const Client = struct { status: u8 = 0, conn_handle: u16, handle_ver: u16, handle_ctrl: u16, handle_data: u16, mtu: u16, meta_data: FullMeta = undefined, fn fota_make_bitmap(self: *Client, optional_latest: ?*const ota_ver_t) ?u16 { var bitmap: u16 = 0xffff; if (optional_latest) |latest| { var value_size: u16 = undefined; if (value_of_characteristic_reader.read(self.conn_handle, self.handle_ver, &value_size)) |value| { print("size: %d\n", value_size); if (value_size != @sizeOf(ota_ver_t)) { return null; } const local = @ptrCast(*const ota_ver_t, @alignCast(2, value)); if (enable_print) { print("device version:\n"); print("platform: %d.%d.%d\n", local.*.platform.major, local.*.platform.minor, local.*.platform.patch); print(" app: %d.%d.%d\n", local.*.app.major, local.*.app.minor, local.*.app.patch); } if (same_version(&local.*.platform, &latest.*.platform)) { bitmap &= ~@as(u16, 0b01); if (same_version(&local.*.app, &latest.*.app)) bitmap &= ~@as(u16, 0b10); } } else return null; } return bitmap; } fn write_cmd2(self: *Client, len: usize, data: [*c] const u8) u8 { return gatt_client_write_value_of_characteristic_without_response(self.conn_handle, self.handle_ctrl, @intCast(u16, len), data); } fn read_status(self: *Client) u8 { var value_size: u16 = undefined; return (value_of_characteristic_reader.read(self.conn_handle, self.handle_ctrl, &value_size) orelse return 0xff).*; } fn check_status(self: *Client) bool { return self.read_status() == OTA_STATUS_OK; } fn enable_fota(self: *Client) bool { const cmd = [_]u8{OTA_CTRL_START, 0, 0, 0, 0}; _ = self.write_cmd2(cmd.len, &cmd[0]); return self.check_status(); } fn reboot(self: *Client) bool { const cmd = [_]u8{OTA_CTRL_REBOOT}; _ = self.write_cmd2(cmd.len, &cmd[0]); return true; } fn burn_page(self: *Client, data: [*c] u8, target_addr: u32, size: usize) bool { if (enable_print) { print("burn_page: %p, %08x, %d\n", data, target_addr, size); } var cmd = [_]u8{OTA_CTRL_PAGE_BEGIN, 0, 0, 0, 0 }; @memcpy(@ptrCast([*]u8, &cmd[1]), @ptrCast([*]const u8, &target_addr), 4); _ = self.write_cmd2(cmd.len, &cmd[0]); if (!self.check_status()) return false; var remain = size; var read = data; while (remain > 0) { const block = if (remain >= self.mtu) self.mtu else remain; if (gatt_client_write_value_of_characteristic_without_response(self.conn_handle, self.handle_data, @intCast(u16, block), read) != 0) { if (!self.check_status()) return false; continue; } read = read + block; remain -= block; } var crc_value = rom_crc.?(data, @intCast(u16, size)); cmd[0] = OTA_CTRL_PAGE_END; cmd[1] = @intCast(u8, size & 0xff); cmd[2] = @intCast(u8, size >> 8); cmd[3] = @intCast(u8, crc_value & 0xff); cmd[4] = @intCast(u8, crc_value >> 8); _ = self.write_cmd2(cmd.len, &cmd[0]); if (!self.check_status()) return false; return true; } fn burn_item(self: *Client, local_storage_addr: u32, target_storage_addr: u32, size0: u32,) bool { var local = local_storage_addr; var target = target_storage_addr; var size = size0; while (size > 0) { const block = if (size >= PAGE_SIZE) PAGE_SIZE else size; if (!self.burn_page(@intToPtr([*c] u8, local), target, block)) return false; local += block; target += block; size -= block; } return true; } fn burn_items(self: *Client, bitmap: u16, item_cnt: c_int, items: [*c] const ota_item_t) bool { var index: usize = 0; while (index < item_cnt) : (index += 1) { if ((bitmap & (@as(u16, 1) << @intCast(u4, index))) == 0) continue; if (enable_print) { print("start new item: %d\n", index); } if (!self.burn_item(items[index].local_storage_addr, items[index].target_storage_addr, items[index].size)) return false; } return true; } fn burn_meta(self: *Client, bitmap: u16, item_cnt: c_int, items: [*c] const ota_item_t, entry: u32) bool { var index: usize = 0; var cnt: usize = 0; while (index < item_cnt) : (index += 1) { if ((bitmap & (@as(u16, 1) << @intCast(u4, index))) == 0) continue; self.meta_data.blocks[cnt].src = items[index].target_storage_addr; self.meta_data.blocks[cnt].dest = items[index].target_load_addr; self.meta_data.blocks[cnt].size = items[index].size; cnt += 1; } self.meta_data.cmd_id = OTA_CTRL_METADATA; self.meta_data.entry = entry; const total = 7 + cnt * 12; self.meta_data.crc_value = rom_crc.?(@ptrCast([*c] u8, &self.meta_data.entry), @intCast(u16, total - 3)); _ = self.write_cmd2(total, @ptrCast([*c] u8, &self.meta_data)); return self.check_status(); } pub fn update(self: *Client, optional_latest: ?*const ota_ver_t, conn_handle: u16, handle_ver: u16, handle_ctrl: u16, handle_data: u16, item_cnt: c_int, items: [*c] const ota_item_t, entry: u32) c_int { self.conn_handle = conn_handle; self.handle_ver = handle_ver; self.handle_ctrl = handle_ctrl; self.handle_data = handle_data; if (item_cnt > MAX_UPDATE_BLOCKS) return -127; _ = gatt_client_get_mtu(conn_handle, &self.mtu); self.mtu -= 3; const bitmap = ((@intCast(u16, 1) << @intCast(u4, item_cnt)) - 1) & (fota_make_bitmap(self, optional_latest) orelse return -1); if (bitmap == 0) return 1; if (enable_print) { print("update bitmap: %02x\n", bitmap); } if (!self.enable_fota()) return -2; if (!self.burn_items(bitmap, item_cnt, items)) return -3; if (!self.burn_meta(bitmap, item_cnt, items, entry)) return -4; if (!self.reboot()) return -5; return 0; } }; fn fota_client_do_update_async(optional_latest: ?*const ota_ver_t, conn_handle: u16, handle_ver: u16, handle_ctrl: u16, handle_data: u16, item_cnt: c_int, items: [*c] const ota_item_t, entry: u32, on_done: fn (err_code: c_int) callconv(.C) void) void { var client: Client = undefined; on_done(client.update(optional_latest, conn_handle, handle_ver, handle_ctrl, handle_data, item_cnt, items, entry)); } var fota_frame: @Frame(fota_client_do_update_async) = undefined; export fn fota_client_do_update(optional_latest: ?*const ota_ver_t, conn_handle: u16, handle_ver: u16, handle_ctrl: u16, handle_data: u16, item_cnt: c_int, items: [*c] const ota_item_t, entry: u32, on_done: fn (err_code: c_int) callconv(.C) void) void { fota_frame = async fota_client_do_update_async(optional_latest, conn_handle, handle_ver, handle_ctrl, handle_data, item_cnt, items, entry, on_done); } pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { print("\n!KERNEL PANIC!\n"); for (message) |value| { print("%c", value); } platform_raise_assertion("panic", 0); while (true) {} }
examples-gcc/central_fota/src/fota_client.zig
const builtin = @import("builtin"); const std = @import("std"); pub const deg_to_rad = std.math.pi / 180.0; pub const rad_to_deg = 180.0 / std.math.pi; pub fn cos(x: f32) f32 { return std.math.cos(x); } pub fn sin(x: f32) f32 { return std.math.sin(x); } const x1 = 1.0 / std.math.ln(2.0) - 1.0; const log2p1_bias: f32 = -(0.0 + (std.math.log2(1.0 + x1) - x1)) / 2.0; // fast log2(1 + x) for x in [0; 1] pub fn a_log2p1(x: f32) f32 { return x - log2p1_bias; } // @bitCast(i32, x) = ~ (log2(x) + 127) * 2^23 const sqrt_bias: i32 = (127 * 1 << 22) - (127 * 1 << 23); pub fn a_sqrt(x: f32) f32 { // 1/2 * log2(x) = log2(sqrt(x)) var i = @bitCast(i32, x); // i = (log2(x) + 127) * 2^23 i = i >> 1; // 1/2 i = (log2(sqrt(x)) * 2^23) + (1/2 * 127 * 2^23) i = i - sqrt_bias; // sqrt_bias = (1/2 * 127 * 2^23) - (127 * 2^23) var y = @bitCast(f32, i); // i = (log2(sqrt(x)) + 127) * 2^23 return y; // y = sqrt(x) } //test "a_sqrt()" { // @sqrt(.1) //} // TODO: investigate assembly: https://www.codeproject.com/Articles/69941/Best-Square-Root-Method-Algorithm-Function-Precisi pub const isqrt_bias: i32 = (-127 * 1 << 22) - (127 * 1 << 23); pub fn a_isqrt(x: f32) f32 { // TODO: account for not quite logarithmic nature of floats //var half_x = x * 0.5; // -1/2 * log2(x) = log2(1/sqrt(x)) var i = @bitCast(i32, x); // i = (log2(x) + 127) * 2^23 i = -(i >> 1); // -1/2 i = (log2(1/sqrt(x)) * 2^23) + (-1/2 * 127 * 2^23) i = i - isqrt_bias; // isqrt_bias = (-1/2 * 127 * 2^23) - (127 * 2^23) var y = @bitCast(f32, i); // i = (log2(1/sqrt(x)) + 127) * 2^23 // Newtons method x = x + f(x)/f'(x) //y = y * (1.5 - (half_x * y * y)); // 1st iteration //y = y * (1.5 - (half_x * y * y)); // 2nd iteration return y; // y = 1/sqrt(x) } pub fn f_sqrt(x: f32) callconv(.Inline) f32 { // .ReleaseFast = 50-100x .Debug return switch (builtin.mode) { else => @sqrt(x), .ReleaseSafe, .ReleaseFast, .ReleaseSmall => a_sqrt(x), }; } pub fn f_isqrt(x: f32) callconv(.Inline) f32 { // .ReleaseFast = 10-75x .Debug return switch (builtin.mode) { else => 1 / @sqrt(x), .ReleaseFast, .ReleaseSmall => a_isqrt(x), }; } pub const vec3 = [3]f32; //pub const vec3 = std.meta.Vector(3, f32); pub fn add_vec3(A: vec3, B: vec3) vec3 { return .{ A[0] + B[0], A[1] + B[1], A[2] + B[2] }; } pub fn sub_vec3(A: vec3, B: vec3) vec3 { return .{ A[0] - B[0], A[1] - B[1], A[2] - B[2] }; } pub fn mul_vec3(A: vec3, x: f32) vec3 { return .{ A[0] * x, A[1] * x, A[2] * x }; } pub fn normalize_vec3(A: vec3) vec3 { return mul_vec3(A, 1 / @sqrt(sq_vec3(A))); } pub fn dot_vec3(A: vec3, B: vec3) f32 { return (A[0] * B[0]) + (A[1] * B[1]) + (A[2] * B[2]); } pub fn cross_vec3(A: vec3, B: vec3) vec3 { return (vec3){ (A[1] * B[2]) - (B[1] * A[2]), (A[2] * B[0]) - (B[2] * A[0]), (A[0] * B[1]) - (B[0] * A[1]), }; } pub fn sq_vec3(A: vec3) f32 { return (A[0] * A[0]) + (A[1] * A[1]) + (A[2] * A[2]); } pub fn cos_vec3(A: vec3, B: vec3) f32 { return dot_vec3(A, B) * f_isqrt(sq_vec3(A) * sq_vec3(B)); }
src/math.zig
const std = @import("std"); // Zig standard library, duh! pub fn build(builder: *std.build.Builder) !void { const ScanProtocolsStep = @import("deps/zig-wayland/build.zig").ScanProtocolsStep; // Creating the wayland-scanner. const scanner = ScanProtocolsStep.create(builder); scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml"); // Creating the executable. const exe = builder.addExecutable("herb", "herb/main.zig"); // Setting executable target and build mode. exe.setTarget(builder.standardTargetOptions(.{})); exe.setBuildMode(builder.standardReleaseOptions()); // Depend on scanner step. exe.step.dependOn(&scanner.step); scanner.addCSource(exe); // TODO: remove when https://github.com/ziglang/zig/issues/131 is implemented // Add the required packages and link it to our project. exe.linkLibC(); exe.step.dependOn(&scanner.step); const wayland = std.build.Pkg{ .name = "wayland", .path = .{ .generated = &scanner.result }, }; exe.addPackage(wayland); exe.linkSystemLibrary("wayland-server"); const pixman = std.build.Pkg{ .name = "pixman", .path = .{ .path = "deps/zig-pixman/pixman.zig" }, }; exe.addPackage(pixman); exe.linkSystemLibrary("pixman-1"); const xkbcommon = std.build.Pkg{ .name = "xkbcommon", .path = .{ .path = "deps/zig-xkbcommon/src/xkbcommon.zig" }, }; exe.addPackage(xkbcommon); exe.linkSystemLibrary("xkbcommon"); const wlroots = std.build.Pkg{ .name = "wlroots", .path = .{ .path = "deps/zig-wlroots/src/wlroots.zig" }, .dependencies = &[_]std.build.Pkg{ wayland, xkbcommon, pixman }, }; exe.addPackage(wlroots); exe.linkSystemLibrary("wlroots"); // Install the .desktop file to the prefix. builder.installFile("./herb.desktop", "share/wayland-sessions/herb.desktop"); // Install the .desktop file to the prefix. builder.installFile("./herb.desktop", "share/wayland-sessions/herb.desktop"); // Install the binary to the mentioned prefix. exe.install(); }
build.zig
const Self = @This(); const std = @import("std"); const Allocator = std.mem.Allocator; const c = @import("xml.zig").c; /// Possible errors that can be returned by many of the functions /// in this library. See the function doc comments for details on /// exactly which of these can be returnd. pub const Set = error{ OutOfMemory, Unimplemented, ReadFailed, WriteFailed, NodeExpected, InvalidElement, RequiredValueMissing, RouteMissingWaypoint, }; /// last error that occurred, this MIGHT be set if an error code is returned. /// This is thread local so using this library in a threaded environment will /// store errors separately. threadlocal var _lastError: ?Self = null; /// Error code for this error code: Set, /// Additional details for this error. Whether this is set depends on what /// triggered the error. The type of this is dependent on the context in which /// the error was triggered. detail: ?Detail = null, /// Extra details for an error. What is set is dependent on what raised the error. pub const Detail = union(enum) { /// message is a basic string message. string: String, /// xml-specific error message (typically a parse error) xml: XMLDetail, /// Gets a human-friendly message regardless of type. pub fn message(self: *Detail) [:0]const u8 { switch (self.*) { .string => |*v| return v.message, .xml => |*v| return v.message(), } } pub fn deinit(self: Detail) void { switch (self) { .string => |v| v.deinit(), .xml => |v| v.deinit(), } } /// XMLDetail when an XML-related error occurs for formats that use XML. pub const XMLDetail = struct { pub const Context = union(enum) { global: void, parser: c.xmlParserCtxtPtr, writer: c.xmlTextWriterPtr, }; ctx: Context, /// Return the raw xmlError structure. pub fn err(self: *XMLDetail) ?*c.xmlError { return switch (self.ctx) { .global => c.xmlGetLastError(), .parser => |ptr| c.xmlCtxtGetLastError(ptr), .writer => |ptr| c.xmlCtxtGetLastError(ptr), }; } pub fn message(self: *XMLDetail) [:0]const u8 { const v = self.err() orelse return "no error"; return std.mem.span(v.message); } pub fn deinit(self: XMLDetail) void { switch (self.ctx) { .global => {}, .parser => |ptr| c.xmlFreeParserCtxt(ptr), .writer => |ptr| c.xmlFreeTextWriter(ptr), } } }; pub const String = struct { alloc: Allocator, message: [:0]const u8, pub fn init(alloc: Allocator, comptime fmt: []const u8, args: anytype) !String { const msg = try std.fmt.allocPrintZ(alloc, fmt, args); return String{ .alloc = alloc, .message = msg }; } pub fn deinit(self: String) void { self.alloc.free(self.message); } }; }; /// Helper to easily initialize an error with a message. pub fn initMessage(alloc: Allocator, code: Set, comptime fmt: []const u8, args: anytype) !Self { const detail = Detail{ .string = try Detail.String.init(alloc, fmt, args), }; return Self{ .code = code, .detail = detail, }; } /// Returns a human-friendly message about the error. pub fn message(self: *Self) [:0]const u8 { if (self.detail) |*detail| { return detail.message(); } return "no error message"; } /// Release resources associated with an error. pub fn deinit(self: Self) void { if (self.detail) |detail| { detail.deinit(); } } /// Return the last error (if any). pub inline fn lastError() ?*Self { if (_lastError) |*err| { return err; } return null; } // Set a new last error. pub fn setLastError(err: ?Self) void { // Unset previous error if there is one. if (_lastError) |last| { last.deinit(); } _lastError = err; } /// Set a new last error that was an XML error. pub fn setLastErrorXML(code: Set, ctx: Detail.XMLDetail.Context) Set { // Can't nest it all due to: https://github.com/ziglang/zig/issues/6043 const detail = Detail{ .xml = .{ .ctx = ctx } }; setLastError(Self{ .code = code, .detail = detail, }); return code; } test "set last error" { // Setting it while null does nothing setLastError(null); setLastError(null); // Can set and retrieve setLastError(Self{ .code = Set.ReadFailed }); const err = lastError().?; try std.testing.expectEqual(err.code, Set.ReadFailed); // Can set to null setLastError(null); try std.testing.expect(lastError() == null); }
src/Error.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const StringHashMap = std.StringHashMap; const _obj = @import("./obj.zig"); const Obj = _obj.Obj; const objToString = _obj.objToString; const ObjTypeDef = _obj.ObjTypeDef; pub const ValueType = enum { Boolean, Number, Null, Void, Obj }; pub const Value = union(ValueType) { Boolean: bool, Number: f64, Null: ?bool, Void: ?bool, Obj: *Obj, }; // We can't hash f64 pub const HashableValue = union(ValueType) { Boolean: bool, Number: i64, Null: ?bool, Void: ?bool, Obj: *Obj }; pub fn valueToHashable(value: Value) HashableValue { switch (value) { .Boolean => return HashableValue{ .Boolean = value.Boolean }, .Number => { const number: f64 = value.Number; if (number - @intToFloat(f64, @floatToInt(i64, number)) == 0) { return HashableValue{ .Number = @floatToInt(i64, value.Number) }; } else { // TODO: something like: https://github.com/lua/lua/blob/master/ltable.c#L117-L143 // See: https://github.com/ziglang/zig/pull/6145 unreachable; } }, .Null => return HashableValue{ .Null = value.Null }, .Void => return HashableValue{ .Void = value.Void }, .Obj => return HashableValue{ .Obj = value.Obj }, } } pub fn hashableToValue(hashable: HashableValue) Value { switch (hashable) { .Boolean => return Value{ .Boolean = hashable.Boolean }, .Number => { return Value{ .Number = @intToFloat(f64, hashable.Number) }; }, .Null => return Value{ .Null = hashable.Null }, .Void => return Value{ .Void = hashable.Void }, .Obj => return Value{ .Obj = hashable.Obj }, } } pub fn valueToString(allocator: Allocator, value: Value) (Allocator.Error || std.fmt.BufPrintError)![]const u8 { // TODO: use arraylist writer var buf: []u8 = try allocator.alloc(u8, 1000); return switch (value) { .Boolean => try std.fmt.bufPrint(buf, "{}", .{value.Boolean}), .Number => try std.fmt.bufPrint(buf, "{d}", .{value.Number}), .Null => try std.fmt.bufPrint(buf, "null", .{}), .Void => try std.fmt.bufPrint(buf, "void", .{}), .Obj => try objToString(allocator, buf, value.Obj), }; } pub fn valueEql(a: Value, b: Value) bool { if (@as(ValueType, a) != @as(ValueType, b)) { return false; } return switch (a) { .Boolean => a.Boolean == b.Boolean, .Number => a.Number == b.Number, .Null => true, .Void => true, .Obj => a.Obj.eql(b.Obj), }; } pub fn valueIs(type_def_val: Value, value: Value) bool { const type_def: *ObjTypeDef = ObjTypeDef.cast(type_def_val.Obj).?; return switch (value) { .Boolean => type_def.def_type == .Bool, .Number => type_def.def_type == .Number, // TODO: this one is ambiguous at runtime, is it the `null` constant? or an optional local with a null value? .Null => type_def.def_type == .Void or type_def.optional, .Void => type_def.def_type == .Void, .Obj => value.Obj.is(type_def), }; } pub fn valueTypeEql(self: Value, type_def: *ObjTypeDef) bool { return switch (self) { .Boolean => type_def.def_type == .Bool, .Number => type_def.def_type == .Number, // TODO: this one is ambiguous at runtime, is it the `null` constant? or an optional local with a null value? .Null => type_def.def_type == .Void or type_def.optional, .Void => type_def.def_type == .Void, .Obj => self.Obj.typeEql(type_def), }; }
src/value.zig
const std = @import("std"); const builtin = @import("builtin"); const event = std.event; const os = std.os; const io = std.io; const fs = std.fs; const mem = std.mem; const process = std.process; const Allocator = mem.Allocator; const ArrayList = std.ArrayList; const Buffer = std.Buffer; const arg = @import("arg.zig"); const c = @import("c.zig"); const introspect = @import("introspect.zig"); const Args = arg.Args; const Flag = arg.Flag; const ZigCompiler = @import("compilation.zig").ZigCompiler; const Compilation = @import("compilation.zig").Compilation; const Target = @import("target.zig").Target; const errmsg = @import("errmsg.zig"); const LibCInstallation = @import("libc_installation.zig").LibCInstallation; var stderr_file: fs.File = undefined; var stderr: *io.OutStream(fs.File.WriteError) = undefined; var stdout: *io.OutStream(fs.File.WriteError) = undefined; pub const max_src_size = 2 * 1024 * 1024 * 1024; // 2 GiB const usage = \\usage: zig [command] [options] \\ \\Commands: \\ \\ build-exe [source] Create executable from source or object files \\ build-lib [source] Create library from source or object files \\ build-obj [source] Create object from source or assembly \\ fmt [source] Parse file and render in canonical zig format \\ libc [paths_file] Display native libc paths file or validate one \\ targets List available compilation targets \\ version Print version number and exit \\ zen Print zen of zig and exit \\ \\ ; const Command = struct { name: []const u8, exec: fn (*Allocator, []const []const u8) anyerror!void, }; pub fn main() !void { // This allocator needs to be thread-safe because we use it for the event.Loop // which multiplexes async functions onto kernel threads. // libc allocator is guaranteed to have this property. const allocator = std.heap.c_allocator; var stdout_file = try std.io.getStdOut(); var stdout_out_stream = stdout_file.outStream(); stdout = &stdout_out_stream.stream; stderr_file = try std.io.getStdErr(); var stderr_out_stream = stderr_file.outStream(); stderr = &stderr_out_stream.stream; const args = try process.argsAlloc(allocator); // TODO I'm getting unreachable code here, which shouldn't happen //defer process.argsFree(allocator, args); if (args.len <= 1) { try stderr.write("expected command argument\n\n"); try stderr.write(usage); process.exit(1); } const commands = [_]Command{ Command{ .name = "build-exe", .exec = cmdBuildExe, }, Command{ .name = "build-lib", .exec = cmdBuildLib, }, Command{ .name = "build-obj", .exec = cmdBuildObj, }, Command{ .name = "fmt", .exec = cmdFmt, }, Command{ .name = "libc", .exec = cmdLibC, }, Command{ .name = "targets", .exec = cmdTargets, }, Command{ .name = "version", .exec = cmdVersion, }, Command{ .name = "zen", .exec = cmdZen, }, // undocumented commands Command{ .name = "help", .exec = cmdHelp, }, Command{ .name = "internal", .exec = cmdInternal, }, }; for (commands) |command| { if (mem.eql(u8, command.name, args[1])) { return command.exec(allocator, args[2..]); } } try stderr.print("unknown command: {}\n\n", args[1]); try stderr.write(usage); process.exit(1); } const usage_build_generic = \\usage: zig build-exe <options> [file] \\ zig build-lib <options> [file] \\ zig build-obj <options> [file] \\ \\General Options: \\ --help Print this help and exit \\ --color [auto|off|on] Enable or disable colored error messages \\ \\Compile Options: \\ --libc [file] Provide a file which specifies libc paths \\ --assembly [source] Add assembly file to build \\ --emit [filetype] Emit a specific file format as compilation output \\ --enable-timing-info Print timing diagnostics \\ --name [name] Override output name \\ --output [file] Override destination path \\ --output-h [file] Override generated header file path \\ --pkg-begin [name] [path] Make package available to import and push current pkg \\ --pkg-end Pop current pkg \\ --mode [mode] Set the build mode \\ debug (default) optimizations off, safety on \\ release-fast optimizations on, safety off \\ release-safe optimizations on, safety on \\ release-small optimize for small binary, safety off \\ --static Output will be statically linked \\ --strip Exclude debug symbols \\ -target [name] <arch><sub>-<os>-<abi> see the targets command \\ --verbose-tokenize Turn on compiler debug output for tokenization \\ --verbose-ast-tree Turn on compiler debug output for parsing into an AST (tree view) \\ --verbose-ast-fmt Turn on compiler debug output for parsing into an AST (render source) \\ --verbose-link Turn on compiler debug output for linking \\ --verbose-ir Turn on compiler debug output for Zig IR \\ --verbose-llvm-ir Turn on compiler debug output for LLVM IR \\ --verbose-cimport Turn on compiler debug output for C imports \\ -dirafter [dir] Same as -isystem but do it last \\ -isystem [dir] Add additional search path for other .h files \\ -mllvm [arg] Additional arguments to forward to LLVM's option processing \\ \\Link Options: \\ --ar-path [path] Set the path to ar \\ --each-lib-rpath Add rpath for each used dynamic library \\ --library [lib] Link against lib \\ --forbid-library [lib] Make it an error to link against lib \\ --library-path [dir] Add a directory to the library search path \\ --linker-script [path] Use a custom linker script \\ --object [obj] Add object file to build \\ -rdynamic Add all symbols to the dynamic symbol table \\ -rpath [path] Add directory to the runtime library search path \\ -mconsole (windows) --subsystem console to the linker \\ -mwindows (windows) --subsystem windows to the linker \\ -framework [name] (darwin) link against framework \\ -mios-version-min [ver] (darwin) set iOS deployment target \\ -mmacosx-version-min [ver] (darwin) set Mac OS X deployment target \\ --ver-major [ver] Dynamic library semver major version \\ --ver-minor [ver] Dynamic library semver minor version \\ --ver-patch [ver] Dynamic library semver patch version \\ \\ ; const args_build_generic = [_]Flag{ Flag.Bool("--help"), Flag.Option("--color", [_][]const u8{ "auto", "off", "on", }), Flag.Option("--mode", [_][]const u8{ "debug", "release-fast", "release-safe", "release-small", }), Flag.ArgMergeN("--assembly", 1), Flag.Option("--emit", [_][]const u8{ "asm", "bin", "llvm-ir", }), Flag.Bool("--enable-timing-info"), Flag.Arg1("--libc"), Flag.Arg1("--name"), Flag.Arg1("--output"), Flag.Arg1("--output-h"), // NOTE: Parsed manually after initial check Flag.ArgN("--pkg-begin", 2), Flag.Bool("--pkg-end"), Flag.Bool("--static"), Flag.Bool("--strip"), Flag.Arg1("-target"), Flag.Bool("--verbose-tokenize"), Flag.Bool("--verbose-ast-tree"), Flag.Bool("--verbose-ast-fmt"), Flag.Bool("--verbose-link"), Flag.Bool("--verbose-ir"), Flag.Bool("--verbose-llvm-ir"), Flag.Bool("--verbose-cimport"), Flag.Arg1("-dirafter"), Flag.ArgMergeN("-isystem", 1), Flag.Arg1("-mllvm"), Flag.Arg1("--ar-path"), Flag.Bool("--each-lib-rpath"), Flag.ArgMergeN("--library", 1), Flag.ArgMergeN("--forbid-library", 1), Flag.ArgMergeN("--library-path", 1), Flag.Arg1("--linker-script"), Flag.ArgMergeN("--object", 1), // NOTE: Removed -L since it would need to be special-cased and we have an alias in library-path Flag.Bool("-rdynamic"), Flag.Arg1("-rpath"), Flag.Bool("-mconsole"), Flag.Bool("-mwindows"), Flag.ArgMergeN("-framework", 1), Flag.Arg1("-mios-version-min"), Flag.Arg1("-mmacosx-version-min"), Flag.Arg1("--ver-major"), Flag.Arg1("--ver-minor"), Flag.Arg1("--ver-patch"), }; fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Compilation.Kind) !void { var flags = try Args.parse(allocator, args_build_generic, args); defer flags.deinit(); if (flags.present("help")) { try stdout.write(usage_build_generic); process.exit(0); } const build_mode = blk: { if (flags.single("mode")) |mode_flag| { if (mem.eql(u8, mode_flag, "debug")) { break :blk builtin.Mode.Debug; } else if (mem.eql(u8, mode_flag, "release-fast")) { break :blk builtin.Mode.ReleaseFast; } else if (mem.eql(u8, mode_flag, "release-safe")) { break :blk builtin.Mode.ReleaseSafe; } else if (mem.eql(u8, mode_flag, "release-small")) { break :blk builtin.Mode.ReleaseSmall; } else unreachable; } else { break :blk builtin.Mode.Debug; } }; const color = blk: { if (flags.single("color")) |color_flag| { if (mem.eql(u8, color_flag, "auto")) { break :blk errmsg.Color.Auto; } else if (mem.eql(u8, color_flag, "on")) { break :blk errmsg.Color.On; } else if (mem.eql(u8, color_flag, "off")) { break :blk errmsg.Color.Off; } else unreachable; } else { break :blk errmsg.Color.Auto; } }; const emit_type = blk: { if (flags.single("emit")) |emit_flag| { if (mem.eql(u8, emit_flag, "asm")) { break :blk Compilation.Emit.Assembly; } else if (mem.eql(u8, emit_flag, "bin")) { break :blk Compilation.Emit.Binary; } else if (mem.eql(u8, emit_flag, "llvm-ir")) { break :blk Compilation.Emit.LlvmIr; } else unreachable; } else { break :blk Compilation.Emit.Binary; } }; var cur_pkg = try CliPkg.init(allocator, "", "", null); defer cur_pkg.deinit(); var i: usize = 0; while (i < args.len) : (i += 1) { const arg_name = args[i]; if (mem.eql(u8, "--pkg-begin", arg_name)) { // following two arguments guaranteed to exist due to arg parsing i += 1; const new_pkg_name = args[i]; i += 1; const new_pkg_path = args[i]; var new_cur_pkg = try CliPkg.init(allocator, new_pkg_name, new_pkg_path, cur_pkg); try cur_pkg.children.append(new_cur_pkg); cur_pkg = new_cur_pkg; } else if (mem.eql(u8, "--pkg-end", arg_name)) { if (cur_pkg.parent) |parent| { cur_pkg = parent; } else { try stderr.print("encountered --pkg-end with no matching --pkg-begin\n"); process.exit(1); } } } if (cur_pkg.parent != null) { try stderr.print("unmatched --pkg-begin\n"); process.exit(1); } const provided_name = flags.single("name"); const root_source_file = switch (flags.positionals.len) { 0 => null, 1 => flags.positionals.at(0), else => { try stderr.print("unexpected extra parameter: {}\n", flags.positionals.at(1)); process.exit(1); }, }; const root_name = if (provided_name) |n| n else blk: { if (root_source_file) |file| { const basename = fs.path.basename(file); var it = mem.separate(basename, "."); break :blk it.next() orelse basename; } else { try stderr.write("--name [name] not provided and unable to infer\n"); process.exit(1); } }; const is_static = flags.present("static"); const assembly_files = flags.many("assembly"); const link_objects = flags.many("object"); if (root_source_file == null and link_objects.len == 0 and assembly_files.len == 0) { try stderr.write("Expected source file argument or at least one --object or --assembly argument\n"); process.exit(1); } if (out_type == Compilation.Kind.Obj and link_objects.len != 0) { try stderr.write("When building an object file, --object arguments are invalid\n"); process.exit(1); } var clang_argv_buf = ArrayList([]const u8).init(allocator); defer clang_argv_buf.deinit(); const mllvm_flags = flags.many("mllvm"); for (mllvm_flags) |mllvm| { try clang_argv_buf.append("-mllvm"); try clang_argv_buf.append(mllvm); } try ZigCompiler.setLlvmArgv(allocator, mllvm_flags); const zig_lib_dir = introspect.resolveZigLibDir(allocator) catch process.exit(1); defer allocator.free(zig_lib_dir); var override_libc: LibCInstallation = undefined; var loop: event.Loop = undefined; try loop.initMultiThreaded(allocator); defer loop.deinit(); var zig_compiler = try ZigCompiler.init(&loop); defer zig_compiler.deinit(); var comp = try Compilation.create( &zig_compiler, root_name, root_source_file, Target.Native, out_type, build_mode, is_static, zig_lib_dir, ); defer comp.destroy(); if (flags.single("libc")) |libc_path| { parseLibcPaths(loop.allocator, &override_libc, libc_path); comp.override_libc = &override_libc; } for (flags.many("library")) |lib| { _ = try comp.addLinkLib(lib, true); } comp.version_major = try std.fmt.parseUnsigned(u32, flags.single("ver-major") orelse "0", 10); comp.version_minor = try std.fmt.parseUnsigned(u32, flags.single("ver-minor") orelse "0", 10); comp.version_patch = try std.fmt.parseUnsigned(u32, flags.single("ver-patch") orelse "0", 10); comp.is_test = false; comp.linker_script = flags.single("linker-script"); comp.each_lib_rpath = flags.present("each-lib-rpath"); comp.clang_argv = clang_argv_buf.toSliceConst(); comp.strip = flags.present("strip"); comp.verbose_tokenize = flags.present("verbose-tokenize"); comp.verbose_ast_tree = flags.present("verbose-ast-tree"); comp.verbose_ast_fmt = flags.present("verbose-ast-fmt"); comp.verbose_link = flags.present("verbose-link"); comp.verbose_ir = flags.present("verbose-ir"); comp.verbose_llvm_ir = flags.present("verbose-llvm-ir"); comp.verbose_cimport = flags.present("verbose-cimport"); comp.err_color = color; comp.lib_dirs = flags.many("library-path"); comp.darwin_frameworks = flags.many("framework"); comp.rpath_list = flags.many("rpath"); if (flags.single("output-h")) |output_h| { comp.out_h_path = output_h; } comp.windows_subsystem_windows = flags.present("mwindows"); comp.windows_subsystem_console = flags.present("mconsole"); comp.linker_rdynamic = flags.present("rdynamic"); if (flags.single("mmacosx-version-min") != null and flags.single("mios-version-min") != null) { try stderr.write("-mmacosx-version-min and -mios-version-min options not allowed together\n"); process.exit(1); } if (flags.single("mmacosx-version-min")) |ver| { comp.darwin_version_min = Compilation.DarwinVersionMin{ .MacOS = ver }; } if (flags.single("mios-version-min")) |ver| { comp.darwin_version_min = Compilation.DarwinVersionMin{ .Ios = ver }; } comp.emit_file_type = emit_type; comp.assembly_files = assembly_files; comp.link_out_file = flags.single("output"); comp.link_objects = link_objects; comp.start(); // TODO const process_build_events_handle = try async<loop.allocator> processBuildEvents(comp, color); loop.run(); } async fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void { var count: usize = 0; while (true) { // TODO directly awaiting async should guarantee memory allocation elision const build_event = await (async comp.events.get() catch unreachable); count += 1; switch (build_event) { Compilation.Event.Ok => { stderr.print("Build {} succeeded\n", count) catch process.exit(1); }, Compilation.Event.Error => |err| { stderr.print("Build {} failed: {}\n", count, @errorName(err)) catch process.exit(1); }, Compilation.Event.Fail => |msgs| { stderr.print("Build {} compile errors:\n", count) catch process.exit(1); for (msgs) |msg| { defer msg.destroy(); msg.printToFile(stderr_file, color) catch process.exit(1); } }, } } } fn cmdBuildExe(allocator: *Allocator, args: []const []const u8) !void { return buildOutputType(allocator, args, Compilation.Kind.Exe); } fn cmdBuildLib(allocator: *Allocator, args: []const []const u8) !void { return buildOutputType(allocator, args, Compilation.Kind.Lib); } fn cmdBuildObj(allocator: *Allocator, args: []const []const u8) !void { return buildOutputType(allocator, args, Compilation.Kind.Obj); } pub const usage_fmt = \\usage: zig fmt [file]... \\ \\ Formats the input files and modifies them in-place. \\ Arguments can be files or directories, which are searched \\ recursively. \\ \\Options: \\ --help Print this help and exit \\ --color [auto|off|on] Enable or disable colored error messages \\ --stdin Format code from stdin; output to stdout \\ --check List non-conforming files and exit with an error \\ if the list is non-empty \\ \\ ; pub const args_fmt_spec = [_]Flag{ Flag.Bool("--help"), Flag.Bool("--check"), Flag.Option("--color", [_][]const u8{ "auto", "off", "on", }), Flag.Bool("--stdin"), }; const Fmt = struct { seen: event.Locked(SeenMap), any_error: bool, color: errmsg.Color, loop: *event.Loop, const SeenMap = std.HashMap([]const u8, void, mem.hash_slice_u8, mem.eql_slice_u8); }; fn parseLibcPaths(allocator: *Allocator, libc: *LibCInstallation, libc_paths_file: []const u8) void { libc.parse(allocator, libc_paths_file, stderr) catch |err| { stderr.print( "Unable to parse libc path file '{}': {}.\n" ++ "Try running `zig libc` to see an example for the native target.\n", libc_paths_file, @errorName(err), ) catch process.exit(1); process.exit(1); }; } fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void { switch (args.len) { 0 => {}, 1 => { var libc_installation: LibCInstallation = undefined; parseLibcPaths(allocator, &libc_installation, args[0]); return; }, else => { try stderr.print("unexpected extra parameter: {}\n", args[1]); process.exit(1); }, } var loop: event.Loop = undefined; try loop.initMultiThreaded(allocator); defer loop.deinit(); var zig_compiler = try ZigCompiler.init(&loop); defer zig_compiler.deinit(); // TODO const handle = try async<loop.allocator> findLibCAsync(&zig_compiler); loop.run(); } async fn findLibCAsync(zig_compiler: *ZigCompiler) void { const libc = (await (async zig_compiler.getNativeLibC() catch unreachable)) catch |err| { stderr.print("unable to find libc: {}\n", @errorName(err)) catch process.exit(1); process.exit(1); }; libc.render(stdout) catch process.exit(1); } fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { var flags = try Args.parse(allocator, args_fmt_spec, args); defer flags.deinit(); if (flags.present("help")) { try stdout.write(usage_fmt); process.exit(0); } const color = blk: { if (flags.single("color")) |color_flag| { if (mem.eql(u8, color_flag, "auto")) { break :blk errmsg.Color.Auto; } else if (mem.eql(u8, color_flag, "on")) { break :blk errmsg.Color.On; } else if (mem.eql(u8, color_flag, "off")) { break :blk errmsg.Color.Off; } else unreachable; } else { break :blk errmsg.Color.Auto; } }; if (flags.present("stdin")) { if (flags.positionals.len != 0) { try stderr.write("cannot use --stdin with positional arguments\n"); process.exit(1); } var stdin_file = try io.getStdIn(); var stdin = stdin_file.inStream(); const source_code = try stdin.stream.readAllAlloc(allocator, max_src_size); defer allocator.free(source_code); const tree = std.zig.parse(allocator, source_code) catch |err| { try stderr.print("error parsing stdin: {}\n", err); process.exit(1); }; defer tree.deinit(); var error_it = tree.errors.iterator(0); while (error_it.next()) |parse_error| { const msg = try errmsg.Msg.createFromParseError(allocator, parse_error, tree, "<stdin>"); defer msg.destroy(); try msg.printToFile(stderr_file, color); } if (tree.errors.len != 0) { process.exit(1); } if (flags.present("check")) { const anything_changed = try std.zig.render(allocator, io.null_out_stream, tree); const code = if (anything_changed) u8(1) else u8(0); process.exit(code); } _ = try std.zig.render(allocator, stdout, tree); return; } if (flags.positionals.len == 0) { try stderr.write("expected at least one source file argument\n"); process.exit(1); } var loop: event.Loop = undefined; try loop.initMultiThreaded(allocator); defer loop.deinit(); var result: FmtError!void = undefined; // TODO const main_handle = try async<allocator> asyncFmtMainChecked( // TODO &result, // TODO &loop, // TODO &flags, // TODO color, // TODO ); loop.run(); return result; } async fn asyncFmtMainChecked( result: *(FmtError!void), loop: *event.Loop, flags: *const Args, color: errmsg.Color, ) void { result.* = await (async asyncFmtMain(loop, flags, color) catch unreachable); } const FmtError = error{ SystemResources, OperationAborted, IoPending, BrokenPipe, Unexpected, WouldBlock, FileClosed, DestinationAddressRequired, DiskQuota, FileTooBig, InputOutput, NoSpaceLeft, AccessDenied, OutOfMemory, RenameAcrossMountPoints, ReadOnlyFileSystem, LinkQuotaExceeded, FileBusy, CurrentWorkingDirectoryUnlinked, } || fs.File.OpenError; async fn asyncFmtMain( loop: *event.Loop, flags: *const Args, color: errmsg.Color, ) FmtError!void { suspend { resume @handle(); } var fmt = Fmt{ .seen = event.Locked(Fmt.SeenMap).init(loop, Fmt.SeenMap.init(loop.allocator)), .any_error = false, .color = color, .loop = loop, }; const check_mode = flags.present("check"); var group = event.Group(FmtError!void).init(loop); for (flags.positionals.toSliceConst()) |file_path| { try group.call(fmtPath, &fmt, file_path, check_mode); } try await (async group.wait() catch unreachable); if (fmt.any_error) { process.exit(1); } } async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void { const file_path = try std.mem.dupe(fmt.loop.allocator, u8, file_path_ref); defer fmt.loop.allocator.free(file_path); { const held = await (async fmt.seen.acquire() catch unreachable); defer held.release(); if (try held.value.put(file_path, {})) |_| return; } const source_code = (await try async event.fs.readFile( fmt.loop, file_path, max_src_size, )) catch |err| switch (err) { error.IsDir, error.AccessDenied => { // TODO make event based (and dir.next()) var dir = try fs.Dir.open(fmt.loop.allocator, file_path); defer dir.close(); var group = event.Group(FmtError!void).init(fmt.loop); while (try dir.next()) |entry| { if (entry.kind == fs.Dir.Entry.Kind.Directory or mem.endsWith(u8, entry.name, ".zig")) { const full_path = try fs.path.join(fmt.loop.allocator, [_][]const u8{ file_path, entry.name }); try group.call(fmtPath, fmt, full_path, check_mode); } } return await (async group.wait() catch unreachable); }, else => { // TODO lock stderr printing try stderr.print("unable to open '{}': {}\n", file_path, err); fmt.any_error = true; return; }, }; defer fmt.loop.allocator.free(source_code); const tree = std.zig.parse(fmt.loop.allocator, source_code) catch |err| { try stderr.print("error parsing file '{}': {}\n", file_path, err); fmt.any_error = true; return; }; defer tree.deinit(); var error_it = tree.errors.iterator(0); while (error_it.next()) |parse_error| { const msg = try errmsg.Msg.createFromParseError(fmt.loop.allocator, parse_error, tree, file_path); defer fmt.loop.allocator.destroy(msg); try msg.printToFile(stderr_file, fmt.color); } if (tree.errors.len != 0) { fmt.any_error = true; return; } if (check_mode) { const anything_changed = try std.zig.render(fmt.loop.allocator, io.null_out_stream, tree); if (anything_changed) { try stderr.print("{}\n", file_path); fmt.any_error = true; } } else { // TODO make this evented const baf = try io.BufferedAtomicFile.create(fmt.loop.allocator, file_path); defer baf.destroy(); const anything_changed = try std.zig.render(fmt.loop.allocator, baf.stream(), tree); if (anything_changed) { try stderr.print("{}\n", file_path); try baf.finish(); } } } // cmd:targets ///////////////////////////////////////////////////////////////////////////////////// fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void { try stdout.write("Architectures:\n"); { comptime var i: usize = 0; inline while (i < @memberCount(builtin.Arch)) : (i += 1) { comptime const arch_tag = @memberName(builtin.Arch, i); // NOTE: Cannot use empty string, see #918. comptime const native_str = if (comptime mem.eql(u8, arch_tag, @tagName(builtin.arch))) " (native)\n" else "\n"; try stdout.print(" {}{}", arch_tag, native_str); } } try stdout.write("\n"); try stdout.write("Operating Systems:\n"); { comptime var i: usize = 0; inline while (i < @memberCount(builtin.Os)) : (i += 1) { comptime const os_tag = @memberName(builtin.Os, i); // NOTE: Cannot use empty string, see #918. comptime const native_str = if (comptime mem.eql(u8, os_tag, @tagName(builtin.os))) " (native)\n" else "\n"; try stdout.print(" {}{}", os_tag, native_str); } } try stdout.write("\n"); try stdout.write("C ABIs:\n"); { comptime var i: usize = 0; inline while (i < @memberCount(builtin.Abi)) : (i += 1) { comptime const abi_tag = @memberName(builtin.Abi, i); // NOTE: Cannot use empty string, see #918. comptime const native_str = if (comptime mem.eql(u8, abi_tag, @tagName(builtin.abi))) " (native)\n" else "\n"; try stdout.print(" {}{}", abi_tag, native_str); } } } fn cmdVersion(allocator: *Allocator, args: []const []const u8) !void { try stdout.print("{}\n", std.mem.toSliceConst(u8, c.ZIG_VERSION_STRING)); } const args_test_spec = [_]Flag{Flag.Bool("--help")}; fn cmdHelp(allocator: *Allocator, args: []const []const u8) !void { try stdout.write(usage); } pub const info_zen = \\ \\ * Communicate intent precisely. \\ * Edge cases matter. \\ * Favor reading code over writing code. \\ * Only one obvious way to do things. \\ * Runtime crashes are better than bugs. \\ * Compile errors are better than runtime crashes. \\ * Incremental improvements. \\ * Avoid local maximums. \\ * Reduce the amount one must remember. \\ * Minimize energy spent on coding style. \\ * Together we serve end users. \\ \\ ; fn cmdZen(allocator: *Allocator, args: []const []const u8) !void { try stdout.write(info_zen); } const usage_internal = \\usage: zig internal [subcommand] \\ \\Sub-Commands: \\ build-info Print static compiler build-info \\ \\ ; fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void { if (args.len == 0) { try stderr.write(usage_internal); process.exit(1); } const sub_commands = [_]Command{Command{ .name = "build-info", .exec = cmdInternalBuildInfo, }}; for (sub_commands) |sub_command| { if (mem.eql(u8, sub_command.name, args[0])) { try sub_command.exec(allocator, args[1..]); return; } } try stderr.print("unknown sub command: {}\n\n", args[0]); try stderr.write(usage_internal); } fn cmdInternalBuildInfo(allocator: *Allocator, args: []const []const u8) !void { try stdout.print( \\ZIG_CMAKE_BINARY_DIR {} \\ZIG_CXX_COMPILER {} \\ZIG_LLVM_CONFIG_EXE {} \\ZIG_LLD_INCLUDE_PATH {} \\ZIG_LLD_LIBRARIES {} \\ZIG_STD_FILES {} \\ZIG_C_HEADER_FILES {} \\ZIG_DIA_GUIDS_LIB {} \\ , std.mem.toSliceConst(u8, c.ZIG_CMAKE_BINARY_DIR), std.mem.toSliceConst(u8, c.ZIG_CXX_COMPILER), std.mem.toSliceConst(u8, c.ZIG_LLVM_CONFIG_EXE), std.mem.toSliceConst(u8, c.ZIG_LLD_INCLUDE_PATH), std.mem.toSliceConst(u8, c.ZIG_LLD_LIBRARIES), std.mem.toSliceConst(u8, c.ZIG_STD_FILES), std.mem.toSliceConst(u8, c.ZIG_C_HEADER_FILES), std.mem.toSliceConst(u8, c.ZIG_DIA_GUIDS_LIB), ); } const CliPkg = struct { name: []const u8, path: []const u8, children: ArrayList(*CliPkg), parent: ?*CliPkg, pub fn init(allocator: *mem.Allocator, name: []const u8, path: []const u8, parent: ?*CliPkg) !*CliPkg { var pkg = try allocator.create(CliPkg); pkg.* = CliPkg{ .name = name, .path = path, .children = ArrayList(*CliPkg).init(allocator), .parent = parent, }; return pkg; } pub fn deinit(self: *CliPkg) void { for (self.children.toSliceConst()) |child| { child.deinit(); } self.children.deinit(); } };
src-self-hosted/main.zig
const builtin = @import("builtin"); const std = @import("std"); const expect = std.testing.expect; const expectError = std.testing.expectError; const expectEqual = std.testing.expectEqual; test "switch with numbers" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO try testSwitchWithNumbers(13); } fn testSwitchWithNumbers(x: u32) !void { const result = switch (x) { 1, 2, 3, 4...8 => false, 13 => true, else => false, }; try expect(result); } test "switch with all ranges" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO try expect(testSwitchWithAllRanges(50, 3) == 1); try expect(testSwitchWithAllRanges(101, 0) == 2); try expect(testSwitchWithAllRanges(300, 5) == 3); try expect(testSwitchWithAllRanges(301, 6) == 6); } fn testSwitchWithAllRanges(x: u32, y: u32) u32 { return switch (x) { 0...100 => 1, 101...200 => 2, 201...300 => 3, else => y, }; } test "implicit comptime switch" { const x = 3 + 4; const result = switch (x) { 3 => 10, 4 => 11, 5, 6 => 12, 7, 8 => 13, else => 14, }; comptime { try expect(result + 1 == 14); } } test "switch on enum" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const fruit = Fruit.Orange; nonConstSwitchOnEnum(fruit); } const Fruit = enum { Apple, Orange, Banana, }; fn nonConstSwitchOnEnum(fruit: Fruit) void { switch (fruit) { Fruit.Apple => unreachable, Fruit.Orange => {}, Fruit.Banana => unreachable, } } test "switch statement" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO try nonConstSwitch(SwitchStatementFoo.C); } fn nonConstSwitch(foo: SwitchStatementFoo) !void { const val = switch (foo) { SwitchStatementFoo.A => @as(i32, 1), SwitchStatementFoo.B => 2, SwitchStatementFoo.C => 3, SwitchStatementFoo.D => 4, }; try expect(val == 3); } const SwitchStatementFoo = enum { A, B, C, D }; test "switch with multiple expressions" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const x = switch (returnsFive()) { 1, 2, 3 => 1, 4, 5, 6 => 2, else => @as(i32, 3), }; try expect(x == 2); } fn returnsFive() i32 { return 5; } test "switch on type" { if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO try expect(trueIfBoolFalseOtherwise(bool)); try expect(!trueIfBoolFalseOtherwise(i32)); } fn trueIfBoolFalseOtherwise(comptime T: type) bool { return switch (T) { bool => true, else => false, }; } test "switching on booleans" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO try testSwitchOnBools(); comptime try testSwitchOnBools(); } fn testSwitchOnBools() !void { try expect(testSwitchOnBoolsTrueAndFalse(true) == false); try expect(testSwitchOnBoolsTrueAndFalse(false) == true); try expect(testSwitchOnBoolsTrueWithElse(true) == false); try expect(testSwitchOnBoolsTrueWithElse(false) == true); try expect(testSwitchOnBoolsFalseWithElse(true) == false); try expect(testSwitchOnBoolsFalseWithElse(false) == true); } fn testSwitchOnBoolsTrueAndFalse(x: bool) bool { return switch (x) { true => false, false => true, }; } fn testSwitchOnBoolsTrueWithElse(x: bool) bool { return switch (x) { true => false, else => true, }; } fn testSwitchOnBoolsFalseWithElse(x: bool) bool { return switch (x) { false => true, else => false, }; } test "u0" { var val: u0 = 0; switch (val) { 0 => try expect(val == 0), } } test "undefined.u0" { var val: u0 = undefined; switch (val) { 0 => try expect(val == 0), } } test "switch with disjoint range" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO var q: u8 = 0; switch (q) { 0...125 => {}, 127...255 => {}, 126...126 => {}, } } test "switch variable for range and multiple prongs" { const S = struct { fn doTheTest() !void { var u: u8 = 16; try doTheSwitch(u); comptime try doTheSwitch(u); var v: u8 = 42; try doTheSwitch(v); comptime try doTheSwitch(v); } fn doTheSwitch(q: u8) !void { switch (q) { 0...40 => |x| try expect(x == 16), 41, 42, 43 => |x| try expect(x == 42), else => try expect(false), } } }; _ = S; } var state: u32 = 0; fn poll() void { switch (state) { 0 => { state = 1; }, else => { state += 1; }, } } test "switch on global mutable var isn't constant-folded" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO while (state < 2) { poll(); } } const SwitchProngWithVarEnum = union(enum) { One: i32, Two: f32, Meh: void, }; test "switch prong with variable" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO try switchProngWithVarFn(SwitchProngWithVarEnum{ .One = 13 }); try switchProngWithVarFn(SwitchProngWithVarEnum{ .Two = 13.0 }); try switchProngWithVarFn(SwitchProngWithVarEnum{ .Meh = {} }); } fn switchProngWithVarFn(a: SwitchProngWithVarEnum) !void { switch (a) { SwitchProngWithVarEnum.One => |x| { try expect(x == 13); }, SwitchProngWithVarEnum.Two => |x| { try expect(x == 13.0); }, SwitchProngWithVarEnum.Meh => |x| { const v: void = x; _ = v; }, } } test "switch on enum using pointer capture" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO try testSwitchEnumPtrCapture(); comptime try testSwitchEnumPtrCapture(); } fn testSwitchEnumPtrCapture() !void { var value = SwitchProngWithVarEnum{ .One = 1234 }; switch (value) { SwitchProngWithVarEnum.One => |*x| x.* += 1, else => unreachable, } switch (value) { SwitchProngWithVarEnum.One => |x| try expect(x == 1235), else => unreachable, } } test "switch handles all cases of number" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO try testSwitchHandleAllCases(); comptime try testSwitchHandleAllCases(); } fn testSwitchHandleAllCases() !void { try expect(testSwitchHandleAllCasesExhaustive(0) == 3); try expect(testSwitchHandleAllCasesExhaustive(1) == 2); try expect(testSwitchHandleAllCasesExhaustive(2) == 1); try expect(testSwitchHandleAllCasesExhaustive(3) == 0); try expect(testSwitchHandleAllCasesRange(100) == 0); try expect(testSwitchHandleAllCasesRange(200) == 1); try expect(testSwitchHandleAllCasesRange(201) == 2); try expect(testSwitchHandleAllCasesRange(202) == 4); try expect(testSwitchHandleAllCasesRange(230) == 3); } fn testSwitchHandleAllCasesExhaustive(x: u2) u2 { return switch (x) { 0 => @as(u2, 3), 1 => 2, 2 => 1, 3 => 0, }; } fn testSwitchHandleAllCasesRange(x: u8) u8 { return switch (x) { 0...100 => @as(u8, 0), 101...200 => 1, 201, 203 => 2, 202 => 4, 204...255 => 3, }; } test "switch on union with some prongs capturing" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const X = union(enum) { a, b: i32, }; var x: X = X{ .b = 10 }; var y: i32 = switch (x) { .a => unreachable, .b => |b| b + 1, }; try expect(y == 11); } const Number = union(enum) { One: u64, Two: u8, Three: f32, }; const number = Number{ .Three = 1.23 }; fn returnsFalse() bool { switch (number) { Number.One => |x| return x > 1234, Number.Two => |x| return x == 'a', Number.Three => |x| return x > 12.34, } } test "switch on const enum with var" { try expect(!returnsFalse()); } test "anon enum literal used in switch on union enum" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const Foo = union(enum) { a: i32, }; var foo = Foo{ .a = 1234 }; switch (foo) { .a => |x| { try expect(x == 1234); }, } } test "switch all prongs unreachable" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO try testAllProngsUnreachable(); comptime try testAllProngsUnreachable(); } fn testAllProngsUnreachable() !void { try expect(switchWithUnreachable(1) == 2); try expect(switchWithUnreachable(2) == 10); } fn switchWithUnreachable(x: i32) i32 { while (true) { switch (x) { 1 => return 2, 2 => break, else => continue, } } return 10; } test "capture value of switch with all unreachable prongs" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const x = return_a_number() catch |err| switch (err) { else => unreachable, }; try expect(x == 1); } fn return_a_number() anyerror!i32 { return 1; } test "switch on integer with else capturing expr" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { var x: i32 = 5; switch (x + 10) { 14 => @panic("fail"), 16 => @panic("fail"), else => |e| try expect(e == 15), } } }; try S.doTheTest(); comptime try S.doTheTest(); } test "else prong of switch on error set excludes other cases" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { try expectError(error.C, bar()); } const E = error{ A, B, } || E2; const E2 = error{ C, D, }; fn foo() E!void { return error.C; } fn bar() E2!void { foo() catch |err| switch (err) { error.A, error.B => {}, else => |e| return e, }; } }; try S.doTheTest(); comptime try S.doTheTest(); } test "switch prongs with error set cases make a new error set type for capture value" { if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { try expectError(error.B, bar()); } const E = E1 || E2; const E1 = error{ A, B, }; const E2 = error{ C, D, }; fn foo() E!void { return error.B; } fn bar() E1!void { foo() catch |err| switch (err) { error.A, error.B => |e| return e, else => {}, }; } }; try S.doTheTest(); comptime try S.doTheTest(); } test "return result loc and then switch with range implicit casted to error union" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { try expect((func(0xb) catch unreachable) == 0xb); } fn func(d: u8) anyerror!u8 { return switch (d) { 0xa...0xf => d, else => unreachable, }; } }; try S.doTheTest(); comptime try S.doTheTest(); } test "switch with null and T peer types and inferred result location type" { if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const S = struct { fn doTheTest(c: u8) !void { if (switch (c) { 0 => true, else => null, }) |v| { _ = v; @panic("fail"); } } }; try S.doTheTest(1); comptime try S.doTheTest(1); } test "switch prongs with cases with identical payload types" { if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO const Union = union(enum) { A: usize, B: isize, C: usize, }; const S = struct { fn doTheTest() !void { try doTheSwitch1(Union{ .A = 8 }); try doTheSwitch2(Union{ .B = -8 }); } fn doTheSwitch1(u: Union) !void { switch (u) { .A, .C => |e| { try expect(@TypeOf(e) == usize); try expect(e == 8); }, .B => |e| { _ = e; @panic("fail"); }, } } fn doTheSwitch2(u: Union) !void { switch (u) { .A, .C => |e| { _ = e; @panic("fail"); }, .B => |e| { try expect(@TypeOf(e) == isize); try expect(e == -8); }, } } }; try S.doTheTest(); comptime try S.doTheTest(); } test "switch on pointer type" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO const S = struct { const X = struct { field: u32, }; const P1 = @intToPtr(*X, 0x400); const P2 = @intToPtr(*X, 0x800); const P3 = @intToPtr(*X, 0xC00); fn doTheTest(arg: *X) i32 { switch (arg) { P1 => return 1, P2 => return 2, else => return 3, } } }; try expect(1 == S.doTheTest(S.P1)); try expect(2 == S.doTheTest(S.P2)); try expect(3 == S.doTheTest(S.P3)); comptime try expect(1 == S.doTheTest(S.P1)); comptime try expect(2 == S.doTheTest(S.P2)); comptime try expect(3 == S.doTheTest(S.P3)); } test "switch on error set with single else" { const S = struct { fn doTheTest() !void { var some: error{Foo} = error.Foo; try expect(switch (some) { else => blk: { break :blk true; }, }); } }; try S.doTheTest(); comptime try S.doTheTest(); } test "switch capture copies its payload" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { var tmp: union(enum) { A: u8, B: u32, } = .{ .A = 42 }; switch (tmp) { .A => |value| { // Modify the original union tmp = .{ .B = 0x10101010 }; try expectEqual(@as(u8, 42), value); }, else => unreachable, } } }; try S.doTheTest(); comptime try S.doTheTest(); }
test/behavior/switch.zig
const std = @import("std"); const os = std.os; const io = std.io; const mem = std.mem; const Buffer = std.Buffer; const llvm = @import("llvm.zig"); const c = @import("c.zig"); const builtin = @import("builtin"); const Target = @import("target.zig").Target; const warn = std.debug.warn; const Token = std.zig.Token; const ArrayList = std.ArrayList; const errmsg = @import("errmsg.zig"); const ast = std.zig.ast; const event = std.event; pub const Module = struct { loop: *event.Loop, name: Buffer, root_src_path: ?[]const u8, module: llvm.ModuleRef, context: llvm.ContextRef, builder: llvm.BuilderRef, target: Target, build_mode: builtin.Mode, zig_lib_dir: []const u8, version_major: u32, version_minor: u32, version_patch: u32, linker_script: ?[]const u8, cache_dir: []const u8, libc_lib_dir: ?[]const u8, libc_static_lib_dir: ?[]const u8, libc_include_dir: ?[]const u8, msvc_lib_dir: ?[]const u8, kernel32_lib_dir: ?[]const u8, dynamic_linker: ?[]const u8, out_h_path: ?[]const u8, is_test: bool, each_lib_rpath: bool, strip: bool, is_static: bool, linker_rdynamic: bool, clang_argv: []const []const u8, llvm_argv: []const []const u8, lib_dirs: []const []const u8, rpath_list: []const []const u8, assembly_files: []const []const u8, link_objects: []const []const u8, windows_subsystem_windows: bool, windows_subsystem_console: bool, link_libs_list: ArrayList(*LinkLib), libc_link_lib: ?*LinkLib, err_color: errmsg.Color, verbose_tokenize: bool, verbose_ast_tree: bool, verbose_ast_fmt: bool, verbose_cimport: bool, verbose_ir: bool, verbose_llvm_ir: bool, verbose_link: bool, darwin_frameworks: []const []const u8, darwin_version_min: DarwinVersionMin, test_filters: []const []const u8, test_name_prefix: ?[]const u8, emit_file_type: Emit, kind: Kind, link_out_file: ?[]const u8, events: *event.Channel(Event), // TODO handle some of these earlier and report them in a way other than error codes pub const BuildError = error{ OutOfMemory, EndOfStream, BadFd, Io, IsDir, Unexpected, SystemResources, SharingViolation, PathAlreadyExists, FileNotFound, AccessDenied, PipeBusy, FileTooBig, SymLinkLoop, ProcessFdQuotaExceeded, NameTooLong, SystemFdQuotaExceeded, NoDevice, PathNotFound, NoSpaceLeft, NotDir, FileSystem, OperationAborted, IoPending, BrokenPipe, WouldBlock, FileClosed, DestinationAddressRequired, DiskQuota, InputOutput, NoStdHandles, Overflow, NotSupported, }; pub const Event = union(enum) { Ok, Fail: []errmsg.Msg, Error: BuildError, }; pub const DarwinVersionMin = union(enum) { None, MacOS: []const u8, Ios: []const u8, }; pub const Kind = enum { Exe, Lib, Obj, }; pub const LinkLib = struct { name: []const u8, path: ?[]const u8, /// the list of symbols we depend on from this lib symbols: ArrayList([]u8), provided_explicitly: bool, }; pub const Emit = enum { Binary, Assembly, LlvmIr, }; pub fn create( loop: *event.Loop, name: []const u8, root_src_path: ?[]const u8, target: *const Target, kind: Kind, build_mode: builtin.Mode, zig_lib_dir: []const u8, cache_dir: []const u8, ) !*Module { var name_buffer = try Buffer.init(loop.allocator, name); errdefer name_buffer.deinit(); const context = c.LLVMContextCreate() orelse return error.OutOfMemory; errdefer c.LLVMContextDispose(context); const module = c.LLVMModuleCreateWithNameInContext(name_buffer.ptr(), context) orelse return error.OutOfMemory; errdefer c.LLVMDisposeModule(module); const builder = c.LLVMCreateBuilderInContext(context) orelse return error.OutOfMemory; errdefer c.LLVMDisposeBuilder(builder); const events = try event.Channel(Event).create(loop, 0); errdefer events.destroy(); return loop.allocator.create(Module{ .loop = loop, .events = events, .name = name_buffer, .root_src_path = root_src_path, .module = module, .context = context, .builder = builder, .target = target.*, .kind = kind, .build_mode = build_mode, .zig_lib_dir = zig_lib_dir, .cache_dir = cache_dir, .version_major = 0, .version_minor = 0, .version_patch = 0, .verbose_tokenize = false, .verbose_ast_tree = false, .verbose_ast_fmt = false, .verbose_cimport = false, .verbose_ir = false, .verbose_llvm_ir = false, .verbose_link = false, .linker_script = null, .libc_lib_dir = null, .libc_static_lib_dir = null, .libc_include_dir = null, .msvc_lib_dir = null, .kernel32_lib_dir = null, .dynamic_linker = null, .out_h_path = null, .is_test = false, .each_lib_rpath = false, .strip = false, .is_static = false, .linker_rdynamic = false, .clang_argv = [][]const u8{}, .llvm_argv = [][]const u8{}, .lib_dirs = [][]const u8{}, .rpath_list = [][]const u8{}, .assembly_files = [][]const u8{}, .link_objects = [][]const u8{}, .windows_subsystem_windows = false, .windows_subsystem_console = false, .link_libs_list = ArrayList(*LinkLib).init(loop.allocator), .libc_link_lib = null, .err_color = errmsg.Color.Auto, .darwin_frameworks = [][]const u8{}, .darwin_version_min = DarwinVersionMin.None, .test_filters = [][]const u8{}, .test_name_prefix = null, .emit_file_type = Emit.Binary, .link_out_file = null, }); } fn dump(self: *Module) void { c.LLVMDumpModule(self.module); } pub fn destroy(self: *Module) void { self.events.destroy(); c.LLVMDisposeBuilder(self.builder); c.LLVMDisposeModule(self.module); c.LLVMContextDispose(self.context); self.name.deinit(); self.a().destroy(self); } pub fn build(self: *Module) !void { if (self.llvm_argv.len != 0) { var c_compatible_args = try std.cstr.NullTerminated2DArray.fromSlices(self.a(), [][]const []const u8{ [][]const u8{"zig (LLVM option parsing)"}, self.llvm_argv, }); defer c_compatible_args.deinit(); // TODO this sets global state c.ZigLLVMParseCommandLineOptions(self.llvm_argv.len + 1, c_compatible_args.ptr); } _ = try async<self.a()> self.buildAsync(); } async fn buildAsync(self: *Module) void { while (true) { // TODO directly awaiting async should guarantee memory allocation elision // TODO also async before suspending should guarantee memory allocation elision (await (async self.addRootSrc() catch unreachable)) catch |err| { await (async self.events.put(Event{ .Error = err }) catch unreachable); return; }; await (async self.events.put(Event.Ok) catch unreachable); } } async fn addRootSrc(self: *Module) !void { const root_src_path = self.root_src_path orelse @panic("TODO handle null root src path"); const root_src_real_path = os.path.real(self.a(), root_src_path) catch |err| { try printError("unable to get real path '{}': {}", root_src_path, err); return err; }; errdefer self.a().free(root_src_real_path); const source_code = io.readFileAlloc(self.a(), root_src_real_path) catch |err| { try printError("unable to open '{}': {}", root_src_real_path, err); return err; }; errdefer self.a().free(source_code); var tree = try std.zig.parse(self.a(), source_code); defer tree.deinit(); //var it = tree.root_node.decls.iterator(); //while (it.next()) |decl_ptr| { // const decl = decl_ptr.*; // switch (decl.id) { // ast.Node.Comptime => @panic("TODO"), // ast.Node.VarDecl => @panic("TODO"), // ast.Node.UseDecl => @panic("TODO"), // ast.Node.FnDef => @panic("TODO"), // ast.Node.TestDecl => @panic("TODO"), // else => unreachable, // } //} } pub fn link(self: *Module, out_file: ?[]const u8) !void { warn("TODO link"); return error.Todo; } pub fn addLinkLib(self: *Module, name: []const u8, provided_explicitly: bool) !*LinkLib { const is_libc = mem.eql(u8, name, "c"); if (is_libc) { if (self.libc_link_lib) |libc_link_lib| { return libc_link_lib; } } for (self.link_libs_list.toSliceConst()) |existing_lib| { if (mem.eql(u8, name, existing_lib.name)) { return existing_lib; } } const link_lib = try self.a().create(LinkLib{ .name = name, .path = null, .provided_explicitly = provided_explicitly, .symbols = ArrayList([]u8).init(self.a()), }); try self.link_libs_list.append(link_lib); if (is_libc) { self.libc_link_lib = link_lib; } return link_lib; } fn a(self: Module) *mem.Allocator { return self.loop.allocator; } }; fn printError(comptime format: []const u8, args: ...) !void { var stderr_file = try std.io.getStdErr(); var stderr_file_out_stream = std.io.FileOutStream.init(&stderr_file); const out_stream = &stderr_file_out_stream.stream; try out_stream.print(format, args); }
src-self-hosted/module.zig
const std = @import("std"); const u64_max = std.math.maxInt(u64); pub const Tag = extern struct { identifier: u64, next: u64, }; pub const StructTagID = enum(u64) { command_line = 0xe5e76a1b4597a781, fb_mtrr = 0x6bc1a78ebe871172, memory_map = 0x2187f79e8612de07, framebuffer = 0x506461d2950408fa, boot_volume = 0x9b4358364c19ee62, pmrs = 0x5df266a64047b6bd, text_mode = 0x38d74c23e0dca893, hhdm = 0xb0ed257db18cb58f, dtb = 0xabb29bd49a2833fa, mmio32uart = 0xb813f9b8dbc78797, pxe = 0x29d1e96239247032, smp = 0x34d1d96339647025, smbios = 0x274bd246c62bf7d1, kernel_base_address = 0x060d78874a2a8af0, kernel_slide = 0xee80847d01506c57, kernel_file = 0xe599d90c2975584a, kernel_filev2 = 0x37c13018a02c6ea2, efi_system_table = 0x4bc5ec15845b558e, firmware = 0x359d837855e3858c, epoch = 0x566a7bed888e1407, rsdp = 0x9e1786930a375e78, modules = 0x4b6fe466aade04ce, terminal = 0xc2b3f4c3233b0974, edid = 0x968609d7af96b845, }; pub const Header = extern struct { entry_point: u64, stack: u64, flags: u64, tags: u64, pub const framebuffer_id = 0x3ecc1bc43d0f7971; pub const fb_mtrr_id = 0x4c7bb07731282e00; pub const terminal_id = 0xa85d499b1823be72; pub const smp_id = 0x1ab015085f3273df; pub const @"5lv_paging_id" = 0x932f477032007e8f; pub const unmap_null_id = 0x92919432b16fe7e7; pub const any_video_id = 0xc75c9fa92a44c4db; pub const hhdmslide_id = 0xdc29269c2af53d1d; pub const Framebuffer = extern struct { tag: Tag, framebuffer_width: u16, framebuffer_height: u16, framebuffer_bpp: u16, _unused: u16, }; pub const Terminal = extern struct { tag: Tag, flags: u64, callback: u64, pub const dec = 10; pub const bell = 10; pub const private_id = 30; pub const status_report = 40; pub const position_report = 50; pub const keyboard_leds = 60; pub const mode = 70; pub const linux = 80; pub const context_size: u64 = u64_max; pub const context_save: u64 = u64_max - 1; pub const context_restore: u64 = u64_max - 2; pub const full_refresh: u64 = u64_max - 3; }; pub const SMP = extern struct { tag: Tag, flags: u64, }; pub const AnyVideo = extern struct { tag: Tag, preference: u64, }; pub const HHDMSlide = extern struct { tag: Tag, flags: u64, alignment: u64, }; }; pub const Struct = extern struct { bootloader_brand: [64]u8, bootloader_version: [64]u8, tags: u64, pub const fb_mtrr_id = 0x6bc1a78ebe871172; pub const CommandLine = extern struct { tag: Tag, cmdline: u64, pub const id = 0xe5e76a1b4597a781; }; pub const MemoryMap = extern struct { tag: Tag align(1), entry_count: u64, pub fn memmap(self: anytype) @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), Entry) { const Intermediate = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), u8); const ReturnType = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), Entry); return @ptrCast(ReturnType, @alignCast(@alignOf(Entry), @ptrCast(Intermediate, self) + 24)); } pub const Entry = extern struct { address: u64, size: u64, type: Type, unused: u32, pub const Type = enum(u32) { usable = 1, reserved = 2, acpi_reclaimable = 3, acpi_nvs = 4, bad_memory = 5, bootloader_reclaimable = 0x1000, kernel_and_modules = 0x1001, framebuffer = 0x1002, }; }; pub const id = 0x2187f79e8612de07; }; pub const Framebuffer = extern struct { tag: Tag, framebuffer_addr: u64, framebuffer_width: u16, framebuffer_height: u16, framebuffer_pitch: u16, framebuffer_bpp: u16, memory_model: u8, red_mask_size: u8, red_mask_shift: u8, green_mask_size: u8, green_mask_shift: u8, blue_mask_size: u8, blue_mask_shift: u8, _unused: u8, pub const memory_model_rgb = 1; pub const id = 0x506461d2950408fa; }; pub const EDID = extern struct { tag: Tag align(1), edid_size: u64, pub fn edid_information(self: anytype) @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), u8) { const Intermediate = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), u8); const ReturnType = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), u8); return @ptrCast(ReturnType, @alignCast(@alignOf(u8), @ptrCast(Intermediate, self) + 24)); } pub const id = 0x968609d7af96b845; }; pub const Terminal = extern struct { tag: Tag, flags: u32, cols: u16, rows: u16, term_write: u64, max_length: u64, pub const id = 0xc2b3f4c3233b0974; }; pub const Modules = extern struct { tag: Tag align(1), module_count: u64, pub fn modules(self: anytype) @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), Module) { const Intermediate = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), u8); const ReturnType = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), Module); return @ptrCast(ReturnType, @alignCast(@alignOf(Module), @ptrCast(Intermediate, self) + 24)); } pub const Module = extern struct { begin: u64, end: u64, string: [128]u8, }; pub const id = 0x4b6fe466aade04ce; }; pub const RSDP = extern struct { tag: Tag, rsdp: u64, pub const id = 0x9e1786930a375e78; }; pub const Epoch = extern struct { tag: Tag, epoch: u64, pub const id = 0x566a7bed888e1407; }; pub const Firmware = extern struct { tag: Tag, flags: u64, pub const bios = 1 << 0; pub const id = 0x359d837855e3858c; }; pub const EFISystemTable = extern struct { tag: Tag, system_table: u64, pub const id = 0x4bc5ec15845b558e; }; pub const KernelFile = extern struct { tag: Tag, kernel_file: u64, pub const id = 0xe599d90c2975584a; }; pub const KernelFileV2 = extern struct { tag: Tag, kernel_file: u64, kernel_size: u64, pub const id = 0x37c13018a02c6ea2; }; pub const KernelSlide = extern struct { tag: Tag, kernel_slide: u64, pub const id = 0xee80847d01506c57; }; pub const KernelBaseAddress = extern struct { tag: Tag, physical_base_address: u64, virtual_base_address: u64, const id = 0x060d78874a2a8af0; }; pub const SMBios = extern struct { tag: Tag, flags: u64, smbios_entry_32: u64, smbios_entry_64: u64, pub const id = 0x274bd246c62bf7d1; }; pub const SMP = extern struct { tag: Tag align(1), flags: u64, bsp_lapic_id: u32, unused: u32, cpu_count: u64, pub fn smp_info(self: anytype) @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), Info) { const Intermediate = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), u8); const ReturnType = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), Info); return @ptrCast(ReturnType, @alignCast(@alignOf(Info), @ptrCast(Intermediate, self) + 40)); } pub const Info = extern struct { processor_id: u32, lapic_id: u32, target_stack: u64, goto_address: u64, extra_argument: u64, }; pub const id = 0x34d1d96339647025; }; pub const PXEServerInfo = extern struct { tag: Tag, server_ip: u32, pub const id = 0x29d1e96239247032; }; pub const MMIO32UART = extern struct { tag: Tag, addr: u64, pub const id = 0xb813f9b8dbc78797; }; pub const DTB = extern struct { tag: Tag, addr: u64, size: u64, pub const id = 0xabb29bd49a2833fa; }; pub const HHDM = extern struct { tag: Tag, addr: u64, pub const id = 0xb0ed257db18cb58f; }; pub const TextMode = extern struct { tag: Tag, address: u64, unused: u16, rows: u16, columns: u16, bytes_per_char: u16, const id = 0x38d74c23e0dca893; }; pub const PMRs = extern struct { tag: Tag, entry_count: u64, pub fn pmrs(self: anytype) @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), PMR) { const Intermediate = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), u8); const ReturnType = @import("std").zig.c_translation.FlexibleArrayType(@TypeOf(self), PMR); return @ptrCast(ReturnType, @alignCast(@alignOf(PMR), @ptrCast(Intermediate, self) + 24)); } pub const PMR = extern struct { address: u64, size: u64, permissions: u64, pub const executable = 1 << 0; pub const writable = 1 << 1; pub const readable = 1 << 2; }; pub const id = 0x5df266a64047b6bd; }; pub const BootVolume = extern struct { tag: Tag, flags: u64, guid: GUID, partition_guid: GUID, pub const id = 0x9b4358364c19ee62; }; }; pub const GUID = extern struct { a: u32, b: u16, c: u16, d: [8]u8, }; pub const Anchor = extern struct { anchor: [15]u8, bits: u8, physical_load_address: u64, physical_bss_start: u64, physical_bss_end: u64, physical_stivale2_header: u64, }; pub const bootloader_brand_size = 64; pub const bootloader_version_size = 64;
src/kernel/arch/x86_64/limine/stivale2/header.zig
const tests = @import("tests.zig"); pub fn addCases(cases: *tests.GenHContext) void { cases.add("declare enum", \\const Foo = extern enum.{ A, B, C }; \\export fn entry(foo: Foo) void { } , \\enum Foo { \\ A = 0, \\ B = 1, \\ C = 2 \\}; \\ \\TEST_EXPORT void entry(enum Foo foo); \\ ); cases.add("declare struct", \\const Foo = extern struct.{ \\ A: i32, \\ B: f32, \\ C: bool, \\ D: u64, \\ E: u64, \\ F: u64, \\}; \\export fn entry(foo: Foo) void { } , \\struct Foo { \\ int32_t A; \\ float B; \\ bool C; \\ uint64_t D; \\ uint64_t E; \\ uint64_t F; \\}; \\ \\TEST_EXPORT void entry(struct Foo foo); \\ ); cases.add("declare union", \\const Big = extern struct.{ \\ A: u64, \\ B: u64, \\ C: u64, \\ D: u64, \\ E: u64, \\}; \\const Foo = extern union.{ \\ A: i32, \\ B: f32, \\ C: bool, \\ D: Big, \\}; \\export fn entry(foo: Foo) void {} , \\struct Big { \\ uint64_t A; \\ uint64_t B; \\ uint64_t C; \\ uint64_t D; \\ uint64_t E; \\}; \\ \\union Foo { \\ int32_t A; \\ float B; \\ bool C; \\ struct Big D; \\}; \\ \\TEST_EXPORT void entry(union Foo foo); \\ ); cases.add("declare opaque type", \\export const Foo = @OpaqueType(); \\ \\export fn entry(foo: ?*Foo) void { } , \\struct Foo; \\ \\TEST_EXPORT void entry(struct Foo * foo); ); cases.add("array field-type", \\const Foo = extern struct.{ \\ A: [2]i32, \\ B: [4]*u32, \\}; \\export fn entry(foo: Foo, bar: [3]u8) void { } , \\struct Foo { \\ int32_t A[2]; \\ uint32_t * B[4]; \\}; \\ \\TEST_EXPORT void entry(struct Foo foo, uint8_t bar[]); \\ ); cases.add("ptr to zig struct", \\const S = struct.{ \\ a: u8, \\}; \\ \\export fn a(s: *S) u8 { \\ return s.a; \\} , \\struct S; \\TEST_EXPORT uint8_t a(struct S * s); \\ ); cases.add("ptr to zig union", \\const U = union(enum).{ \\ A: u8, \\ B: u16, \\}; \\ \\export fn a(s: *U) u8 { \\ return s.A; \\} , \\union U; \\TEST_EXPORT uint8_t a(union U * s); \\ ); cases.add("ptr to zig enum", \\const E = enum(u8).{ \\ A, \\ B, \\}; \\ \\export fn a(s: *E) u8 { \\ return @enumToInt(s.*); \\} , \\enum E; \\TEST_EXPORT uint8_t a(enum E * s); \\ ); }
test/gen_h.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const testing = std.testing; const Tree = @import("Tree.zig"); const Token = Tree.Token; const TokenIndex = Tree.TokenIndex; const NodeIndex = Tree.NodeIndex; const Type = @import("Type.zig"); const Diagnostics = @import("Diagnostics.zig"); const NodeList = std.ArrayList(NodeIndex); const Parser = @import("Parser.zig"); const InitList = @This(); const Item = struct { list: InitList = .{}, index: u64, node: NodeIndex, tok: TokenIndex, fn order(_: void, a: Item, b: Item) std.math.Order { return std.math.order(a.index, b.index); } }; list: std.ArrayListUnmanaged(Item) = .{}, /// Deinitialize freeing all memory. pub fn deinit(il: *InitList, gpa: *Allocator) void { for (il.list.items) |*item| item.list.deinit(gpa); il.list.deinit(gpa); il.* = undefined; } /// Insert initializer at index, returning previous entry if one exists. pub fn put(il: *InitList, gpa: *Allocator, index: usize, node: NodeIndex, tok: TokenIndex) !?TokenIndex { const items = il.list.items; var left: usize = 0; var right: usize = items.len; while (left < right) { // Avoid overflowing in the midpoint calculation const mid = left + (right - left) / 2; // Compare the key with the midpoint element switch (std.math.order(items[mid].index, index)) { .eq => { // Replace previous entry. const prev = items[mid].tok; items[mid].list.deinit(gpa); items[mid] = .{ .node = node, .tok = tok, .index = index, }; return prev; }, .gt => left = mid + 1, .lt => right = mid, } } // Insert a new value into a sorted position. try il.list.insert(gpa, left, .{ .node = node, .tok = tok, .index = index, }); return null; } /// Find item at index, create new if one does not exist. pub fn find(il: *InitList, gpa: *Allocator, index: usize) !*Item { const items = il.list.items; var left: usize = 0; var right: usize = items.len; while (left < right) { // Avoid overflowing in the midpoint calculation const mid = left + (right - left) / 2; // Compare the key with the midpoint element switch (std.math.order(items[mid].index, index)) { .eq => return &items[mid], .gt => left = mid + 1, .lt => right = mid, } } // Insert a new value into a sorted position. try il.list.insert(gpa, left, .{ .node = .none, .tok = 0, .index = index, }); return &il.list.items[left]; } test "basic usage" { const gpa = testing.allocator; var il: InitList = .{}; defer il.deinit(gpa); { var i: usize = 0; while (i < 5) : (i += 1) { const prev = try il.put(gpa, i, .none, 0); try testing.expect(prev == null); } } { const failing = testing.failing_allocator; var i: usize = 0; while (i < 5) : (i += 1) { _ = try il.find(failing, i); } } { var item = try il.find(gpa, 0); var i: usize = 1; while (i < 5) : (i += 1) { item = try item.list.find(gpa, i); } } { const failing = testing.failing_allocator; var item = try il.find(failing, 0); var i: usize = 1; while (i < 5) : (i += 1) { item = try item.list.find(failing, i); } } }
src/InitList.zig
const std = @import("std"); const assert = std.debug.assert; const mem = std.mem; const ArrayList = std.ArrayList; const testing = std.testing; const stdout = std.io.getStdOut(); const print = stdout.writer().print; const flash = @import("flash.zig"); const Work = struct { src_slot: usize, src_page: usize, dest_slot: usize, dest_page: usize, // The hash we're intending to move. hash: flash.Hash, }; pub const SwapState = struct { const Self = @This(); allocator: mem.Allocator, // Allocated, and owned by us. Pointer shared so we don't have to // worry about moves. counter: *flash.Counter, slots: [2]flash.Flash, work: ArrayList(Work), pub fn init(allocator: mem.Allocator, total_sectors: usize) !SwapState { const counter = try allocator.create(flash.Counter); errdefer allocator.destroy(counter); counter.* = flash.Counter.init(std.math.maxInt(usize)); var primary = try flash.Flash.init(allocator, total_sectors, counter); var secondary = try flash.Flash.init(allocator, total_sectors, counter); var work = ArrayList(Work).init(allocator); return SwapState{ .allocator = allocator, .counter = counter, .slots = [2]flash.Flash{ primary, secondary }, .work = work, }; } pub fn deinit(self: *Self) void { self.slots[0].deinit(); self.slots[1].deinit(); self.allocator.destroy(self.counter); self.work.deinit(); } // Set up the initial flash, and the work indicator. pub fn setup(self: *Self) !void { // We track the contents of flash as we build work, and use // this to skip work that isn't needed. In a real device, // this will be build by hashing the images before starting // the upgrades. var track = try Tracker.init(self.allocator, self.slots[0..]); defer track.deinit(self.allocator); var i: usize = 0; const size = self.slots[0].state.len - 2; while (i < size) : (i += 1) { for (self.slots) |*slot, slt| { try slot.erase(i); const h = hash(slt, i); try slot.write(i, h); track.set(slt, i, h); } } self.work.clearRetainingCapacity(); // Move slot 0 down. i = size; while (i > 0) : (i -= 1) { try track.tryMove(&self.work, Work{ .src_slot = 0, .dest_slot = 0, .src_page = i - 1, .dest_page = i, .hash = hash(0, i - 1), }); } // The following moves will happen to the same region as the // above, so we need a barrier. //try self.work.append(Work{ // .kind = .Barrier, // .slot = 0, // .page = 0, //}); try track.show(); i = 0; while (i < size) : (i += 1) { // TODO: Skip the move if the destination already matches. // Move slot 1 into the empty space now in slot 0. try track.tryMove(&self.work, Work{ .src_slot = 1, .src_page = i, .dest_slot = 0, .dest_page = i, .hash = hash(1, i), }); // Move the shifted slot 0 value into slot 1's final // destination. try track.tryMove(&self.work, Work{ .src_slot = 0, .src_page = i + 1, .dest_slot = 1, .dest_page = i, .hash = hash(0, i), }); } // Finally, we should erase the last page after the shift. // This doesn't have anything to do with a correct shift, // though. //try self.work.append(Work{ // .kind = .Erase, // .slot = 0, // .page = size, //}); } // Show our current state. pub fn show(self: *Self) !void { try print("Swap state:\n", .{}); var i: usize = 0; while (i < self.slots[0].state.len) : (i += 1) { try print("{:3} {} {}\n", .{ i, self.slots[0].state[i], self.slots[1].state[i], }); } if (false) { try print("\n", .{}); for (self.work.items) |item| { try print("{}\n", .{item}); } } } // Run the work. pub fn run(self: *Self) !void { try print("Running {} steps\n", .{self.work.items.len}); for (self.work.items) |item| { try print("run: {}\n", .{item}); const h = try self.slots[item.src_slot].read(item.src_page); assert(h == item.hash); try self.slots[item.dest_slot].erase(item.dest_page); try self.slots[item.dest_slot].write(item.dest_page, h); } } // Perform recovery, looking for where we can do work. pub fn recover(self: *Self) !void { try print("----------\n", .{}); // Scan the work list, stopping at the first entry where the // destination doesn't appear to have been written. var i: usize = 0; while (i < self.work.items.len) : (i += 1) { const item = &self.work.items[i]; const wstate = self.slots[item.dest_slot].readState(item.dest_page); if (!wstate.isWritten(item.hash)) { try print("{} stop {}\n", .{ i, item }); const rstate = self.slots[item.src_slot].readState(item.src_page); if (!rstate.isWritten(item.hash)) { try print("Src is not written\n", .{}); return error.Corruption; } break; } try print("{} {}\n", .{ i, item }); } try print("---Recovery---\n", .{}); // At this point, as long as we are past the first work item, // it is unclear if the previous work item completed. If the // previous item has its source still accessible, back up one, // and redo starting with that previous entry. if (i > 0) { i -= 1; const item = &self.work.items[i]; const rstate = self.slots[item.src_slot].readState(item.src_page); try print("Check prior: {} {}\n", .{ item, rstate }); if (rstate.isWritten(item.hash)) { try print("Backing up\n", .{}); } else { i += 1; } } while (i < self.work.items.len) : (i += 1) { const item = &self.work.items[i]; try print("run: {}\n", .{item}); const h = try self.slots[item.src_slot].read(item.src_page); assert(h == item.hash); try self.slots[item.dest_slot].erase(item.dest_page); try self.slots[item.dest_slot].write(item.dest_page, h); } } // Check that, post recovery, the swap is completed. pub fn check(self: *Self) !void { var i: usize = 0; while (i < self.slots[0].state.len - 2) : (i += 1) { const h0 = try self.slots[0].read(i); if (h0 != hash(1, i)) { return error.TestMismatch; } const h1 = try self.slots[1].read(i); if (h1 != hash(0, i)) { return error.TestMismatch; } assert(h1 == hash(0, i)); } } // Run the entire state through a tested interruption. Returns // 'true' if the test ran to the end without being interrupted. pub fn testAt(self: *Self, stopAt: usize) !bool { try print("stop at: {}\n", .{stopAt}); try self.setup(); self.counter.reset(); try self.counter.setLimit(stopAt); if (self.run()) |_| { // All operations completed, so we are done. return true; } else |err| { if (err != error.Expired) return err; } try self.show(); self.counter.noLimit(); try self.recover(); try self.show(); try self.check(); return false; } }; // Tracker, used for building up the state. const Tracker = struct { const Self = @This(); state: [2][]flash.State, fn init(allocator: mem.Allocator, slots: []flash.Flash) !Tracker { var state = [2][]flash.State{ try allocator.alloc(flash.State, slots[0].state.len), try allocator.alloc(flash.State, slots[1].state.len), }; mem.set(flash.State, state[0], .{ .Unsafe = {} }); mem.set(flash.State, state[1], .{ .Unsafe = {} }); return Tracker{ .state = state, }; } fn deinit(self: *Self, allocator: mem.Allocator) void { allocator.free(self.state[0]); allocator.free(self.state[1]); } fn set(self: *Self, slot: usize, page: usize, h: flash.Hash) void { self.state[slot][page] = .{ .Written = h }; } // Try moving appropriately, creates work if that is appropriate. fn tryMove(self: *Self, work: *ArrayList(Work), w: Work) !void { //try print("tryMove: {}\n {}\n {}\n", .{ // w, // self.state[w.src_slot][w.src_page], // self.state[w.dest_slot][w.dest_page], //}); if (self.state[w.src_slot][w.src_page].sameHash(&self.state[w.dest_slot][w.dest_page])) { //try print("Skipping: {}\n", .{w}); return; } self.state[w.dest_slot][w.dest_page] = self.state[w.src_slot][w.src_page]; // self.state[w.src_slot][w.src_page] = .{ .Unsafe = {} }; try work.append(w); } fn show(self: *const Self) !void { for (self.state[0]) |st0, i| { const st1 = self.state[1][i]; try print(" track: {} {}\n", .{ st0, st1 }); } } }; // Compute a "hash". These are just indicators to make it easier to // tell what is happening. fn hash(slot: usize, sector: usize) flash.Hash { // return @intCast(flash.Hash, slot * 1000 + sector + 1); return @intCast(flash.Hash, slot * 0 + sector + 1); } test "Swap" { var state = try SwapState.init(testing.allocator, 10); defer state.deinit(); _ = try state.testAt(16); //var stopAt: usize = 1; //while (true) : (stopAt += 1) { // if (try state.testAt(stopAt)) // break; //} }
nswap/src/swap.zig
const std = @import("std"); const c = @import("c.zig"); pub const MemoryMode = enum(u2) { duplicate = c.HB_MEMORY_MODE_DUPLICATE, readonly = c.HB_MEMORY_MODE_READONLY, writable = c.HB_MEMORY_MODE_WRITABLE, readonly_may_make_writable = c.HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE, }; pub const Blob = struct { handle: *c.hb_blob_t, pub fn init(data: []u8, mode: MemoryMode) ?Blob { return Blob{ .handle = c.hb_blob_create_or_fail(&data[0], @intCast(c_uint, data.len), @enumToInt(mode), null, null) orelse return null, }; } pub fn initOrEmpty(data: []u8, mode: MemoryMode) Blob { return .{ .handle = c.hb_blob_create(&data[0], @intCast(c_uint, data.len), @enumToInt(mode), null, null).?, }; } pub fn initFromFile(path: [*:0]const u8) ?Blob { return Blob{ .handle = c.hb_blob_create_from_file_or_fail(path) orelse return null, }; } pub fn initFromFileOrEmpty(path: [*:0]const u8) Blob { return .{ .handle = c.hb_blob_create_from_file(path).?, }; } pub fn initEmpty() Blob { return .{ .handle = c.hb_blob_get_empty().? }; } pub fn createSubBlobOrEmpty(self: Blob, offset: u32, len: u32) Blob { return .{ .handle = c.hb_blob_create_sub_blob(self.handle, offset, len).?, }; } pub fn copyWritable(self: Blob) ?Blob { return Blob{ .handle = c.hb_blob_copy_writable_or_fail(self.handle) orelse return null, }; } pub fn deinit(self: Blob) void { c.hb_blob_destroy(self.handle); } pub fn getData(self: Blob, len: ?u32) []const u8 { var l = len; const data = c.hb_blob_get_data(self.handle, if (l) |_| &l.? else null); return if (l) |_| data[0..l.?] else std.mem.sliceTo(data, 0); } pub fn getDataWritable(self: Blob, len: ?u32) ?[]const u8 { var l = len; const data = c.hb_blob_get_data(self.handle, if (l) |_| &l.? else null); return if (data == null) null else if (l) |_| data[0..l.?] else std.mem.sliceTo(data, 0); } pub fn getLength(self: Blob) u32 { return c.hb_blob_get_length(self.handle); } pub fn isImmutable(self: Blob) bool { return c.hb_blob_is_immutable(self.handle) > 0; } pub fn makeImmutable(self: Blob) void { c.hb_blob_make_immutable(self.handle); } pub fn reference(self: Blob) Blob { return .{ .handle = c.hb_blob_reference(self.handle).?, }; } };
freetype/src/harfbuzz/blob.zig
const std = @import("std"); const ConstantOrBuffer = @import("trigger.zig").ConstantOrBuffer; const Span = @import("basics.zig").Span; const fcdcoffset: f32 = 3.814697265625e-6; // 2^-18 pub const FilterType = enum { bypass, low_pass, band_pass, high_pass, notch, all_pass, }; // convert a frequency into a cutoff value so it can be used with the filter pub fn cutoffFromFrequency(frequency: f32, sample_rate: f32) f32 { var v: f32 = undefined; v = 2.0 * (1.0 - std.math.cos(std.math.pi * frequency / sample_rate)); v = std.math.max(0.0, std.math.min(1.0, v)); v = std.math.sqrt(v); return v; } pub const Filter = struct { pub const num_outputs = 1; pub const num_temps = 0; pub const Params = struct { input: []const f32, type: FilterType, cutoff: ConstantOrBuffer, // 0-1 res: f32, // 0-1 }; l: f32, b: f32, pub fn init() Filter { return .{ .l = 0.0, .b = 0.0, }; } pub fn paint( self: *Filter, span: Span, outputs: [num_outputs][]f32, temps: [num_temps][]f32, note_id_changed: bool, params: Params, ) void { // TODO make res a ConstantOrBuffer as well const output = outputs[0][span.start..span.end]; const input = params.input[span.start..span.end]; switch (params.cutoff) { .constant => |cutoff| { self.paintSimple( output, input, params.type, cutoff, params.res, ); }, .buffer => |cutoff| { self.paintControlledCutoff( output, input, params.type, cutoff[span.start..span.end], params.res, ); }, } } fn paintSimple( self: *Filter, buf: []f32, input: []const f32, filter_type: FilterType, cutoff: f32, resonance: f32, ) void { var l_mul: f32 = 0.0; var b_mul: f32 = 0.0; var h_mul: f32 = 0.0; switch (filter_type) { .bypass => { std.mem.copy(f32, buf, input); return; }, .low_pass => { l_mul = 1.0; }, .band_pass => { b_mul = 1.0; }, .high_pass => { h_mul = 1.0; }, .notch => { l_mul = 1.0; h_mul = 1.0; }, .all_pass => { l_mul = 1.0; b_mul = 1.0; h_mul = 1.0; }, } var i: usize = 0; const cut = std.math.max(0.0, std.math.min(1.0, cutoff)); const res = 1.0 - std.math.max(0.0, std.math.min(1.0, resonance)); var l = self.l; var b = self.b; var h: f32 = undefined; while (i < buf.len) : (i += 1) { // run 2x oversampled step // the filters get slightly biased inputs to avoid the state variables // getting too close to 0 for prolonged periods of time (which would // cause denormals to appear) const in = input[i] + fcdcoffset; // step 1 l += cut * b - fcdcoffset; // undo bias here (1 sample delay) b += cut * (in - b * res - l); // step 2 l += cut * b; h = in - b * res - l; b += cut * h; buf[i] += l * l_mul + b * b_mul + h * h_mul; } self.l = l; self.b = b; } fn paintControlledCutoff( self: *Filter, buf: []f32, input: []const f32, filter_type: FilterType, input_cutoff: []const f32, resonance: f32, ) void { std.debug.assert(buf.len == input.len); var l_mul: f32 = 0.0; var b_mul: f32 = 0.0; var h_mul: f32 = 0.0; switch (filter_type) { .bypass => { std.mem.copy(f32, buf, input); return; }, .low_pass => { l_mul = 1.0; }, .band_pass => { b_mul = 1.0; }, .high_pass => { h_mul = 1.0; }, .notch => { l_mul = 1.0; h_mul = 1.0; }, .all_pass => { l_mul = 1.0; b_mul = 1.0; h_mul = 1.0; }, } var i: usize = 0; const res = 1.0 - std.math.max(0.0, std.math.min(1.0, resonance)); var l = self.l; var b = self.b; var h: f32 = undefined; while (i < buf.len) : (i += 1) { const cutoff = std.math.max(0.0, std.math.min(1.0, input_cutoff[i])); // run 2x oversampled step // the filters get slightly biased inputs to avoid the state variables // getting too close to 0 for prolonged periods of time (which would // cause denormals to appear) const in = input[i] + fcdcoffset; // step 1 l += cutoff * b - fcdcoffset; // undo bias here (1 sample delay) b += cutoff * (in - b * res - l); // step 2 l += cutoff * b; h = in - b * res - l; b += cutoff * h; buf[i] += l * l_mul + b * b_mul + h * h_mul; } self.l = l; self.b = b; } };
src/zang/mod_filter.zig
const std = @import("std"); const gpa = std.heap.c_allocator; const ansi = @import("ansi"); const u = @import("index.zig"); // // pub const b = 1; pub const kb = b * 1024; pub const mb = kb * 1024; pub const gb = mb * 1024; pub fn print(comptime fmt: []const u8, args: anytype) void { std.debug.print(fmt++"\n", args); } pub fn assert(ok: bool, comptime fmt: []const u8, args: anytype) void { if (!ok) { print(comptime ansi.color.Fg(.Red, "error: " ++ fmt), args); std.os.exit(1); } } pub fn try_index(comptime T: type, array: []T, n: usize, def: T) T { if (array.len <= n) { return def; } return array[n]; } pub fn split(in: []const u8, delim: []const u8) ![][]const u8 { const list = &std.ArrayList([]const u8).init(gpa); const iter = &std.mem.split(in, delim); while (iter.next()) |str| { try list.append(str); } return list.items; } pub fn trim_prefix(in: []const u8, prefix: []const u8) []const u8 { if (std.mem.startsWith(u8, in, prefix)) { return in[prefix.len..]; } return in; } pub fn does_file_exist(fpath: []const u8) !bool { const file = std.fs.cwd().openFile(fpath, .{}) catch |e| switch (e) { error.FileNotFound => return false, error.IsDir => return true, else => return e, }; defer file.close(); return true; } pub fn does_folder_exist(fpath: []const u8) !bool { const file = std.fs.cwd().openFile(fpath, .{}) catch |e| switch (e) { error.FileNotFound => return false, error.IsDir => return true, else => return e, }; defer file.close(); const s = try file.stat(); if (s.kind != .Directory) { return false; } return true; } pub fn _join(comptime delim: []const u8, comptime xs: [][]const u8) []const u8 { var buf: []const u8 = ""; for (xs) |x,i| { buf = buf ++ x; if (i < xs.len-1) buf = buf ++ delim; } return buf; } pub fn trim_suffix(comptime T: type, in: []const T, suffix: []const T) []const T { if (std.mem.endsWith(T, in, suffix)) { return in[0..in.len-suffix.len]; } return in; } pub fn repeat(s: []const u8, times: i32) ![]const u8 { const list = &std.ArrayList([]const u8).init(gpa); var i: i32 = 0; while (i < times) : (i += 1) { try list.append(s); } return join(list.items, ""); } pub fn join(xs: [][]const u8, delim: []const u8) ![]const u8 { var res: []const u8 = ""; for (xs) |x, i| { res = try std.fmt.allocPrint(gpa, "{s}{s}{s}", .{res, x, if (i < xs.len-1) delim else ""}); } return res; } pub fn concat(items: [][]const u8) ![]const u8 { var buf: []const u8 = ""; for (items) |x| { buf = try std.fmt.allocPrint(gpa, "{s}{s}", .{buf, x}); } return buf; } pub fn print_all(w: std.fs.File.Writer, items: anytype, ln: bool) !void { inline for (items) |x, i| { if (i == 0) { try w.print("{s}", .{x}); } else { try w.print(" {s}", .{x}); } } if (ln) { try w.print("\n", .{}); } } pub fn list_contains(haystack: [][]const u8, needle: []const u8) bool { for (haystack) |item| { if (std.mem.eql(u8, item, needle)) { return true; } } return false; } pub fn list_contains_gen(comptime T: type, haystack: *std.ArrayList(T), needle: T) bool { for (haystack.items) |item| { if (item.eql(needle)) { return true; } } return false; } pub fn file_list(dpath: []const u8, list: *std.ArrayList([]const u8)) !void { var walk = try std.fs.walkPath(gpa, dpath); while (true) { if (try walk.next()) |entry| { if (entry.kind != .File) { continue; } try list.append(try gpa.dupe(u8, entry.path)); } else { break; } } } pub fn run_cmd(dir: ?[]const u8, args: []const []const u8) !u32 { const result = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, .max_output_bytes = std.math.maxInt(usize) }) catch |e| switch(e) { error.FileNotFound => { u.assert(false, "\"{s}\" command not found", .{args[0]}); unreachable; }, else => return e, }; gpa.free(result.stdout); gpa.free(result.stderr); return result.term.Exited; } pub fn list_remove(input: [][]const u8, search: []const u8) ![][]const u8 { const list = &std.ArrayList([]const u8).init(gpa); for (input) |item| { if (!std.mem.eql(u8, item, search)) { try list.append(item); } } return list.items; } pub fn last(in: [][]const u8) ![]const u8 { if (in.len == 0) { return error.EmptyArray; } return in[in.len - 1]; } pub fn mkdir_all(dpath: []const u8) anyerror!void { if (dpath.len == 0) { return; } const d = if (dpath[dpath.len-1] == std.fs.path.sep) dpath[0..dpath.len-1] else dpath; const ps = std.fs.path.sep_str; if (std.mem.lastIndexOf(u8, d, ps)) |index| { try mkdir_all(d[0..index]); } if (!try does_folder_exist(d)) { try std.fs.cwd().makeDir(d); } } pub fn rm_recv(path: []const u8) anyerror!void { const abs_path = std.fs.realpathAlloc(gpa, path) catch |e| switch (e) { error.FileNotFound => return, else => return e, }; const file = try std.fs.openFileAbsolute(abs_path, .{}); defer file.close(); const s = try file.stat(); if (s.kind == .Directory) { const dir = std.fs.cwd().openDir(abs_path, .{ .iterate=true, }) catch unreachable; var iter = dir.iterate(); while (try iter.next()) |item| { try rm_recv(try std.fs.path.join(gpa, &.{abs_path, item.name})); } try std.fs.deleteDirAbsolute(abs_path); } else { try std.fs.deleteFileAbsolute(abs_path); } } const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; pub fn random_string(len: usize) ![]const u8 { const now = @intCast(u64, std.time.nanoTimestamp()); var rand = std.rand.DefaultPrng.init(now); const r = &rand.random; var buf = try gpa.alloc(u8, len); var i: usize = 0; while (i < len) : (i += 1) { buf[i] = alphabet[r.int(usize)%alphabet.len]; } return buf; } pub fn parse_split(comptime T: type, delim: []const u8) type { return struct { const Self = @This(); id: T, string: []const u8, pub fn do(input: []const u8) !Self { const iter = &std.mem.split(input, delim); return Self{ .id = std.meta.stringToEnum(T, iter.next() orelse return error.IterEmpty) orelse return error.NoMemberFound, .string = iter.rest(), }; } }; } pub const HashFn = enum { blake3, sha256, sha512, }; pub fn validate_hash(input: []const u8, file_path: []const u8) !bool { const hash = parse_split(HashFn, "-").do(input) catch return false; const file = try std.fs.cwd().openFile(file_path, .{}); defer file.close(); const data = try file.reader().readAllAlloc(gpa, gb); const expected = hash.string; const actual = switch (hash.id) { .blake3 => try do_hash(std.crypto.hash.Blake3, data), .sha256 => try do_hash(std.crypto.hash.sha2.Sha256, data), .sha512 => try do_hash(std.crypto.hash.sha2.Sha512, data), }; const result = std.mem.eql(u8, expected, actual); if (!result) { std.log.info("expected: {s}, actual: {s}", .{expected, actual}); } return result; } pub fn do_hash(comptime algo: type, data: []const u8) ![]const u8 { const h = &algo.init(.{}); var out: [algo.digest_length]u8 = undefined; h.update(data); h.final(&out); const hex = try std.fmt.allocPrint(gpa, "{x}", .{std.fmt.fmtSliceHexLower(out[0..])}); return hex; }
src/util/funcs.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; pub fn main() !void { two: for (numbers) |n1, i| { if (i + 1 == numbers.len) @panic(":("); for (numbers[i + 1 ..]) |n2| { if (n1 + n2 == 2020) { print("Match found: {}+{}=2020, {}*{}={}\n", .{ n1, n2, n1, n2, n1 * n2 }); break :two; } } } for (numbers) |n1, i| { if (i + 1 == numbers.len) @panic(":("); for (numbers[i + 1 ..]) |n2, j| { for (numbers[j + 1 ..]) |n3| { if (n1 + n2 + n3 == 2020) { print("Match found: {}+{}+{}=2020, {}*{}*{}={}\n", .{ n1, n2, n3, n1, n2, n3, n1 * n2 * n3 }); return; } } } } } const numbers = [_]usize{ 1078, 1109, 1702, 1293, 1541, 1422, 1679, 1891, 1898, 1455, 1540, 1205, 1971, 1582, 1139, 1438, 1457, 1725, 1907, 1872, 1101, 1403, 1557, 1597, 1619, 1974, 1287, 292, 1647, 1444, 1241, 879, 1761, 1067, 1178, 1510, 1110, 1233, 1121, 1299, 1796, 1124, 1768, 1466, 1871, 1279, 1344, 1485, 1258, 1179, 1147, 492, 1234, 1843, 1421, 1819, 1964, 1671, 1793, 1302, 1731, 1886, 1686, 1150, 1806, 1960, 1841, 1936, 1845, 1520, 1779, 1102, 1323, 1892, 1742, 1941, 1395, 1525, 1165, 715, 1829, 1448, 1906, 1191, 1981, 1115, 1716, 1644, 1310, 1836, 1105, 1517, 1790, 1950, 1741, 1256, 1467, 1677, 1372, 1838, 1637, 1143, 1763, 1222, 1291, 1835, 1602, 1927, 1933, 1952, 1692, 1662, 1967, 1791, 1984, 1176, 1324, 1460, 1416, 562, 1862, 1273, 1518, 1535, 1093, 1977, 1923, 1246, 1570, 1674, 1861, 1811, 1431, 47, 1158, 1912, 1322, 1062, 1407, 1528, 1068, 1868, 1997, 1930, 959, 1676, 1759, 2000, 1993, 1722, 1738, 1264, 1361, 1542, 1187, 1735, 1405, 1745, 1753, 1833, 1493, 1311, 1547, 1180, 1553, 1513, 1812, 1951, 1948, 1834, 1925, 1726, 1326, 1931, 1962, 1947, 1173, 1633, 1901, 1781, 1483, 1789, 1417, 1929, 1859, 1760, 1347, 1996, 1328, 1798, 1230, 1298, 1877, 1840, 1607, 1253, 1057, 1650, 1171, 1593, };
src/day01.zig
const std = @import("std"); const assert = std.debug.assert; const allocator = std.testing.allocator; const Computer = @import("./computer.zig").Computer; pub const Pos = struct { x: usize, y: usize, pub fn encode(self: Pos) usize { return self.x * 10000 + self.y; } }; pub const Board = struct { cells: std.AutoHashMap(usize, Tile), computer: Computer, nx: i64, ny: i64, pmin: Pos, pmax: Pos, finished: bool, state: usize, bpos: Pos, ppos: Pos, score: usize, hacked: bool, pub const Tile = enum(u8) { Empty = 0, Wall = 1, Block = 2, Paddle = 3, Ball = 4, }; pub fn init(hacked: bool) Board { var self = Board{ .cells = std.AutoHashMap(usize, Tile).init(allocator), .computer = Computer.init(true), .nx = undefined, .ny = undefined, .pmin = Pos{ .x = 999999, .y = 999999 }, .pmax = Pos{ .x = 0, .y = 0 }, .bpos = Pos{ .x = 0, .y = 0 }, .ppos = Pos{ .x = 0, .y = 0 }, .finished = false, .state = 0, .score = 0, .hacked = hacked, }; return self; } pub fn deinit(self: *Board) void { self.computer.deinit(); self.cells.deinit(); } pub fn parse(self: *Board, str: []const u8) void { self.computer.parse(str, self.hacked); } pub fn run(self: *Board) void { while (true) { self.computer.run(); while (true) { const output = self.computer.getOutput(); if (output == null) break; _ = self.process_output(output.?); } if (self.hacked) self.show(); if (self.computer.halted) { std.debug.warn("HALT computer\n", .{}); break; } } } pub fn process_output(self: *Board, output: i64) bool { switch (self.state) { 0 => { self.nx = output; self.state = 1; }, 1 => { self.ny = output; self.state = 2; }, 2 => { if (self.nx == -1 and self.ny == 0) { // std.debug.warn("SCORE: {}\n", output); self.score = @intCast(usize, output); } else { const p = Pos{ .x = @intCast(usize, self.nx), .y = @intCast(usize, self.ny) }; var t: Tile = @intToEnum(Tile, @intCast(u8, output)); self.put_tile(p, t); // std.debug.warn("TILE: {} {} {}\n", p.x, p.y, t); } self.state = 0; }, else => unreachable, } return true; } pub fn get_tile(self: Board, pos: Pos) []const u8 { const label = pos.encode(); const got = self.cells.get(label); var c: []const u8 = " "; if (got == null) return c; switch (got.?) { Tile.Empty => c = " ", Tile.Wall => c = "X", Tile.Block => c = "#", Tile.Paddle => c = "-", Tile.Ball => c = "O", } return c; } pub fn show(self: Board) void { const out = std.io.getStdOut().writer(); const escape: u8 = 0o33; out.print("{c}[2J{c}[H", .{ escape, escape }) catch unreachable; var y: usize = self.pmin.y; while (y <= self.pmax.y) : (y += 1) { var x: usize = self.pmin.x; while (x <= self.pmax.x) : (x += 1) { const pos = Pos{ .x = x, .y = y }; const tile = self.get_tile(pos); out.print("{s}", .{tile}) catch unreachable; } out.print("\n", .{}) catch unreachable; } out.print("SCORE: {}\n", .{self.score}) catch unreachable; } pub fn put_tile(self: *Board, pos: Pos, t: Tile) void { const label = pos.encode(); _ = self.cells.put(label, t) catch unreachable; if (t == Tile.Block) {} if (t == Tile.Ball) { self.bpos = pos; if (self.ppos.x > self.bpos.x) { // std.debug.warn("MOVE left {} {}\n", self.ppos.x, self.bpos.x); self.computer.enqueueInput(-1); } else if (self.ppos.x < self.bpos.x) { // std.debug.warn("MOVE right {} {}\n", self.ppos.x, self.bpos.x); self.computer.enqueueInput(1); } else { // std.debug.warn("MOVE none {} {}\n", self.ppos.x, self.bpos.x); self.computer.enqueueInput(0); } } if (t == Tile.Paddle) { self.ppos = pos; } if (t == Tile.Block) {} if (self.pmin.x > pos.x) self.pmin.x = pos.x; if (self.pmin.y > pos.y) self.pmin.y = pos.y; if (self.pmax.x < pos.x) self.pmax.x = pos.x; if (self.pmax.y < pos.y) self.pmax.y = pos.y; } pub fn count_tiles(self: Board, t: Tile) usize { // std.debug.warn("MIN {} {} - MAX {} {}\n", self.pmin.x, self.pmin.y, self.pmax.x, self.pmax.y); // std.debug.warn("BALL {} {}\n", self.bpos.x, self.bpos.y); // std.debug.warn("PADDLE {} {}\n", self.ppos.x, self.ppos.y); var it = self.cells.iterator(); var count: usize = 0; while (it.next()) |entry| { if (entry.value_ptr.* != t) continue; count += 1; } return count; } }; test "count tiles without blocks" { // std.debug.warn("\n"); var board = Board.init(false); defer board.deinit(); const data = "1,2,2,6,5,4"; var it = std.mem.split(u8, data, ","); while (it.next()) |what| { const output = std.fmt.parseInt(i64, what, 10) catch unreachable; const more = board.process_output(output); if (!more) break; } const count = board.count_tiles(Board.Tile.Block); assert(count == 1); } test "count tiles with blocks" { // std.debug.warn("\n"); var board = Board.init(false); defer board.deinit(); const data = "1,2,3,6,5,4"; var it = std.mem.split(u8, data, ","); while (it.next()) |what| { const output = std.fmt.parseInt(i64, what, 10) catch unreachable; const more = board.process_output(output); if (!more) break; } const count = board.count_tiles(Board.Tile.Block); assert(count == 0); }
2019/p13/board.zig
/// The function fiatP434AddcarryxU64 is an addition with carry. /// Postconditions: /// out1 = (arg1 + arg2 + arg3) mod 2^64 /// out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0x1] fn fiatP434AddcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { const x1: u128 = ((@intCast(u128, arg1) + @intCast(u128, arg2)) + @intCast(u128, arg3)); const x2: u64 = @intCast(u64, (x1 & @intCast(u128, 0xffffffffffffffff))); const x3: u1 = @intCast(u1, (x1 >> 64)); out1.* = x2; out2.* = x3; } /// The function fiatP434SubborrowxU64 is a subtraction with borrow. /// Postconditions: /// out1 = (-arg1 + arg2 + -arg3) mod 2^64 /// out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0x1] fn fiatP434SubborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { const x1: i128 = ((@intCast(i128, arg2) - @intCast(i128, arg1)) - @intCast(i128, arg3)); const x2: i1 = @intCast(i1, (x1 >> 64)); const x3: u64 = @intCast(u64, (x1 & @intCast(i128, 0xffffffffffffffff))); out1.* = x3; out2.* = @intCast(u1, (@intCast(i2, 0x0) - @intCast(i2, x2))); } /// The function fiatP434MulxU64 is a multiplication, returning the full double-width result. /// Postconditions: /// out1 = (arg1 * arg2) mod 2^64 /// out2 = ⌊arg1 * arg2 / 2^64⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0xffffffffffffffff] /// arg2: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0xffffffffffffffff] fn fiatP434MulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void { const x1: u128 = (@intCast(u128, arg1) * @intCast(u128, arg2)); const x2: u64 = @intCast(u64, (x1 & @intCast(u128, 0xffffffffffffffff))); const x3: u64 = @intCast(u64, (x1 >> 64)); out1.* = x2; out2.* = x3; } /// The function fiatP434CmovznzU64 is a single-word conditional move. /// Postconditions: /// out1 = (if arg1 = 0 then arg2 else arg3) /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] fn fiatP434CmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { const x1: u1 = (~(~arg1)); const x2: u64 = @intCast(u64, (@intCast(i128, @intCast(i1, (@intCast(i2, 0x0) - @intCast(i2, x1)))) & @intCast(i128, 0xffffffffffffffff))); const x3: u64 = ((x2 & arg3) | ((~x2) & arg2)); out1.* = x3; } /// The function fiatP434Mul multiplies two field elements in the Montgomery domain. /// Preconditions: /// 0 ≤ eval arg1 < m /// 0 ≤ eval arg2 < m /// Postconditions: /// eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434Mul(out1: *[7]u64, arg1: [7]u64, arg2: [7]u64) void { const x1: u64 = (arg1[1]); const x2: u64 = (arg1[2]); const x3: u64 = (arg1[3]); const x4: u64 = (arg1[4]); const x5: u64 = (arg1[5]); const x6: u64 = (arg1[6]); const x7: u64 = (arg1[0]); var x8: u64 = undefined; var x9: u64 = undefined; fiatP434MulxU64(&x8, &x9, x7, (arg2[6])); var x10: u64 = undefined; var x11: u64 = undefined; fiatP434MulxU64(&x10, &x11, x7, (arg2[5])); var x12: u64 = undefined; var x13: u64 = undefined; fiatP434MulxU64(&x12, &x13, x7, (arg2[4])); var x14: u64 = undefined; var x15: u64 = undefined; fiatP434MulxU64(&x14, &x15, x7, (arg2[3])); var x16: u64 = undefined; var x17: u64 = undefined; fiatP434MulxU64(&x16, &x17, x7, (arg2[2])); var x18: u64 = undefined; var x19: u64 = undefined; fiatP434MulxU64(&x18, &x19, x7, (arg2[1])); var x20: u64 = undefined; var x21: u64 = undefined; fiatP434MulxU64(&x20, &x21, x7, (arg2[0])); var x22: u64 = undefined; var x23: u1 = undefined; fiatP434AddcarryxU64(&x22, &x23, 0x0, x21, x18); var x24: u64 = undefined; var x25: u1 = undefined; fiatP434AddcarryxU64(&x24, &x25, x23, x19, x16); var x26: u64 = undefined; var x27: u1 = undefined; fiatP434AddcarryxU64(&x26, &x27, x25, x17, x14); var x28: u64 = undefined; var x29: u1 = undefined; fiatP434AddcarryxU64(&x28, &x29, x27, x15, x12); var x30: u64 = undefined; var x31: u1 = undefined; fiatP434AddcarryxU64(&x30, &x31, x29, x13, x10); var x32: u64 = undefined; var x33: u1 = undefined; fiatP434AddcarryxU64(&x32, &x33, x31, x11, x8); const x34: u64 = (@intCast(u64, x33) + x9); var x35: u64 = undefined; var x36: u64 = undefined; fiatP434MulxU64(&x35, &x36, x20, 0x2341f27177344); var x37: u64 = undefined; var x38: u64 = undefined; fiatP434MulxU64(&x37, &x38, x20, 0x6cfc5fd681c52056); var x39: u64 = undefined; var x40: u64 = undefined; fiatP434MulxU64(&x39, &x40, x20, 0x7bc65c783158aea3); var x41: u64 = undefined; var x42: u64 = undefined; fiatP434MulxU64(&x41, &x42, x20, 0xfdc1767ae2ffffff); var x43: u64 = undefined; var x44: u64 = undefined; fiatP434MulxU64(&x43, &x44, x20, 0xffffffffffffffff); var x45: u64 = undefined; var x46: u64 = undefined; fiatP434MulxU64(&x45, &x46, x20, 0xffffffffffffffff); var x47: u64 = undefined; var x48: u64 = undefined; fiatP434MulxU64(&x47, &x48, x20, 0xffffffffffffffff); var x49: u64 = undefined; var x50: u1 = undefined; fiatP434AddcarryxU64(&x49, &x50, 0x0, x48, x45); var x51: u64 = undefined; var x52: u1 = undefined; fiatP434AddcarryxU64(&x51, &x52, x50, x46, x43); var x53: u64 = undefined; var x54: u1 = undefined; fiatP434AddcarryxU64(&x53, &x54, x52, x44, x41); var x55: u64 = undefined; var x56: u1 = undefined; fiatP434AddcarryxU64(&x55, &x56, x54, x42, x39); var x57: u64 = undefined; var x58: u1 = undefined; fiatP434AddcarryxU64(&x57, &x58, x56, x40, x37); var x59: u64 = undefined; var x60: u1 = undefined; fiatP434AddcarryxU64(&x59, &x60, x58, x38, x35); const x61: u64 = (@intCast(u64, x60) + x36); var x62: u64 = undefined; var x63: u1 = undefined; fiatP434AddcarryxU64(&x62, &x63, 0x0, x20, x47); var x64: u64 = undefined; var x65: u1 = undefined; fiatP434AddcarryxU64(&x64, &x65, x63, x22, x49); var x66: u64 = undefined; var x67: u1 = undefined; fiatP434AddcarryxU64(&x66, &x67, x65, x24, x51); var x68: u64 = undefined; var x69: u1 = undefined; fiatP434AddcarryxU64(&x68, &x69, x67, x26, x53); var x70: u64 = undefined; var x71: u1 = undefined; fiatP434AddcarryxU64(&x70, &x71, x69, x28, x55); var x72: u64 = undefined; var x73: u1 = undefined; fiatP434AddcarryxU64(&x72, &x73, x71, x30, x57); var x74: u64 = undefined; var x75: u1 = undefined; fiatP434AddcarryxU64(&x74, &x75, x73, x32, x59); var x76: u64 = undefined; var x77: u1 = undefined; fiatP434AddcarryxU64(&x76, &x77, x75, x34, x61); var x78: u64 = undefined; var x79: u64 = undefined; fiatP434MulxU64(&x78, &x79, x1, (arg2[6])); var x80: u64 = undefined; var x81: u64 = undefined; fiatP434MulxU64(&x80, &x81, x1, (arg2[5])); var x82: u64 = undefined; var x83: u64 = undefined; fiatP434MulxU64(&x82, &x83, x1, (arg2[4])); var x84: u64 = undefined; var x85: u64 = undefined; fiatP434MulxU64(&x84, &x85, x1, (arg2[3])); var x86: u64 = undefined; var x87: u64 = undefined; fiatP434MulxU64(&x86, &x87, x1, (arg2[2])); var x88: u64 = undefined; var x89: u64 = undefined; fiatP434MulxU64(&x88, &x89, x1, (arg2[1])); var x90: u64 = undefined; var x91: u64 = undefined; fiatP434MulxU64(&x90, &x91, x1, (arg2[0])); var x92: u64 = undefined; var x93: u1 = undefined; fiatP434AddcarryxU64(&x92, &x93, 0x0, x91, x88); var x94: u64 = undefined; var x95: u1 = undefined; fiatP434AddcarryxU64(&x94, &x95, x93, x89, x86); var x96: u64 = undefined; var x97: u1 = undefined; fiatP434AddcarryxU64(&x96, &x97, x95, x87, x84); var x98: u64 = undefined; var x99: u1 = undefined; fiatP434AddcarryxU64(&x98, &x99, x97, x85, x82); var x100: u64 = undefined; var x101: u1 = undefined; fiatP434AddcarryxU64(&x100, &x101, x99, x83, x80); var x102: u64 = undefined; var x103: u1 = undefined; fiatP434AddcarryxU64(&x102, &x103, x101, x81, x78); const x104: u64 = (@intCast(u64, x103) + x79); var x105: u64 = undefined; var x106: u1 = undefined; fiatP434AddcarryxU64(&x105, &x106, 0x0, x64, x90); var x107: u64 = undefined; var x108: u1 = undefined; fiatP434AddcarryxU64(&x107, &x108, x106, x66, x92); var x109: u64 = undefined; var x110: u1 = undefined; fiatP434AddcarryxU64(&x109, &x110, x108, x68, x94); var x111: u64 = undefined; var x112: u1 = undefined; fiatP434AddcarryxU64(&x111, &x112, x110, x70, x96); var x113: u64 = undefined; var x114: u1 = undefined; fiatP434AddcarryxU64(&x113, &x114, x112, x72, x98); var x115: u64 = undefined; var x116: u1 = undefined; fiatP434AddcarryxU64(&x115, &x116, x114, x74, x100); var x117: u64 = undefined; var x118: u1 = undefined; fiatP434AddcarryxU64(&x117, &x118, x116, x76, x102); var x119: u64 = undefined; var x120: u1 = undefined; fiatP434AddcarryxU64(&x119, &x120, x118, @intCast(u64, x77), x104); var x121: u64 = undefined; var x122: u64 = undefined; fiatP434MulxU64(&x121, &x122, x105, 0x2341f27177344); var x123: u64 = undefined; var x124: u64 = undefined; fiatP434MulxU64(&x123, &x124, x105, 0x6cfc5fd681c52056); var x125: u64 = undefined; var x126: u64 = undefined; fiatP434MulxU64(&x125, &x126, x105, 0x7bc65c783158aea3); var x127: u64 = undefined; var x128: u64 = undefined; fiatP434MulxU64(&x127, &x128, x105, 0xfdc1767ae2ffffff); var x129: u64 = undefined; var x130: u64 = undefined; fiatP434MulxU64(&x129, &x130, x105, 0xffffffffffffffff); var x131: u64 = undefined; var x132: u64 = undefined; fiatP434MulxU64(&x131, &x132, x105, 0xffffffffffffffff); var x133: u64 = undefined; var x134: u64 = undefined; fiatP434MulxU64(&x133, &x134, x105, 0xffffffffffffffff); var x135: u64 = undefined; var x136: u1 = undefined; fiatP434AddcarryxU64(&x135, &x136, 0x0, x134, x131); var x137: u64 = undefined; var x138: u1 = undefined; fiatP434AddcarryxU64(&x137, &x138, x136, x132, x129); var x139: u64 = undefined; var x140: u1 = undefined; fiatP434AddcarryxU64(&x139, &x140, x138, x130, x127); var x141: u64 = undefined; var x142: u1 = undefined; fiatP434AddcarryxU64(&x141, &x142, x140, x128, x125); var x143: u64 = undefined; var x144: u1 = undefined; fiatP434AddcarryxU64(&x143, &x144, x142, x126, x123); var x145: u64 = undefined; var x146: u1 = undefined; fiatP434AddcarryxU64(&x145, &x146, x144, x124, x121); const x147: u64 = (@intCast(u64, x146) + x122); var x148: u64 = undefined; var x149: u1 = undefined; fiatP434AddcarryxU64(&x148, &x149, 0x0, x105, x133); var x150: u64 = undefined; var x151: u1 = undefined; fiatP434AddcarryxU64(&x150, &x151, x149, x107, x135); var x152: u64 = undefined; var x153: u1 = undefined; fiatP434AddcarryxU64(&x152, &x153, x151, x109, x137); var x154: u64 = undefined; var x155: u1 = undefined; fiatP434AddcarryxU64(&x154, &x155, x153, x111, x139); var x156: u64 = undefined; var x157: u1 = undefined; fiatP434AddcarryxU64(&x156, &x157, x155, x113, x141); var x158: u64 = undefined; var x159: u1 = undefined; fiatP434AddcarryxU64(&x158, &x159, x157, x115, x143); var x160: u64 = undefined; var x161: u1 = undefined; fiatP434AddcarryxU64(&x160, &x161, x159, x117, x145); var x162: u64 = undefined; var x163: u1 = undefined; fiatP434AddcarryxU64(&x162, &x163, x161, x119, x147); const x164: u64 = (@intCast(u64, x163) + @intCast(u64, x120)); var x165: u64 = undefined; var x166: u64 = undefined; fiatP434MulxU64(&x165, &x166, x2, (arg2[6])); var x167: u64 = undefined; var x168: u64 = undefined; fiatP434MulxU64(&x167, &x168, x2, (arg2[5])); var x169: u64 = undefined; var x170: u64 = undefined; fiatP434MulxU64(&x169, &x170, x2, (arg2[4])); var x171: u64 = undefined; var x172: u64 = undefined; fiatP434MulxU64(&x171, &x172, x2, (arg2[3])); var x173: u64 = undefined; var x174: u64 = undefined; fiatP434MulxU64(&x173, &x174, x2, (arg2[2])); var x175: u64 = undefined; var x176: u64 = undefined; fiatP434MulxU64(&x175, &x176, x2, (arg2[1])); var x177: u64 = undefined; var x178: u64 = undefined; fiatP434MulxU64(&x177, &x178, x2, (arg2[0])); var x179: u64 = undefined; var x180: u1 = undefined; fiatP434AddcarryxU64(&x179, &x180, 0x0, x178, x175); var x181: u64 = undefined; var x182: u1 = undefined; fiatP434AddcarryxU64(&x181, &x182, x180, x176, x173); var x183: u64 = undefined; var x184: u1 = undefined; fiatP434AddcarryxU64(&x183, &x184, x182, x174, x171); var x185: u64 = undefined; var x186: u1 = undefined; fiatP434AddcarryxU64(&x185, &x186, x184, x172, x169); var x187: u64 = undefined; var x188: u1 = undefined; fiatP434AddcarryxU64(&x187, &x188, x186, x170, x167); var x189: u64 = undefined; var x190: u1 = undefined; fiatP434AddcarryxU64(&x189, &x190, x188, x168, x165); const x191: u64 = (@intCast(u64, x190) + x166); var x192: u64 = undefined; var x193: u1 = undefined; fiatP434AddcarryxU64(&x192, &x193, 0x0, x150, x177); var x194: u64 = undefined; var x195: u1 = undefined; fiatP434AddcarryxU64(&x194, &x195, x193, x152, x179); var x196: u64 = undefined; var x197: u1 = undefined; fiatP434AddcarryxU64(&x196, &x197, x195, x154, x181); var x198: u64 = undefined; var x199: u1 = undefined; fiatP434AddcarryxU64(&x198, &x199, x197, x156, x183); var x200: u64 = undefined; var x201: u1 = undefined; fiatP434AddcarryxU64(&x200, &x201, x199, x158, x185); var x202: u64 = undefined; var x203: u1 = undefined; fiatP434AddcarryxU64(&x202, &x203, x201, x160, x187); var x204: u64 = undefined; var x205: u1 = undefined; fiatP434AddcarryxU64(&x204, &x205, x203, x162, x189); var x206: u64 = undefined; var x207: u1 = undefined; fiatP434AddcarryxU64(&x206, &x207, x205, x164, x191); var x208: u64 = undefined; var x209: u64 = undefined; fiatP434MulxU64(&x208, &x209, x192, 0x2341f27177344); var x210: u64 = undefined; var x211: u64 = undefined; fiatP434MulxU64(&x210, &x211, x192, 0x6cfc5fd681c52056); var x212: u64 = undefined; var x213: u64 = undefined; fiatP434MulxU64(&x212, &x213, x192, 0x7bc65c783158aea3); var x214: u64 = undefined; var x215: u64 = undefined; fiatP434MulxU64(&x214, &x215, x192, 0xfdc1767ae2ffffff); var x216: u64 = undefined; var x217: u64 = undefined; fiatP434MulxU64(&x216, &x217, x192, 0xffffffffffffffff); var x218: u64 = undefined; var x219: u64 = undefined; fiatP434MulxU64(&x218, &x219, x192, 0xffffffffffffffff); var x220: u64 = undefined; var x221: u64 = undefined; fiatP434MulxU64(&x220, &x221, x192, 0xffffffffffffffff); var x222: u64 = undefined; var x223: u1 = undefined; fiatP434AddcarryxU64(&x222, &x223, 0x0, x221, x218); var x224: u64 = undefined; var x225: u1 = undefined; fiatP434AddcarryxU64(&x224, &x225, x223, x219, x216); var x226: u64 = undefined; var x227: u1 = undefined; fiatP434AddcarryxU64(&x226, &x227, x225, x217, x214); var x228: u64 = undefined; var x229: u1 = undefined; fiatP434AddcarryxU64(&x228, &x229, x227, x215, x212); var x230: u64 = undefined; var x231: u1 = undefined; fiatP434AddcarryxU64(&x230, &x231, x229, x213, x210); var x232: u64 = undefined; var x233: u1 = undefined; fiatP434AddcarryxU64(&x232, &x233, x231, x211, x208); const x234: u64 = (@intCast(u64, x233) + x209); var x235: u64 = undefined; var x236: u1 = undefined; fiatP434AddcarryxU64(&x235, &x236, 0x0, x192, x220); var x237: u64 = undefined; var x238: u1 = undefined; fiatP434AddcarryxU64(&x237, &x238, x236, x194, x222); var x239: u64 = undefined; var x240: u1 = undefined; fiatP434AddcarryxU64(&x239, &x240, x238, x196, x224); var x241: u64 = undefined; var x242: u1 = undefined; fiatP434AddcarryxU64(&x241, &x242, x240, x198, x226); var x243: u64 = undefined; var x244: u1 = undefined; fiatP434AddcarryxU64(&x243, &x244, x242, x200, x228); var x245: u64 = undefined; var x246: u1 = undefined; fiatP434AddcarryxU64(&x245, &x246, x244, x202, x230); var x247: u64 = undefined; var x248: u1 = undefined; fiatP434AddcarryxU64(&x247, &x248, x246, x204, x232); var x249: u64 = undefined; var x250: u1 = undefined; fiatP434AddcarryxU64(&x249, &x250, x248, x206, x234); const x251: u64 = (@intCast(u64, x250) + @intCast(u64, x207)); var x252: u64 = undefined; var x253: u64 = undefined; fiatP434MulxU64(&x252, &x253, x3, (arg2[6])); var x254: u64 = undefined; var x255: u64 = undefined; fiatP434MulxU64(&x254, &x255, x3, (arg2[5])); var x256: u64 = undefined; var x257: u64 = undefined; fiatP434MulxU64(&x256, &x257, x3, (arg2[4])); var x258: u64 = undefined; var x259: u64 = undefined; fiatP434MulxU64(&x258, &x259, x3, (arg2[3])); var x260: u64 = undefined; var x261: u64 = undefined; fiatP434MulxU64(&x260, &x261, x3, (arg2[2])); var x262: u64 = undefined; var x263: u64 = undefined; fiatP434MulxU64(&x262, &x263, x3, (arg2[1])); var x264: u64 = undefined; var x265: u64 = undefined; fiatP434MulxU64(&x264, &x265, x3, (arg2[0])); var x266: u64 = undefined; var x267: u1 = undefined; fiatP434AddcarryxU64(&x266, &x267, 0x0, x265, x262); var x268: u64 = undefined; var x269: u1 = undefined; fiatP434AddcarryxU64(&x268, &x269, x267, x263, x260); var x270: u64 = undefined; var x271: u1 = undefined; fiatP434AddcarryxU64(&x270, &x271, x269, x261, x258); var x272: u64 = undefined; var x273: u1 = undefined; fiatP434AddcarryxU64(&x272, &x273, x271, x259, x256); var x274: u64 = undefined; var x275: u1 = undefined; fiatP434AddcarryxU64(&x274, &x275, x273, x257, x254); var x276: u64 = undefined; var x277: u1 = undefined; fiatP434AddcarryxU64(&x276, &x277, x275, x255, x252); const x278: u64 = (@intCast(u64, x277) + x253); var x279: u64 = undefined; var x280: u1 = undefined; fiatP434AddcarryxU64(&x279, &x280, 0x0, x237, x264); var x281: u64 = undefined; var x282: u1 = undefined; fiatP434AddcarryxU64(&x281, &x282, x280, x239, x266); var x283: u64 = undefined; var x284: u1 = undefined; fiatP434AddcarryxU64(&x283, &x284, x282, x241, x268); var x285: u64 = undefined; var x286: u1 = undefined; fiatP434AddcarryxU64(&x285, &x286, x284, x243, x270); var x287: u64 = undefined; var x288: u1 = undefined; fiatP434AddcarryxU64(&x287, &x288, x286, x245, x272); var x289: u64 = undefined; var x290: u1 = undefined; fiatP434AddcarryxU64(&x289, &x290, x288, x247, x274); var x291: u64 = undefined; var x292: u1 = undefined; fiatP434AddcarryxU64(&x291, &x292, x290, x249, x276); var x293: u64 = undefined; var x294: u1 = undefined; fiatP434AddcarryxU64(&x293, &x294, x292, x251, x278); var x295: u64 = undefined; var x296: u64 = undefined; fiatP434MulxU64(&x295, &x296, x279, 0x2341f27177344); var x297: u64 = undefined; var x298: u64 = undefined; fiatP434MulxU64(&x297, &x298, x279, 0x6cfc5fd681c52056); var x299: u64 = undefined; var x300: u64 = undefined; fiatP434MulxU64(&x299, &x300, x279, 0x7bc65c783158aea3); var x301: u64 = undefined; var x302: u64 = undefined; fiatP434MulxU64(&x301, &x302, x279, 0xfdc1767ae2ffffff); var x303: u64 = undefined; var x304: u64 = undefined; fiatP434MulxU64(&x303, &x304, x279, 0xffffffffffffffff); var x305: u64 = undefined; var x306: u64 = undefined; fiatP434MulxU64(&x305, &x306, x279, 0xffffffffffffffff); var x307: u64 = undefined; var x308: u64 = undefined; fiatP434MulxU64(&x307, &x308, x279, 0xffffffffffffffff); var x309: u64 = undefined; var x310: u1 = undefined; fiatP434AddcarryxU64(&x309, &x310, 0x0, x308, x305); var x311: u64 = undefined; var x312: u1 = undefined; fiatP434AddcarryxU64(&x311, &x312, x310, x306, x303); var x313: u64 = undefined; var x314: u1 = undefined; fiatP434AddcarryxU64(&x313, &x314, x312, x304, x301); var x315: u64 = undefined; var x316: u1 = undefined; fiatP434AddcarryxU64(&x315, &x316, x314, x302, x299); var x317: u64 = undefined; var x318: u1 = undefined; fiatP434AddcarryxU64(&x317, &x318, x316, x300, x297); var x319: u64 = undefined; var x320: u1 = undefined; fiatP434AddcarryxU64(&x319, &x320, x318, x298, x295); const x321: u64 = (@intCast(u64, x320) + x296); var x322: u64 = undefined; var x323: u1 = undefined; fiatP434AddcarryxU64(&x322, &x323, 0x0, x279, x307); var x324: u64 = undefined; var x325: u1 = undefined; fiatP434AddcarryxU64(&x324, &x325, x323, x281, x309); var x326: u64 = undefined; var x327: u1 = undefined; fiatP434AddcarryxU64(&x326, &x327, x325, x283, x311); var x328: u64 = undefined; var x329: u1 = undefined; fiatP434AddcarryxU64(&x328, &x329, x327, x285, x313); var x330: u64 = undefined; var x331: u1 = undefined; fiatP434AddcarryxU64(&x330, &x331, x329, x287, x315); var x332: u64 = undefined; var x333: u1 = undefined; fiatP434AddcarryxU64(&x332, &x333, x331, x289, x317); var x334: u64 = undefined; var x335: u1 = undefined; fiatP434AddcarryxU64(&x334, &x335, x333, x291, x319); var x336: u64 = undefined; var x337: u1 = undefined; fiatP434AddcarryxU64(&x336, &x337, x335, x293, x321); const x338: u64 = (@intCast(u64, x337) + @intCast(u64, x294)); var x339: u64 = undefined; var x340: u64 = undefined; fiatP434MulxU64(&x339, &x340, x4, (arg2[6])); var x341: u64 = undefined; var x342: u64 = undefined; fiatP434MulxU64(&x341, &x342, x4, (arg2[5])); var x343: u64 = undefined; var x344: u64 = undefined; fiatP434MulxU64(&x343, &x344, x4, (arg2[4])); var x345: u64 = undefined; var x346: u64 = undefined; fiatP434MulxU64(&x345, &x346, x4, (arg2[3])); var x347: u64 = undefined; var x348: u64 = undefined; fiatP434MulxU64(&x347, &x348, x4, (arg2[2])); var x349: u64 = undefined; var x350: u64 = undefined; fiatP434MulxU64(&x349, &x350, x4, (arg2[1])); var x351: u64 = undefined; var x352: u64 = undefined; fiatP434MulxU64(&x351, &x352, x4, (arg2[0])); var x353: u64 = undefined; var x354: u1 = undefined; fiatP434AddcarryxU64(&x353, &x354, 0x0, x352, x349); var x355: u64 = undefined; var x356: u1 = undefined; fiatP434AddcarryxU64(&x355, &x356, x354, x350, x347); var x357: u64 = undefined; var x358: u1 = undefined; fiatP434AddcarryxU64(&x357, &x358, x356, x348, x345); var x359: u64 = undefined; var x360: u1 = undefined; fiatP434AddcarryxU64(&x359, &x360, x358, x346, x343); var x361: u64 = undefined; var x362: u1 = undefined; fiatP434AddcarryxU64(&x361, &x362, x360, x344, x341); var x363: u64 = undefined; var x364: u1 = undefined; fiatP434AddcarryxU64(&x363, &x364, x362, x342, x339); const x365: u64 = (@intCast(u64, x364) + x340); var x366: u64 = undefined; var x367: u1 = undefined; fiatP434AddcarryxU64(&x366, &x367, 0x0, x324, x351); var x368: u64 = undefined; var x369: u1 = undefined; fiatP434AddcarryxU64(&x368, &x369, x367, x326, x353); var x370: u64 = undefined; var x371: u1 = undefined; fiatP434AddcarryxU64(&x370, &x371, x369, x328, x355); var x372: u64 = undefined; var x373: u1 = undefined; fiatP434AddcarryxU64(&x372, &x373, x371, x330, x357); var x374: u64 = undefined; var x375: u1 = undefined; fiatP434AddcarryxU64(&x374, &x375, x373, x332, x359); var x376: u64 = undefined; var x377: u1 = undefined; fiatP434AddcarryxU64(&x376, &x377, x375, x334, x361); var x378: u64 = undefined; var x379: u1 = undefined; fiatP434AddcarryxU64(&x378, &x379, x377, x336, x363); var x380: u64 = undefined; var x381: u1 = undefined; fiatP434AddcarryxU64(&x380, &x381, x379, x338, x365); var x382: u64 = undefined; var x383: u64 = undefined; fiatP434MulxU64(&x382, &x383, x366, 0x2341f27177344); var x384: u64 = undefined; var x385: u64 = undefined; fiatP434MulxU64(&x384, &x385, x366, 0x6cfc5fd681c52056); var x386: u64 = undefined; var x387: u64 = undefined; fiatP434MulxU64(&x386, &x387, x366, 0x7bc65c783158aea3); var x388: u64 = undefined; var x389: u64 = undefined; fiatP434MulxU64(&x388, &x389, x366, 0xfdc1767ae2ffffff); var x390: u64 = undefined; var x391: u64 = undefined; fiatP434MulxU64(&x390, &x391, x366, 0xffffffffffffffff); var x392: u64 = undefined; var x393: u64 = undefined; fiatP434MulxU64(&x392, &x393, x366, 0xffffffffffffffff); var x394: u64 = undefined; var x395: u64 = undefined; fiatP434MulxU64(&x394, &x395, x366, 0xffffffffffffffff); var x396: u64 = undefined; var x397: u1 = undefined; fiatP434AddcarryxU64(&x396, &x397, 0x0, x395, x392); var x398: u64 = undefined; var x399: u1 = undefined; fiatP434AddcarryxU64(&x398, &x399, x397, x393, x390); var x400: u64 = undefined; var x401: u1 = undefined; fiatP434AddcarryxU64(&x400, &x401, x399, x391, x388); var x402: u64 = undefined; var x403: u1 = undefined; fiatP434AddcarryxU64(&x402, &x403, x401, x389, x386); var x404: u64 = undefined; var x405: u1 = undefined; fiatP434AddcarryxU64(&x404, &x405, x403, x387, x384); var x406: u64 = undefined; var x407: u1 = undefined; fiatP434AddcarryxU64(&x406, &x407, x405, x385, x382); const x408: u64 = (@intCast(u64, x407) + x383); var x409: u64 = undefined; var x410: u1 = undefined; fiatP434AddcarryxU64(&x409, &x410, 0x0, x366, x394); var x411: u64 = undefined; var x412: u1 = undefined; fiatP434AddcarryxU64(&x411, &x412, x410, x368, x396); var x413: u64 = undefined; var x414: u1 = undefined; fiatP434AddcarryxU64(&x413, &x414, x412, x370, x398); var x415: u64 = undefined; var x416: u1 = undefined; fiatP434AddcarryxU64(&x415, &x416, x414, x372, x400); var x417: u64 = undefined; var x418: u1 = undefined; fiatP434AddcarryxU64(&x417, &x418, x416, x374, x402); var x419: u64 = undefined; var x420: u1 = undefined; fiatP434AddcarryxU64(&x419, &x420, x418, x376, x404); var x421: u64 = undefined; var x422: u1 = undefined; fiatP434AddcarryxU64(&x421, &x422, x420, x378, x406); var x423: u64 = undefined; var x424: u1 = undefined; fiatP434AddcarryxU64(&x423, &x424, x422, x380, x408); const x425: u64 = (@intCast(u64, x424) + @intCast(u64, x381)); var x426: u64 = undefined; var x427: u64 = undefined; fiatP434MulxU64(&x426, &x427, x5, (arg2[6])); var x428: u64 = undefined; var x429: u64 = undefined; fiatP434MulxU64(&x428, &x429, x5, (arg2[5])); var x430: u64 = undefined; var x431: u64 = undefined; fiatP434MulxU64(&x430, &x431, x5, (arg2[4])); var x432: u64 = undefined; var x433: u64 = undefined; fiatP434MulxU64(&x432, &x433, x5, (arg2[3])); var x434: u64 = undefined; var x435: u64 = undefined; fiatP434MulxU64(&x434, &x435, x5, (arg2[2])); var x436: u64 = undefined; var x437: u64 = undefined; fiatP434MulxU64(&x436, &x437, x5, (arg2[1])); var x438: u64 = undefined; var x439: u64 = undefined; fiatP434MulxU64(&x438, &x439, x5, (arg2[0])); var x440: u64 = undefined; var x441: u1 = undefined; fiatP434AddcarryxU64(&x440, &x441, 0x0, x439, x436); var x442: u64 = undefined; var x443: u1 = undefined; fiatP434AddcarryxU64(&x442, &x443, x441, x437, x434); var x444: u64 = undefined; var x445: u1 = undefined; fiatP434AddcarryxU64(&x444, &x445, x443, x435, x432); var x446: u64 = undefined; var x447: u1 = undefined; fiatP434AddcarryxU64(&x446, &x447, x445, x433, x430); var x448: u64 = undefined; var x449: u1 = undefined; fiatP434AddcarryxU64(&x448, &x449, x447, x431, x428); var x450: u64 = undefined; var x451: u1 = undefined; fiatP434AddcarryxU64(&x450, &x451, x449, x429, x426); const x452: u64 = (@intCast(u64, x451) + x427); var x453: u64 = undefined; var x454: u1 = undefined; fiatP434AddcarryxU64(&x453, &x454, 0x0, x411, x438); var x455: u64 = undefined; var x456: u1 = undefined; fiatP434AddcarryxU64(&x455, &x456, x454, x413, x440); var x457: u64 = undefined; var x458: u1 = undefined; fiatP434AddcarryxU64(&x457, &x458, x456, x415, x442); var x459: u64 = undefined; var x460: u1 = undefined; fiatP434AddcarryxU64(&x459, &x460, x458, x417, x444); var x461: u64 = undefined; var x462: u1 = undefined; fiatP434AddcarryxU64(&x461, &x462, x460, x419, x446); var x463: u64 = undefined; var x464: u1 = undefined; fiatP434AddcarryxU64(&x463, &x464, x462, x421, x448); var x465: u64 = undefined; var x466: u1 = undefined; fiatP434AddcarryxU64(&x465, &x466, x464, x423, x450); var x467: u64 = undefined; var x468: u1 = undefined; fiatP434AddcarryxU64(&x467, &x468, x466, x425, x452); var x469: u64 = undefined; var x470: u64 = undefined; fiatP434MulxU64(&x469, &x470, x453, 0x2341f27177344); var x471: u64 = undefined; var x472: u64 = undefined; fiatP434MulxU64(&x471, &x472, x453, 0x6cfc5fd681c52056); var x473: u64 = undefined; var x474: u64 = undefined; fiatP434MulxU64(&x473, &x474, x453, 0x7bc65c783158aea3); var x475: u64 = undefined; var x476: u64 = undefined; fiatP434MulxU64(&x475, &x476, x453, 0xfdc1767ae2ffffff); var x477: u64 = undefined; var x478: u64 = undefined; fiatP434MulxU64(&x477, &x478, x453, 0xffffffffffffffff); var x479: u64 = undefined; var x480: u64 = undefined; fiatP434MulxU64(&x479, &x480, x453, 0xffffffffffffffff); var x481: u64 = undefined; var x482: u64 = undefined; fiatP434MulxU64(&x481, &x482, x453, 0xffffffffffffffff); var x483: u64 = undefined; var x484: u1 = undefined; fiatP434AddcarryxU64(&x483, &x484, 0x0, x482, x479); var x485: u64 = undefined; var x486: u1 = undefined; fiatP434AddcarryxU64(&x485, &x486, x484, x480, x477); var x487: u64 = undefined; var x488: u1 = undefined; fiatP434AddcarryxU64(&x487, &x488, x486, x478, x475); var x489: u64 = undefined; var x490: u1 = undefined; fiatP434AddcarryxU64(&x489, &x490, x488, x476, x473); var x491: u64 = undefined; var x492: u1 = undefined; fiatP434AddcarryxU64(&x491, &x492, x490, x474, x471); var x493: u64 = undefined; var x494: u1 = undefined; fiatP434AddcarryxU64(&x493, &x494, x492, x472, x469); const x495: u64 = (@intCast(u64, x494) + x470); var x496: u64 = undefined; var x497: u1 = undefined; fiatP434AddcarryxU64(&x496, &x497, 0x0, x453, x481); var x498: u64 = undefined; var x499: u1 = undefined; fiatP434AddcarryxU64(&x498, &x499, x497, x455, x483); var x500: u64 = undefined; var x501: u1 = undefined; fiatP434AddcarryxU64(&x500, &x501, x499, x457, x485); var x502: u64 = undefined; var x503: u1 = undefined; fiatP434AddcarryxU64(&x502, &x503, x501, x459, x487); var x504: u64 = undefined; var x505: u1 = undefined; fiatP434AddcarryxU64(&x504, &x505, x503, x461, x489); var x506: u64 = undefined; var x507: u1 = undefined; fiatP434AddcarryxU64(&x506, &x507, x505, x463, x491); var x508: u64 = undefined; var x509: u1 = undefined; fiatP434AddcarryxU64(&x508, &x509, x507, x465, x493); var x510: u64 = undefined; var x511: u1 = undefined; fiatP434AddcarryxU64(&x510, &x511, x509, x467, x495); const x512: u64 = (@intCast(u64, x511) + @intCast(u64, x468)); var x513: u64 = undefined; var x514: u64 = undefined; fiatP434MulxU64(&x513, &x514, x6, (arg2[6])); var x515: u64 = undefined; var x516: u64 = undefined; fiatP434MulxU64(&x515, &x516, x6, (arg2[5])); var x517: u64 = undefined; var x518: u64 = undefined; fiatP434MulxU64(&x517, &x518, x6, (arg2[4])); var x519: u64 = undefined; var x520: u64 = undefined; fiatP434MulxU64(&x519, &x520, x6, (arg2[3])); var x521: u64 = undefined; var x522: u64 = undefined; fiatP434MulxU64(&x521, &x522, x6, (arg2[2])); var x523: u64 = undefined; var x524: u64 = undefined; fiatP434MulxU64(&x523, &x524, x6, (arg2[1])); var x525: u64 = undefined; var x526: u64 = undefined; fiatP434MulxU64(&x525, &x526, x6, (arg2[0])); var x527: u64 = undefined; var x528: u1 = undefined; fiatP434AddcarryxU64(&x527, &x528, 0x0, x526, x523); var x529: u64 = undefined; var x530: u1 = undefined; fiatP434AddcarryxU64(&x529, &x530, x528, x524, x521); var x531: u64 = undefined; var x532: u1 = undefined; fiatP434AddcarryxU64(&x531, &x532, x530, x522, x519); var x533: u64 = undefined; var x534: u1 = undefined; fiatP434AddcarryxU64(&x533, &x534, x532, x520, x517); var x535: u64 = undefined; var x536: u1 = undefined; fiatP434AddcarryxU64(&x535, &x536, x534, x518, x515); var x537: u64 = undefined; var x538: u1 = undefined; fiatP434AddcarryxU64(&x537, &x538, x536, x516, x513); const x539: u64 = (@intCast(u64, x538) + x514); var x540: u64 = undefined; var x541: u1 = undefined; fiatP434AddcarryxU64(&x540, &x541, 0x0, x498, x525); var x542: u64 = undefined; var x543: u1 = undefined; fiatP434AddcarryxU64(&x542, &x543, x541, x500, x527); var x544: u64 = undefined; var x545: u1 = undefined; fiatP434AddcarryxU64(&x544, &x545, x543, x502, x529); var x546: u64 = undefined; var x547: u1 = undefined; fiatP434AddcarryxU64(&x546, &x547, x545, x504, x531); var x548: u64 = undefined; var x549: u1 = undefined; fiatP434AddcarryxU64(&x548, &x549, x547, x506, x533); var x550: u64 = undefined; var x551: u1 = undefined; fiatP434AddcarryxU64(&x550, &x551, x549, x508, x535); var x552: u64 = undefined; var x553: u1 = undefined; fiatP434AddcarryxU64(&x552, &x553, x551, x510, x537); var x554: u64 = undefined; var x555: u1 = undefined; fiatP434AddcarryxU64(&x554, &x555, x553, x512, x539); var x556: u64 = undefined; var x557: u64 = undefined; fiatP434MulxU64(&x556, &x557, x540, 0x2341f27177344); var x558: u64 = undefined; var x559: u64 = undefined; fiatP434MulxU64(&x558, &x559, x540, 0x6cfc5fd681c52056); var x560: u64 = undefined; var x561: u64 = undefined; fiatP434MulxU64(&x560, &x561, x540, 0x7bc65c783158aea3); var x562: u64 = undefined; var x563: u64 = undefined; fiatP434MulxU64(&x562, &x563, x540, 0xfdc1767ae2ffffff); var x564: u64 = undefined; var x565: u64 = undefined; fiatP434MulxU64(&x564, &x565, x540, 0xffffffffffffffff); var x566: u64 = undefined; var x567: u64 = undefined; fiatP434MulxU64(&x566, &x567, x540, 0xffffffffffffffff); var x568: u64 = undefined; var x569: u64 = undefined; fiatP434MulxU64(&x568, &x569, x540, 0xffffffffffffffff); var x570: u64 = undefined; var x571: u1 = undefined; fiatP434AddcarryxU64(&x570, &x571, 0x0, x569, x566); var x572: u64 = undefined; var x573: u1 = undefined; fiatP434AddcarryxU64(&x572, &x573, x571, x567, x564); var x574: u64 = undefined; var x575: u1 = undefined; fiatP434AddcarryxU64(&x574, &x575, x573, x565, x562); var x576: u64 = undefined; var x577: u1 = undefined; fiatP434AddcarryxU64(&x576, &x577, x575, x563, x560); var x578: u64 = undefined; var x579: u1 = undefined; fiatP434AddcarryxU64(&x578, &x579, x577, x561, x558); var x580: u64 = undefined; var x581: u1 = undefined; fiatP434AddcarryxU64(&x580, &x581, x579, x559, x556); const x582: u64 = (@intCast(u64, x581) + x557); var x583: u64 = undefined; var x584: u1 = undefined; fiatP434AddcarryxU64(&x583, &x584, 0x0, x540, x568); var x585: u64 = undefined; var x586: u1 = undefined; fiatP434AddcarryxU64(&x585, &x586, x584, x542, x570); var x587: u64 = undefined; var x588: u1 = undefined; fiatP434AddcarryxU64(&x587, &x588, x586, x544, x572); var x589: u64 = undefined; var x590: u1 = undefined; fiatP434AddcarryxU64(&x589, &x590, x588, x546, x574); var x591: u64 = undefined; var x592: u1 = undefined; fiatP434AddcarryxU64(&x591, &x592, x590, x548, x576); var x593: u64 = undefined; var x594: u1 = undefined; fiatP434AddcarryxU64(&x593, &x594, x592, x550, x578); var x595: u64 = undefined; var x596: u1 = undefined; fiatP434AddcarryxU64(&x595, &x596, x594, x552, x580); var x597: u64 = undefined; var x598: u1 = undefined; fiatP434AddcarryxU64(&x597, &x598, x596, x554, x582); const x599: u64 = (@intCast(u64, x598) + @intCast(u64, x555)); var x600: u64 = undefined; var x601: u1 = undefined; fiatP434SubborrowxU64(&x600, &x601, 0x0, x585, 0xffffffffffffffff); var x602: u64 = undefined; var x603: u1 = undefined; fiatP434SubborrowxU64(&x602, &x603, x601, x587, 0xffffffffffffffff); var x604: u64 = undefined; var x605: u1 = undefined; fiatP434SubborrowxU64(&x604, &x605, x603, x589, 0xffffffffffffffff); var x606: u64 = undefined; var x607: u1 = undefined; fiatP434SubborrowxU64(&x606, &x607, x605, x591, 0xfdc1767ae2ffffff); var x608: u64 = undefined; var x609: u1 = undefined; fiatP434SubborrowxU64(&x608, &x609, x607, x593, 0x7bc65c783158aea3); var x610: u64 = undefined; var x611: u1 = undefined; fiatP434SubborrowxU64(&x610, &x611, x609, x595, 0x6cfc5fd681c52056); var x612: u64 = undefined; var x613: u1 = undefined; fiatP434SubborrowxU64(&x612, &x613, x611, x597, 0x2341f27177344); var x614: u64 = undefined; var x615: u1 = undefined; fiatP434SubborrowxU64(&x614, &x615, x613, x599, @intCast(u64, 0x0)); var x616: u64 = undefined; fiatP434CmovznzU64(&x616, x615, x600, x585); var x617: u64 = undefined; fiatP434CmovznzU64(&x617, x615, x602, x587); var x618: u64 = undefined; fiatP434CmovznzU64(&x618, x615, x604, x589); var x619: u64 = undefined; fiatP434CmovznzU64(&x619, x615, x606, x591); var x620: u64 = undefined; fiatP434CmovznzU64(&x620, x615, x608, x593); var x621: u64 = undefined; fiatP434CmovznzU64(&x621, x615, x610, x595); var x622: u64 = undefined; fiatP434CmovznzU64(&x622, x615, x612, x597); out1[0] = x616; out1[1] = x617; out1[2] = x618; out1[3] = x619; out1[4] = x620; out1[5] = x621; out1[6] = x622; } /// The function fiatP434Square squares a field element in the Montgomery domain. /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434Square(out1: *[7]u64, arg1: [7]u64) void { const x1: u64 = (arg1[1]); const x2: u64 = (arg1[2]); const x3: u64 = (arg1[3]); const x4: u64 = (arg1[4]); const x5: u64 = (arg1[5]); const x6: u64 = (arg1[6]); const x7: u64 = (arg1[0]); var x8: u64 = undefined; var x9: u64 = undefined; fiatP434MulxU64(&x8, &x9, x7, (arg1[6])); var x10: u64 = undefined; var x11: u64 = undefined; fiatP434MulxU64(&x10, &x11, x7, (arg1[5])); var x12: u64 = undefined; var x13: u64 = undefined; fiatP434MulxU64(&x12, &x13, x7, (arg1[4])); var x14: u64 = undefined; var x15: u64 = undefined; fiatP434MulxU64(&x14, &x15, x7, (arg1[3])); var x16: u64 = undefined; var x17: u64 = undefined; fiatP434MulxU64(&x16, &x17, x7, (arg1[2])); var x18: u64 = undefined; var x19: u64 = undefined; fiatP434MulxU64(&x18, &x19, x7, (arg1[1])); var x20: u64 = undefined; var x21: u64 = undefined; fiatP434MulxU64(&x20, &x21, x7, (arg1[0])); var x22: u64 = undefined; var x23: u1 = undefined; fiatP434AddcarryxU64(&x22, &x23, 0x0, x21, x18); var x24: u64 = undefined; var x25: u1 = undefined; fiatP434AddcarryxU64(&x24, &x25, x23, x19, x16); var x26: u64 = undefined; var x27: u1 = undefined; fiatP434AddcarryxU64(&x26, &x27, x25, x17, x14); var x28: u64 = undefined; var x29: u1 = undefined; fiatP434AddcarryxU64(&x28, &x29, x27, x15, x12); var x30: u64 = undefined; var x31: u1 = undefined; fiatP434AddcarryxU64(&x30, &x31, x29, x13, x10); var x32: u64 = undefined; var x33: u1 = undefined; fiatP434AddcarryxU64(&x32, &x33, x31, x11, x8); const x34: u64 = (@intCast(u64, x33) + x9); var x35: u64 = undefined; var x36: u64 = undefined; fiatP434MulxU64(&x35, &x36, x20, 0x2341f27177344); var x37: u64 = undefined; var x38: u64 = undefined; fiatP434MulxU64(&x37, &x38, x20, 0x6cfc5fd681c52056); var x39: u64 = undefined; var x40: u64 = undefined; fiatP434MulxU64(&x39, &x40, x20, 0x7bc65c783158aea3); var x41: u64 = undefined; var x42: u64 = undefined; fiatP434MulxU64(&x41, &x42, x20, 0xfdc1767ae2ffffff); var x43: u64 = undefined; var x44: u64 = undefined; fiatP434MulxU64(&x43, &x44, x20, 0xffffffffffffffff); var x45: u64 = undefined; var x46: u64 = undefined; fiatP434MulxU64(&x45, &x46, x20, 0xffffffffffffffff); var x47: u64 = undefined; var x48: u64 = undefined; fiatP434MulxU64(&x47, &x48, x20, 0xffffffffffffffff); var x49: u64 = undefined; var x50: u1 = undefined; fiatP434AddcarryxU64(&x49, &x50, 0x0, x48, x45); var x51: u64 = undefined; var x52: u1 = undefined; fiatP434AddcarryxU64(&x51, &x52, x50, x46, x43); var x53: u64 = undefined; var x54: u1 = undefined; fiatP434AddcarryxU64(&x53, &x54, x52, x44, x41); var x55: u64 = undefined; var x56: u1 = undefined; fiatP434AddcarryxU64(&x55, &x56, x54, x42, x39); var x57: u64 = undefined; var x58: u1 = undefined; fiatP434AddcarryxU64(&x57, &x58, x56, x40, x37); var x59: u64 = undefined; var x60: u1 = undefined; fiatP434AddcarryxU64(&x59, &x60, x58, x38, x35); const x61: u64 = (@intCast(u64, x60) + x36); var x62: u64 = undefined; var x63: u1 = undefined; fiatP434AddcarryxU64(&x62, &x63, 0x0, x20, x47); var x64: u64 = undefined; var x65: u1 = undefined; fiatP434AddcarryxU64(&x64, &x65, x63, x22, x49); var x66: u64 = undefined; var x67: u1 = undefined; fiatP434AddcarryxU64(&x66, &x67, x65, x24, x51); var x68: u64 = undefined; var x69: u1 = undefined; fiatP434AddcarryxU64(&x68, &x69, x67, x26, x53); var x70: u64 = undefined; var x71: u1 = undefined; fiatP434AddcarryxU64(&x70, &x71, x69, x28, x55); var x72: u64 = undefined; var x73: u1 = undefined; fiatP434AddcarryxU64(&x72, &x73, x71, x30, x57); var x74: u64 = undefined; var x75: u1 = undefined; fiatP434AddcarryxU64(&x74, &x75, x73, x32, x59); var x76: u64 = undefined; var x77: u1 = undefined; fiatP434AddcarryxU64(&x76, &x77, x75, x34, x61); var x78: u64 = undefined; var x79: u64 = undefined; fiatP434MulxU64(&x78, &x79, x1, (arg1[6])); var x80: u64 = undefined; var x81: u64 = undefined; fiatP434MulxU64(&x80, &x81, x1, (arg1[5])); var x82: u64 = undefined; var x83: u64 = undefined; fiatP434MulxU64(&x82, &x83, x1, (arg1[4])); var x84: u64 = undefined; var x85: u64 = undefined; fiatP434MulxU64(&x84, &x85, x1, (arg1[3])); var x86: u64 = undefined; var x87: u64 = undefined; fiatP434MulxU64(&x86, &x87, x1, (arg1[2])); var x88: u64 = undefined; var x89: u64 = undefined; fiatP434MulxU64(&x88, &x89, x1, (arg1[1])); var x90: u64 = undefined; var x91: u64 = undefined; fiatP434MulxU64(&x90, &x91, x1, (arg1[0])); var x92: u64 = undefined; var x93: u1 = undefined; fiatP434AddcarryxU64(&x92, &x93, 0x0, x91, x88); var x94: u64 = undefined; var x95: u1 = undefined; fiatP434AddcarryxU64(&x94, &x95, x93, x89, x86); var x96: u64 = undefined; var x97: u1 = undefined; fiatP434AddcarryxU64(&x96, &x97, x95, x87, x84); var x98: u64 = undefined; var x99: u1 = undefined; fiatP434AddcarryxU64(&x98, &x99, x97, x85, x82); var x100: u64 = undefined; var x101: u1 = undefined; fiatP434AddcarryxU64(&x100, &x101, x99, x83, x80); var x102: u64 = undefined; var x103: u1 = undefined; fiatP434AddcarryxU64(&x102, &x103, x101, x81, x78); const x104: u64 = (@intCast(u64, x103) + x79); var x105: u64 = undefined; var x106: u1 = undefined; fiatP434AddcarryxU64(&x105, &x106, 0x0, x64, x90); var x107: u64 = undefined; var x108: u1 = undefined; fiatP434AddcarryxU64(&x107, &x108, x106, x66, x92); var x109: u64 = undefined; var x110: u1 = undefined; fiatP434AddcarryxU64(&x109, &x110, x108, x68, x94); var x111: u64 = undefined; var x112: u1 = undefined; fiatP434AddcarryxU64(&x111, &x112, x110, x70, x96); var x113: u64 = undefined; var x114: u1 = undefined; fiatP434AddcarryxU64(&x113, &x114, x112, x72, x98); var x115: u64 = undefined; var x116: u1 = undefined; fiatP434AddcarryxU64(&x115, &x116, x114, x74, x100); var x117: u64 = undefined; var x118: u1 = undefined; fiatP434AddcarryxU64(&x117, &x118, x116, x76, x102); var x119: u64 = undefined; var x120: u1 = undefined; fiatP434AddcarryxU64(&x119, &x120, x118, @intCast(u64, x77), x104); var x121: u64 = undefined; var x122: u64 = undefined; fiatP434MulxU64(&x121, &x122, x105, 0x2341f27177344); var x123: u64 = undefined; var x124: u64 = undefined; fiatP434MulxU64(&x123, &x124, x105, 0x6cfc5fd681c52056); var x125: u64 = undefined; var x126: u64 = undefined; fiatP434MulxU64(&x125, &x126, x105, 0x7bc65c783158aea3); var x127: u64 = undefined; var x128: u64 = undefined; fiatP434MulxU64(&x127, &x128, x105, 0xfdc1767ae2ffffff); var x129: u64 = undefined; var x130: u64 = undefined; fiatP434MulxU64(&x129, &x130, x105, 0xffffffffffffffff); var x131: u64 = undefined; var x132: u64 = undefined; fiatP434MulxU64(&x131, &x132, x105, 0xffffffffffffffff); var x133: u64 = undefined; var x134: u64 = undefined; fiatP434MulxU64(&x133, &x134, x105, 0xffffffffffffffff); var x135: u64 = undefined; var x136: u1 = undefined; fiatP434AddcarryxU64(&x135, &x136, 0x0, x134, x131); var x137: u64 = undefined; var x138: u1 = undefined; fiatP434AddcarryxU64(&x137, &x138, x136, x132, x129); var x139: u64 = undefined; var x140: u1 = undefined; fiatP434AddcarryxU64(&x139, &x140, x138, x130, x127); var x141: u64 = undefined; var x142: u1 = undefined; fiatP434AddcarryxU64(&x141, &x142, x140, x128, x125); var x143: u64 = undefined; var x144: u1 = undefined; fiatP434AddcarryxU64(&x143, &x144, x142, x126, x123); var x145: u64 = undefined; var x146: u1 = undefined; fiatP434AddcarryxU64(&x145, &x146, x144, x124, x121); const x147: u64 = (@intCast(u64, x146) + x122); var x148: u64 = undefined; var x149: u1 = undefined; fiatP434AddcarryxU64(&x148, &x149, 0x0, x105, x133); var x150: u64 = undefined; var x151: u1 = undefined; fiatP434AddcarryxU64(&x150, &x151, x149, x107, x135); var x152: u64 = undefined; var x153: u1 = undefined; fiatP434AddcarryxU64(&x152, &x153, x151, x109, x137); var x154: u64 = undefined; var x155: u1 = undefined; fiatP434AddcarryxU64(&x154, &x155, x153, x111, x139); var x156: u64 = undefined; var x157: u1 = undefined; fiatP434AddcarryxU64(&x156, &x157, x155, x113, x141); var x158: u64 = undefined; var x159: u1 = undefined; fiatP434AddcarryxU64(&x158, &x159, x157, x115, x143); var x160: u64 = undefined; var x161: u1 = undefined; fiatP434AddcarryxU64(&x160, &x161, x159, x117, x145); var x162: u64 = undefined; var x163: u1 = undefined; fiatP434AddcarryxU64(&x162, &x163, x161, x119, x147); const x164: u64 = (@intCast(u64, x163) + @intCast(u64, x120)); var x165: u64 = undefined; var x166: u64 = undefined; fiatP434MulxU64(&x165, &x166, x2, (arg1[6])); var x167: u64 = undefined; var x168: u64 = undefined; fiatP434MulxU64(&x167, &x168, x2, (arg1[5])); var x169: u64 = undefined; var x170: u64 = undefined; fiatP434MulxU64(&x169, &x170, x2, (arg1[4])); var x171: u64 = undefined; var x172: u64 = undefined; fiatP434MulxU64(&x171, &x172, x2, (arg1[3])); var x173: u64 = undefined; var x174: u64 = undefined; fiatP434MulxU64(&x173, &x174, x2, (arg1[2])); var x175: u64 = undefined; var x176: u64 = undefined; fiatP434MulxU64(&x175, &x176, x2, (arg1[1])); var x177: u64 = undefined; var x178: u64 = undefined; fiatP434MulxU64(&x177, &x178, x2, (arg1[0])); var x179: u64 = undefined; var x180: u1 = undefined; fiatP434AddcarryxU64(&x179, &x180, 0x0, x178, x175); var x181: u64 = undefined; var x182: u1 = undefined; fiatP434AddcarryxU64(&x181, &x182, x180, x176, x173); var x183: u64 = undefined; var x184: u1 = undefined; fiatP434AddcarryxU64(&x183, &x184, x182, x174, x171); var x185: u64 = undefined; var x186: u1 = undefined; fiatP434AddcarryxU64(&x185, &x186, x184, x172, x169); var x187: u64 = undefined; var x188: u1 = undefined; fiatP434AddcarryxU64(&x187, &x188, x186, x170, x167); var x189: u64 = undefined; var x190: u1 = undefined; fiatP434AddcarryxU64(&x189, &x190, x188, x168, x165); const x191: u64 = (@intCast(u64, x190) + x166); var x192: u64 = undefined; var x193: u1 = undefined; fiatP434AddcarryxU64(&x192, &x193, 0x0, x150, x177); var x194: u64 = undefined; var x195: u1 = undefined; fiatP434AddcarryxU64(&x194, &x195, x193, x152, x179); var x196: u64 = undefined; var x197: u1 = undefined; fiatP434AddcarryxU64(&x196, &x197, x195, x154, x181); var x198: u64 = undefined; var x199: u1 = undefined; fiatP434AddcarryxU64(&x198, &x199, x197, x156, x183); var x200: u64 = undefined; var x201: u1 = undefined; fiatP434AddcarryxU64(&x200, &x201, x199, x158, x185); var x202: u64 = undefined; var x203: u1 = undefined; fiatP434AddcarryxU64(&x202, &x203, x201, x160, x187); var x204: u64 = undefined; var x205: u1 = undefined; fiatP434AddcarryxU64(&x204, &x205, x203, x162, x189); var x206: u64 = undefined; var x207: u1 = undefined; fiatP434AddcarryxU64(&x206, &x207, x205, x164, x191); var x208: u64 = undefined; var x209: u64 = undefined; fiatP434MulxU64(&x208, &x209, x192, 0x2341f27177344); var x210: u64 = undefined; var x211: u64 = undefined; fiatP434MulxU64(&x210, &x211, x192, 0x6cfc5fd681c52056); var x212: u64 = undefined; var x213: u64 = undefined; fiatP434MulxU64(&x212, &x213, x192, 0x7bc65c783158aea3); var x214: u64 = undefined; var x215: u64 = undefined; fiatP434MulxU64(&x214, &x215, x192, 0xfdc1767ae2ffffff); var x216: u64 = undefined; var x217: u64 = undefined; fiatP434MulxU64(&x216, &x217, x192, 0xffffffffffffffff); var x218: u64 = undefined; var x219: u64 = undefined; fiatP434MulxU64(&x218, &x219, x192, 0xffffffffffffffff); var x220: u64 = undefined; var x221: u64 = undefined; fiatP434MulxU64(&x220, &x221, x192, 0xffffffffffffffff); var x222: u64 = undefined; var x223: u1 = undefined; fiatP434AddcarryxU64(&x222, &x223, 0x0, x221, x218); var x224: u64 = undefined; var x225: u1 = undefined; fiatP434AddcarryxU64(&x224, &x225, x223, x219, x216); var x226: u64 = undefined; var x227: u1 = undefined; fiatP434AddcarryxU64(&x226, &x227, x225, x217, x214); var x228: u64 = undefined; var x229: u1 = undefined; fiatP434AddcarryxU64(&x228, &x229, x227, x215, x212); var x230: u64 = undefined; var x231: u1 = undefined; fiatP434AddcarryxU64(&x230, &x231, x229, x213, x210); var x232: u64 = undefined; var x233: u1 = undefined; fiatP434AddcarryxU64(&x232, &x233, x231, x211, x208); const x234: u64 = (@intCast(u64, x233) + x209); var x235: u64 = undefined; var x236: u1 = undefined; fiatP434AddcarryxU64(&x235, &x236, 0x0, x192, x220); var x237: u64 = undefined; var x238: u1 = undefined; fiatP434AddcarryxU64(&x237, &x238, x236, x194, x222); var x239: u64 = undefined; var x240: u1 = undefined; fiatP434AddcarryxU64(&x239, &x240, x238, x196, x224); var x241: u64 = undefined; var x242: u1 = undefined; fiatP434AddcarryxU64(&x241, &x242, x240, x198, x226); var x243: u64 = undefined; var x244: u1 = undefined; fiatP434AddcarryxU64(&x243, &x244, x242, x200, x228); var x245: u64 = undefined; var x246: u1 = undefined; fiatP434AddcarryxU64(&x245, &x246, x244, x202, x230); var x247: u64 = undefined; var x248: u1 = undefined; fiatP434AddcarryxU64(&x247, &x248, x246, x204, x232); var x249: u64 = undefined; var x250: u1 = undefined; fiatP434AddcarryxU64(&x249, &x250, x248, x206, x234); const x251: u64 = (@intCast(u64, x250) + @intCast(u64, x207)); var x252: u64 = undefined; var x253: u64 = undefined; fiatP434MulxU64(&x252, &x253, x3, (arg1[6])); var x254: u64 = undefined; var x255: u64 = undefined; fiatP434MulxU64(&x254, &x255, x3, (arg1[5])); var x256: u64 = undefined; var x257: u64 = undefined; fiatP434MulxU64(&x256, &x257, x3, (arg1[4])); var x258: u64 = undefined; var x259: u64 = undefined; fiatP434MulxU64(&x258, &x259, x3, (arg1[3])); var x260: u64 = undefined; var x261: u64 = undefined; fiatP434MulxU64(&x260, &x261, x3, (arg1[2])); var x262: u64 = undefined; var x263: u64 = undefined; fiatP434MulxU64(&x262, &x263, x3, (arg1[1])); var x264: u64 = undefined; var x265: u64 = undefined; fiatP434MulxU64(&x264, &x265, x3, (arg1[0])); var x266: u64 = undefined; var x267: u1 = undefined; fiatP434AddcarryxU64(&x266, &x267, 0x0, x265, x262); var x268: u64 = undefined; var x269: u1 = undefined; fiatP434AddcarryxU64(&x268, &x269, x267, x263, x260); var x270: u64 = undefined; var x271: u1 = undefined; fiatP434AddcarryxU64(&x270, &x271, x269, x261, x258); var x272: u64 = undefined; var x273: u1 = undefined; fiatP434AddcarryxU64(&x272, &x273, x271, x259, x256); var x274: u64 = undefined; var x275: u1 = undefined; fiatP434AddcarryxU64(&x274, &x275, x273, x257, x254); var x276: u64 = undefined; var x277: u1 = undefined; fiatP434AddcarryxU64(&x276, &x277, x275, x255, x252); const x278: u64 = (@intCast(u64, x277) + x253); var x279: u64 = undefined; var x280: u1 = undefined; fiatP434AddcarryxU64(&x279, &x280, 0x0, x237, x264); var x281: u64 = undefined; var x282: u1 = undefined; fiatP434AddcarryxU64(&x281, &x282, x280, x239, x266); var x283: u64 = undefined; var x284: u1 = undefined; fiatP434AddcarryxU64(&x283, &x284, x282, x241, x268); var x285: u64 = undefined; var x286: u1 = undefined; fiatP434AddcarryxU64(&x285, &x286, x284, x243, x270); var x287: u64 = undefined; var x288: u1 = undefined; fiatP434AddcarryxU64(&x287, &x288, x286, x245, x272); var x289: u64 = undefined; var x290: u1 = undefined; fiatP434AddcarryxU64(&x289, &x290, x288, x247, x274); var x291: u64 = undefined; var x292: u1 = undefined; fiatP434AddcarryxU64(&x291, &x292, x290, x249, x276); var x293: u64 = undefined; var x294: u1 = undefined; fiatP434AddcarryxU64(&x293, &x294, x292, x251, x278); var x295: u64 = undefined; var x296: u64 = undefined; fiatP434MulxU64(&x295, &x296, x279, 0x2341f27177344); var x297: u64 = undefined; var x298: u64 = undefined; fiatP434MulxU64(&x297, &x298, x279, 0x6cfc5fd681c52056); var x299: u64 = undefined; var x300: u64 = undefined; fiatP434MulxU64(&x299, &x300, x279, 0x7bc65c783158aea3); var x301: u64 = undefined; var x302: u64 = undefined; fiatP434MulxU64(&x301, &x302, x279, 0xfdc1767ae2ffffff); var x303: u64 = undefined; var x304: u64 = undefined; fiatP434MulxU64(&x303, &x304, x279, 0xffffffffffffffff); var x305: u64 = undefined; var x306: u64 = undefined; fiatP434MulxU64(&x305, &x306, x279, 0xffffffffffffffff); var x307: u64 = undefined; var x308: u64 = undefined; fiatP434MulxU64(&x307, &x308, x279, 0xffffffffffffffff); var x309: u64 = undefined; var x310: u1 = undefined; fiatP434AddcarryxU64(&x309, &x310, 0x0, x308, x305); var x311: u64 = undefined; var x312: u1 = undefined; fiatP434AddcarryxU64(&x311, &x312, x310, x306, x303); var x313: u64 = undefined; var x314: u1 = undefined; fiatP434AddcarryxU64(&x313, &x314, x312, x304, x301); var x315: u64 = undefined; var x316: u1 = undefined; fiatP434AddcarryxU64(&x315, &x316, x314, x302, x299); var x317: u64 = undefined; var x318: u1 = undefined; fiatP434AddcarryxU64(&x317, &x318, x316, x300, x297); var x319: u64 = undefined; var x320: u1 = undefined; fiatP434AddcarryxU64(&x319, &x320, x318, x298, x295); const x321: u64 = (@intCast(u64, x320) + x296); var x322: u64 = undefined; var x323: u1 = undefined; fiatP434AddcarryxU64(&x322, &x323, 0x0, x279, x307); var x324: u64 = undefined; var x325: u1 = undefined; fiatP434AddcarryxU64(&x324, &x325, x323, x281, x309); var x326: u64 = undefined; var x327: u1 = undefined; fiatP434AddcarryxU64(&x326, &x327, x325, x283, x311); var x328: u64 = undefined; var x329: u1 = undefined; fiatP434AddcarryxU64(&x328, &x329, x327, x285, x313); var x330: u64 = undefined; var x331: u1 = undefined; fiatP434AddcarryxU64(&x330, &x331, x329, x287, x315); var x332: u64 = undefined; var x333: u1 = undefined; fiatP434AddcarryxU64(&x332, &x333, x331, x289, x317); var x334: u64 = undefined; var x335: u1 = undefined; fiatP434AddcarryxU64(&x334, &x335, x333, x291, x319); var x336: u64 = undefined; var x337: u1 = undefined; fiatP434AddcarryxU64(&x336, &x337, x335, x293, x321); const x338: u64 = (@intCast(u64, x337) + @intCast(u64, x294)); var x339: u64 = undefined; var x340: u64 = undefined; fiatP434MulxU64(&x339, &x340, x4, (arg1[6])); var x341: u64 = undefined; var x342: u64 = undefined; fiatP434MulxU64(&x341, &x342, x4, (arg1[5])); var x343: u64 = undefined; var x344: u64 = undefined; fiatP434MulxU64(&x343, &x344, x4, (arg1[4])); var x345: u64 = undefined; var x346: u64 = undefined; fiatP434MulxU64(&x345, &x346, x4, (arg1[3])); var x347: u64 = undefined; var x348: u64 = undefined; fiatP434MulxU64(&x347, &x348, x4, (arg1[2])); var x349: u64 = undefined; var x350: u64 = undefined; fiatP434MulxU64(&x349, &x350, x4, (arg1[1])); var x351: u64 = undefined; var x352: u64 = undefined; fiatP434MulxU64(&x351, &x352, x4, (arg1[0])); var x353: u64 = undefined; var x354: u1 = undefined; fiatP434AddcarryxU64(&x353, &x354, 0x0, x352, x349); var x355: u64 = undefined; var x356: u1 = undefined; fiatP434AddcarryxU64(&x355, &x356, x354, x350, x347); var x357: u64 = undefined; var x358: u1 = undefined; fiatP434AddcarryxU64(&x357, &x358, x356, x348, x345); var x359: u64 = undefined; var x360: u1 = undefined; fiatP434AddcarryxU64(&x359, &x360, x358, x346, x343); var x361: u64 = undefined; var x362: u1 = undefined; fiatP434AddcarryxU64(&x361, &x362, x360, x344, x341); var x363: u64 = undefined; var x364: u1 = undefined; fiatP434AddcarryxU64(&x363, &x364, x362, x342, x339); const x365: u64 = (@intCast(u64, x364) + x340); var x366: u64 = undefined; var x367: u1 = undefined; fiatP434AddcarryxU64(&x366, &x367, 0x0, x324, x351); var x368: u64 = undefined; var x369: u1 = undefined; fiatP434AddcarryxU64(&x368, &x369, x367, x326, x353); var x370: u64 = undefined; var x371: u1 = undefined; fiatP434AddcarryxU64(&x370, &x371, x369, x328, x355); var x372: u64 = undefined; var x373: u1 = undefined; fiatP434AddcarryxU64(&x372, &x373, x371, x330, x357); var x374: u64 = undefined; var x375: u1 = undefined; fiatP434AddcarryxU64(&x374, &x375, x373, x332, x359); var x376: u64 = undefined; var x377: u1 = undefined; fiatP434AddcarryxU64(&x376, &x377, x375, x334, x361); var x378: u64 = undefined; var x379: u1 = undefined; fiatP434AddcarryxU64(&x378, &x379, x377, x336, x363); var x380: u64 = undefined; var x381: u1 = undefined; fiatP434AddcarryxU64(&x380, &x381, x379, x338, x365); var x382: u64 = undefined; var x383: u64 = undefined; fiatP434MulxU64(&x382, &x383, x366, 0x2341f27177344); var x384: u64 = undefined; var x385: u64 = undefined; fiatP434MulxU64(&x384, &x385, x366, 0x6cfc5fd681c52056); var x386: u64 = undefined; var x387: u64 = undefined; fiatP434MulxU64(&x386, &x387, x366, 0x7bc65c783158aea3); var x388: u64 = undefined; var x389: u64 = undefined; fiatP434MulxU64(&x388, &x389, x366, 0xfdc1767ae2ffffff); var x390: u64 = undefined; var x391: u64 = undefined; fiatP434MulxU64(&x390, &x391, x366, 0xffffffffffffffff); var x392: u64 = undefined; var x393: u64 = undefined; fiatP434MulxU64(&x392, &x393, x366, 0xffffffffffffffff); var x394: u64 = undefined; var x395: u64 = undefined; fiatP434MulxU64(&x394, &x395, x366, 0xffffffffffffffff); var x396: u64 = undefined; var x397: u1 = undefined; fiatP434AddcarryxU64(&x396, &x397, 0x0, x395, x392); var x398: u64 = undefined; var x399: u1 = undefined; fiatP434AddcarryxU64(&x398, &x399, x397, x393, x390); var x400: u64 = undefined; var x401: u1 = undefined; fiatP434AddcarryxU64(&x400, &x401, x399, x391, x388); var x402: u64 = undefined; var x403: u1 = undefined; fiatP434AddcarryxU64(&x402, &x403, x401, x389, x386); var x404: u64 = undefined; var x405: u1 = undefined; fiatP434AddcarryxU64(&x404, &x405, x403, x387, x384); var x406: u64 = undefined; var x407: u1 = undefined; fiatP434AddcarryxU64(&x406, &x407, x405, x385, x382); const x408: u64 = (@intCast(u64, x407) + x383); var x409: u64 = undefined; var x410: u1 = undefined; fiatP434AddcarryxU64(&x409, &x410, 0x0, x366, x394); var x411: u64 = undefined; var x412: u1 = undefined; fiatP434AddcarryxU64(&x411, &x412, x410, x368, x396); var x413: u64 = undefined; var x414: u1 = undefined; fiatP434AddcarryxU64(&x413, &x414, x412, x370, x398); var x415: u64 = undefined; var x416: u1 = undefined; fiatP434AddcarryxU64(&x415, &x416, x414, x372, x400); var x417: u64 = undefined; var x418: u1 = undefined; fiatP434AddcarryxU64(&x417, &x418, x416, x374, x402); var x419: u64 = undefined; var x420: u1 = undefined; fiatP434AddcarryxU64(&x419, &x420, x418, x376, x404); var x421: u64 = undefined; var x422: u1 = undefined; fiatP434AddcarryxU64(&x421, &x422, x420, x378, x406); var x423: u64 = undefined; var x424: u1 = undefined; fiatP434AddcarryxU64(&x423, &x424, x422, x380, x408); const x425: u64 = (@intCast(u64, x424) + @intCast(u64, x381)); var x426: u64 = undefined; var x427: u64 = undefined; fiatP434MulxU64(&x426, &x427, x5, (arg1[6])); var x428: u64 = undefined; var x429: u64 = undefined; fiatP434MulxU64(&x428, &x429, x5, (arg1[5])); var x430: u64 = undefined; var x431: u64 = undefined; fiatP434MulxU64(&x430, &x431, x5, (arg1[4])); var x432: u64 = undefined; var x433: u64 = undefined; fiatP434MulxU64(&x432, &x433, x5, (arg1[3])); var x434: u64 = undefined; var x435: u64 = undefined; fiatP434MulxU64(&x434, &x435, x5, (arg1[2])); var x436: u64 = undefined; var x437: u64 = undefined; fiatP434MulxU64(&x436, &x437, x5, (arg1[1])); var x438: u64 = undefined; var x439: u64 = undefined; fiatP434MulxU64(&x438, &x439, x5, (arg1[0])); var x440: u64 = undefined; var x441: u1 = undefined; fiatP434AddcarryxU64(&x440, &x441, 0x0, x439, x436); var x442: u64 = undefined; var x443: u1 = undefined; fiatP434AddcarryxU64(&x442, &x443, x441, x437, x434); var x444: u64 = undefined; var x445: u1 = undefined; fiatP434AddcarryxU64(&x444, &x445, x443, x435, x432); var x446: u64 = undefined; var x447: u1 = undefined; fiatP434AddcarryxU64(&x446, &x447, x445, x433, x430); var x448: u64 = undefined; var x449: u1 = undefined; fiatP434AddcarryxU64(&x448, &x449, x447, x431, x428); var x450: u64 = undefined; var x451: u1 = undefined; fiatP434AddcarryxU64(&x450, &x451, x449, x429, x426); const x452: u64 = (@intCast(u64, x451) + x427); var x453: u64 = undefined; var x454: u1 = undefined; fiatP434AddcarryxU64(&x453, &x454, 0x0, x411, x438); var x455: u64 = undefined; var x456: u1 = undefined; fiatP434AddcarryxU64(&x455, &x456, x454, x413, x440); var x457: u64 = undefined; var x458: u1 = undefined; fiatP434AddcarryxU64(&x457, &x458, x456, x415, x442); var x459: u64 = undefined; var x460: u1 = undefined; fiatP434AddcarryxU64(&x459, &x460, x458, x417, x444); var x461: u64 = undefined; var x462: u1 = undefined; fiatP434AddcarryxU64(&x461, &x462, x460, x419, x446); var x463: u64 = undefined; var x464: u1 = undefined; fiatP434AddcarryxU64(&x463, &x464, x462, x421, x448); var x465: u64 = undefined; var x466: u1 = undefined; fiatP434AddcarryxU64(&x465, &x466, x464, x423, x450); var x467: u64 = undefined; var x468: u1 = undefined; fiatP434AddcarryxU64(&x467, &x468, x466, x425, x452); var x469: u64 = undefined; var x470: u64 = undefined; fiatP434MulxU64(&x469, &x470, x453, 0x2341f27177344); var x471: u64 = undefined; var x472: u64 = undefined; fiatP434MulxU64(&x471, &x472, x453, 0x6cfc5fd681c52056); var x473: u64 = undefined; var x474: u64 = undefined; fiatP434MulxU64(&x473, &x474, x453, 0x7bc65c783158aea3); var x475: u64 = undefined; var x476: u64 = undefined; fiatP434MulxU64(&x475, &x476, x453, 0xfdc1767ae2ffffff); var x477: u64 = undefined; var x478: u64 = undefined; fiatP434MulxU64(&x477, &x478, x453, 0xffffffffffffffff); var x479: u64 = undefined; var x480: u64 = undefined; fiatP434MulxU64(&x479, &x480, x453, 0xffffffffffffffff); var x481: u64 = undefined; var x482: u64 = undefined; fiatP434MulxU64(&x481, &x482, x453, 0xffffffffffffffff); var x483: u64 = undefined; var x484: u1 = undefined; fiatP434AddcarryxU64(&x483, &x484, 0x0, x482, x479); var x485: u64 = undefined; var x486: u1 = undefined; fiatP434AddcarryxU64(&x485, &x486, x484, x480, x477); var x487: u64 = undefined; var x488: u1 = undefined; fiatP434AddcarryxU64(&x487, &x488, x486, x478, x475); var x489: u64 = undefined; var x490: u1 = undefined; fiatP434AddcarryxU64(&x489, &x490, x488, x476, x473); var x491: u64 = undefined; var x492: u1 = undefined; fiatP434AddcarryxU64(&x491, &x492, x490, x474, x471); var x493: u64 = undefined; var x494: u1 = undefined; fiatP434AddcarryxU64(&x493, &x494, x492, x472, x469); const x495: u64 = (@intCast(u64, x494) + x470); var x496: u64 = undefined; var x497: u1 = undefined; fiatP434AddcarryxU64(&x496, &x497, 0x0, x453, x481); var x498: u64 = undefined; var x499: u1 = undefined; fiatP434AddcarryxU64(&x498, &x499, x497, x455, x483); var x500: u64 = undefined; var x501: u1 = undefined; fiatP434AddcarryxU64(&x500, &x501, x499, x457, x485); var x502: u64 = undefined; var x503: u1 = undefined; fiatP434AddcarryxU64(&x502, &x503, x501, x459, x487); var x504: u64 = undefined; var x505: u1 = undefined; fiatP434AddcarryxU64(&x504, &x505, x503, x461, x489); var x506: u64 = undefined; var x507: u1 = undefined; fiatP434AddcarryxU64(&x506, &x507, x505, x463, x491); var x508: u64 = undefined; var x509: u1 = undefined; fiatP434AddcarryxU64(&x508, &x509, x507, x465, x493); var x510: u64 = undefined; var x511: u1 = undefined; fiatP434AddcarryxU64(&x510, &x511, x509, x467, x495); const x512: u64 = (@intCast(u64, x511) + @intCast(u64, x468)); var x513: u64 = undefined; var x514: u64 = undefined; fiatP434MulxU64(&x513, &x514, x6, (arg1[6])); var x515: u64 = undefined; var x516: u64 = undefined; fiatP434MulxU64(&x515, &x516, x6, (arg1[5])); var x517: u64 = undefined; var x518: u64 = undefined; fiatP434MulxU64(&x517, &x518, x6, (arg1[4])); var x519: u64 = undefined; var x520: u64 = undefined; fiatP434MulxU64(&x519, &x520, x6, (arg1[3])); var x521: u64 = undefined; var x522: u64 = undefined; fiatP434MulxU64(&x521, &x522, x6, (arg1[2])); var x523: u64 = undefined; var x524: u64 = undefined; fiatP434MulxU64(&x523, &x524, x6, (arg1[1])); var x525: u64 = undefined; var x526: u64 = undefined; fiatP434MulxU64(&x525, &x526, x6, (arg1[0])); var x527: u64 = undefined; var x528: u1 = undefined; fiatP434AddcarryxU64(&x527, &x528, 0x0, x526, x523); var x529: u64 = undefined; var x530: u1 = undefined; fiatP434AddcarryxU64(&x529, &x530, x528, x524, x521); var x531: u64 = undefined; var x532: u1 = undefined; fiatP434AddcarryxU64(&x531, &x532, x530, x522, x519); var x533: u64 = undefined; var x534: u1 = undefined; fiatP434AddcarryxU64(&x533, &x534, x532, x520, x517); var x535: u64 = undefined; var x536: u1 = undefined; fiatP434AddcarryxU64(&x535, &x536, x534, x518, x515); var x537: u64 = undefined; var x538: u1 = undefined; fiatP434AddcarryxU64(&x537, &x538, x536, x516, x513); const x539: u64 = (@intCast(u64, x538) + x514); var x540: u64 = undefined; var x541: u1 = undefined; fiatP434AddcarryxU64(&x540, &x541, 0x0, x498, x525); var x542: u64 = undefined; var x543: u1 = undefined; fiatP434AddcarryxU64(&x542, &x543, x541, x500, x527); var x544: u64 = undefined; var x545: u1 = undefined; fiatP434AddcarryxU64(&x544, &x545, x543, x502, x529); var x546: u64 = undefined; var x547: u1 = undefined; fiatP434AddcarryxU64(&x546, &x547, x545, x504, x531); var x548: u64 = undefined; var x549: u1 = undefined; fiatP434AddcarryxU64(&x548, &x549, x547, x506, x533); var x550: u64 = undefined; var x551: u1 = undefined; fiatP434AddcarryxU64(&x550, &x551, x549, x508, x535); var x552: u64 = undefined; var x553: u1 = undefined; fiatP434AddcarryxU64(&x552, &x553, x551, x510, x537); var x554: u64 = undefined; var x555: u1 = undefined; fiatP434AddcarryxU64(&x554, &x555, x553, x512, x539); var x556: u64 = undefined; var x557: u64 = undefined; fiatP434MulxU64(&x556, &x557, x540, 0x2341f27177344); var x558: u64 = undefined; var x559: u64 = undefined; fiatP434MulxU64(&x558, &x559, x540, 0x6cfc5fd681c52056); var x560: u64 = undefined; var x561: u64 = undefined; fiatP434MulxU64(&x560, &x561, x540, 0x7bc65c783158aea3); var x562: u64 = undefined; var x563: u64 = undefined; fiatP434MulxU64(&x562, &x563, x540, 0xfdc1767ae2ffffff); var x564: u64 = undefined; var x565: u64 = undefined; fiatP434MulxU64(&x564, &x565, x540, 0xffffffffffffffff); var x566: u64 = undefined; var x567: u64 = undefined; fiatP434MulxU64(&x566, &x567, x540, 0xffffffffffffffff); var x568: u64 = undefined; var x569: u64 = undefined; fiatP434MulxU64(&x568, &x569, x540, 0xffffffffffffffff); var x570: u64 = undefined; var x571: u1 = undefined; fiatP434AddcarryxU64(&x570, &x571, 0x0, x569, x566); var x572: u64 = undefined; var x573: u1 = undefined; fiatP434AddcarryxU64(&x572, &x573, x571, x567, x564); var x574: u64 = undefined; var x575: u1 = undefined; fiatP434AddcarryxU64(&x574, &x575, x573, x565, x562); var x576: u64 = undefined; var x577: u1 = undefined; fiatP434AddcarryxU64(&x576, &x577, x575, x563, x560); var x578: u64 = undefined; var x579: u1 = undefined; fiatP434AddcarryxU64(&x578, &x579, x577, x561, x558); var x580: u64 = undefined; var x581: u1 = undefined; fiatP434AddcarryxU64(&x580, &x581, x579, x559, x556); const x582: u64 = (@intCast(u64, x581) + x557); var x583: u64 = undefined; var x584: u1 = undefined; fiatP434AddcarryxU64(&x583, &x584, 0x0, x540, x568); var x585: u64 = undefined; var x586: u1 = undefined; fiatP434AddcarryxU64(&x585, &x586, x584, x542, x570); var x587: u64 = undefined; var x588: u1 = undefined; fiatP434AddcarryxU64(&x587, &x588, x586, x544, x572); var x589: u64 = undefined; var x590: u1 = undefined; fiatP434AddcarryxU64(&x589, &x590, x588, x546, x574); var x591: u64 = undefined; var x592: u1 = undefined; fiatP434AddcarryxU64(&x591, &x592, x590, x548, x576); var x593: u64 = undefined; var x594: u1 = undefined; fiatP434AddcarryxU64(&x593, &x594, x592, x550, x578); var x595: u64 = undefined; var x596: u1 = undefined; fiatP434AddcarryxU64(&x595, &x596, x594, x552, x580); var x597: u64 = undefined; var x598: u1 = undefined; fiatP434AddcarryxU64(&x597, &x598, x596, x554, x582); const x599: u64 = (@intCast(u64, x598) + @intCast(u64, x555)); var x600: u64 = undefined; var x601: u1 = undefined; fiatP434SubborrowxU64(&x600, &x601, 0x0, x585, 0xffffffffffffffff); var x602: u64 = undefined; var x603: u1 = undefined; fiatP434SubborrowxU64(&x602, &x603, x601, x587, 0xffffffffffffffff); var x604: u64 = undefined; var x605: u1 = undefined; fiatP434SubborrowxU64(&x604, &x605, x603, x589, 0xffffffffffffffff); var x606: u64 = undefined; var x607: u1 = undefined; fiatP434SubborrowxU64(&x606, &x607, x605, x591, 0xfdc1767ae2ffffff); var x608: u64 = undefined; var x609: u1 = undefined; fiatP434SubborrowxU64(&x608, &x609, x607, x593, 0x7bc65c783158aea3); var x610: u64 = undefined; var x611: u1 = undefined; fiatP434SubborrowxU64(&x610, &x611, x609, x595, 0x6cfc5fd681c52056); var x612: u64 = undefined; var x613: u1 = undefined; fiatP434SubborrowxU64(&x612, &x613, x611, x597, 0x2341f27177344); var x614: u64 = undefined; var x615: u1 = undefined; fiatP434SubborrowxU64(&x614, &x615, x613, x599, @intCast(u64, 0x0)); var x616: u64 = undefined; fiatP434CmovznzU64(&x616, x615, x600, x585); var x617: u64 = undefined; fiatP434CmovznzU64(&x617, x615, x602, x587); var x618: u64 = undefined; fiatP434CmovznzU64(&x618, x615, x604, x589); var x619: u64 = undefined; fiatP434CmovznzU64(&x619, x615, x606, x591); var x620: u64 = undefined; fiatP434CmovznzU64(&x620, x615, x608, x593); var x621: u64 = undefined; fiatP434CmovznzU64(&x621, x615, x610, x595); var x622: u64 = undefined; fiatP434CmovznzU64(&x622, x615, x612, x597); out1[0] = x616; out1[1] = x617; out1[2] = x618; out1[3] = x619; out1[4] = x620; out1[5] = x621; out1[6] = x622; } /// The function fiatP434Add adds two field elements in the Montgomery domain. /// Preconditions: /// 0 ≤ eval arg1 < m /// 0 ≤ eval arg2 < m /// Postconditions: /// eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434Add(out1: *[7]u64, arg1: [7]u64, arg2: [7]u64) void { var x1: u64 = undefined; var x2: u1 = undefined; fiatP434AddcarryxU64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); var x3: u64 = undefined; var x4: u1 = undefined; fiatP434AddcarryxU64(&x3, &x4, x2, (arg1[1]), (arg2[1])); var x5: u64 = undefined; var x6: u1 = undefined; fiatP434AddcarryxU64(&x5, &x6, x4, (arg1[2]), (arg2[2])); var x7: u64 = undefined; var x8: u1 = undefined; fiatP434AddcarryxU64(&x7, &x8, x6, (arg1[3]), (arg2[3])); var x9: u64 = undefined; var x10: u1 = undefined; fiatP434AddcarryxU64(&x9, &x10, x8, (arg1[4]), (arg2[4])); var x11: u64 = undefined; var x12: u1 = undefined; fiatP434AddcarryxU64(&x11, &x12, x10, (arg1[5]), (arg2[5])); var x13: u64 = undefined; var x14: u1 = undefined; fiatP434AddcarryxU64(&x13, &x14, x12, (arg1[6]), (arg2[6])); var x15: u64 = undefined; var x16: u1 = undefined; fiatP434SubborrowxU64(&x15, &x16, 0x0, x1, 0xffffffffffffffff); var x17: u64 = undefined; var x18: u1 = undefined; fiatP434SubborrowxU64(&x17, &x18, x16, x3, 0xffffffffffffffff); var x19: u64 = undefined; var x20: u1 = undefined; fiatP434SubborrowxU64(&x19, &x20, x18, x5, 0xffffffffffffffff); var x21: u64 = undefined; var x22: u1 = undefined; fiatP434SubborrowxU64(&x21, &x22, x20, x7, 0xfdc1767ae2ffffff); var x23: u64 = undefined; var x24: u1 = undefined; fiatP434SubborrowxU64(&x23, &x24, x22, x9, 0x7bc65c783158aea3); var x25: u64 = undefined; var x26: u1 = undefined; fiatP434SubborrowxU64(&x25, &x26, x24, x11, 0x6cfc5fd681c52056); var x27: u64 = undefined; var x28: u1 = undefined; fiatP434SubborrowxU64(&x27, &x28, x26, x13, 0x2341f27177344); var x29: u64 = undefined; var x30: u1 = undefined; fiatP434SubborrowxU64(&x29, &x30, x28, @intCast(u64, x14), @intCast(u64, 0x0)); var x31: u64 = undefined; fiatP434CmovznzU64(&x31, x30, x15, x1); var x32: u64 = undefined; fiatP434CmovznzU64(&x32, x30, x17, x3); var x33: u64 = undefined; fiatP434CmovznzU64(&x33, x30, x19, x5); var x34: u64 = undefined; fiatP434CmovznzU64(&x34, x30, x21, x7); var x35: u64 = undefined; fiatP434CmovznzU64(&x35, x30, x23, x9); var x36: u64 = undefined; fiatP434CmovznzU64(&x36, x30, x25, x11); var x37: u64 = undefined; fiatP434CmovznzU64(&x37, x30, x27, x13); out1[0] = x31; out1[1] = x32; out1[2] = x33; out1[3] = x34; out1[4] = x35; out1[5] = x36; out1[6] = x37; } /// The function fiatP434Sub subtracts two field elements in the Montgomery domain. /// Preconditions: /// 0 ≤ eval arg1 < m /// 0 ≤ eval arg2 < m /// Postconditions: /// eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434Sub(out1: *[7]u64, arg1: [7]u64, arg2: [7]u64) void { var x1: u64 = undefined; var x2: u1 = undefined; fiatP434SubborrowxU64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); var x3: u64 = undefined; var x4: u1 = undefined; fiatP434SubborrowxU64(&x3, &x4, x2, (arg1[1]), (arg2[1])); var x5: u64 = undefined; var x6: u1 = undefined; fiatP434SubborrowxU64(&x5, &x6, x4, (arg1[2]), (arg2[2])); var x7: u64 = undefined; var x8: u1 = undefined; fiatP434SubborrowxU64(&x7, &x8, x6, (arg1[3]), (arg2[3])); var x9: u64 = undefined; var x10: u1 = undefined; fiatP434SubborrowxU64(&x9, &x10, x8, (arg1[4]), (arg2[4])); var x11: u64 = undefined; var x12: u1 = undefined; fiatP434SubborrowxU64(&x11, &x12, x10, (arg1[5]), (arg2[5])); var x13: u64 = undefined; var x14: u1 = undefined; fiatP434SubborrowxU64(&x13, &x14, x12, (arg1[6]), (arg2[6])); var x15: u64 = undefined; fiatP434CmovznzU64(&x15, x14, @intCast(u64, 0x0), 0xffffffffffffffff); var x16: u64 = undefined; var x17: u1 = undefined; fiatP434AddcarryxU64(&x16, &x17, 0x0, x1, x15); var x18: u64 = undefined; var x19: u1 = undefined; fiatP434AddcarryxU64(&x18, &x19, x17, x3, x15); var x20: u64 = undefined; var x21: u1 = undefined; fiatP434AddcarryxU64(&x20, &x21, x19, x5, x15); var x22: u64 = undefined; var x23: u1 = undefined; fiatP434AddcarryxU64(&x22, &x23, x21, x7, (x15 & 0xfdc1767ae2ffffff)); var x24: u64 = undefined; var x25: u1 = undefined; fiatP434AddcarryxU64(&x24, &x25, x23, x9, (x15 & 0x7bc65c783158aea3)); var x26: u64 = undefined; var x27: u1 = undefined; fiatP434AddcarryxU64(&x26, &x27, x25, x11, (x15 & 0x6cfc5fd681c52056)); var x28: u64 = undefined; var x29: u1 = undefined; fiatP434AddcarryxU64(&x28, &x29, x27, x13, (x15 & 0x2341f27177344)); out1[0] = x16; out1[1] = x18; out1[2] = x20; out1[3] = x22; out1[4] = x24; out1[5] = x26; out1[6] = x28; } /// The function fiatP434Opp negates a field element in the Montgomery domain. /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434Opp(out1: *[7]u64, arg1: [7]u64) void { var x1: u64 = undefined; var x2: u1 = undefined; fiatP434SubborrowxU64(&x1, &x2, 0x0, @intCast(u64, 0x0), (arg1[0])); var x3: u64 = undefined; var x4: u1 = undefined; fiatP434SubborrowxU64(&x3, &x4, x2, @intCast(u64, 0x0), (arg1[1])); var x5: u64 = undefined; var x6: u1 = undefined; fiatP434SubborrowxU64(&x5, &x6, x4, @intCast(u64, 0x0), (arg1[2])); var x7: u64 = undefined; var x8: u1 = undefined; fiatP434SubborrowxU64(&x7, &x8, x6, @intCast(u64, 0x0), (arg1[3])); var x9: u64 = undefined; var x10: u1 = undefined; fiatP434SubborrowxU64(&x9, &x10, x8, @intCast(u64, 0x0), (arg1[4])); var x11: u64 = undefined; var x12: u1 = undefined; fiatP434SubborrowxU64(&x11, &x12, x10, @intCast(u64, 0x0), (arg1[5])); var x13: u64 = undefined; var x14: u1 = undefined; fiatP434SubborrowxU64(&x13, &x14, x12, @intCast(u64, 0x0), (arg1[6])); var x15: u64 = undefined; fiatP434CmovznzU64(&x15, x14, @intCast(u64, 0x0), 0xffffffffffffffff); var x16: u64 = undefined; var x17: u1 = undefined; fiatP434AddcarryxU64(&x16, &x17, 0x0, x1, x15); var x18: u64 = undefined; var x19: u1 = undefined; fiatP434AddcarryxU64(&x18, &x19, x17, x3, x15); var x20: u64 = undefined; var x21: u1 = undefined; fiatP434AddcarryxU64(&x20, &x21, x19, x5, x15); var x22: u64 = undefined; var x23: u1 = undefined; fiatP434AddcarryxU64(&x22, &x23, x21, x7, (x15 & 0xfdc1767ae2ffffff)); var x24: u64 = undefined; var x25: u1 = undefined; fiatP434AddcarryxU64(&x24, &x25, x23, x9, (x15 & 0x7bc65c783158aea3)); var x26: u64 = undefined; var x27: u1 = undefined; fiatP434AddcarryxU64(&x26, &x27, x25, x11, (x15 & 0x6cfc5fd681c52056)); var x28: u64 = undefined; var x29: u1 = undefined; fiatP434AddcarryxU64(&x28, &x29, x27, x13, (x15 & 0x2341f27177344)); out1[0] = x16; out1[1] = x18; out1[2] = x20; out1[3] = x22; out1[4] = x24; out1[5] = x26; out1[6] = x28; } /// The function fiatP434FromMontgomery translates a field element out of the Montgomery domain. /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// eval out1 mod m = (eval arg1 * ((2^64)⁻¹ mod m)^7) mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434FromMontgomery(out1: *[7]u64, arg1: [7]u64) void { const x1: u64 = (arg1[0]); var x2: u64 = undefined; var x3: u64 = undefined; fiatP434MulxU64(&x2, &x3, x1, 0x2341f27177344); var x4: u64 = undefined; var x5: u64 = undefined; fiatP434MulxU64(&x4, &x5, x1, 0x6cfc5fd681c52056); var x6: u64 = undefined; var x7: u64 = undefined; fiatP434MulxU64(&x6, &x7, x1, 0x7bc65c783158aea3); var x8: u64 = undefined; var x9: u64 = undefined; fiatP434MulxU64(&x8, &x9, x1, 0xfdc1767ae2ffffff); var x10: u64 = undefined; var x11: u64 = undefined; fiatP434MulxU64(&x10, &x11, x1, 0xffffffffffffffff); var x12: u64 = undefined; var x13: u64 = undefined; fiatP434MulxU64(&x12, &x13, x1, 0xffffffffffffffff); var x14: u64 = undefined; var x15: u64 = undefined; fiatP434MulxU64(&x14, &x15, x1, 0xffffffffffffffff); var x16: u64 = undefined; var x17: u1 = undefined; fiatP434AddcarryxU64(&x16, &x17, 0x0, x15, x12); var x18: u64 = undefined; var x19: u1 = undefined; fiatP434AddcarryxU64(&x18, &x19, x17, x13, x10); var x20: u64 = undefined; var x21: u1 = undefined; fiatP434AddcarryxU64(&x20, &x21, x19, x11, x8); var x22: u64 = undefined; var x23: u1 = undefined; fiatP434AddcarryxU64(&x22, &x23, x21, x9, x6); var x24: u64 = undefined; var x25: u1 = undefined; fiatP434AddcarryxU64(&x24, &x25, x23, x7, x4); var x26: u64 = undefined; var x27: u1 = undefined; fiatP434AddcarryxU64(&x26, &x27, x25, x5, x2); var x28: u64 = undefined; var x29: u1 = undefined; fiatP434AddcarryxU64(&x28, &x29, 0x0, x1, x14); var x30: u64 = undefined; var x31: u1 = undefined; fiatP434AddcarryxU64(&x30, &x31, x29, @intCast(u64, 0x0), x16); var x32: u64 = undefined; var x33: u1 = undefined; fiatP434AddcarryxU64(&x32, &x33, x31, @intCast(u64, 0x0), x18); var x34: u64 = undefined; var x35: u1 = undefined; fiatP434AddcarryxU64(&x34, &x35, x33, @intCast(u64, 0x0), x20); var x36: u64 = undefined; var x37: u1 = undefined; fiatP434AddcarryxU64(&x36, &x37, x35, @intCast(u64, 0x0), x22); var x38: u64 = undefined; var x39: u1 = undefined; fiatP434AddcarryxU64(&x38, &x39, x37, @intCast(u64, 0x0), x24); var x40: u64 = undefined; var x41: u1 = undefined; fiatP434AddcarryxU64(&x40, &x41, x39, @intCast(u64, 0x0), x26); var x42: u64 = undefined; var x43: u1 = undefined; fiatP434AddcarryxU64(&x42, &x43, 0x0, x30, (arg1[1])); var x44: u64 = undefined; var x45: u1 = undefined; fiatP434AddcarryxU64(&x44, &x45, x43, x32, @intCast(u64, 0x0)); var x46: u64 = undefined; var x47: u1 = undefined; fiatP434AddcarryxU64(&x46, &x47, x45, x34, @intCast(u64, 0x0)); var x48: u64 = undefined; var x49: u1 = undefined; fiatP434AddcarryxU64(&x48, &x49, x47, x36, @intCast(u64, 0x0)); var x50: u64 = undefined; var x51: u1 = undefined; fiatP434AddcarryxU64(&x50, &x51, x49, x38, @intCast(u64, 0x0)); var x52: u64 = undefined; var x53: u1 = undefined; fiatP434AddcarryxU64(&x52, &x53, x51, x40, @intCast(u64, 0x0)); var x54: u64 = undefined; var x55: u64 = undefined; fiatP434MulxU64(&x54, &x55, x42, 0x2341f27177344); var x56: u64 = undefined; var x57: u64 = undefined; fiatP434MulxU64(&x56, &x57, x42, 0x6cfc5fd681c52056); var x58: u64 = undefined; var x59: u64 = undefined; fiatP434MulxU64(&x58, &x59, x42, 0x7bc65c783158aea3); var x60: u64 = undefined; var x61: u64 = undefined; fiatP434MulxU64(&x60, &x61, x42, 0xfdc1767ae2ffffff); var x62: u64 = undefined; var x63: u64 = undefined; fiatP434MulxU64(&x62, &x63, x42, 0xffffffffffffffff); var x64: u64 = undefined; var x65: u64 = undefined; fiatP434MulxU64(&x64, &x65, x42, 0xffffffffffffffff); var x66: u64 = undefined; var x67: u64 = undefined; fiatP434MulxU64(&x66, &x67, x42, 0xffffffffffffffff); var x68: u64 = undefined; var x69: u1 = undefined; fiatP434AddcarryxU64(&x68, &x69, 0x0, x67, x64); var x70: u64 = undefined; var x71: u1 = undefined; fiatP434AddcarryxU64(&x70, &x71, x69, x65, x62); var x72: u64 = undefined; var x73: u1 = undefined; fiatP434AddcarryxU64(&x72, &x73, x71, x63, x60); var x74: u64 = undefined; var x75: u1 = undefined; fiatP434AddcarryxU64(&x74, &x75, x73, x61, x58); var x76: u64 = undefined; var x77: u1 = undefined; fiatP434AddcarryxU64(&x76, &x77, x75, x59, x56); var x78: u64 = undefined; var x79: u1 = undefined; fiatP434AddcarryxU64(&x78, &x79, x77, x57, x54); var x80: u64 = undefined; var x81: u1 = undefined; fiatP434AddcarryxU64(&x80, &x81, 0x0, x42, x66); var x82: u64 = undefined; var x83: u1 = undefined; fiatP434AddcarryxU64(&x82, &x83, x81, x44, x68); var x84: u64 = undefined; var x85: u1 = undefined; fiatP434AddcarryxU64(&x84, &x85, x83, x46, x70); var x86: u64 = undefined; var x87: u1 = undefined; fiatP434AddcarryxU64(&x86, &x87, x85, x48, x72); var x88: u64 = undefined; var x89: u1 = undefined; fiatP434AddcarryxU64(&x88, &x89, x87, x50, x74); var x90: u64 = undefined; var x91: u1 = undefined; fiatP434AddcarryxU64(&x90, &x91, x89, x52, x76); var x92: u64 = undefined; var x93: u1 = undefined; fiatP434AddcarryxU64(&x92, &x93, x91, (@intCast(u64, x53) + (@intCast(u64, x41) + (@intCast(u64, x27) + x3))), x78); var x94: u64 = undefined; var x95: u1 = undefined; fiatP434AddcarryxU64(&x94, &x95, 0x0, x82, (arg1[2])); var x96: u64 = undefined; var x97: u1 = undefined; fiatP434AddcarryxU64(&x96, &x97, x95, x84, @intCast(u64, 0x0)); var x98: u64 = undefined; var x99: u1 = undefined; fiatP434AddcarryxU64(&x98, &x99, x97, x86, @intCast(u64, 0x0)); var x100: u64 = undefined; var x101: u1 = undefined; fiatP434AddcarryxU64(&x100, &x101, x99, x88, @intCast(u64, 0x0)); var x102: u64 = undefined; var x103: u1 = undefined; fiatP434AddcarryxU64(&x102, &x103, x101, x90, @intCast(u64, 0x0)); var x104: u64 = undefined; var x105: u1 = undefined; fiatP434AddcarryxU64(&x104, &x105, x103, x92, @intCast(u64, 0x0)); var x106: u64 = undefined; var x107: u64 = undefined; fiatP434MulxU64(&x106, &x107, x94, 0x2341f27177344); var x108: u64 = undefined; var x109: u64 = undefined; fiatP434MulxU64(&x108, &x109, x94, 0x6cfc5fd681c52056); var x110: u64 = undefined; var x111: u64 = undefined; fiatP434MulxU64(&x110, &x111, x94, 0x7bc65c783158aea3); var x112: u64 = undefined; var x113: u64 = undefined; fiatP434MulxU64(&x112, &x113, x94, 0xfdc1767ae2ffffff); var x114: u64 = undefined; var x115: u64 = undefined; fiatP434MulxU64(&x114, &x115, x94, 0xffffffffffffffff); var x116: u64 = undefined; var x117: u64 = undefined; fiatP434MulxU64(&x116, &x117, x94, 0xffffffffffffffff); var x118: u64 = undefined; var x119: u64 = undefined; fiatP434MulxU64(&x118, &x119, x94, 0xffffffffffffffff); var x120: u64 = undefined; var x121: u1 = undefined; fiatP434AddcarryxU64(&x120, &x121, 0x0, x119, x116); var x122: u64 = undefined; var x123: u1 = undefined; fiatP434AddcarryxU64(&x122, &x123, x121, x117, x114); var x124: u64 = undefined; var x125: u1 = undefined; fiatP434AddcarryxU64(&x124, &x125, x123, x115, x112); var x126: u64 = undefined; var x127: u1 = undefined; fiatP434AddcarryxU64(&x126, &x127, x125, x113, x110); var x128: u64 = undefined; var x129: u1 = undefined; fiatP434AddcarryxU64(&x128, &x129, x127, x111, x108); var x130: u64 = undefined; var x131: u1 = undefined; fiatP434AddcarryxU64(&x130, &x131, x129, x109, x106); var x132: u64 = undefined; var x133: u1 = undefined; fiatP434AddcarryxU64(&x132, &x133, 0x0, x94, x118); var x134: u64 = undefined; var x135: u1 = undefined; fiatP434AddcarryxU64(&x134, &x135, x133, x96, x120); var x136: u64 = undefined; var x137: u1 = undefined; fiatP434AddcarryxU64(&x136, &x137, x135, x98, x122); var x138: u64 = undefined; var x139: u1 = undefined; fiatP434AddcarryxU64(&x138, &x139, x137, x100, x124); var x140: u64 = undefined; var x141: u1 = undefined; fiatP434AddcarryxU64(&x140, &x141, x139, x102, x126); var x142: u64 = undefined; var x143: u1 = undefined; fiatP434AddcarryxU64(&x142, &x143, x141, x104, x128); var x144: u64 = undefined; var x145: u1 = undefined; fiatP434AddcarryxU64(&x144, &x145, x143, (@intCast(u64, x105) + (@intCast(u64, x93) + (@intCast(u64, x79) + x55))), x130); var x146: u64 = undefined; var x147: u1 = undefined; fiatP434AddcarryxU64(&x146, &x147, 0x0, x134, (arg1[3])); var x148: u64 = undefined; var x149: u1 = undefined; fiatP434AddcarryxU64(&x148, &x149, x147, x136, @intCast(u64, 0x0)); var x150: u64 = undefined; var x151: u1 = undefined; fiatP434AddcarryxU64(&x150, &x151, x149, x138, @intCast(u64, 0x0)); var x152: u64 = undefined; var x153: u1 = undefined; fiatP434AddcarryxU64(&x152, &x153, x151, x140, @intCast(u64, 0x0)); var x154: u64 = undefined; var x155: u1 = undefined; fiatP434AddcarryxU64(&x154, &x155, x153, x142, @intCast(u64, 0x0)); var x156: u64 = undefined; var x157: u1 = undefined; fiatP434AddcarryxU64(&x156, &x157, x155, x144, @intCast(u64, 0x0)); var x158: u64 = undefined; var x159: u64 = undefined; fiatP434MulxU64(&x158, &x159, x146, 0x2341f27177344); var x160: u64 = undefined; var x161: u64 = undefined; fiatP434MulxU64(&x160, &x161, x146, 0x6cfc5fd681c52056); var x162: u64 = undefined; var x163: u64 = undefined; fiatP434MulxU64(&x162, &x163, x146, 0x7bc65c783158aea3); var x164: u64 = undefined; var x165: u64 = undefined; fiatP434MulxU64(&x164, &x165, x146, 0xfdc1767ae2ffffff); var x166: u64 = undefined; var x167: u64 = undefined; fiatP434MulxU64(&x166, &x167, x146, 0xffffffffffffffff); var x168: u64 = undefined; var x169: u64 = undefined; fiatP434MulxU64(&x168, &x169, x146, 0xffffffffffffffff); var x170: u64 = undefined; var x171: u64 = undefined; fiatP434MulxU64(&x170, &x171, x146, 0xffffffffffffffff); var x172: u64 = undefined; var x173: u1 = undefined; fiatP434AddcarryxU64(&x172, &x173, 0x0, x171, x168); var x174: u64 = undefined; var x175: u1 = undefined; fiatP434AddcarryxU64(&x174, &x175, x173, x169, x166); var x176: u64 = undefined; var x177: u1 = undefined; fiatP434AddcarryxU64(&x176, &x177, x175, x167, x164); var x178: u64 = undefined; var x179: u1 = undefined; fiatP434AddcarryxU64(&x178, &x179, x177, x165, x162); var x180: u64 = undefined; var x181: u1 = undefined; fiatP434AddcarryxU64(&x180, &x181, x179, x163, x160); var x182: u64 = undefined; var x183: u1 = undefined; fiatP434AddcarryxU64(&x182, &x183, x181, x161, x158); var x184: u64 = undefined; var x185: u1 = undefined; fiatP434AddcarryxU64(&x184, &x185, 0x0, x146, x170); var x186: u64 = undefined; var x187: u1 = undefined; fiatP434AddcarryxU64(&x186, &x187, x185, x148, x172); var x188: u64 = undefined; var x189: u1 = undefined; fiatP434AddcarryxU64(&x188, &x189, x187, x150, x174); var x190: u64 = undefined; var x191: u1 = undefined; fiatP434AddcarryxU64(&x190, &x191, x189, x152, x176); var x192: u64 = undefined; var x193: u1 = undefined; fiatP434AddcarryxU64(&x192, &x193, x191, x154, x178); var x194: u64 = undefined; var x195: u1 = undefined; fiatP434AddcarryxU64(&x194, &x195, x193, x156, x180); var x196: u64 = undefined; var x197: u1 = undefined; fiatP434AddcarryxU64(&x196, &x197, x195, (@intCast(u64, x157) + (@intCast(u64, x145) + (@intCast(u64, x131) + x107))), x182); var x198: u64 = undefined; var x199: u1 = undefined; fiatP434AddcarryxU64(&x198, &x199, 0x0, x186, (arg1[4])); var x200: u64 = undefined; var x201: u1 = undefined; fiatP434AddcarryxU64(&x200, &x201, x199, x188, @intCast(u64, 0x0)); var x202: u64 = undefined; var x203: u1 = undefined; fiatP434AddcarryxU64(&x202, &x203, x201, x190, @intCast(u64, 0x0)); var x204: u64 = undefined; var x205: u1 = undefined; fiatP434AddcarryxU64(&x204, &x205, x203, x192, @intCast(u64, 0x0)); var x206: u64 = undefined; var x207: u1 = undefined; fiatP434AddcarryxU64(&x206, &x207, x205, x194, @intCast(u64, 0x0)); var x208: u64 = undefined; var x209: u1 = undefined; fiatP434AddcarryxU64(&x208, &x209, x207, x196, @intCast(u64, 0x0)); var x210: u64 = undefined; var x211: u64 = undefined; fiatP434MulxU64(&x210, &x211, x198, 0x2341f27177344); var x212: u64 = undefined; var x213: u64 = undefined; fiatP434MulxU64(&x212, &x213, x198, 0x6cfc5fd681c52056); var x214: u64 = undefined; var x215: u64 = undefined; fiatP434MulxU64(&x214, &x215, x198, 0x7bc65c783158aea3); var x216: u64 = undefined; var x217: u64 = undefined; fiatP434MulxU64(&x216, &x217, x198, 0xfdc1767ae2ffffff); var x218: u64 = undefined; var x219: u64 = undefined; fiatP434MulxU64(&x218, &x219, x198, 0xffffffffffffffff); var x220: u64 = undefined; var x221: u64 = undefined; fiatP434MulxU64(&x220, &x221, x198, 0xffffffffffffffff); var x222: u64 = undefined; var x223: u64 = undefined; fiatP434MulxU64(&x222, &x223, x198, 0xffffffffffffffff); var x224: u64 = undefined; var x225: u1 = undefined; fiatP434AddcarryxU64(&x224, &x225, 0x0, x223, x220); var x226: u64 = undefined; var x227: u1 = undefined; fiatP434AddcarryxU64(&x226, &x227, x225, x221, x218); var x228: u64 = undefined; var x229: u1 = undefined; fiatP434AddcarryxU64(&x228, &x229, x227, x219, x216); var x230: u64 = undefined; var x231: u1 = undefined; fiatP434AddcarryxU64(&x230, &x231, x229, x217, x214); var x232: u64 = undefined; var x233: u1 = undefined; fiatP434AddcarryxU64(&x232, &x233, x231, x215, x212); var x234: u64 = undefined; var x235: u1 = undefined; fiatP434AddcarryxU64(&x234, &x235, x233, x213, x210); var x236: u64 = undefined; var x237: u1 = undefined; fiatP434AddcarryxU64(&x236, &x237, 0x0, x198, x222); var x238: u64 = undefined; var x239: u1 = undefined; fiatP434AddcarryxU64(&x238, &x239, x237, x200, x224); var x240: u64 = undefined; var x241: u1 = undefined; fiatP434AddcarryxU64(&x240, &x241, x239, x202, x226); var x242: u64 = undefined; var x243: u1 = undefined; fiatP434AddcarryxU64(&x242, &x243, x241, x204, x228); var x244: u64 = undefined; var x245: u1 = undefined; fiatP434AddcarryxU64(&x244, &x245, x243, x206, x230); var x246: u64 = undefined; var x247: u1 = undefined; fiatP434AddcarryxU64(&x246, &x247, x245, x208, x232); var x248: u64 = undefined; var x249: u1 = undefined; fiatP434AddcarryxU64(&x248, &x249, x247, (@intCast(u64, x209) + (@intCast(u64, x197) + (@intCast(u64, x183) + x159))), x234); var x250: u64 = undefined; var x251: u1 = undefined; fiatP434AddcarryxU64(&x250, &x251, 0x0, x238, (arg1[5])); var x252: u64 = undefined; var x253: u1 = undefined; fiatP434AddcarryxU64(&x252, &x253, x251, x240, @intCast(u64, 0x0)); var x254: u64 = undefined; var x255: u1 = undefined; fiatP434AddcarryxU64(&x254, &x255, x253, x242, @intCast(u64, 0x0)); var x256: u64 = undefined; var x257: u1 = undefined; fiatP434AddcarryxU64(&x256, &x257, x255, x244, @intCast(u64, 0x0)); var x258: u64 = undefined; var x259: u1 = undefined; fiatP434AddcarryxU64(&x258, &x259, x257, x246, @intCast(u64, 0x0)); var x260: u64 = undefined; var x261: u1 = undefined; fiatP434AddcarryxU64(&x260, &x261, x259, x248, @intCast(u64, 0x0)); var x262: u64 = undefined; var x263: u64 = undefined; fiatP434MulxU64(&x262, &x263, x250, 0x2341f27177344); var x264: u64 = undefined; var x265: u64 = undefined; fiatP434MulxU64(&x264, &x265, x250, 0x6cfc5fd681c52056); var x266: u64 = undefined; var x267: u64 = undefined; fiatP434MulxU64(&x266, &x267, x250, 0x7bc65c783158aea3); var x268: u64 = undefined; var x269: u64 = undefined; fiatP434MulxU64(&x268, &x269, x250, 0xfdc1767ae2ffffff); var x270: u64 = undefined; var x271: u64 = undefined; fiatP434MulxU64(&x270, &x271, x250, 0xffffffffffffffff); var x272: u64 = undefined; var x273: u64 = undefined; fiatP434MulxU64(&x272, &x273, x250, 0xffffffffffffffff); var x274: u64 = undefined; var x275: u64 = undefined; fiatP434MulxU64(&x274, &x275, x250, 0xffffffffffffffff); var x276: u64 = undefined; var x277: u1 = undefined; fiatP434AddcarryxU64(&x276, &x277, 0x0, x275, x272); var x278: u64 = undefined; var x279: u1 = undefined; fiatP434AddcarryxU64(&x278, &x279, x277, x273, x270); var x280: u64 = undefined; var x281: u1 = undefined; fiatP434AddcarryxU64(&x280, &x281, x279, x271, x268); var x282: u64 = undefined; var x283: u1 = undefined; fiatP434AddcarryxU64(&x282, &x283, x281, x269, x266); var x284: u64 = undefined; var x285: u1 = undefined; fiatP434AddcarryxU64(&x284, &x285, x283, x267, x264); var x286: u64 = undefined; var x287: u1 = undefined; fiatP434AddcarryxU64(&x286, &x287, x285, x265, x262); var x288: u64 = undefined; var x289: u1 = undefined; fiatP434AddcarryxU64(&x288, &x289, 0x0, x250, x274); var x290: u64 = undefined; var x291: u1 = undefined; fiatP434AddcarryxU64(&x290, &x291, x289, x252, x276); var x292: u64 = undefined; var x293: u1 = undefined; fiatP434AddcarryxU64(&x292, &x293, x291, x254, x278); var x294: u64 = undefined; var x295: u1 = undefined; fiatP434AddcarryxU64(&x294, &x295, x293, x256, x280); var x296: u64 = undefined; var x297: u1 = undefined; fiatP434AddcarryxU64(&x296, &x297, x295, x258, x282); var x298: u64 = undefined; var x299: u1 = undefined; fiatP434AddcarryxU64(&x298, &x299, x297, x260, x284); var x300: u64 = undefined; var x301: u1 = undefined; fiatP434AddcarryxU64(&x300, &x301, x299, (@intCast(u64, x261) + (@intCast(u64, x249) + (@intCast(u64, x235) + x211))), x286); var x302: u64 = undefined; var x303: u1 = undefined; fiatP434AddcarryxU64(&x302, &x303, 0x0, x290, (arg1[6])); var x304: u64 = undefined; var x305: u1 = undefined; fiatP434AddcarryxU64(&x304, &x305, x303, x292, @intCast(u64, 0x0)); var x306: u64 = undefined; var x307: u1 = undefined; fiatP434AddcarryxU64(&x306, &x307, x305, x294, @intCast(u64, 0x0)); var x308: u64 = undefined; var x309: u1 = undefined; fiatP434AddcarryxU64(&x308, &x309, x307, x296, @intCast(u64, 0x0)); var x310: u64 = undefined; var x311: u1 = undefined; fiatP434AddcarryxU64(&x310, &x311, x309, x298, @intCast(u64, 0x0)); var x312: u64 = undefined; var x313: u1 = undefined; fiatP434AddcarryxU64(&x312, &x313, x311, x300, @intCast(u64, 0x0)); var x314: u64 = undefined; var x315: u64 = undefined; fiatP434MulxU64(&x314, &x315, x302, 0x2341f27177344); var x316: u64 = undefined; var x317: u64 = undefined; fiatP434MulxU64(&x316, &x317, x302, 0x6cfc5fd681c52056); var x318: u64 = undefined; var x319: u64 = undefined; fiatP434MulxU64(&x318, &x319, x302, 0x7bc65c783158aea3); var x320: u64 = undefined; var x321: u64 = undefined; fiatP434MulxU64(&x320, &x321, x302, 0xfdc1767ae2ffffff); var x322: u64 = undefined; var x323: u64 = undefined; fiatP434MulxU64(&x322, &x323, x302, 0xffffffffffffffff); var x324: u64 = undefined; var x325: u64 = undefined; fiatP434MulxU64(&x324, &x325, x302, 0xffffffffffffffff); var x326: u64 = undefined; var x327: u64 = undefined; fiatP434MulxU64(&x326, &x327, x302, 0xffffffffffffffff); var x328: u64 = undefined; var x329: u1 = undefined; fiatP434AddcarryxU64(&x328, &x329, 0x0, x327, x324); var x330: u64 = undefined; var x331: u1 = undefined; fiatP434AddcarryxU64(&x330, &x331, x329, x325, x322); var x332: u64 = undefined; var x333: u1 = undefined; fiatP434AddcarryxU64(&x332, &x333, x331, x323, x320); var x334: u64 = undefined; var x335: u1 = undefined; fiatP434AddcarryxU64(&x334, &x335, x333, x321, x318); var x336: u64 = undefined; var x337: u1 = undefined; fiatP434AddcarryxU64(&x336, &x337, x335, x319, x316); var x338: u64 = undefined; var x339: u1 = undefined; fiatP434AddcarryxU64(&x338, &x339, x337, x317, x314); var x340: u64 = undefined; var x341: u1 = undefined; fiatP434AddcarryxU64(&x340, &x341, 0x0, x302, x326); var x342: u64 = undefined; var x343: u1 = undefined; fiatP434AddcarryxU64(&x342, &x343, x341, x304, x328); var x344: u64 = undefined; var x345: u1 = undefined; fiatP434AddcarryxU64(&x344, &x345, x343, x306, x330); var x346: u64 = undefined; var x347: u1 = undefined; fiatP434AddcarryxU64(&x346, &x347, x345, x308, x332); var x348: u64 = undefined; var x349: u1 = undefined; fiatP434AddcarryxU64(&x348, &x349, x347, x310, x334); var x350: u64 = undefined; var x351: u1 = undefined; fiatP434AddcarryxU64(&x350, &x351, x349, x312, x336); var x352: u64 = undefined; var x353: u1 = undefined; fiatP434AddcarryxU64(&x352, &x353, x351, (@intCast(u64, x313) + (@intCast(u64, x301) + (@intCast(u64, x287) + x263))), x338); const x354: u64 = (@intCast(u64, x353) + (@intCast(u64, x339) + x315)); var x355: u64 = undefined; var x356: u1 = undefined; fiatP434SubborrowxU64(&x355, &x356, 0x0, x342, 0xffffffffffffffff); var x357: u64 = undefined; var x358: u1 = undefined; fiatP434SubborrowxU64(&x357, &x358, x356, x344, 0xffffffffffffffff); var x359: u64 = undefined; var x360: u1 = undefined; fiatP434SubborrowxU64(&x359, &x360, x358, x346, 0xffffffffffffffff); var x361: u64 = undefined; var x362: u1 = undefined; fiatP434SubborrowxU64(&x361, &x362, x360, x348, 0xfdc1767ae2ffffff); var x363: u64 = undefined; var x364: u1 = undefined; fiatP434SubborrowxU64(&x363, &x364, x362, x350, 0x7bc65c783158aea3); var x365: u64 = undefined; var x366: u1 = undefined; fiatP434SubborrowxU64(&x365, &x366, x364, x352, 0x6cfc5fd681c52056); var x367: u64 = undefined; var x368: u1 = undefined; fiatP434SubborrowxU64(&x367, &x368, x366, x354, 0x2341f27177344); var x369: u64 = undefined; var x370: u1 = undefined; fiatP434SubborrowxU64(&x369, &x370, x368, @intCast(u64, 0x0), @intCast(u64, 0x0)); var x371: u64 = undefined; fiatP434CmovznzU64(&x371, x370, x355, x342); var x372: u64 = undefined; fiatP434CmovznzU64(&x372, x370, x357, x344); var x373: u64 = undefined; fiatP434CmovznzU64(&x373, x370, x359, x346); var x374: u64 = undefined; fiatP434CmovznzU64(&x374, x370, x361, x348); var x375: u64 = undefined; fiatP434CmovznzU64(&x375, x370, x363, x350); var x376: u64 = undefined; fiatP434CmovznzU64(&x376, x370, x365, x352); var x377: u64 = undefined; fiatP434CmovznzU64(&x377, x370, x367, x354); out1[0] = x371; out1[1] = x372; out1[2] = x373; out1[3] = x374; out1[4] = x375; out1[5] = x376; out1[6] = x377; } /// The function fiatP434ToMontgomery translates a field element into the Montgomery domain. /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// eval (from_montgomery out1) mod m = eval arg1 mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434ToMontgomery(out1: *[7]u64, arg1: [7]u64) void { const x1: u64 = (arg1[1]); const x2: u64 = (arg1[2]); const x3: u64 = (arg1[3]); const x4: u64 = (arg1[4]); const x5: u64 = (arg1[5]); const x6: u64 = (arg1[6]); const x7: u64 = (arg1[0]); var x8: u64 = undefined; var x9: u64 = undefined; fiatP434MulxU64(&x8, &x9, x7, 0x25a89bcdd12a); var x10: u64 = undefined; var x11: u64 = undefined; fiatP434MulxU64(&x10, &x11, x7, 0x69e16a61c7686d9a); var x12: u64 = undefined; var x13: u64 = undefined; fiatP434MulxU64(&x12, &x13, x7, 0xabcd92bf2dde347e); var x14: u64 = undefined; var x15: u64 = undefined; fiatP434MulxU64(&x14, &x15, x7, 0x175cc6af8d6c7c0b); var x16: u64 = undefined; var x17: u64 = undefined; fiatP434MulxU64(&x16, &x17, x7, 0xab27973f8311688d); var x18: u64 = undefined; var x19: u64 = undefined; fiatP434MulxU64(&x18, &x19, x7, 0xacec7367768798c2); var x20: u64 = undefined; var x21: u64 = undefined; fiatP434MulxU64(&x20, &x21, x7, 0x28e55b65dcd69b30); var x22: u64 = undefined; var x23: u1 = undefined; fiatP434AddcarryxU64(&x22, &x23, 0x0, x21, x18); var x24: u64 = undefined; var x25: u1 = undefined; fiatP434AddcarryxU64(&x24, &x25, x23, x19, x16); var x26: u64 = undefined; var x27: u1 = undefined; fiatP434AddcarryxU64(&x26, &x27, x25, x17, x14); var x28: u64 = undefined; var x29: u1 = undefined; fiatP434AddcarryxU64(&x28, &x29, x27, x15, x12); var x30: u64 = undefined; var x31: u1 = undefined; fiatP434AddcarryxU64(&x30, &x31, x29, x13, x10); var x32: u64 = undefined; var x33: u1 = undefined; fiatP434AddcarryxU64(&x32, &x33, x31, x11, x8); var x34: u64 = undefined; var x35: u64 = undefined; fiatP434MulxU64(&x34, &x35, x20, 0x2341f27177344); var x36: u64 = undefined; var x37: u64 = undefined; fiatP434MulxU64(&x36, &x37, x20, 0x6cfc5fd681c52056); var x38: u64 = undefined; var x39: u64 = undefined; fiatP434MulxU64(&x38, &x39, x20, 0x7bc65c783158aea3); var x40: u64 = undefined; var x41: u64 = undefined; fiatP434MulxU64(&x40, &x41, x20, 0xfdc1767ae2ffffff); var x42: u64 = undefined; var x43: u64 = undefined; fiatP434MulxU64(&x42, &x43, x20, 0xffffffffffffffff); var x44: u64 = undefined; var x45: u64 = undefined; fiatP434MulxU64(&x44, &x45, x20, 0xffffffffffffffff); var x46: u64 = undefined; var x47: u64 = undefined; fiatP434MulxU64(&x46, &x47, x20, 0xffffffffffffffff); var x48: u64 = undefined; var x49: u1 = undefined; fiatP434AddcarryxU64(&x48, &x49, 0x0, x47, x44); var x50: u64 = undefined; var x51: u1 = undefined; fiatP434AddcarryxU64(&x50, &x51, x49, x45, x42); var x52: u64 = undefined; var x53: u1 = undefined; fiatP434AddcarryxU64(&x52, &x53, x51, x43, x40); var x54: u64 = undefined; var x55: u1 = undefined; fiatP434AddcarryxU64(&x54, &x55, x53, x41, x38); var x56: u64 = undefined; var x57: u1 = undefined; fiatP434AddcarryxU64(&x56, &x57, x55, x39, x36); var x58: u64 = undefined; var x59: u1 = undefined; fiatP434AddcarryxU64(&x58, &x59, x57, x37, x34); var x60: u64 = undefined; var x61: u1 = undefined; fiatP434AddcarryxU64(&x60, &x61, 0x0, x20, x46); var x62: u64 = undefined; var x63: u1 = undefined; fiatP434AddcarryxU64(&x62, &x63, x61, x22, x48); var x64: u64 = undefined; var x65: u1 = undefined; fiatP434AddcarryxU64(&x64, &x65, x63, x24, x50); var x66: u64 = undefined; var x67: u1 = undefined; fiatP434AddcarryxU64(&x66, &x67, x65, x26, x52); var x68: u64 = undefined; var x69: u1 = undefined; fiatP434AddcarryxU64(&x68, &x69, x67, x28, x54); var x70: u64 = undefined; var x71: u1 = undefined; fiatP434AddcarryxU64(&x70, &x71, x69, x30, x56); var x72: u64 = undefined; var x73: u1 = undefined; fiatP434AddcarryxU64(&x72, &x73, x71, x32, x58); var x74: u64 = undefined; var x75: u64 = undefined; fiatP434MulxU64(&x74, &x75, x1, 0x25a89bcdd12a); var x76: u64 = undefined; var x77: u64 = undefined; fiatP434MulxU64(&x76, &x77, x1, 0x69e16a61c7686d9a); var x78: u64 = undefined; var x79: u64 = undefined; fiatP434MulxU64(&x78, &x79, x1, 0xabcd92bf2dde347e); var x80: u64 = undefined; var x81: u64 = undefined; fiatP434MulxU64(&x80, &x81, x1, 0x175cc6af8d6c7c0b); var x82: u64 = undefined; var x83: u64 = undefined; fiatP434MulxU64(&x82, &x83, x1, 0xab27973f8311688d); var x84: u64 = undefined; var x85: u64 = undefined; fiatP434MulxU64(&x84, &x85, x1, 0xacec7367768798c2); var x86: u64 = undefined; var x87: u64 = undefined; fiatP434MulxU64(&x86, &x87, x1, 0x28e55b65dcd69b30); var x88: u64 = undefined; var x89: u1 = undefined; fiatP434AddcarryxU64(&x88, &x89, 0x0, x87, x84); var x90: u64 = undefined; var x91: u1 = undefined; fiatP434AddcarryxU64(&x90, &x91, x89, x85, x82); var x92: u64 = undefined; var x93: u1 = undefined; fiatP434AddcarryxU64(&x92, &x93, x91, x83, x80); var x94: u64 = undefined; var x95: u1 = undefined; fiatP434AddcarryxU64(&x94, &x95, x93, x81, x78); var x96: u64 = undefined; var x97: u1 = undefined; fiatP434AddcarryxU64(&x96, &x97, x95, x79, x76); var x98: u64 = undefined; var x99: u1 = undefined; fiatP434AddcarryxU64(&x98, &x99, x97, x77, x74); var x100: u64 = undefined; var x101: u1 = undefined; fiatP434AddcarryxU64(&x100, &x101, 0x0, x62, x86); var x102: u64 = undefined; var x103: u1 = undefined; fiatP434AddcarryxU64(&x102, &x103, x101, x64, x88); var x104: u64 = undefined; var x105: u1 = undefined; fiatP434AddcarryxU64(&x104, &x105, x103, x66, x90); var x106: u64 = undefined; var x107: u1 = undefined; fiatP434AddcarryxU64(&x106, &x107, x105, x68, x92); var x108: u64 = undefined; var x109: u1 = undefined; fiatP434AddcarryxU64(&x108, &x109, x107, x70, x94); var x110: u64 = undefined; var x111: u1 = undefined; fiatP434AddcarryxU64(&x110, &x111, x109, x72, x96); var x112: u64 = undefined; var x113: u1 = undefined; fiatP434AddcarryxU64(&x112, &x113, x111, ((@intCast(u64, x73) + (@intCast(u64, x33) + x9)) + (@intCast(u64, x59) + x35)), x98); var x114: u64 = undefined; var x115: u64 = undefined; fiatP434MulxU64(&x114, &x115, x100, 0x2341f27177344); var x116: u64 = undefined; var x117: u64 = undefined; fiatP434MulxU64(&x116, &x117, x100, 0x6cfc5fd681c52056); var x118: u64 = undefined; var x119: u64 = undefined; fiatP434MulxU64(&x118, &x119, x100, 0x7bc65c783158aea3); var x120: u64 = undefined; var x121: u64 = undefined; fiatP434MulxU64(&x120, &x121, x100, 0xfdc1767ae2ffffff); var x122: u64 = undefined; var x123: u64 = undefined; fiatP434MulxU64(&x122, &x123, x100, 0xffffffffffffffff); var x124: u64 = undefined; var x125: u64 = undefined; fiatP434MulxU64(&x124, &x125, x100, 0xffffffffffffffff); var x126: u64 = undefined; var x127: u64 = undefined; fiatP434MulxU64(&x126, &x127, x100, 0xffffffffffffffff); var x128: u64 = undefined; var x129: u1 = undefined; fiatP434AddcarryxU64(&x128, &x129, 0x0, x127, x124); var x130: u64 = undefined; var x131: u1 = undefined; fiatP434AddcarryxU64(&x130, &x131, x129, x125, x122); var x132: u64 = undefined; var x133: u1 = undefined; fiatP434AddcarryxU64(&x132, &x133, x131, x123, x120); var x134: u64 = undefined; var x135: u1 = undefined; fiatP434AddcarryxU64(&x134, &x135, x133, x121, x118); var x136: u64 = undefined; var x137: u1 = undefined; fiatP434AddcarryxU64(&x136, &x137, x135, x119, x116); var x138: u64 = undefined; var x139: u1 = undefined; fiatP434AddcarryxU64(&x138, &x139, x137, x117, x114); var x140: u64 = undefined; var x141: u1 = undefined; fiatP434AddcarryxU64(&x140, &x141, 0x0, x100, x126); var x142: u64 = undefined; var x143: u1 = undefined; fiatP434AddcarryxU64(&x142, &x143, x141, x102, x128); var x144: u64 = undefined; var x145: u1 = undefined; fiatP434AddcarryxU64(&x144, &x145, x143, x104, x130); var x146: u64 = undefined; var x147: u1 = undefined; fiatP434AddcarryxU64(&x146, &x147, x145, x106, x132); var x148: u64 = undefined; var x149: u1 = undefined; fiatP434AddcarryxU64(&x148, &x149, x147, x108, x134); var x150: u64 = undefined; var x151: u1 = undefined; fiatP434AddcarryxU64(&x150, &x151, x149, x110, x136); var x152: u64 = undefined; var x153: u1 = undefined; fiatP434AddcarryxU64(&x152, &x153, x151, x112, x138); var x154: u64 = undefined; var x155: u64 = undefined; fiatP434MulxU64(&x154, &x155, x2, 0x25a89bcdd12a); var x156: u64 = undefined; var x157: u64 = undefined; fiatP434MulxU64(&x156, &x157, x2, 0x69e16a61c7686d9a); var x158: u64 = undefined; var x159: u64 = undefined; fiatP434MulxU64(&x158, &x159, x2, 0xabcd92bf2dde347e); var x160: u64 = undefined; var x161: u64 = undefined; fiatP434MulxU64(&x160, &x161, x2, 0x175cc6af8d6c7c0b); var x162: u64 = undefined; var x163: u64 = undefined; fiatP434MulxU64(&x162, &x163, x2, 0xab27973f8311688d); var x164: u64 = undefined; var x165: u64 = undefined; fiatP434MulxU64(&x164, &x165, x2, 0xacec7367768798c2); var x166: u64 = undefined; var x167: u64 = undefined; fiatP434MulxU64(&x166, &x167, x2, 0x28e55b65dcd69b30); var x168: u64 = undefined; var x169: u1 = undefined; fiatP434AddcarryxU64(&x168, &x169, 0x0, x167, x164); var x170: u64 = undefined; var x171: u1 = undefined; fiatP434AddcarryxU64(&x170, &x171, x169, x165, x162); var x172: u64 = undefined; var x173: u1 = undefined; fiatP434AddcarryxU64(&x172, &x173, x171, x163, x160); var x174: u64 = undefined; var x175: u1 = undefined; fiatP434AddcarryxU64(&x174, &x175, x173, x161, x158); var x176: u64 = undefined; var x177: u1 = undefined; fiatP434AddcarryxU64(&x176, &x177, x175, x159, x156); var x178: u64 = undefined; var x179: u1 = undefined; fiatP434AddcarryxU64(&x178, &x179, x177, x157, x154); var x180: u64 = undefined; var x181: u1 = undefined; fiatP434AddcarryxU64(&x180, &x181, 0x0, x142, x166); var x182: u64 = undefined; var x183: u1 = undefined; fiatP434AddcarryxU64(&x182, &x183, x181, x144, x168); var x184: u64 = undefined; var x185: u1 = undefined; fiatP434AddcarryxU64(&x184, &x185, x183, x146, x170); var x186: u64 = undefined; var x187: u1 = undefined; fiatP434AddcarryxU64(&x186, &x187, x185, x148, x172); var x188: u64 = undefined; var x189: u1 = undefined; fiatP434AddcarryxU64(&x188, &x189, x187, x150, x174); var x190: u64 = undefined; var x191: u1 = undefined; fiatP434AddcarryxU64(&x190, &x191, x189, x152, x176); var x192: u64 = undefined; var x193: u1 = undefined; fiatP434AddcarryxU64(&x192, &x193, x191, ((@intCast(u64, x153) + (@intCast(u64, x113) + (@intCast(u64, x99) + x75))) + (@intCast(u64, x139) + x115)), x178); var x194: u64 = undefined; var x195: u64 = undefined; fiatP434MulxU64(&x194, &x195, x180, 0x2341f27177344); var x196: u64 = undefined; var x197: u64 = undefined; fiatP434MulxU64(&x196, &x197, x180, 0x6cfc5fd681c52056); var x198: u64 = undefined; var x199: u64 = undefined; fiatP434MulxU64(&x198, &x199, x180, 0x7bc65c783158aea3); var x200: u64 = undefined; var x201: u64 = undefined; fiatP434MulxU64(&x200, &x201, x180, 0xfdc1767ae2ffffff); var x202: u64 = undefined; var x203: u64 = undefined; fiatP434MulxU64(&x202, &x203, x180, 0xffffffffffffffff); var x204: u64 = undefined; var x205: u64 = undefined; fiatP434MulxU64(&x204, &x205, x180, 0xffffffffffffffff); var x206: u64 = undefined; var x207: u64 = undefined; fiatP434MulxU64(&x206, &x207, x180, 0xffffffffffffffff); var x208: u64 = undefined; var x209: u1 = undefined; fiatP434AddcarryxU64(&x208, &x209, 0x0, x207, x204); var x210: u64 = undefined; var x211: u1 = undefined; fiatP434AddcarryxU64(&x210, &x211, x209, x205, x202); var x212: u64 = undefined; var x213: u1 = undefined; fiatP434AddcarryxU64(&x212, &x213, x211, x203, x200); var x214: u64 = undefined; var x215: u1 = undefined; fiatP434AddcarryxU64(&x214, &x215, x213, x201, x198); var x216: u64 = undefined; var x217: u1 = undefined; fiatP434AddcarryxU64(&x216, &x217, x215, x199, x196); var x218: u64 = undefined; var x219: u1 = undefined; fiatP434AddcarryxU64(&x218, &x219, x217, x197, x194); var x220: u64 = undefined; var x221: u1 = undefined; fiatP434AddcarryxU64(&x220, &x221, 0x0, x180, x206); var x222: u64 = undefined; var x223: u1 = undefined; fiatP434AddcarryxU64(&x222, &x223, x221, x182, x208); var x224: u64 = undefined; var x225: u1 = undefined; fiatP434AddcarryxU64(&x224, &x225, x223, x184, x210); var x226: u64 = undefined; var x227: u1 = undefined; fiatP434AddcarryxU64(&x226, &x227, x225, x186, x212); var x228: u64 = undefined; var x229: u1 = undefined; fiatP434AddcarryxU64(&x228, &x229, x227, x188, x214); var x230: u64 = undefined; var x231: u1 = undefined; fiatP434AddcarryxU64(&x230, &x231, x229, x190, x216); var x232: u64 = undefined; var x233: u1 = undefined; fiatP434AddcarryxU64(&x232, &x233, x231, x192, x218); var x234: u64 = undefined; var x235: u64 = undefined; fiatP434MulxU64(&x234, &x235, x3, 0x25a89bcdd12a); var x236: u64 = undefined; var x237: u64 = undefined; fiatP434MulxU64(&x236, &x237, x3, 0x69e16a61c7686d9a); var x238: u64 = undefined; var x239: u64 = undefined; fiatP434MulxU64(&x238, &x239, x3, 0xabcd92bf2dde347e); var x240: u64 = undefined; var x241: u64 = undefined; fiatP434MulxU64(&x240, &x241, x3, 0x175cc6af8d6c7c0b); var x242: u64 = undefined; var x243: u64 = undefined; fiatP434MulxU64(&x242, &x243, x3, 0xab27973f8311688d); var x244: u64 = undefined; var x245: u64 = undefined; fiatP434MulxU64(&x244, &x245, x3, 0xacec7367768798c2); var x246: u64 = undefined; var x247: u64 = undefined; fiatP434MulxU64(&x246, &x247, x3, 0x28e55b65dcd69b30); var x248: u64 = undefined; var x249: u1 = undefined; fiatP434AddcarryxU64(&x248, &x249, 0x0, x247, x244); var x250: u64 = undefined; var x251: u1 = undefined; fiatP434AddcarryxU64(&x250, &x251, x249, x245, x242); var x252: u64 = undefined; var x253: u1 = undefined; fiatP434AddcarryxU64(&x252, &x253, x251, x243, x240); var x254: u64 = undefined; var x255: u1 = undefined; fiatP434AddcarryxU64(&x254, &x255, x253, x241, x238); var x256: u64 = undefined; var x257: u1 = undefined; fiatP434AddcarryxU64(&x256, &x257, x255, x239, x236); var x258: u64 = undefined; var x259: u1 = undefined; fiatP434AddcarryxU64(&x258, &x259, x257, x237, x234); var x260: u64 = undefined; var x261: u1 = undefined; fiatP434AddcarryxU64(&x260, &x261, 0x0, x222, x246); var x262: u64 = undefined; var x263: u1 = undefined; fiatP434AddcarryxU64(&x262, &x263, x261, x224, x248); var x264: u64 = undefined; var x265: u1 = undefined; fiatP434AddcarryxU64(&x264, &x265, x263, x226, x250); var x266: u64 = undefined; var x267: u1 = undefined; fiatP434AddcarryxU64(&x266, &x267, x265, x228, x252); var x268: u64 = undefined; var x269: u1 = undefined; fiatP434AddcarryxU64(&x268, &x269, x267, x230, x254); var x270: u64 = undefined; var x271: u1 = undefined; fiatP434AddcarryxU64(&x270, &x271, x269, x232, x256); var x272: u64 = undefined; var x273: u1 = undefined; fiatP434AddcarryxU64(&x272, &x273, x271, ((@intCast(u64, x233) + (@intCast(u64, x193) + (@intCast(u64, x179) + x155))) + (@intCast(u64, x219) + x195)), x258); var x274: u64 = undefined; var x275: u64 = undefined; fiatP434MulxU64(&x274, &x275, x260, 0x2341f27177344); var x276: u64 = undefined; var x277: u64 = undefined; fiatP434MulxU64(&x276, &x277, x260, 0x6cfc5fd681c52056); var x278: u64 = undefined; var x279: u64 = undefined; fiatP434MulxU64(&x278, &x279, x260, 0x7bc65c783158aea3); var x280: u64 = undefined; var x281: u64 = undefined; fiatP434MulxU64(&x280, &x281, x260, 0xfdc1767ae2ffffff); var x282: u64 = undefined; var x283: u64 = undefined; fiatP434MulxU64(&x282, &x283, x260, 0xffffffffffffffff); var x284: u64 = undefined; var x285: u64 = undefined; fiatP434MulxU64(&x284, &x285, x260, 0xffffffffffffffff); var x286: u64 = undefined; var x287: u64 = undefined; fiatP434MulxU64(&x286, &x287, x260, 0xffffffffffffffff); var x288: u64 = undefined; var x289: u1 = undefined; fiatP434AddcarryxU64(&x288, &x289, 0x0, x287, x284); var x290: u64 = undefined; var x291: u1 = undefined; fiatP434AddcarryxU64(&x290, &x291, x289, x285, x282); var x292: u64 = undefined; var x293: u1 = undefined; fiatP434AddcarryxU64(&x292, &x293, x291, x283, x280); var x294: u64 = undefined; var x295: u1 = undefined; fiatP434AddcarryxU64(&x294, &x295, x293, x281, x278); var x296: u64 = undefined; var x297: u1 = undefined; fiatP434AddcarryxU64(&x296, &x297, x295, x279, x276); var x298: u64 = undefined; var x299: u1 = undefined; fiatP434AddcarryxU64(&x298, &x299, x297, x277, x274); var x300: u64 = undefined; var x301: u1 = undefined; fiatP434AddcarryxU64(&x300, &x301, 0x0, x260, x286); var x302: u64 = undefined; var x303: u1 = undefined; fiatP434AddcarryxU64(&x302, &x303, x301, x262, x288); var x304: u64 = undefined; var x305: u1 = undefined; fiatP434AddcarryxU64(&x304, &x305, x303, x264, x290); var x306: u64 = undefined; var x307: u1 = undefined; fiatP434AddcarryxU64(&x306, &x307, x305, x266, x292); var x308: u64 = undefined; var x309: u1 = undefined; fiatP434AddcarryxU64(&x308, &x309, x307, x268, x294); var x310: u64 = undefined; var x311: u1 = undefined; fiatP434AddcarryxU64(&x310, &x311, x309, x270, x296); var x312: u64 = undefined; var x313: u1 = undefined; fiatP434AddcarryxU64(&x312, &x313, x311, x272, x298); var x314: u64 = undefined; var x315: u64 = undefined; fiatP434MulxU64(&x314, &x315, x4, 0x25a89bcdd12a); var x316: u64 = undefined; var x317: u64 = undefined; fiatP434MulxU64(&x316, &x317, x4, 0x69e16a61c7686d9a); var x318: u64 = undefined; var x319: u64 = undefined; fiatP434MulxU64(&x318, &x319, x4, 0xabcd92bf2dde347e); var x320: u64 = undefined; var x321: u64 = undefined; fiatP434MulxU64(&x320, &x321, x4, 0x175cc6af8d6c7c0b); var x322: u64 = undefined; var x323: u64 = undefined; fiatP434MulxU64(&x322, &x323, x4, 0xab27973f8311688d); var x324: u64 = undefined; var x325: u64 = undefined; fiatP434MulxU64(&x324, &x325, x4, 0xacec7367768798c2); var x326: u64 = undefined; var x327: u64 = undefined; fiatP434MulxU64(&x326, &x327, x4, 0x28e55b65dcd69b30); var x328: u64 = undefined; var x329: u1 = undefined; fiatP434AddcarryxU64(&x328, &x329, 0x0, x327, x324); var x330: u64 = undefined; var x331: u1 = undefined; fiatP434AddcarryxU64(&x330, &x331, x329, x325, x322); var x332: u64 = undefined; var x333: u1 = undefined; fiatP434AddcarryxU64(&x332, &x333, x331, x323, x320); var x334: u64 = undefined; var x335: u1 = undefined; fiatP434AddcarryxU64(&x334, &x335, x333, x321, x318); var x336: u64 = undefined; var x337: u1 = undefined; fiatP434AddcarryxU64(&x336, &x337, x335, x319, x316); var x338: u64 = undefined; var x339: u1 = undefined; fiatP434AddcarryxU64(&x338, &x339, x337, x317, x314); var x340: u64 = undefined; var x341: u1 = undefined; fiatP434AddcarryxU64(&x340, &x341, 0x0, x302, x326); var x342: u64 = undefined; var x343: u1 = undefined; fiatP434AddcarryxU64(&x342, &x343, x341, x304, x328); var x344: u64 = undefined; var x345: u1 = undefined; fiatP434AddcarryxU64(&x344, &x345, x343, x306, x330); var x346: u64 = undefined; var x347: u1 = undefined; fiatP434AddcarryxU64(&x346, &x347, x345, x308, x332); var x348: u64 = undefined; var x349: u1 = undefined; fiatP434AddcarryxU64(&x348, &x349, x347, x310, x334); var x350: u64 = undefined; var x351: u1 = undefined; fiatP434AddcarryxU64(&x350, &x351, x349, x312, x336); var x352: u64 = undefined; var x353: u1 = undefined; fiatP434AddcarryxU64(&x352, &x353, x351, ((@intCast(u64, x313) + (@intCast(u64, x273) + (@intCast(u64, x259) + x235))) + (@intCast(u64, x299) + x275)), x338); var x354: u64 = undefined; var x355: u64 = undefined; fiatP434MulxU64(&x354, &x355, x340, 0x2341f27177344); var x356: u64 = undefined; var x357: u64 = undefined; fiatP434MulxU64(&x356, &x357, x340, 0x6cfc5fd681c52056); var x358: u64 = undefined; var x359: u64 = undefined; fiatP434MulxU64(&x358, &x359, x340, 0x7bc65c783158aea3); var x360: u64 = undefined; var x361: u64 = undefined; fiatP434MulxU64(&x360, &x361, x340, 0xfdc1767ae2ffffff); var x362: u64 = undefined; var x363: u64 = undefined; fiatP434MulxU64(&x362, &x363, x340, 0xffffffffffffffff); var x364: u64 = undefined; var x365: u64 = undefined; fiatP434MulxU64(&x364, &x365, x340, 0xffffffffffffffff); var x366: u64 = undefined; var x367: u64 = undefined; fiatP434MulxU64(&x366, &x367, x340, 0xffffffffffffffff); var x368: u64 = undefined; var x369: u1 = undefined; fiatP434AddcarryxU64(&x368, &x369, 0x0, x367, x364); var x370: u64 = undefined; var x371: u1 = undefined; fiatP434AddcarryxU64(&x370, &x371, x369, x365, x362); var x372: u64 = undefined; var x373: u1 = undefined; fiatP434AddcarryxU64(&x372, &x373, x371, x363, x360); var x374: u64 = undefined; var x375: u1 = undefined; fiatP434AddcarryxU64(&x374, &x375, x373, x361, x358); var x376: u64 = undefined; var x377: u1 = undefined; fiatP434AddcarryxU64(&x376, &x377, x375, x359, x356); var x378: u64 = undefined; var x379: u1 = undefined; fiatP434AddcarryxU64(&x378, &x379, x377, x357, x354); var x380: u64 = undefined; var x381: u1 = undefined; fiatP434AddcarryxU64(&x380, &x381, 0x0, x340, x366); var x382: u64 = undefined; var x383: u1 = undefined; fiatP434AddcarryxU64(&x382, &x383, x381, x342, x368); var x384: u64 = undefined; var x385: u1 = undefined; fiatP434AddcarryxU64(&x384, &x385, x383, x344, x370); var x386: u64 = undefined; var x387: u1 = undefined; fiatP434AddcarryxU64(&x386, &x387, x385, x346, x372); var x388: u64 = undefined; var x389: u1 = undefined; fiatP434AddcarryxU64(&x388, &x389, x387, x348, x374); var x390: u64 = undefined; var x391: u1 = undefined; fiatP434AddcarryxU64(&x390, &x391, x389, x350, x376); var x392: u64 = undefined; var x393: u1 = undefined; fiatP434AddcarryxU64(&x392, &x393, x391, x352, x378); var x394: u64 = undefined; var x395: u64 = undefined; fiatP434MulxU64(&x394, &x395, x5, 0x25a89bcdd12a); var x396: u64 = undefined; var x397: u64 = undefined; fiatP434MulxU64(&x396, &x397, x5, 0x69e16a61c7686d9a); var x398: u64 = undefined; var x399: u64 = undefined; fiatP434MulxU64(&x398, &x399, x5, 0xabcd92bf2dde347e); var x400: u64 = undefined; var x401: u64 = undefined; fiatP434MulxU64(&x400, &x401, x5, 0x175cc6af8d6c7c0b); var x402: u64 = undefined; var x403: u64 = undefined; fiatP434MulxU64(&x402, &x403, x5, 0xab27973f8311688d); var x404: u64 = undefined; var x405: u64 = undefined; fiatP434MulxU64(&x404, &x405, x5, 0xacec7367768798c2); var x406: u64 = undefined; var x407: u64 = undefined; fiatP434MulxU64(&x406, &x407, x5, 0x28e55b65dcd69b30); var x408: u64 = undefined; var x409: u1 = undefined; fiatP434AddcarryxU64(&x408, &x409, 0x0, x407, x404); var x410: u64 = undefined; var x411: u1 = undefined; fiatP434AddcarryxU64(&x410, &x411, x409, x405, x402); var x412: u64 = undefined; var x413: u1 = undefined; fiatP434AddcarryxU64(&x412, &x413, x411, x403, x400); var x414: u64 = undefined; var x415: u1 = undefined; fiatP434AddcarryxU64(&x414, &x415, x413, x401, x398); var x416: u64 = undefined; var x417: u1 = undefined; fiatP434AddcarryxU64(&x416, &x417, x415, x399, x396); var x418: u64 = undefined; var x419: u1 = undefined; fiatP434AddcarryxU64(&x418, &x419, x417, x397, x394); var x420: u64 = undefined; var x421: u1 = undefined; fiatP434AddcarryxU64(&x420, &x421, 0x0, x382, x406); var x422: u64 = undefined; var x423: u1 = undefined; fiatP434AddcarryxU64(&x422, &x423, x421, x384, x408); var x424: u64 = undefined; var x425: u1 = undefined; fiatP434AddcarryxU64(&x424, &x425, x423, x386, x410); var x426: u64 = undefined; var x427: u1 = undefined; fiatP434AddcarryxU64(&x426, &x427, x425, x388, x412); var x428: u64 = undefined; var x429: u1 = undefined; fiatP434AddcarryxU64(&x428, &x429, x427, x390, x414); var x430: u64 = undefined; var x431: u1 = undefined; fiatP434AddcarryxU64(&x430, &x431, x429, x392, x416); var x432: u64 = undefined; var x433: u1 = undefined; fiatP434AddcarryxU64(&x432, &x433, x431, ((@intCast(u64, x393) + (@intCast(u64, x353) + (@intCast(u64, x339) + x315))) + (@intCast(u64, x379) + x355)), x418); var x434: u64 = undefined; var x435: u64 = undefined; fiatP434MulxU64(&x434, &x435, x420, 0x2341f27177344); var x436: u64 = undefined; var x437: u64 = undefined; fiatP434MulxU64(&x436, &x437, x420, 0x6cfc5fd681c52056); var x438: u64 = undefined; var x439: u64 = undefined; fiatP434MulxU64(&x438, &x439, x420, 0x7bc65c783158aea3); var x440: u64 = undefined; var x441: u64 = undefined; fiatP434MulxU64(&x440, &x441, x420, 0xfdc1767ae2ffffff); var x442: u64 = undefined; var x443: u64 = undefined; fiatP434MulxU64(&x442, &x443, x420, 0xffffffffffffffff); var x444: u64 = undefined; var x445: u64 = undefined; fiatP434MulxU64(&x444, &x445, x420, 0xffffffffffffffff); var x446: u64 = undefined; var x447: u64 = undefined; fiatP434MulxU64(&x446, &x447, x420, 0xffffffffffffffff); var x448: u64 = undefined; var x449: u1 = undefined; fiatP434AddcarryxU64(&x448, &x449, 0x0, x447, x444); var x450: u64 = undefined; var x451: u1 = undefined; fiatP434AddcarryxU64(&x450, &x451, x449, x445, x442); var x452: u64 = undefined; var x453: u1 = undefined; fiatP434AddcarryxU64(&x452, &x453, x451, x443, x440); var x454: u64 = undefined; var x455: u1 = undefined; fiatP434AddcarryxU64(&x454, &x455, x453, x441, x438); var x456: u64 = undefined; var x457: u1 = undefined; fiatP434AddcarryxU64(&x456, &x457, x455, x439, x436); var x458: u64 = undefined; var x459: u1 = undefined; fiatP434AddcarryxU64(&x458, &x459, x457, x437, x434); var x460: u64 = undefined; var x461: u1 = undefined; fiatP434AddcarryxU64(&x460, &x461, 0x0, x420, x446); var x462: u64 = undefined; var x463: u1 = undefined; fiatP434AddcarryxU64(&x462, &x463, x461, x422, x448); var x464: u64 = undefined; var x465: u1 = undefined; fiatP434AddcarryxU64(&x464, &x465, x463, x424, x450); var x466: u64 = undefined; var x467: u1 = undefined; fiatP434AddcarryxU64(&x466, &x467, x465, x426, x452); var x468: u64 = undefined; var x469: u1 = undefined; fiatP434AddcarryxU64(&x468, &x469, x467, x428, x454); var x470: u64 = undefined; var x471: u1 = undefined; fiatP434AddcarryxU64(&x470, &x471, x469, x430, x456); var x472: u64 = undefined; var x473: u1 = undefined; fiatP434AddcarryxU64(&x472, &x473, x471, x432, x458); var x474: u64 = undefined; var x475: u64 = undefined; fiatP434MulxU64(&x474, &x475, x6, 0x25a89bcdd12a); var x476: u64 = undefined; var x477: u64 = undefined; fiatP434MulxU64(&x476, &x477, x6, 0x69e16a61c7686d9a); var x478: u64 = undefined; var x479: u64 = undefined; fiatP434MulxU64(&x478, &x479, x6, 0xabcd92bf2dde347e); var x480: u64 = undefined; var x481: u64 = undefined; fiatP434MulxU64(&x480, &x481, x6, 0x175cc6af8d6c7c0b); var x482: u64 = undefined; var x483: u64 = undefined; fiatP434MulxU64(&x482, &x483, x6, 0xab27973f8311688d); var x484: u64 = undefined; var x485: u64 = undefined; fiatP434MulxU64(&x484, &x485, x6, 0xacec7367768798c2); var x486: u64 = undefined; var x487: u64 = undefined; fiatP434MulxU64(&x486, &x487, x6, 0x28e55b65dcd69b30); var x488: u64 = undefined; var x489: u1 = undefined; fiatP434AddcarryxU64(&x488, &x489, 0x0, x487, x484); var x490: u64 = undefined; var x491: u1 = undefined; fiatP434AddcarryxU64(&x490, &x491, x489, x485, x482); var x492: u64 = undefined; var x493: u1 = undefined; fiatP434AddcarryxU64(&x492, &x493, x491, x483, x480); var x494: u64 = undefined; var x495: u1 = undefined; fiatP434AddcarryxU64(&x494, &x495, x493, x481, x478); var x496: u64 = undefined; var x497: u1 = undefined; fiatP434AddcarryxU64(&x496, &x497, x495, x479, x476); var x498: u64 = undefined; var x499: u1 = undefined; fiatP434AddcarryxU64(&x498, &x499, x497, x477, x474); var x500: u64 = undefined; var x501: u1 = undefined; fiatP434AddcarryxU64(&x500, &x501, 0x0, x462, x486); var x502: u64 = undefined; var x503: u1 = undefined; fiatP434AddcarryxU64(&x502, &x503, x501, x464, x488); var x504: u64 = undefined; var x505: u1 = undefined; fiatP434AddcarryxU64(&x504, &x505, x503, x466, x490); var x506: u64 = undefined; var x507: u1 = undefined; fiatP434AddcarryxU64(&x506, &x507, x505, x468, x492); var x508: u64 = undefined; var x509: u1 = undefined; fiatP434AddcarryxU64(&x508, &x509, x507, x470, x494); var x510: u64 = undefined; var x511: u1 = undefined; fiatP434AddcarryxU64(&x510, &x511, x509, x472, x496); var x512: u64 = undefined; var x513: u1 = undefined; fiatP434AddcarryxU64(&x512, &x513, x511, ((@intCast(u64, x473) + (@intCast(u64, x433) + (@intCast(u64, x419) + x395))) + (@intCast(u64, x459) + x435)), x498); var x514: u64 = undefined; var x515: u64 = undefined; fiatP434MulxU64(&x514, &x515, x500, 0x2341f27177344); var x516: u64 = undefined; var x517: u64 = undefined; fiatP434MulxU64(&x516, &x517, x500, 0x6cfc5fd681c52056); var x518: u64 = undefined; var x519: u64 = undefined; fiatP434MulxU64(&x518, &x519, x500, 0x7bc65c783158aea3); var x520: u64 = undefined; var x521: u64 = undefined; fiatP434MulxU64(&x520, &x521, x500, 0xfdc1767ae2ffffff); var x522: u64 = undefined; var x523: u64 = undefined; fiatP434MulxU64(&x522, &x523, x500, 0xffffffffffffffff); var x524: u64 = undefined; var x525: u64 = undefined; fiatP434MulxU64(&x524, &x525, x500, 0xffffffffffffffff); var x526: u64 = undefined; var x527: u64 = undefined; fiatP434MulxU64(&x526, &x527, x500, 0xffffffffffffffff); var x528: u64 = undefined; var x529: u1 = undefined; fiatP434AddcarryxU64(&x528, &x529, 0x0, x527, x524); var x530: u64 = undefined; var x531: u1 = undefined; fiatP434AddcarryxU64(&x530, &x531, x529, x525, x522); var x532: u64 = undefined; var x533: u1 = undefined; fiatP434AddcarryxU64(&x532, &x533, x531, x523, x520); var x534: u64 = undefined; var x535: u1 = undefined; fiatP434AddcarryxU64(&x534, &x535, x533, x521, x518); var x536: u64 = undefined; var x537: u1 = undefined; fiatP434AddcarryxU64(&x536, &x537, x535, x519, x516); var x538: u64 = undefined; var x539: u1 = undefined; fiatP434AddcarryxU64(&x538, &x539, x537, x517, x514); var x540: u64 = undefined; var x541: u1 = undefined; fiatP434AddcarryxU64(&x540, &x541, 0x0, x500, x526); var x542: u64 = undefined; var x543: u1 = undefined; fiatP434AddcarryxU64(&x542, &x543, x541, x502, x528); var x544: u64 = undefined; var x545: u1 = undefined; fiatP434AddcarryxU64(&x544, &x545, x543, x504, x530); var x546: u64 = undefined; var x547: u1 = undefined; fiatP434AddcarryxU64(&x546, &x547, x545, x506, x532); var x548: u64 = undefined; var x549: u1 = undefined; fiatP434AddcarryxU64(&x548, &x549, x547, x508, x534); var x550: u64 = undefined; var x551: u1 = undefined; fiatP434AddcarryxU64(&x550, &x551, x549, x510, x536); var x552: u64 = undefined; var x553: u1 = undefined; fiatP434AddcarryxU64(&x552, &x553, x551, x512, x538); const x554: u64 = ((@intCast(u64, x553) + (@intCast(u64, x513) + (@intCast(u64, x499) + x475))) + (@intCast(u64, x539) + x515)); var x555: u64 = undefined; var x556: u1 = undefined; fiatP434SubborrowxU64(&x555, &x556, 0x0, x542, 0xffffffffffffffff); var x557: u64 = undefined; var x558: u1 = undefined; fiatP434SubborrowxU64(&x557, &x558, x556, x544, 0xffffffffffffffff); var x559: u64 = undefined; var x560: u1 = undefined; fiatP434SubborrowxU64(&x559, &x560, x558, x546, 0xffffffffffffffff); var x561: u64 = undefined; var x562: u1 = undefined; fiatP434SubborrowxU64(&x561, &x562, x560, x548, 0xfdc1767ae2ffffff); var x563: u64 = undefined; var x564: u1 = undefined; fiatP434SubborrowxU64(&x563, &x564, x562, x550, 0x7bc65c783158aea3); var x565: u64 = undefined; var x566: u1 = undefined; fiatP434SubborrowxU64(&x565, &x566, x564, x552, 0x6cfc5fd681c52056); var x567: u64 = undefined; var x568: u1 = undefined; fiatP434SubborrowxU64(&x567, &x568, x566, x554, 0x2341f27177344); var x569: u64 = undefined; var x570: u1 = undefined; fiatP434SubborrowxU64(&x569, &x570, x568, @intCast(u64, 0x0), @intCast(u64, 0x0)); var x571: u64 = undefined; fiatP434CmovznzU64(&x571, x570, x555, x542); var x572: u64 = undefined; fiatP434CmovznzU64(&x572, x570, x557, x544); var x573: u64 = undefined; fiatP434CmovznzU64(&x573, x570, x559, x546); var x574: u64 = undefined; fiatP434CmovznzU64(&x574, x570, x561, x548); var x575: u64 = undefined; fiatP434CmovznzU64(&x575, x570, x563, x550); var x576: u64 = undefined; fiatP434CmovznzU64(&x576, x570, x565, x552); var x577: u64 = undefined; fiatP434CmovznzU64(&x577, x570, x567, x554); out1[0] = x571; out1[1] = x572; out1[2] = x573; out1[3] = x574; out1[4] = x575; out1[5] = x576; out1[6] = x577; } /// The function fiatP434Nonzero outputs a single non-zero word if the input is non-zero and zero otherwise. /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0 /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] pub fn fiatP434Nonzero(out1: *u64, arg1: [7]u64) void { const x1: u64 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | ((arg1[3]) | ((arg1[4]) | ((arg1[5]) | (arg1[6]))))))); out1.* = x1; } /// The function fiatP434Selectznz is a multi-limb conditional select. /// Postconditions: /// eval out1 = (if arg1 = 0 then eval arg2 else eval arg3) /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434Selectznz(out1: *[7]u64, arg1: u1, arg2: [7]u64, arg3: [7]u64) void { var x1: u64 = undefined; fiatP434CmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); var x2: u64 = undefined; fiatP434CmovznzU64(&x2, arg1, (arg2[1]), (arg3[1])); var x3: u64 = undefined; fiatP434CmovznzU64(&x3, arg1, (arg2[2]), (arg3[2])); var x4: u64 = undefined; fiatP434CmovznzU64(&x4, arg1, (arg2[3]), (arg3[3])); var x5: u64 = undefined; fiatP434CmovznzU64(&x5, arg1, (arg2[4]), (arg3[4])); var x6: u64 = undefined; fiatP434CmovznzU64(&x6, arg1, (arg2[5]), (arg3[5])); var x7: u64 = undefined; fiatP434CmovznzU64(&x7, arg1, (arg2[6]), (arg3[6])); out1[0] = x1; out1[1] = x2; out1[2] = x3; out1[3] = x4; out1[4] = x5; out1[5] = x6; out1[6] = x7; } /// The function fiatP434ToBytes serializes a field element NOT in the Montgomery domain to bytes in little-endian order. /// Preconditions: /// 0 ≤ eval arg1 < m /// Postconditions: /// out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..54] /// /// Input Bounds: /// arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0x3ffffffffffff]] /// Output Bounds: /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x3]] pub fn fiatP434ToBytes(out1: *[55]u8, arg1: [7]u64) void { const x1: u64 = (arg1[6]); const x2: u64 = (arg1[5]); const x3: u64 = (arg1[4]); const x4: u64 = (arg1[3]); const x5: u64 = (arg1[2]); const x6: u64 = (arg1[1]); const x7: u64 = (arg1[0]); const x8: u8 = @intCast(u8, (x7 & @intCast(u64, 0xff))); const x9: u64 = (x7 >> 8); const x10: u8 = @intCast(u8, (x9 & @intCast(u64, 0xff))); const x11: u64 = (x9 >> 8); const x12: u8 = @intCast(u8, (x11 & @intCast(u64, 0xff))); const x13: u64 = (x11 >> 8); const x14: u8 = @intCast(u8, (x13 & @intCast(u64, 0xff))); const x15: u64 = (x13 >> 8); const x16: u8 = @intCast(u8, (x15 & @intCast(u64, 0xff))); const x17: u64 = (x15 >> 8); const x18: u8 = @intCast(u8, (x17 & @intCast(u64, 0xff))); const x19: u64 = (x17 >> 8); const x20: u8 = @intCast(u8, (x19 & @intCast(u64, 0xff))); const x21: u8 = @intCast(u8, (x19 >> 8)); const x22: u8 = @intCast(u8, (x6 & @intCast(u64, 0xff))); const x23: u64 = (x6 >> 8); const x24: u8 = @intCast(u8, (x23 & @intCast(u64, 0xff))); const x25: u64 = (x23 >> 8); const x26: u8 = @intCast(u8, (x25 & @intCast(u64, 0xff))); const x27: u64 = (x25 >> 8); const x28: u8 = @intCast(u8, (x27 & @intCast(u64, 0xff))); const x29: u64 = (x27 >> 8); const x30: u8 = @intCast(u8, (x29 & @intCast(u64, 0xff))); const x31: u64 = (x29 >> 8); const x32: u8 = @intCast(u8, (x31 & @intCast(u64, 0xff))); const x33: u64 = (x31 >> 8); const x34: u8 = @intCast(u8, (x33 & @intCast(u64, 0xff))); const x35: u8 = @intCast(u8, (x33 >> 8)); const x36: u8 = @intCast(u8, (x5 & @intCast(u64, 0xff))); const x37: u64 = (x5 >> 8); const x38: u8 = @intCast(u8, (x37 & @intCast(u64, 0xff))); const x39: u64 = (x37 >> 8); const x40: u8 = @intCast(u8, (x39 & @intCast(u64, 0xff))); const x41: u64 = (x39 >> 8); const x42: u8 = @intCast(u8, (x41 & @intCast(u64, 0xff))); const x43: u64 = (x41 >> 8); const x44: u8 = @intCast(u8, (x43 & @intCast(u64, 0xff))); const x45: u64 = (x43 >> 8); const x46: u8 = @intCast(u8, (x45 & @intCast(u64, 0xff))); const x47: u64 = (x45 >> 8); const x48: u8 = @intCast(u8, (x47 & @intCast(u64, 0xff))); const x49: u8 = @intCast(u8, (x47 >> 8)); const x50: u8 = @intCast(u8, (x4 & @intCast(u64, 0xff))); const x51: u64 = (x4 >> 8); const x52: u8 = @intCast(u8, (x51 & @intCast(u64, 0xff))); const x53: u64 = (x51 >> 8); const x54: u8 = @intCast(u8, (x53 & @intCast(u64, 0xff))); const x55: u64 = (x53 >> 8); const x56: u8 = @intCast(u8, (x55 & @intCast(u64, 0xff))); const x57: u64 = (x55 >> 8); const x58: u8 = @intCast(u8, (x57 & @intCast(u64, 0xff))); const x59: u64 = (x57 >> 8); const x60: u8 = @intCast(u8, (x59 & @intCast(u64, 0xff))); const x61: u64 = (x59 >> 8); const x62: u8 = @intCast(u8, (x61 & @intCast(u64, 0xff))); const x63: u8 = @intCast(u8, (x61 >> 8)); const x64: u8 = @intCast(u8, (x3 & @intCast(u64, 0xff))); const x65: u64 = (x3 >> 8); const x66: u8 = @intCast(u8, (x65 & @intCast(u64, 0xff))); const x67: u64 = (x65 >> 8); const x68: u8 = @intCast(u8, (x67 & @intCast(u64, 0xff))); const x69: u64 = (x67 >> 8); const x70: u8 = @intCast(u8, (x69 & @intCast(u64, 0xff))); const x71: u64 = (x69 >> 8); const x72: u8 = @intCast(u8, (x71 & @intCast(u64, 0xff))); const x73: u64 = (x71 >> 8); const x74: u8 = @intCast(u8, (x73 & @intCast(u64, 0xff))); const x75: u64 = (x73 >> 8); const x76: u8 = @intCast(u8, (x75 & @intCast(u64, 0xff))); const x77: u8 = @intCast(u8, (x75 >> 8)); const x78: u8 = @intCast(u8, (x2 & @intCast(u64, 0xff))); const x79: u64 = (x2 >> 8); const x80: u8 = @intCast(u8, (x79 & @intCast(u64, 0xff))); const x81: u64 = (x79 >> 8); const x82: u8 = @intCast(u8, (x81 & @intCast(u64, 0xff))); const x83: u64 = (x81 >> 8); const x84: u8 = @intCast(u8, (x83 & @intCast(u64, 0xff))); const x85: u64 = (x83 >> 8); const x86: u8 = @intCast(u8, (x85 & @intCast(u64, 0xff))); const x87: u64 = (x85 >> 8); const x88: u8 = @intCast(u8, (x87 & @intCast(u64, 0xff))); const x89: u64 = (x87 >> 8); const x90: u8 = @intCast(u8, (x89 & @intCast(u64, 0xff))); const x91: u8 = @intCast(u8, (x89 >> 8)); const x92: u8 = @intCast(u8, (x1 & @intCast(u64, 0xff))); const x93: u64 = (x1 >> 8); const x94: u8 = @intCast(u8, (x93 & @intCast(u64, 0xff))); const x95: u64 = (x93 >> 8); const x96: u8 = @intCast(u8, (x95 & @intCast(u64, 0xff))); const x97: u64 = (x95 >> 8); const x98: u8 = @intCast(u8, (x97 & @intCast(u64, 0xff))); const x99: u64 = (x97 >> 8); const x100: u8 = @intCast(u8, (x99 & @intCast(u64, 0xff))); const x101: u64 = (x99 >> 8); const x102: u8 = @intCast(u8, (x101 & @intCast(u64, 0xff))); const x103: u8 = @intCast(u8, (x101 >> 8)); out1[0] = x8; out1[1] = x10; out1[2] = x12; out1[3] = x14; out1[4] = x16; out1[5] = x18; out1[6] = x20; out1[7] = x21; out1[8] = x22; out1[9] = x24; out1[10] = x26; out1[11] = x28; out1[12] = x30; out1[13] = x32; out1[14] = x34; out1[15] = x35; out1[16] = x36; out1[17] = x38; out1[18] = x40; out1[19] = x42; out1[20] = x44; out1[21] = x46; out1[22] = x48; out1[23] = x49; out1[24] = x50; out1[25] = x52; out1[26] = x54; out1[27] = x56; out1[28] = x58; out1[29] = x60; out1[30] = x62; out1[31] = x63; out1[32] = x64; out1[33] = x66; out1[34] = x68; out1[35] = x70; out1[36] = x72; out1[37] = x74; out1[38] = x76; out1[39] = x77; out1[40] = x78; out1[41] = x80; out1[42] = x82; out1[43] = x84; out1[44] = x86; out1[45] = x88; out1[46] = x90; out1[47] = x91; out1[48] = x92; out1[49] = x94; out1[50] = x96; out1[51] = x98; out1[52] = x100; out1[53] = x102; out1[54] = x103; } /// The function fiatP434FromBytes deserializes a field element NOT in the Montgomery domain from bytes in little-endian order. /// Preconditions: /// 0 ≤ bytes_eval arg1 < m /// Postconditions: /// eval out1 mod m = bytes_eval arg1 mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x3]] /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0x3ffffffffffff]] pub fn fiatP434FromBytes(out1: *[7]u64, arg1: [55]u8) void { const x1: u64 = (@intCast(u64, (arg1[54])) << 48); const x2: u64 = (@intCast(u64, (arg1[53])) << 40); const x3: u64 = (@intCast(u64, (arg1[52])) << 32); const x4: u64 = (@intCast(u64, (arg1[51])) << 24); const x5: u64 = (@intCast(u64, (arg1[50])) << 16); const x6: u64 = (@intCast(u64, (arg1[49])) << 8); const x7: u8 = (arg1[48]); const x8: u64 = (@intCast(u64, (arg1[47])) << 56); const x9: u64 = (@intCast(u64, (arg1[46])) << 48); const x10: u64 = (@intCast(u64, (arg1[45])) << 40); const x11: u64 = (@intCast(u64, (arg1[44])) << 32); const x12: u64 = (@intCast(u64, (arg1[43])) << 24); const x13: u64 = (@intCast(u64, (arg1[42])) << 16); const x14: u64 = (@intCast(u64, (arg1[41])) << 8); const x15: u8 = (arg1[40]); const x16: u64 = (@intCast(u64, (arg1[39])) << 56); const x17: u64 = (@intCast(u64, (arg1[38])) << 48); const x18: u64 = (@intCast(u64, (arg1[37])) << 40); const x19: u64 = (@intCast(u64, (arg1[36])) << 32); const x20: u64 = (@intCast(u64, (arg1[35])) << 24); const x21: u64 = (@intCast(u64, (arg1[34])) << 16); const x22: u64 = (@intCast(u64, (arg1[33])) << 8); const x23: u8 = (arg1[32]); const x24: u64 = (@intCast(u64, (arg1[31])) << 56); const x25: u64 = (@intCast(u64, (arg1[30])) << 48); const x26: u64 = (@intCast(u64, (arg1[29])) << 40); const x27: u64 = (@intCast(u64, (arg1[28])) << 32); const x28: u64 = (@intCast(u64, (arg1[27])) << 24); const x29: u64 = (@intCast(u64, (arg1[26])) << 16); const x30: u64 = (@intCast(u64, (arg1[25])) << 8); const x31: u8 = (arg1[24]); const x32: u64 = (@intCast(u64, (arg1[23])) << 56); const x33: u64 = (@intCast(u64, (arg1[22])) << 48); const x34: u64 = (@intCast(u64, (arg1[21])) << 40); const x35: u64 = (@intCast(u64, (arg1[20])) << 32); const x36: u64 = (@intCast(u64, (arg1[19])) << 24); const x37: u64 = (@intCast(u64, (arg1[18])) << 16); const x38: u64 = (@intCast(u64, (arg1[17])) << 8); const x39: u8 = (arg1[16]); const x40: u64 = (@intCast(u64, (arg1[15])) << 56); const x41: u64 = (@intCast(u64, (arg1[14])) << 48); const x42: u64 = (@intCast(u64, (arg1[13])) << 40); const x43: u64 = (@intCast(u64, (arg1[12])) << 32); const x44: u64 = (@intCast(u64, (arg1[11])) << 24); const x45: u64 = (@intCast(u64, (arg1[10])) << 16); const x46: u64 = (@intCast(u64, (arg1[9])) << 8); const x47: u8 = (arg1[8]); const x48: u64 = (@intCast(u64, (arg1[7])) << 56); const x49: u64 = (@intCast(u64, (arg1[6])) << 48); const x50: u64 = (@intCast(u64, (arg1[5])) << 40); const x51: u64 = (@intCast(u64, (arg1[4])) << 32); const x52: u64 = (@intCast(u64, (arg1[3])) << 24); const x53: u64 = (@intCast(u64, (arg1[2])) << 16); const x54: u64 = (@intCast(u64, (arg1[1])) << 8); const x55: u8 = (arg1[0]); const x56: u64 = (x54 + @intCast(u64, x55)); const x57: u64 = (x53 + x56); const x58: u64 = (x52 + x57); const x59: u64 = (x51 + x58); const x60: u64 = (x50 + x59); const x61: u64 = (x49 + x60); const x62: u64 = (x48 + x61); const x63: u64 = (x46 + @intCast(u64, x47)); const x64: u64 = (x45 + x63); const x65: u64 = (x44 + x64); const x66: u64 = (x43 + x65); const x67: u64 = (x42 + x66); const x68: u64 = (x41 + x67); const x69: u64 = (x40 + x68); const x70: u64 = (x38 + @intCast(u64, x39)); const x71: u64 = (x37 + x70); const x72: u64 = (x36 + x71); const x73: u64 = (x35 + x72); const x74: u64 = (x34 + x73); const x75: u64 = (x33 + x74); const x76: u64 = (x32 + x75); const x77: u64 = (x30 + @intCast(u64, x31)); const x78: u64 = (x29 + x77); const x79: u64 = (x28 + x78); const x80: u64 = (x27 + x79); const x81: u64 = (x26 + x80); const x82: u64 = (x25 + x81); const x83: u64 = (x24 + x82); const x84: u64 = (x22 + @intCast(u64, x23)); const x85: u64 = (x21 + x84); const x86: u64 = (x20 + x85); const x87: u64 = (x19 + x86); const x88: u64 = (x18 + x87); const x89: u64 = (x17 + x88); const x90: u64 = (x16 + x89); const x91: u64 = (x14 + @intCast(u64, x15)); const x92: u64 = (x13 + x91); const x93: u64 = (x12 + x92); const x94: u64 = (x11 + x93); const x95: u64 = (x10 + x94); const x96: u64 = (x9 + x95); const x97: u64 = (x8 + x96); const x98: u64 = (x6 + @intCast(u64, x7)); const x99: u64 = (x5 + x98); const x100: u64 = (x4 + x99); const x101: u64 = (x3 + x100); const x102: u64 = (x2 + x101); const x103: u64 = (x1 + x102); out1[0] = x62; out1[1] = x69; out1[2] = x76; out1[3] = x83; out1[4] = x90; out1[5] = x97; out1[6] = x103; } /// The function fiatP434SetOne returns the field element one in the Montgomery domain. /// Postconditions: /// eval (from_montgomery out1) mod m = 1 mod m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434SetOne(out1: *[7]u64) void { out1[0] = 0x742c; out1[1] = @intCast(u64, 0x0); out1[2] = @intCast(u64, 0x0); out1[3] = 0xb90ff404fc000000; out1[4] = 0xd801a4fb559facd4; out1[5] = 0xe93254545f77410c; out1[6] = 0xeceea7bd2eda; } /// The function fiatP434Msat returns the saturated representation of the prime modulus. /// Postconditions: /// twos_complement_eval out1 = m /// 0 ≤ eval out1 < m /// /// Input Bounds: /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434Msat(out1: *[8]u64) void { out1[0] = 0xffffffffffffffff; out1[1] = 0xffffffffffffffff; out1[2] = 0xffffffffffffffff; out1[3] = 0xfdc1767ae2ffffff; out1[4] = 0x7bc65c783158aea3; out1[5] = 0x6cfc5fd681c52056; out1[6] = 0x2341f27177344; out1[7] = @intCast(u64, 0x0); } /// The function fiatP434Divstep computes a divstep. /// Preconditions: /// 0 ≤ eval arg4 < m /// 0 ≤ eval arg5 < m /// Postconditions: /// out1 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then 1 - arg1 else 1 + arg1) /// twos_complement_eval out2 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then twos_complement_eval arg3 else twos_complement_eval arg2) /// twos_complement_eval out3 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then ⌊(twos_complement_eval arg3 - twos_complement_eval arg2) / 2⌋ else ⌊(twos_complement_eval arg3 + (twos_complement_eval arg3 mod 2) * twos_complement_eval arg2) / 2⌋) /// eval (from_montgomery out4) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (2 * eval (from_montgomery arg5)) mod m else (2 * eval (from_montgomery arg4)) mod m) /// eval (from_montgomery out5) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (eval (from_montgomery arg4) - eval (from_montgomery arg4)) mod m else (eval (from_montgomery arg5) + (twos_complement_eval arg3 mod 2) * eval (from_montgomery arg4)) mod m) /// 0 ≤ eval out5 < m /// 0 ≤ eval out5 < m /// 0 ≤ eval out2 < m /// 0 ≤ eval out3 < m /// /// Input Bounds: /// arg1: [0x0 ~> 0xffffffffffffffff] /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// arg5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434Divstep(out1: *u64, out2: *[8]u64, out3: *[8]u64, out4: *[7]u64, out5: *[7]u64, arg1: u64, arg2: [8]u64, arg3: [8]u64, arg4: [7]u64, arg5: [7]u64) void { var x1: u64 = undefined; var x2: u1 = undefined; fiatP434AddcarryxU64(&x1, &x2, 0x0, (~arg1), @intCast(u64, 0x1)); const x3: u1 = (@intCast(u1, (x1 >> 63)) & @intCast(u1, ((arg3[0]) & @intCast(u64, 0x1)))); var x4: u64 = undefined; var x5: u1 = undefined; fiatP434AddcarryxU64(&x4, &x5, 0x0, (~arg1), @intCast(u64, 0x1)); var x6: u64 = undefined; fiatP434CmovznzU64(&x6, x3, arg1, x4); var x7: u64 = undefined; fiatP434CmovznzU64(&x7, x3, (arg2[0]), (arg3[0])); var x8: u64 = undefined; fiatP434CmovznzU64(&x8, x3, (arg2[1]), (arg3[1])); var x9: u64 = undefined; fiatP434CmovznzU64(&x9, x3, (arg2[2]), (arg3[2])); var x10: u64 = undefined; fiatP434CmovznzU64(&x10, x3, (arg2[3]), (arg3[3])); var x11: u64 = undefined; fiatP434CmovznzU64(&x11, x3, (arg2[4]), (arg3[4])); var x12: u64 = undefined; fiatP434CmovznzU64(&x12, x3, (arg2[5]), (arg3[5])); var x13: u64 = undefined; fiatP434CmovznzU64(&x13, x3, (arg2[6]), (arg3[6])); var x14: u64 = undefined; fiatP434CmovznzU64(&x14, x3, (arg2[7]), (arg3[7])); var x15: u64 = undefined; var x16: u1 = undefined; fiatP434AddcarryxU64(&x15, &x16, 0x0, @intCast(u64, 0x1), (~(arg2[0]))); var x17: u64 = undefined; var x18: u1 = undefined; fiatP434AddcarryxU64(&x17, &x18, x16, @intCast(u64, 0x0), (~(arg2[1]))); var x19: u64 = undefined; var x20: u1 = undefined; fiatP434AddcarryxU64(&x19, &x20, x18, @intCast(u64, 0x0), (~(arg2[2]))); var x21: u64 = undefined; var x22: u1 = undefined; fiatP434AddcarryxU64(&x21, &x22, x20, @intCast(u64, 0x0), (~(arg2[3]))); var x23: u64 = undefined; var x24: u1 = undefined; fiatP434AddcarryxU64(&x23, &x24, x22, @intCast(u64, 0x0), (~(arg2[4]))); var x25: u64 = undefined; var x26: u1 = undefined; fiatP434AddcarryxU64(&x25, &x26, x24, @intCast(u64, 0x0), (~(arg2[5]))); var x27: u64 = undefined; var x28: u1 = undefined; fiatP434AddcarryxU64(&x27, &x28, x26, @intCast(u64, 0x0), (~(arg2[6]))); var x29: u64 = undefined; var x30: u1 = undefined; fiatP434AddcarryxU64(&x29, &x30, x28, @intCast(u64, 0x0), (~(arg2[7]))); var x31: u64 = undefined; fiatP434CmovznzU64(&x31, x3, (arg3[0]), x15); var x32: u64 = undefined; fiatP434CmovznzU64(&x32, x3, (arg3[1]), x17); var x33: u64 = undefined; fiatP434CmovznzU64(&x33, x3, (arg3[2]), x19); var x34: u64 = undefined; fiatP434CmovznzU64(&x34, x3, (arg3[3]), x21); var x35: u64 = undefined; fiatP434CmovznzU64(&x35, x3, (arg3[4]), x23); var x36: u64 = undefined; fiatP434CmovznzU64(&x36, x3, (arg3[5]), x25); var x37: u64 = undefined; fiatP434CmovznzU64(&x37, x3, (arg3[6]), x27); var x38: u64 = undefined; fiatP434CmovznzU64(&x38, x3, (arg3[7]), x29); var x39: u64 = undefined; fiatP434CmovznzU64(&x39, x3, (arg4[0]), (arg5[0])); var x40: u64 = undefined; fiatP434CmovznzU64(&x40, x3, (arg4[1]), (arg5[1])); var x41: u64 = undefined; fiatP434CmovznzU64(&x41, x3, (arg4[2]), (arg5[2])); var x42: u64 = undefined; fiatP434CmovznzU64(&x42, x3, (arg4[3]), (arg5[3])); var x43: u64 = undefined; fiatP434CmovznzU64(&x43, x3, (arg4[4]), (arg5[4])); var x44: u64 = undefined; fiatP434CmovznzU64(&x44, x3, (arg4[5]), (arg5[5])); var x45: u64 = undefined; fiatP434CmovznzU64(&x45, x3, (arg4[6]), (arg5[6])); var x46: u64 = undefined; var x47: u1 = undefined; fiatP434AddcarryxU64(&x46, &x47, 0x0, x39, x39); var x48: u64 = undefined; var x49: u1 = undefined; fiatP434AddcarryxU64(&x48, &x49, x47, x40, x40); var x50: u64 = undefined; var x51: u1 = undefined; fiatP434AddcarryxU64(&x50, &x51, x49, x41, x41); var x52: u64 = undefined; var x53: u1 = undefined; fiatP434AddcarryxU64(&x52, &x53, x51, x42, x42); var x54: u64 = undefined; var x55: u1 = undefined; fiatP434AddcarryxU64(&x54, &x55, x53, x43, x43); var x56: u64 = undefined; var x57: u1 = undefined; fiatP434AddcarryxU64(&x56, &x57, x55, x44, x44); var x58: u64 = undefined; var x59: u1 = undefined; fiatP434AddcarryxU64(&x58, &x59, x57, x45, x45); var x60: u64 = undefined; var x61: u1 = undefined; fiatP434SubborrowxU64(&x60, &x61, 0x0, x46, 0xffffffffffffffff); var x62: u64 = undefined; var x63: u1 = undefined; fiatP434SubborrowxU64(&x62, &x63, x61, x48, 0xffffffffffffffff); var x64: u64 = undefined; var x65: u1 = undefined; fiatP434SubborrowxU64(&x64, &x65, x63, x50, 0xffffffffffffffff); var x66: u64 = undefined; var x67: u1 = undefined; fiatP434SubborrowxU64(&x66, &x67, x65, x52, 0xfdc1767ae2ffffff); var x68: u64 = undefined; var x69: u1 = undefined; fiatP434SubborrowxU64(&x68, &x69, x67, x54, 0x7bc65c783158aea3); var x70: u64 = undefined; var x71: u1 = undefined; fiatP434SubborrowxU64(&x70, &x71, x69, x56, 0x6cfc5fd681c52056); var x72: u64 = undefined; var x73: u1 = undefined; fiatP434SubborrowxU64(&x72, &x73, x71, x58, 0x2341f27177344); var x74: u64 = undefined; var x75: u1 = undefined; fiatP434SubborrowxU64(&x74, &x75, x73, @intCast(u64, x59), @intCast(u64, 0x0)); const x76: u64 = (arg4[6]); const x77: u64 = (arg4[5]); const x78: u64 = (arg4[4]); const x79: u64 = (arg4[3]); const x80: u64 = (arg4[2]); const x81: u64 = (arg4[1]); const x82: u64 = (arg4[0]); var x83: u64 = undefined; var x84: u1 = undefined; fiatP434SubborrowxU64(&x83, &x84, 0x0, @intCast(u64, 0x0), x82); var x85: u64 = undefined; var x86: u1 = undefined; fiatP434SubborrowxU64(&x85, &x86, x84, @intCast(u64, 0x0), x81); var x87: u64 = undefined; var x88: u1 = undefined; fiatP434SubborrowxU64(&x87, &x88, x86, @intCast(u64, 0x0), x80); var x89: u64 = undefined; var x90: u1 = undefined; fiatP434SubborrowxU64(&x89, &x90, x88, @intCast(u64, 0x0), x79); var x91: u64 = undefined; var x92: u1 = undefined; fiatP434SubborrowxU64(&x91, &x92, x90, @intCast(u64, 0x0), x78); var x93: u64 = undefined; var x94: u1 = undefined; fiatP434SubborrowxU64(&x93, &x94, x92, @intCast(u64, 0x0), x77); var x95: u64 = undefined; var x96: u1 = undefined; fiatP434SubborrowxU64(&x95, &x96, x94, @intCast(u64, 0x0), x76); var x97: u64 = undefined; fiatP434CmovznzU64(&x97, x96, @intCast(u64, 0x0), 0xffffffffffffffff); var x98: u64 = undefined; var x99: u1 = undefined; fiatP434AddcarryxU64(&x98, &x99, 0x0, x83, x97); var x100: u64 = undefined; var x101: u1 = undefined; fiatP434AddcarryxU64(&x100, &x101, x99, x85, x97); var x102: u64 = undefined; var x103: u1 = undefined; fiatP434AddcarryxU64(&x102, &x103, x101, x87, x97); var x104: u64 = undefined; var x105: u1 = undefined; fiatP434AddcarryxU64(&x104, &x105, x103, x89, (x97 & 0xfdc1767ae2ffffff)); var x106: u64 = undefined; var x107: u1 = undefined; fiatP434AddcarryxU64(&x106, &x107, x105, x91, (x97 & 0x7bc65c783158aea3)); var x108: u64 = undefined; var x109: u1 = undefined; fiatP434AddcarryxU64(&x108, &x109, x107, x93, (x97 & 0x6cfc5fd681c52056)); var x110: u64 = undefined; var x111: u1 = undefined; fiatP434AddcarryxU64(&x110, &x111, x109, x95, (x97 & 0x2341f27177344)); var x112: u64 = undefined; fiatP434CmovznzU64(&x112, x3, (arg5[0]), x98); var x113: u64 = undefined; fiatP434CmovznzU64(&x113, x3, (arg5[1]), x100); var x114: u64 = undefined; fiatP434CmovznzU64(&x114, x3, (arg5[2]), x102); var x115: u64 = undefined; fiatP434CmovznzU64(&x115, x3, (arg5[3]), x104); var x116: u64 = undefined; fiatP434CmovznzU64(&x116, x3, (arg5[4]), x106); var x117: u64 = undefined; fiatP434CmovznzU64(&x117, x3, (arg5[5]), x108); var x118: u64 = undefined; fiatP434CmovznzU64(&x118, x3, (arg5[6]), x110); const x119: u1 = @intCast(u1, (x31 & @intCast(u64, 0x1))); var x120: u64 = undefined; fiatP434CmovznzU64(&x120, x119, @intCast(u64, 0x0), x7); var x121: u64 = undefined; fiatP434CmovznzU64(&x121, x119, @intCast(u64, 0x0), x8); var x122: u64 = undefined; fiatP434CmovznzU64(&x122, x119, @intCast(u64, 0x0), x9); var x123: u64 = undefined; fiatP434CmovznzU64(&x123, x119, @intCast(u64, 0x0), x10); var x124: u64 = undefined; fiatP434CmovznzU64(&x124, x119, @intCast(u64, 0x0), x11); var x125: u64 = undefined; fiatP434CmovznzU64(&x125, x119, @intCast(u64, 0x0), x12); var x126: u64 = undefined; fiatP434CmovznzU64(&x126, x119, @intCast(u64, 0x0), x13); var x127: u64 = undefined; fiatP434CmovznzU64(&x127, x119, @intCast(u64, 0x0), x14); var x128: u64 = undefined; var x129: u1 = undefined; fiatP434AddcarryxU64(&x128, &x129, 0x0, x31, x120); var x130: u64 = undefined; var x131: u1 = undefined; fiatP434AddcarryxU64(&x130, &x131, x129, x32, x121); var x132: u64 = undefined; var x133: u1 = undefined; fiatP434AddcarryxU64(&x132, &x133, x131, x33, x122); var x134: u64 = undefined; var x135: u1 = undefined; fiatP434AddcarryxU64(&x134, &x135, x133, x34, x123); var x136: u64 = undefined; var x137: u1 = undefined; fiatP434AddcarryxU64(&x136, &x137, x135, x35, x124); var x138: u64 = undefined; var x139: u1 = undefined; fiatP434AddcarryxU64(&x138, &x139, x137, x36, x125); var x140: u64 = undefined; var x141: u1 = undefined; fiatP434AddcarryxU64(&x140, &x141, x139, x37, x126); var x142: u64 = undefined; var x143: u1 = undefined; fiatP434AddcarryxU64(&x142, &x143, x141, x38, x127); var x144: u64 = undefined; fiatP434CmovznzU64(&x144, x119, @intCast(u64, 0x0), x39); var x145: u64 = undefined; fiatP434CmovznzU64(&x145, x119, @intCast(u64, 0x0), x40); var x146: u64 = undefined; fiatP434CmovznzU64(&x146, x119, @intCast(u64, 0x0), x41); var x147: u64 = undefined; fiatP434CmovznzU64(&x147, x119, @intCast(u64, 0x0), x42); var x148: u64 = undefined; fiatP434CmovznzU64(&x148, x119, @intCast(u64, 0x0), x43); var x149: u64 = undefined; fiatP434CmovznzU64(&x149, x119, @intCast(u64, 0x0), x44); var x150: u64 = undefined; fiatP434CmovznzU64(&x150, x119, @intCast(u64, 0x0), x45); var x151: u64 = undefined; var x152: u1 = undefined; fiatP434AddcarryxU64(&x151, &x152, 0x0, x112, x144); var x153: u64 = undefined; var x154: u1 = undefined; fiatP434AddcarryxU64(&x153, &x154, x152, x113, x145); var x155: u64 = undefined; var x156: u1 = undefined; fiatP434AddcarryxU64(&x155, &x156, x154, x114, x146); var x157: u64 = undefined; var x158: u1 = undefined; fiatP434AddcarryxU64(&x157, &x158, x156, x115, x147); var x159: u64 = undefined; var x160: u1 = undefined; fiatP434AddcarryxU64(&x159, &x160, x158, x116, x148); var x161: u64 = undefined; var x162: u1 = undefined; fiatP434AddcarryxU64(&x161, &x162, x160, x117, x149); var x163: u64 = undefined; var x164: u1 = undefined; fiatP434AddcarryxU64(&x163, &x164, x162, x118, x150); var x165: u64 = undefined; var x166: u1 = undefined; fiatP434SubborrowxU64(&x165, &x166, 0x0, x151, 0xffffffffffffffff); var x167: u64 = undefined; var x168: u1 = undefined; fiatP434SubborrowxU64(&x167, &x168, x166, x153, 0xffffffffffffffff); var x169: u64 = undefined; var x170: u1 = undefined; fiatP434SubborrowxU64(&x169, &x170, x168, x155, 0xffffffffffffffff); var x171: u64 = undefined; var x172: u1 = undefined; fiatP434SubborrowxU64(&x171, &x172, x170, x157, 0xfdc1767ae2ffffff); var x173: u64 = undefined; var x174: u1 = undefined; fiatP434SubborrowxU64(&x173, &x174, x172, x159, 0x7bc65c783158aea3); var x175: u64 = undefined; var x176: u1 = undefined; fiatP434SubborrowxU64(&x175, &x176, x174, x161, 0x6cfc5fd681c52056); var x177: u64 = undefined; var x178: u1 = undefined; fiatP434SubborrowxU64(&x177, &x178, x176, x163, 0x2341f27177344); var x179: u64 = undefined; var x180: u1 = undefined; fiatP434SubborrowxU64(&x179, &x180, x178, @intCast(u64, x164), @intCast(u64, 0x0)); var x181: u64 = undefined; var x182: u1 = undefined; fiatP434AddcarryxU64(&x181, &x182, 0x0, x6, @intCast(u64, 0x1)); const x183: u64 = ((x128 >> 1) | ((x130 << 63) & 0xffffffffffffffff)); const x184: u64 = ((x130 >> 1) | ((x132 << 63) & 0xffffffffffffffff)); const x185: u64 = ((x132 >> 1) | ((x134 << 63) & 0xffffffffffffffff)); const x186: u64 = ((x134 >> 1) | ((x136 << 63) & 0xffffffffffffffff)); const x187: u64 = ((x136 >> 1) | ((x138 << 63) & 0xffffffffffffffff)); const x188: u64 = ((x138 >> 1) | ((x140 << 63) & 0xffffffffffffffff)); const x189: u64 = ((x140 >> 1) | ((x142 << 63) & 0xffffffffffffffff)); const x190: u64 = ((x142 & 0x8000000000000000) | (x142 >> 1)); var x191: u64 = undefined; fiatP434CmovznzU64(&x191, x75, x60, x46); var x192: u64 = undefined; fiatP434CmovznzU64(&x192, x75, x62, x48); var x193: u64 = undefined; fiatP434CmovznzU64(&x193, x75, x64, x50); var x194: u64 = undefined; fiatP434CmovznzU64(&x194, x75, x66, x52); var x195: u64 = undefined; fiatP434CmovznzU64(&x195, x75, x68, x54); var x196: u64 = undefined; fiatP434CmovznzU64(&x196, x75, x70, x56); var x197: u64 = undefined; fiatP434CmovznzU64(&x197, x75, x72, x58); var x198: u64 = undefined; fiatP434CmovznzU64(&x198, x180, x165, x151); var x199: u64 = undefined; fiatP434CmovznzU64(&x199, x180, x167, x153); var x200: u64 = undefined; fiatP434CmovznzU64(&x200, x180, x169, x155); var x201: u64 = undefined; fiatP434CmovznzU64(&x201, x180, x171, x157); var x202: u64 = undefined; fiatP434CmovznzU64(&x202, x180, x173, x159); var x203: u64 = undefined; fiatP434CmovznzU64(&x203, x180, x175, x161); var x204: u64 = undefined; fiatP434CmovznzU64(&x204, x180, x177, x163); out1.* = x181; out2[0] = x7; out2[1] = x8; out2[2] = x9; out2[3] = x10; out2[4] = x11; out2[5] = x12; out2[6] = x13; out2[7] = x14; out3[0] = x183; out3[1] = x184; out3[2] = x185; out3[3] = x186; out3[4] = x187; out3[5] = x188; out3[6] = x189; out3[7] = x190; out4[0] = x191; out4[1] = x192; out4[2] = x193; out4[3] = x194; out4[4] = x195; out4[5] = x196; out4[6] = x197; out5[0] = x198; out5[1] = x199; out5[2] = x200; out5[3] = x201; out5[4] = x202; out5[5] = x203; out5[6] = x204; } /// The function fiatP434DivstepPrecomp returns the precomputed value for Bernstein-Yang-inversion (in montgomery form). /// Postconditions: /// eval (from_montgomery out1) = ⌊(m - 1) / 2⌋^(if (log2 m) + 1 < 46 then ⌊(49 * ((log2 m) + 1) + 80) / 17⌋ else ⌊(49 * ((log2 m) + 1) + 57) / 17⌋) /// 0 ≤ eval out1 < m /// /// Input Bounds: /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fiatP434DivstepPrecomp(out1: *[7]u64) void { out1[0] = 0x9f9776e27e1a2b72; out1[1] = 0x28b59f067e2393d0; out1[2] = 0xcf316ce1572add54; out1[3] = 0x312c8965f9032c2f; out1[4] = 0x9d9cab29ad90d34c; out1[5] = 0x6e1ddae1d9609ae1; out1[6] = 0x6df82285eec6; }
fiat-zig/src/p434_64.zig
const std = @import("std.zig"); const builtin = @import("builtin"); const assert = std.debug.assert; const mem = std.mem; const math = std.math; const ziggurat = @import("rand/ziggurat.zig"); const maxInt = std.math.maxInt; /// Fast unbiased random numbers. pub const DefaultPrng = Xoshiro256; /// Cryptographically secure random numbers. pub const DefaultCsprng = Gimli; pub const Isaac64 = @import("rand/Isaac64.zig"); pub const Gimli = @import("rand/Gimli.zig"); pub const Pcg = @import("rand/Pcg.zig"); pub const Xoroshiro128 = @import("rand/Xoroshiro128.zig"); pub const Xoshiro256 = @import("rand/Xoshiro256.zig"); pub const Sfc64 = @import("rand/Sfc64.zig"); pub const RomuTrio = @import("rand/RomuTrio.zig"); pub const Random = struct { ptr: *anyopaque, fillFn: if (builtin.zig_backend == .stage1) fn (ptr: *anyopaque, buf: []u8) void else *const fn (ptr: *anyopaque, buf: []u8) void, pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random { const Ptr = @TypeOf(pointer); assert(@typeInfo(Ptr) == .Pointer); // Must be a pointer assert(@typeInfo(Ptr).Pointer.size == .One); // Must be a single-item pointer assert(@typeInfo(@typeInfo(Ptr).Pointer.child) == .Struct); // Must point to a struct const gen = struct { fn fill(ptr: *anyopaque, buf: []u8) void { const alignment = @typeInfo(Ptr).Pointer.alignment; const self = @ptrCast(Ptr, @alignCast(alignment, ptr)); fillFn(self, buf); } }; return .{ .ptr = pointer, .fillFn = gen.fill, }; } /// Read random bytes into the specified buffer until full. pub fn bytes(r: Random, buf: []u8) void { r.fillFn(r.ptr, buf); } pub fn boolean(r: Random) bool { return r.int(u1) != 0; } /// Returns a random value from an enum, evenly distributed. pub fn enumValue(r: Random, comptime EnumType: type) EnumType { comptime assert(@typeInfo(EnumType) == .Enum); // We won't use int -> enum casting because enum elements can have // arbitrary values. Instead we'll randomly pick one of the type's values. const values = std.enums.values(EnumType); const index = r.uintLessThan(usize, values.len); return values[index]; } /// Returns a random int `i` such that `minInt(T) <= i <= maxInt(T)`. /// `i` is evenly distributed. pub fn int(r: Random, comptime T: type) T { const bits = @typeInfo(T).Int.bits; const UnsignedT = std.meta.Int(.unsigned, bits); const ByteAlignedT = std.meta.Int(.unsigned, @divTrunc(bits + 7, 8) * 8); var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined; r.bytes(rand_bytes[0..]); // use LE instead of native endian for better portability maybe? // TODO: endian portability is pointless if the underlying prng isn't endian portable. // TODO: document the endian portability of this library. const byte_aligned_result = mem.readIntSliceLittle(ByteAlignedT, &rand_bytes); const unsigned_result = @truncate(UnsignedT, byte_aligned_result); return @bitCast(T, unsigned_result); } /// Constant-time implementation off `uintLessThan`. /// The results of this function may be biased. pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T { comptime assert(@typeInfo(T).Int.signedness == .unsigned); const bits = @typeInfo(T).Int.bits; comptime assert(bits <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation! assert(0 < less_than); if (bits <= 32) { return @intCast(T, limitRangeBiased(u32, r.int(u32), less_than)); } else { return @intCast(T, limitRangeBiased(u64, r.int(u64), less_than)); } } /// Returns an evenly distributed random unsigned integer `0 <= i < less_than`. /// This function assumes that the underlying `fillFn` produces evenly distributed values. /// Within this assumption, the runtime of this function is exponentially distributed. /// If `fillFn` were backed by a true random generator, /// the runtime of this function would technically be unbounded. /// However, if `fillFn` is backed by any evenly distributed pseudo random number generator, /// this function is guaranteed to return. /// If you need deterministic runtime bounds, use `uintLessThanBiased`. pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T { comptime assert(@typeInfo(T).Int.signedness == .unsigned); const bits = @typeInfo(T).Int.bits; comptime assert(bits <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation! assert(0 < less_than); // Small is typically u32 const small_bits = @divTrunc(bits + 31, 32) * 32; const Small = std.meta.Int(.unsigned, small_bits); // Large is typically u64 const Large = std.meta.Int(.unsigned, small_bits * 2); // adapted from: // http://www.pcg-random.org/posts/bounded-rands.html // "Lemire's (with an extra tweak from me)" var x: Small = r.int(Small); var m: Large = @as(Large, x) * @as(Large, less_than); var l: Small = @truncate(Small, m); if (l < less_than) { var t: Small = -%less_than; if (t >= less_than) { t -= less_than; if (t >= less_than) { t %= less_than; } } while (l < t) { x = r.int(Small); m = @as(Large, x) * @as(Large, less_than); l = @truncate(Small, m); } } return @intCast(T, m >> small_bits); } /// Constant-time implementation off `uintAtMost`. /// The results of this function may be biased. pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T { assert(@typeInfo(T).Int.signedness == .unsigned); if (at_most == maxInt(T)) { // have the full range return r.int(T); } return r.uintLessThanBiased(T, at_most + 1); } /// Returns an evenly distributed random unsigned integer `0 <= i <= at_most`. /// See `uintLessThan`, which this function uses in most cases, /// for commentary on the runtime of this function. pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T { assert(@typeInfo(T).Int.signedness == .unsigned); if (at_most == maxInt(T)) { // have the full range return r.int(T); } return r.uintLessThan(T, at_most + 1); } /// Constant-time implementation off `intRangeLessThan`. /// The results of this function may be biased. pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_than: T) T { assert(at_least < less_than); const info = @typeInfo(T).Int; if (info.signedness == .signed) { // Two's complement makes this math pretty easy. const UnsignedT = std.meta.Int(.unsigned, info.bits); const lo = @bitCast(UnsignedT, at_least); const hi = @bitCast(UnsignedT, less_than); const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo); return @bitCast(T, result); } else { // The signed implementation would work fine, but we can use stricter arithmetic operators here. return at_least + r.uintLessThanBiased(T, less_than - at_least); } } /// Returns an evenly distributed random integer `at_least <= i < less_than`. /// See `uintLessThan`, which this function uses in most cases, /// for commentary on the runtime of this function. pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T) T { assert(at_least < less_than); const info = @typeInfo(T).Int; if (info.signedness == .signed) { // Two's complement makes this math pretty easy. const UnsignedT = std.meta.Int(.unsigned, info.bits); const lo = @bitCast(UnsignedT, at_least); const hi = @bitCast(UnsignedT, less_than); const result = lo +% r.uintLessThan(UnsignedT, hi -% lo); return @bitCast(T, result); } else { // The signed implementation would work fine, but we can use stricter arithmetic operators here. return at_least + r.uintLessThan(T, less_than - at_least); } } /// Constant-time implementation off `intRangeAtMostBiased`. /// The results of this function may be biased. pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T) T { assert(at_least <= at_most); const info = @typeInfo(T).Int; if (info.signedness == .signed) { // Two's complement makes this math pretty easy. const UnsignedT = std.meta.Int(.unsigned, info.bits); const lo = @bitCast(UnsignedT, at_least); const hi = @bitCast(UnsignedT, at_most); const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo); return @bitCast(T, result); } else { // The signed implementation would work fine, but we can use stricter arithmetic operators here. return at_least + r.uintAtMostBiased(T, at_most - at_least); } } /// Returns an evenly distributed random integer `at_least <= i <= at_most`. /// See `uintLessThan`, which this function uses in most cases, /// for commentary on the runtime of this function. pub fn intRangeAtMost(r: Random, comptime T: type, at_least: T, at_most: T) T { assert(at_least <= at_most); const info = @typeInfo(T).Int; if (info.signedness == .signed) { // Two's complement makes this math pretty easy. const UnsignedT = std.meta.Int(.unsigned, info.bits); const lo = @bitCast(UnsignedT, at_least); const hi = @bitCast(UnsignedT, at_most); const result = lo +% r.uintAtMost(UnsignedT, hi -% lo); return @bitCast(T, result); } else { // The signed implementation would work fine, but we can use stricter arithmetic operators here. return at_least + r.uintAtMost(T, at_most - at_least); } } /// Return a floating point value evenly distributed in the range [0, 1). pub fn float(r: Random, comptime T: type) T { // Generate a uniformly random value for the mantissa. // Then generate an exponentially biased random value for the exponent. // This covers every possible value in the range. switch (T) { f32 => { // Use 23 random bits for the mantissa, and the rest for the exponent. // If all 41 bits are zero, generate additional random bits, until a // set bit is found, or 126 bits have been generated. const rand = r.int(u64); var rand_lz = @clz(u64, rand); if (rand_lz >= 41) { // TODO: when #5177 or #489 is implemented, // tell the compiler it is unlikely (1/2^41) to reach this point. // (Same for the if branch and the f64 calculations below.) rand_lz = 41 + @clz(u64, r.int(u64)); if (rand_lz == 41 + 64) { // It is astronomically unlikely to reach this point. rand_lz += @clz(u32, r.int(u32) | 0x7FF); } } const mantissa = @truncate(u23, rand); const exponent = @as(u32, 126 - rand_lz) << 23; return @bitCast(f32, exponent | mantissa); }, f64 => { // Use 52 random bits for the mantissa, and the rest for the exponent. // If all 12 bits are zero, generate additional random bits, until a // set bit is found, or 1022 bits have been generated. const rand = r.int(u64); var rand_lz: u64 = @clz(u64, rand); if (rand_lz >= 12) { rand_lz = 12; while (true) { // It is astronomically unlikely for this loop to execute more than once. const addl_rand_lz = @clz(u64, r.int(u64)); rand_lz += addl_rand_lz; if (addl_rand_lz != 64) { break; } if (rand_lz >= 1022) { rand_lz = 1022; break; } } } const mantissa = rand & 0xFFFFFFFFFFFFF; const exponent = (1022 - rand_lz) << 52; return @bitCast(f64, exponent | mantissa); }, else => @compileError("unknown floating point type"), } } /// Return a floating point value normally distributed with mean = 0, stddev = 1. /// /// To use different parameters, use: floatNorm(...) * desiredStddev + desiredMean. pub fn floatNorm(r: Random, comptime T: type) T { const value = ziggurat.next_f64(r, ziggurat.NormDist); switch (T) { f32 => return @floatCast(f32, value), f64 => return value, else => @compileError("unknown floating point type"), } } /// Return an exponentially distributed float with a rate parameter of 1. /// /// To use a different rate parameter, use: floatExp(...) / desiredRate. pub fn floatExp(r: Random, comptime T: type) T { const value = ziggurat.next_f64(r, ziggurat.ExpDist); switch (T) { f32 => return @floatCast(f32, value), f64 => return value, else => @compileError("unknown floating point type"), } } /// Shuffle a slice into a random order. pub fn shuffle(r: Random, comptime T: type, buf: []T) void { if (buf.len < 2) { return; } var i: usize = 0; while (i < buf.len - 1) : (i += 1) { const j = r.intRangeLessThan(usize, i, buf.len); mem.swap(T, &buf[i], &buf[j]); } } }; /// Convert a random integer 0 <= random_int <= maxValue(T), /// into an integer 0 <= result < less_than. /// This function introduces a minor bias. pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T { comptime assert(@typeInfo(T).Int.signedness == .unsigned); const bits = @typeInfo(T).Int.bits; const T2 = std.meta.Int(.unsigned, bits * 2); // adapted from: // http://www.pcg-random.org/posts/bounded-rands.html // "Integer Multiplication (Biased)" var m: T2 = @as(T2, random_int) * @as(T2, less_than); return @intCast(T, m >> bits); } // Generator to extend 64-bit seed values into longer sequences. // // The number of cycles is thus limited to 64-bits regardless of the engine, but this // is still plenty for practical purposes. pub const SplitMix64 = struct { s: u64, pub fn init(seed: u64) SplitMix64 { return SplitMix64{ .s = seed }; } pub fn next(self: *SplitMix64) u64 { self.s +%= 0x9e3779b97f4a7c15; var z = self.s; z = (z ^ (z >> 30)) *% 0xbf58476d1ce4e5b9; z = (z ^ (z >> 27)) *% 0x94d049bb133111eb; return z ^ (z >> 31); } }; test { std.testing.refAllDecls(@This()); _ = @import("rand/test.zig"); }
lib/std/rand.zig
const std = @import("std"); const assert = std.debug.assert; const Compilation = @import("Compilation.zig"); const build_options = @import("build_options"); const trace = @import("tracy.zig").trace; pub fn buildTsan(comp: *Compilation) !void { if (!build_options.have_llvm) { return error.ZigCompilerNotBuiltWithLLVMExtensions; } const tracy = trace(@src()); defer tracy.end(); var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); defer arena_allocator.deinit(); const arena = &arena_allocator.allocator; const root_name = "tsan"; const output_mode = .Lib; const link_mode = .Static; const target = comp.getTarget(); const basename = try std.zig.binNameAlloc(arena, .{ .root_name = root_name, .target = target, .output_mode = output_mode, .link_mode = link_mode, }); const emit_bin = Compilation.EmitLoc{ .directory = null, // Put it in the cache directory. .basename = basename, }; var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena); try c_source_files.ensureCapacity(c_source_files.items.len + tsan_sources.len); const tsan_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{"tsan"}); for (tsan_sources) |tsan_src| { var cflags = std.ArrayList([]const u8).init(arena); try cflags.append("-I"); try cflags.append(tsan_include_path); try cflags.append("-nostdinc++"); try cflags.append("-fvisibility-inlines-hidden"); try cflags.append("-std=c++14"); try cflags.append("-fno-rtti"); c_source_files.appendAssumeCapacity(.{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", tsan_src }), .extra_flags = cflags.items, }); } const platform_tsan_sources = if (target.isDarwin()) &darwin_tsan_sources else &unix_tsan_sources; try c_source_files.ensureCapacity(c_source_files.items.len + platform_tsan_sources.len); for (platform_tsan_sources) |tsan_src| { var cflags = std.ArrayList([]const u8).init(arena); try cflags.append("-I"); try cflags.append(tsan_include_path); try cflags.append("-nostdinc++"); try cflags.append("-fvisibility-inlines-hidden"); try cflags.append("-std=c++14"); try cflags.append("-fno-rtti"); c_source_files.appendAssumeCapacity(.{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", tsan_src }), .extra_flags = cflags.items, }); } { const asm_source = switch (target.cpu.arch) { .aarch64 => "tsan_rtl_aarch64.S", .x86_64 => "tsan_rtl_amd64.S", .mips64 => "tsan_rtl_mips64.S", .powerpc64 => "tsan_rtl_ppc64.S", else => return error.TSANUnsupportedCPUArchitecture, }; var cflags = std.ArrayList([]const u8).init(arena); try cflags.append("-I"); try cflags.append(tsan_include_path); try cflags.append("-DNDEBUG"); c_source_files.appendAssumeCapacity(.{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", asm_source }), .extra_flags = cflags.items, }); } try c_source_files.ensureCapacity(c_source_files.items.len + sanitizer_common_sources.len); const sanitizer_common_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", "sanitizer_common", }); for (sanitizer_common_sources) |common_src| { var cflags = std.ArrayList([]const u8).init(arena); try cflags.append("-I"); try cflags.append(sanitizer_common_include_path); try cflags.append("-nostdinc++"); try cflags.append("-fvisibility-inlines-hidden"); try cflags.append("-std=c++14"); try cflags.append("-fno-rtti"); c_source_files.appendAssumeCapacity(.{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", "sanitizer_common", common_src, }), .extra_flags = cflags.items, }); } const to_c_or_not_to_c_sources = if (comp.bin_file.options.link_libc) &sanitizer_libcdep_sources else &sanitizer_nolibc_sources; try c_source_files.ensureCapacity(c_source_files.items.len + to_c_or_not_to_c_sources.len); for (to_c_or_not_to_c_sources) |c_src| { var cflags = std.ArrayList([]const u8).init(arena); try cflags.append("-I"); try cflags.append(sanitizer_common_include_path); try cflags.append("-nostdinc++"); try cflags.append("-fvisibility-inlines-hidden"); try cflags.append("-std=c++14"); try cflags.append("-fno-rtti"); c_source_files.appendAssumeCapacity(.{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", "sanitizer_common", c_src, }), .extra_flags = cflags.items, }); } try c_source_files.ensureCapacity(c_source_files.items.len + sanitizer_symbolizer_sources.len); for (sanitizer_symbolizer_sources) |c_src| { var cflags = std.ArrayList([]const u8).init(arena); try cflags.append("-I"); try cflags.append(tsan_include_path); try cflags.append("-nostdinc++"); try cflags.append("-fvisibility-inlines-hidden"); try cflags.append("-std=c++14"); try cflags.append("-fno-rtti"); c_source_files.appendAssumeCapacity(.{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", "sanitizer_common", c_src, }), .extra_flags = cflags.items, }); } const interception_include_path = try comp.zig_lib_directory.join( arena, &[_][]const u8{"interception"}, ); try c_source_files.ensureCapacity(c_source_files.items.len + interception_sources.len); for (interception_sources) |c_src| { var cflags = std.ArrayList([]const u8).init(arena); try cflags.append("-I"); try cflags.append(interception_include_path); try cflags.append("-I"); try cflags.append(tsan_include_path); try cflags.append("-nostdinc++"); try cflags.append("-fvisibility-inlines-hidden"); try cflags.append("-std=c++14"); try cflags.append("-fno-rtti"); c_source_files.appendAssumeCapacity(.{ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", "interception", c_src, }), .extra_flags = cflags.items, }); } const common_flags = [_][]const u8{ "-DTSAN_CONTAINS_UBSAN=0", }; const sub_compilation = try Compilation.create(comp.gpa, .{ .local_cache_directory = comp.global_cache_directory, .global_cache_directory = comp.global_cache_directory, .zig_lib_directory = comp.zig_lib_directory, .target = target, .root_name = root_name, .root_pkg = null, .output_mode = output_mode, .thread_pool = comp.thread_pool, .libc_installation = comp.bin_file.options.libc_installation, .emit_bin = emit_bin, .optimize_mode = comp.compilerRtOptMode(), .link_mode = link_mode, .want_sanitize_c = false, .want_stack_check = false, .want_valgrind = false, .want_tsan = false, .want_pic = true, .want_pie = true, .emit_h = null, .strip = comp.compilerRtStrip(), .is_native_os = comp.bin_file.options.is_native_os, .is_native_abi = comp.bin_file.options.is_native_abi, .self_exe_path = comp.self_exe_path, .c_source_files = c_source_files.items, .verbose_cc = comp.verbose_cc, .verbose_link = comp.bin_file.options.verbose_link, .verbose_tokenize = comp.verbose_tokenize, .verbose_ast = comp.verbose_ast, .verbose_ir = comp.verbose_ir, .verbose_llvm_ir = comp.verbose_llvm_ir, .verbose_cimport = comp.verbose_cimport, .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, .clang_passthrough_mode = comp.clang_passthrough_mode, .link_libc = true, .skip_linker_dependencies = true, .clang_argv = &common_flags, }); defer sub_compilation.destroy(); try sub_compilation.updateSubCompilation(); assert(comp.tsan_static_lib == null); comp.tsan_static_lib = Compilation.CRTFile{ .full_object_path = try sub_compilation.bin_file.options.emit.?.directory.join( comp.gpa, &[_][]const u8{basename}, ), .lock = sub_compilation.bin_file.toOwnedLock(), }; } const tsan_sources = [_][]const u8{ "tsan_clock.cpp", "tsan_debugging.cpp", "tsan_external.cpp", "tsan_fd.cpp", "tsan_flags.cpp", "tsan_ignoreset.cpp", "tsan_interceptors_posix.cpp", "tsan_interface.cpp", "tsan_interface_ann.cpp", "tsan_interface_atomic.cpp", "tsan_interface_java.cpp", "tsan_malloc_mac.cpp", "tsan_md5.cpp", "tsan_mman.cpp", "tsan_mutex.cpp", "tsan_mutexset.cpp", "tsan_preinit.cpp", "tsan_report.cpp", "tsan_rtl.cpp", "tsan_rtl_mutex.cpp", "tsan_rtl_proc.cpp", "tsan_rtl_report.cpp", "tsan_rtl_thread.cpp", "tsan_stack_trace.cpp", "tsan_stat.cpp", "tsan_suppressions.cpp", "tsan_symbolize.cpp", "tsan_sync.cpp", }; const darwin_tsan_sources = [_][]const u8{ "tsan_interceptors_mac.cpp", "tsan_interceptors_mach_vm.cpp", "tsan_platform_mac.cpp", "tsan_platform_posix.cpp", }; const unix_tsan_sources = [_][]const u8{ "tsan_platform_linux.cpp", "tsan_platform_posix.cpp", }; const sanitizer_common_sources = [_][]const u8{ "sanitizer_allocator.cpp", "sanitizer_common.cpp", "sanitizer_deadlock_detector1.cpp", "sanitizer_deadlock_detector2.cpp", "sanitizer_errno.cpp", "sanitizer_file.cpp", "sanitizer_flags.cpp", "sanitizer_flag_parser.cpp", "sanitizer_fuchsia.cpp", "sanitizer_libc.cpp", "sanitizer_libignore.cpp", "sanitizer_linux.cpp", "sanitizer_linux_s390.cpp", "sanitizer_mac.cpp", "sanitizer_netbsd.cpp", "sanitizer_openbsd.cpp", "sanitizer_persistent_allocator.cpp", "sanitizer_platform_limits_freebsd.cpp", "sanitizer_platform_limits_linux.cpp", "sanitizer_platform_limits_netbsd.cpp", "sanitizer_platform_limits_openbsd.cpp", "sanitizer_platform_limits_posix.cpp", "sanitizer_platform_limits_solaris.cpp", "sanitizer_posix.cpp", "sanitizer_printf.cpp", "sanitizer_procmaps_common.cpp", "sanitizer_procmaps_bsd.cpp", "sanitizer_procmaps_fuchsia.cpp", "sanitizer_procmaps_linux.cpp", "sanitizer_procmaps_mac.cpp", "sanitizer_procmaps_solaris.cpp", "sanitizer_rtems.cpp", "sanitizer_solaris.cpp", "sanitizer_stoptheworld_fuchsia.cpp", "sanitizer_stoptheworld_mac.cpp", "sanitizer_suppressions.cpp", "sanitizer_termination.cpp", "sanitizer_tls_get_addr.cpp", "sanitizer_thread_registry.cpp", "sanitizer_type_traits.cpp", "sanitizer_win.cpp", }; const sanitizer_nolibc_sources = [_][]const u8{ "sanitizer_common_nolibc.cpp", }; const sanitizer_libcdep_sources = [_][]const u8{ "sanitizer_common_libcdep.cpp", "sanitizer_allocator_checks.cpp", "sanitizer_linux_libcdep.cpp", "sanitizer_mac_libcdep.cpp", "sanitizer_posix_libcdep.cpp", "sanitizer_stoptheworld_linux_libcdep.cpp", "sanitizer_stoptheworld_netbsd_libcdep.cpp", }; const sanitizer_symbolizer_sources = [_][]const u8{ "sanitizer_allocator_report.cpp", "sanitizer_stackdepot.cpp", "sanitizer_stacktrace.cpp", "sanitizer_stacktrace_libcdep.cpp", "sanitizer_stacktrace_printer.cpp", "sanitizer_stacktrace_sparc.cpp", "sanitizer_symbolizer.cpp", "sanitizer_symbolizer_libbacktrace.cpp", "sanitizer_symbolizer_libcdep.cpp", "sanitizer_symbolizer_mac.cpp", "sanitizer_symbolizer_markup.cpp", "sanitizer_symbolizer_posix_libcdep.cpp", "sanitizer_symbolizer_report.cpp", "sanitizer_symbolizer_win.cpp", "sanitizer_unwind_linux_libcdep.cpp", "sanitizer_unwind_win.cpp", }; const interception_sources = [_][]const u8{ "interception_linux.cpp", "interception_mac.cpp", "interception_win.cpp", "interception_type_test.cpp", };
src/libtsan.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day03.txt"); const one = @as(u32, 1); // Wrapper struct for gamma and epsilon pub const GammaEpsilon = struct { gamma: u32 = 0, epsilon: u32 = 0, }; /// Get an integer representing the most common bit-values in the input set. /// /// The resulting number will have a 1 in a given bit-position if the inputs have mostly 1's at that /// position, or an equal number of 1's as 0's in that position. The resulting number will have a 0 /// in that bit position otherwise. pub fn getMostCommonBitSet(num_bits: u5, inputs: []u32) u32 { var result: u32 = 0; var i: @TypeOf(num_bits) = 0; while (i < num_bits) : (i += 1) { var ones: u32 = 0; for (inputs) |input| { if ((one << i) & input != 0) ones += 1; } // More ones than not (or equal) if (inputs.len - ones <= ones) { result |= (one << i); } } return result; } /// Calculate gamma and epsilon as per part 1 algorithm. pub fn getGammaAndEpsilon(inputs: []u32, num_bits: u5) GammaEpsilon { var result = GammaEpsilon{}; const most_common = getMostCommonBitSet(num_bits, inputs); var i: u5 = 0; while (i < num_bits) : (i += 1) { const current_bit = one << i; if ((most_common & current_bit) != 0) { result.gamma |= current_bit; } else { result.epsilon |= current_bit; } if (i == 31) break; } return result; } /// Reduces the given inputs down to a single value, according to the part 2 algorithm. If /// use_most_common is true, the _most_ common bit is the one that is taken at any given position; /// otherwise, the _least_ common bit is taken. Ties are broken as described in the part 2 algorithm. pub fn reduceInputsToCommonalitySet(allocator: *util.Allocator, inputs: []u32, num_bits: u5, use_most_common: bool) !u32 { // Duplicate input values so we can start eliminating them var remaining_inputs = util.List(u32).fromOwnedSlice(allocator, try allocator.dupe(u32, inputs)); defer remaining_inputs.deinit(); var bit: u5 = num_bits - 1; while (bit >= 0) : (bit -= 1) { const cur_bit = (one << bit); var most_common_set = getMostCommonBitSet(num_bits, remaining_inputs.items); var most_common = if (use_most_common) most_common_set & cur_bit else ~most_common_set & cur_bit; var idx = remaining_inputs.items.len - 1; while (idx >= 0) : (idx -= 1) { var item = remaining_inputs.items[idx]; if ((item & cur_bit) != most_common) { _ = remaining_inputs.orderedRemove(idx); } if (remaining_inputs.items.len == 1) return remaining_inputs.items[0]; if (idx == 0) break; } // Violates invariants we're given; there _has_ to be one left if (bit == 0) return error.InvalidInput; } } pub fn main() !void { defer { const leaks = util.gpa_impl.deinit(); std.debug.assert(!leaks); } var inputs = util.List(u32).init(util.gpa); defer inputs.deinit(); var it = std.mem.tokenize(u8, data, "\n"); while (it.next()) |line| { try inputs.append(util.parseInt(u32, line, 2) catch { return error.InvalidInput; }); } var result_pt1 = getGammaAndEpsilon(inputs.items, 12); util.print("Pt 1 Gamma-Epsilon: {}\n", .{result_pt1}); util.print("Pt 1 Gamma * Epsilon: {d}\n", .{result_pt1.gamma * result_pt1.epsilon}); var o2_rating = try reduceInputsToCommonalitySet(util.gpa, inputs.items, 12, true); util.print("O2 Rating: {}\n", .{o2_rating}); var co2_rating = try reduceInputsToCommonalitySet(util.gpa, inputs.items, 12, false); util.print("CO2 Rating: {}\n", .{co2_rating}); util.print("O2 * CO2: {d}\n", .{o2_rating * co2_rating}); }
src/day03.zig
const std = @import("std"); const util = @import("util"); pub const Instr = enum(u32) { jmp, acc, nop, }; pub fn Interpreter(comptime src: []const u8, comptime mixin: anytype) type { @setEvalBranchQuota(src.len * 1000); comptime var bytecode: []u32 = &[_]u32{}; comptime { var index: usize = 0; var lines = std.mem.tokenize(src, "\n"); while (lines.next()) |line| { std.debug.assert(line.len >= 5); const param = util.parseInt(i32, line[4..]) catch unreachable; const instr = @field(Instr, line[0..3]); var new_slice: [bytecode.len + 2]u32 = bytecode[0..bytecode.len].* ++ [_]u32{ @enumToInt(instr), @bitCast(u32, param), }; bytecode = new_slice[0..]; } var idx = 0; while (idx < bytecode.len) : (idx += 2) { if (bytecode[idx] != @enumToInt(Instr.acc)) { const target_idx = idx + @as(comptime_int, @bitCast(i32, bytecode[idx + 1])) * 2; bytecode[idx + 1] = @intCast(u32, target_idx); } } } return struct { /// The current index into the interpreted bytecode. index: usize = 0, /// The value of the accumulator set by the `acc` instruction. accum: i32 = 0, /// Optional metadata to be stored within the interpreter state. mixin: Mixin = mixin_default, /// The bytecode currently being considered for execution. bytecode: [bytecode.len]u32 = bytecode_init, /// The bytecode used to initialize the interpreter. pub const bytecode_init: [bytecode.len]u32 = bytecode[0..bytecode.len].*; /// The type of the mixin field (which optionally contains an update hook). pub const Mixin = if (@TypeOf(mixin) == type) mixin else mixin(Self); const should_update = Mixin != void and @hasDecl(Mixin, "update"); const mixin_default: Mixin = if (Mixin == void) {} else if (@hasDecl(Mixin, "default_value")) Mixin.default_value else undefined; pub usingnamespace if (Mixin != void and @hasDecl(Mixin, "namespace")) Mixin.namespace else struct {}; inline fn updateMixin(self: *Self) !bool { comptime std.debug.assert(should_update); return Mixin.update(self); } /// Execute one instruction from the interpreter, returning `true` if /// the interpreter executed an instruction, and `false` if it halted. /// By default, this should not return `false` until the interpreter /// reaches the end of instructions, but this can be overriden by mixins. pub fn step(self: *Self) !bool { if (should_update and (try self.updateMixin()) == false) return false; if (self.index >= self.bytecode.len) return should_update; const instr = self.getInstr(); switch (instr) { .acc => self.accum = try std.math.add(i32, self.accum, self.param_i32()), .nop, .jmp => {}, } self.index = if (instr == .jmp) self.param_usize() else self.index + 2; return true; } /// Get the instruction id for the current index. pub inline fn getInstr(self: Self) Instr { return @intToEnum(Instr, self.bytecode[self.index]); } /// Get the parameter for the current instruction as a u32. pub inline fn param_u32(self: Self) u32 { return self.bytecode[self.index + 1]; } /// Get the parameter for the current instruction as an i32. pub inline fn param_i32(self: Self) i32 { return @bitCast(i32, self.param_u32()); } /// Get the parameter for the current instruction as a usize. pub inline fn param_usize(self: Self) usize { return @intCast(usize, self.param_u32()); } const Self = @This(); }; }
2020/vm.zig
pub const GDI_ERROR = @as(i32, -1); pub const ERROR = @as(u32, 0); pub const NULLREGION = @as(u32, 1); pub const SIMPLEREGION = @as(u32, 2); pub const COMPLEXREGION = @as(u32, 3); pub const MAXSTRETCHBLTMODE = @as(u32, 4); pub const POLYFILL_LAST = @as(u32, 2); pub const LAYOUT_BTT = @as(u32, 2); pub const LAYOUT_VBH = @as(u32, 4); pub const ASPECT_FILTERING = @as(u32, 1); pub const META_SETBKCOLOR = @as(u32, 513); pub const META_SETBKMODE = @as(u32, 258); pub const META_SETMAPMODE = @as(u32, 259); pub const META_SETROP2 = @as(u32, 260); pub const META_SETRELABS = @as(u32, 261); pub const META_SETPOLYFILLMODE = @as(u32, 262); pub const META_SETSTRETCHBLTMODE = @as(u32, 263); pub const META_SETTEXTCHAREXTRA = @as(u32, 264); pub const META_SETTEXTCOLOR = @as(u32, 521); pub const META_SETTEXTJUSTIFICATION = @as(u32, 522); pub const META_SETWINDOWORG = @as(u32, 523); pub const META_SETWINDOWEXT = @as(u32, 524); pub const META_SETVIEWPORTORG = @as(u32, 525); pub const META_SETVIEWPORTEXT = @as(u32, 526); pub const META_OFFSETWINDOWORG = @as(u32, 527); pub const META_SCALEWINDOWEXT = @as(u32, 1040); pub const META_OFFSETVIEWPORTORG = @as(u32, 529); pub const META_SCALEVIEWPORTEXT = @as(u32, 1042); pub const META_LINETO = @as(u32, 531); pub const META_MOVETO = @as(u32, 532); pub const META_EXCLUDECLIPRECT = @as(u32, 1045); pub const META_INTERSECTCLIPRECT = @as(u32, 1046); pub const META_ARC = @as(u32, 2071); pub const META_ELLIPSE = @as(u32, 1048); pub const META_FLOODFILL = @as(u32, 1049); pub const META_PIE = @as(u32, 2074); pub const META_RECTANGLE = @as(u32, 1051); pub const META_ROUNDRECT = @as(u32, 1564); pub const META_PATBLT = @as(u32, 1565); pub const META_SAVEDC = @as(u32, 30); pub const META_SETPIXEL = @as(u32, 1055); pub const META_OFFSETCLIPRGN = @as(u32, 544); pub const META_TEXTOUT = @as(u32, 1313); pub const META_BITBLT = @as(u32, 2338); pub const META_STRETCHBLT = @as(u32, 2851); pub const META_POLYGON = @as(u32, 804); pub const META_POLYLINE = @as(u32, 805); pub const META_ESCAPE = @as(u32, 1574); pub const META_RESTOREDC = @as(u32, 295); pub const META_FILLREGION = @as(u32, 552); pub const META_FRAMEREGION = @as(u32, 1065); pub const META_INVERTREGION = @as(u32, 298); pub const META_PAINTREGION = @as(u32, 299); pub const META_SELECTCLIPREGION = @as(u32, 300); pub const META_SELECTOBJECT = @as(u32, 301); pub const META_SETTEXTALIGN = @as(u32, 302); pub const META_CHORD = @as(u32, 2096); pub const META_SETMAPPERFLAGS = @as(u32, 561); pub const META_EXTTEXTOUT = @as(u32, 2610); pub const META_SETDIBTODEV = @as(u32, 3379); pub const META_SELECTPALETTE = @as(u32, 564); pub const META_REALIZEPALETTE = @as(u32, 53); pub const META_ANIMATEPALETTE = @as(u32, 1078); pub const META_SETPALENTRIES = @as(u32, 55); pub const META_POLYPOLYGON = @as(u32, 1336); pub const META_RESIZEPALETTE = @as(u32, 313); pub const META_DIBBITBLT = @as(u32, 2368); pub const META_DIBSTRETCHBLT = @as(u32, 2881); pub const META_DIBCREATEPATTERNBRUSH = @as(u32, 322); pub const META_STRETCHDIB = @as(u32, 3907); pub const META_EXTFLOODFILL = @as(u32, 1352); pub const META_SETLAYOUT = @as(u32, 329); pub const META_DELETEOBJECT = @as(u32, 496); pub const META_CREATEPALETTE = @as(u32, 247); pub const META_CREATEPATTERNBRUSH = @as(u32, 505); pub const META_CREATEPENINDIRECT = @as(u32, 762); pub const META_CREATEFONTINDIRECT = @as(u32, 763); pub const META_CREATEBRUSHINDIRECT = @as(u32, 764); pub const META_CREATEREGION = @as(u32, 1791); pub const NEWFRAME = @as(u32, 1); pub const ABORTDOC = @as(u32, 2); pub const NEXTBAND = @as(u32, 3); pub const SETCOLORTABLE = @as(u32, 4); pub const GETCOLORTABLE = @as(u32, 5); pub const FLUSHOUTPUT = @as(u32, 6); pub const DRAFTMODE = @as(u32, 7); pub const QUERYESCSUPPORT = @as(u32, 8); pub const SETABORTPROC = @as(u32, 9); pub const STARTDOC = @as(u32, 10); pub const ENDDOC = @as(u32, 11); pub const GETPHYSPAGESIZE = @as(u32, 12); pub const GETPRINTINGOFFSET = @as(u32, 13); pub const GETSCALINGFACTOR = @as(u32, 14); pub const MFCOMMENT = @as(u32, 15); pub const GETPENWIDTH = @as(u32, 16); pub const SETCOPYCOUNT = @as(u32, 17); pub const SELECTPAPERSOURCE = @as(u32, 18); pub const DEVICEDATA = @as(u32, 19); pub const PASSTHROUGH = @as(u32, 19); pub const GETTECHNOLGY = @as(u32, 20); pub const GETTECHNOLOGY = @as(u32, 20); pub const SETLINECAP = @as(u32, 21); pub const SETLINEJOIN = @as(u32, 22); pub const SETMITERLIMIT = @as(u32, 23); pub const BANDINFO = @as(u32, 24); pub const DRAWPATTERNRECT = @as(u32, 25); pub const GETVECTORPENSIZE = @as(u32, 26); pub const GETVECTORBRUSHSIZE = @as(u32, 27); pub const ENABLEDUPLEX = @as(u32, 28); pub const GETSETPAPERBINS = @as(u32, 29); pub const GETSETPRINTORIENT = @as(u32, 30); pub const ENUMPAPERBINS = @as(u32, 31); pub const SETDIBSCALING = @as(u32, 32); pub const EPSPRINTING = @as(u32, 33); pub const ENUMPAPERMETRICS = @as(u32, 34); pub const GETSETPAPERMETRICS = @as(u32, 35); pub const POSTSCRIPT_DATA = @as(u32, 37); pub const POSTSCRIPT_IGNORE = @as(u32, 38); pub const MOUSETRAILS = @as(u32, 39); pub const GETDEVICEUNITS = @as(u32, 42); pub const GETEXTENDEDTEXTMETRICS = @as(u32, 256); pub const GETEXTENTTABLE = @as(u32, 257); pub const GETPAIRKERNTABLE = @as(u32, 258); pub const GETTRACKKERNTABLE = @as(u32, 259); pub const EXTTEXTOUT = @as(u32, 512); pub const GETFACENAME = @as(u32, 513); pub const DOWNLOADFACE = @as(u32, 514); pub const ENABLERELATIVEWIDTHS = @as(u32, 768); pub const ENABLEPAIRKERNING = @as(u32, 769); pub const SETKERNTRACK = @as(u32, 770); pub const SETALLJUSTVALUES = @as(u32, 771); pub const SETCHARSET = @as(u32, 772); pub const STRETCHBLT = @as(u32, 2048); pub const METAFILE_DRIVER = @as(u32, 2049); pub const GETSETSCREENPARAMS = @as(u32, 3072); pub const QUERYDIBSUPPORT = @as(u32, 3073); pub const BEGIN_PATH = @as(u32, 4096); pub const CLIP_TO_PATH = @as(u32, 4097); pub const END_PATH = @as(u32, 4098); pub const EXT_DEVICE_CAPS = @as(u32, 4099); pub const RESTORE_CTM = @as(u32, 4100); pub const SAVE_CTM = @as(u32, 4101); pub const SET_ARC_DIRECTION = @as(u32, 4102); pub const SET_BACKGROUND_COLOR = @as(u32, 4103); pub const SET_POLY_MODE = @as(u32, 4104); pub const SET_SCREEN_ANGLE = @as(u32, 4105); pub const SET_SPREAD = @as(u32, 4106); pub const TRANSFORM_CTM = @as(u32, 4107); pub const SET_CLIP_BOX = @as(u32, 4108); pub const SET_BOUNDS = @as(u32, 4109); pub const SET_MIRROR_MODE = @as(u32, 4110); pub const OPENCHANNEL = @as(u32, 4110); pub const DOWNLOADHEADER = @as(u32, 4111); pub const CLOSECHANNEL = @as(u32, 4112); pub const POSTSCRIPT_PASSTHROUGH = @as(u32, 4115); pub const ENCAPSULATED_POSTSCRIPT = @as(u32, 4116); pub const POSTSCRIPT_IDENTIFY = @as(u32, 4117); pub const POSTSCRIPT_INJECTION = @as(u32, 4118); pub const CHECKJPEGFORMAT = @as(u32, 4119); pub const CHECKPNGFORMAT = @as(u32, 4120); pub const GET_PS_FEATURESETTING = @as(u32, 4121); pub const GDIPLUS_TS_QUERYVER = @as(u32, 4122); pub const GDIPLUS_TS_RECORD = @as(u32, 4123); pub const MILCORE_TS_QUERYVER_RESULT_FALSE = @as(u32, 0); pub const MILCORE_TS_QUERYVER_RESULT_TRUE = @as(u32, 2147483647); pub const SPCLPASSTHROUGH2 = @as(u32, 4568); pub const PSIDENT_GDICENTRIC = @as(u32, 0); pub const PSIDENT_PSCENTRIC = @as(u32, 1); pub const PSINJECT_DLFONT = @as(u32, 3722304989); pub const FEATURESETTING_NUP = @as(u32, 0); pub const FEATURESETTING_OUTPUT = @as(u32, 1); pub const FEATURESETTING_PSLEVEL = @as(u32, 2); pub const FEATURESETTING_CUSTPAPER = @as(u32, 3); pub const FEATURESETTING_MIRROR = @as(u32, 4); pub const FEATURESETTING_NEGATIVE = @as(u32, 5); pub const FEATURESETTING_PROTOCOL = @as(u32, 6); pub const FEATURESETTING_PRIVATE_BEGIN = @as(u32, 4096); pub const FEATURESETTING_PRIVATE_END = @as(u32, 8191); pub const PSPROTOCOL_ASCII = @as(u32, 0); pub const PSPROTOCOL_BCP = @as(u32, 1); pub const PSPROTOCOL_TBCP = @as(u32, 2); pub const PSPROTOCOL_BINARY = @as(u32, 3); pub const QDI_SETDIBITS = @as(u32, 1); pub const QDI_GETDIBITS = @as(u32, 2); pub const QDI_DIBTOSCREEN = @as(u32, 4); pub const QDI_STRETCHDIB = @as(u32, 8); pub const SP_NOTREPORTED = @as(u32, 16384); pub const SP_ERROR = @as(i32, -1); pub const SP_APPABORT = @as(i32, -2); pub const SP_USERABORT = @as(i32, -3); pub const SP_OUTOFDISK = @as(i32, -4); pub const SP_OUTOFMEMORY = @as(i32, -5); pub const PR_JOBSTATUS = @as(u32, 0); pub const LCS_CALIBRATED_RGB = @as(i32, 0); pub const LCS_GM_BUSINESS = @as(i32, 1); pub const LCS_GM_GRAPHICS = @as(i32, 2); pub const LCS_GM_IMAGES = @as(i32, 4); pub const LCS_GM_ABS_COLORIMETRIC = @as(i32, 8); pub const CM_OUT_OF_GAMUT = @as(u32, 255); pub const CM_IN_GAMUT = @as(u32, 0); pub const BI_RGB = @as(i32, 0); pub const BI_RLE8 = @as(i32, 1); pub const BI_RLE4 = @as(i32, 2); pub const BI_BITFIELDS = @as(i32, 3); pub const BI_JPEG = @as(i32, 4); pub const BI_PNG = @as(i32, 5); pub const TMPF_FIXED_PITCH = @as(u32, 1); pub const TMPF_VECTOR = @as(u32, 2); pub const TMPF_DEVICE = @as(u32, 8); pub const TMPF_TRUETYPE = @as(u32, 4); pub const NTM_REGULAR = @as(i32, 64); pub const NTM_BOLD = @as(i32, 32); pub const NTM_ITALIC = @as(i32, 1); pub const NTM_NONNEGATIVE_AC = @as(u32, 65536); pub const NTM_PS_OPENTYPE = @as(u32, 131072); pub const NTM_TT_OPENTYPE = @as(u32, 262144); pub const NTM_MULTIPLEMASTER = @as(u32, 524288); pub const NTM_TYPE1 = @as(u32, 1048576); pub const NTM_DSIG = @as(u32, 2097152); pub const LF_FACESIZE = @as(u32, 32); pub const LF_FULLFACESIZE = @as(u32, 64); pub const OUT_SCREEN_OUTLINE_PRECIS = @as(u32, 9); pub const CLEARTYPE_NATURAL_QUALITY = @as(u32, 6); pub const DEFAULT_PITCH = @as(u32, 0); pub const FIXED_PITCH = @as(u32, 1); pub const VARIABLE_PITCH = @as(u32, 2); pub const MONO_FONT = @as(u32, 8); pub const ANSI_CHARSET = @as(u32, 0); pub const DEFAULT_CHARSET = @as(u32, 1); pub const SYMBOL_CHARSET = @as(u32, 2); pub const SHIFTJIS_CHARSET = @as(u32, 128); pub const HANGEUL_CHARSET = @as(u32, 129); pub const HANGUL_CHARSET = @as(u32, 129); pub const GB2312_CHARSET = @as(u32, 134); pub const CHINESEBIG5_CHARSET = @as(u32, 136); pub const OEM_CHARSET = @as(u32, 255); pub const JOHAB_CHARSET = @as(u32, 130); pub const HEBREW_CHARSET = @as(u32, 177); pub const ARABIC_CHARSET = @as(u32, 178); pub const GREEK_CHARSET = @as(u32, 161); pub const TURKISH_CHARSET = @as(u32, 162); pub const VIETNAMESE_CHARSET = @as(u32, 163); pub const THAI_CHARSET = @as(u32, 222); pub const EASTEUROPE_CHARSET = @as(u32, 238); pub const RUSSIAN_CHARSET = @as(u32, 204); pub const MAC_CHARSET = @as(u32, 77); pub const BALTIC_CHARSET = @as(u32, 186); pub const FS_LATIN1 = @as(i32, 1); pub const FS_LATIN2 = @as(i32, 2); pub const FS_CYRILLIC = @as(i32, 4); pub const FS_GREEK = @as(i32, 8); pub const FS_TURKISH = @as(i32, 16); pub const FS_HEBREW = @as(i32, 32); pub const FS_ARABIC = @as(i32, 64); pub const FS_BALTIC = @as(i32, 128); pub const FS_VIETNAMESE = @as(i32, 256); pub const FS_THAI = @as(i32, 65536); pub const FS_JISJAPAN = @as(i32, 131072); pub const FS_CHINESESIMP = @as(i32, 262144); pub const FS_WANSUNG = @as(i32, 524288); pub const FS_CHINESETRAD = @as(i32, 1048576); pub const FS_JOHAB = @as(i32, 2097152); pub const FS_SYMBOL = @as(i32, -2147483648); pub const FW_DONTCARE = @as(u32, 0); pub const FW_THIN = @as(u32, 100); pub const FW_EXTRALIGHT = @as(u32, 200); pub const FW_LIGHT = @as(u32, 300); pub const FW_NORMAL = @as(u32, 400); pub const FW_MEDIUM = @as(u32, 500); pub const FW_SEMIBOLD = @as(u32, 600); pub const FW_BOLD = @as(u32, 700); pub const FW_EXTRABOLD = @as(u32, 800); pub const FW_HEAVY = @as(u32, 900); pub const PANOSE_COUNT = @as(u32, 10); pub const PAN_FAMILYTYPE_INDEX = @as(u32, 0); pub const PAN_SERIFSTYLE_INDEX = @as(u32, 1); pub const PAN_WEIGHT_INDEX = @as(u32, 2); pub const PAN_PROPORTION_INDEX = @as(u32, 3); pub const PAN_CONTRAST_INDEX = @as(u32, 4); pub const PAN_STROKEVARIATION_INDEX = @as(u32, 5); pub const PAN_ARMSTYLE_INDEX = @as(u32, 6); pub const PAN_LETTERFORM_INDEX = @as(u32, 7); pub const PAN_MIDLINE_INDEX = @as(u32, 8); pub const PAN_XHEIGHT_INDEX = @as(u32, 9); pub const PAN_CULTURE_LATIN = @as(u32, 0); pub const PAN_ANY = @as(u32, 0); pub const PAN_NO_FIT = @as(u32, 1); pub const PAN_FAMILY_TEXT_DISPLAY = @as(u32, 2); pub const PAN_FAMILY_SCRIPT = @as(u32, 3); pub const PAN_FAMILY_DECORATIVE = @as(u32, 4); pub const PAN_FAMILY_PICTORIAL = @as(u32, 5); pub const PAN_SERIF_COVE = @as(u32, 2); pub const PAN_SERIF_OBTUSE_COVE = @as(u32, 3); pub const PAN_SERIF_SQUARE_COVE = @as(u32, 4); pub const PAN_SERIF_OBTUSE_SQUARE_COVE = @as(u32, 5); pub const PAN_SERIF_SQUARE = @as(u32, 6); pub const PAN_SERIF_THIN = @as(u32, 7); pub const PAN_SERIF_BONE = @as(u32, 8); pub const PAN_SERIF_EXAGGERATED = @as(u32, 9); pub const PAN_SERIF_TRIANGLE = @as(u32, 10); pub const PAN_SERIF_NORMAL_SANS = @as(u32, 11); pub const PAN_SERIF_OBTUSE_SANS = @as(u32, 12); pub const PAN_SERIF_PERP_SANS = @as(u32, 13); pub const PAN_SERIF_FLARED = @as(u32, 14); pub const PAN_SERIF_ROUNDED = @as(u32, 15); pub const PAN_WEIGHT_VERY_LIGHT = @as(u32, 2); pub const PAN_WEIGHT_LIGHT = @as(u32, 3); pub const PAN_WEIGHT_THIN = @as(u32, 4); pub const PAN_WEIGHT_BOOK = @as(u32, 5); pub const PAN_WEIGHT_MEDIUM = @as(u32, 6); pub const PAN_WEIGHT_DEMI = @as(u32, 7); pub const PAN_WEIGHT_BOLD = @as(u32, 8); pub const PAN_WEIGHT_HEAVY = @as(u32, 9); pub const PAN_WEIGHT_BLACK = @as(u32, 10); pub const PAN_WEIGHT_NORD = @as(u32, 11); pub const PAN_PROP_OLD_STYLE = @as(u32, 2); pub const PAN_PROP_MODERN = @as(u32, 3); pub const PAN_PROP_EVEN_WIDTH = @as(u32, 4); pub const PAN_PROP_EXPANDED = @as(u32, 5); pub const PAN_PROP_CONDENSED = @as(u32, 6); pub const PAN_PROP_VERY_EXPANDED = @as(u32, 7); pub const PAN_PROP_VERY_CONDENSED = @as(u32, 8); pub const PAN_PROP_MONOSPACED = @as(u32, 9); pub const PAN_CONTRAST_NONE = @as(u32, 2); pub const PAN_CONTRAST_VERY_LOW = @as(u32, 3); pub const PAN_CONTRAST_LOW = @as(u32, 4); pub const PAN_CONTRAST_MEDIUM_LOW = @as(u32, 5); pub const PAN_CONTRAST_MEDIUM = @as(u32, 6); pub const PAN_CONTRAST_MEDIUM_HIGH = @as(u32, 7); pub const PAN_CONTRAST_HIGH = @as(u32, 8); pub const PAN_CONTRAST_VERY_HIGH = @as(u32, 9); pub const PAN_STROKE_GRADUAL_DIAG = @as(u32, 2); pub const PAN_STROKE_GRADUAL_TRAN = @as(u32, 3); pub const PAN_STROKE_GRADUAL_VERT = @as(u32, 4); pub const PAN_STROKE_GRADUAL_HORZ = @as(u32, 5); pub const PAN_STROKE_RAPID_VERT = @as(u32, 6); pub const PAN_STROKE_RAPID_HORZ = @as(u32, 7); pub const PAN_STROKE_INSTANT_VERT = @as(u32, 8); pub const PAN_STRAIGHT_ARMS_HORZ = @as(u32, 2); pub const PAN_STRAIGHT_ARMS_WEDGE = @as(u32, 3); pub const PAN_STRAIGHT_ARMS_VERT = @as(u32, 4); pub const PAN_STRAIGHT_ARMS_SINGLE_SERIF = @as(u32, 5); pub const PAN_STRAIGHT_ARMS_DOUBLE_SERIF = @as(u32, 6); pub const PAN_BENT_ARMS_HORZ = @as(u32, 7); pub const PAN_BENT_ARMS_WEDGE = @as(u32, 8); pub const PAN_BENT_ARMS_VERT = @as(u32, 9); pub const PAN_BENT_ARMS_SINGLE_SERIF = @as(u32, 10); pub const PAN_BENT_ARMS_DOUBLE_SERIF = @as(u32, 11); pub const PAN_LETT_NORMAL_CONTACT = @as(u32, 2); pub const PAN_LETT_NORMAL_WEIGHTED = @as(u32, 3); pub const PAN_LETT_NORMAL_BOXED = @as(u32, 4); pub const PAN_LETT_NORMAL_FLATTENED = @as(u32, 5); pub const PAN_LETT_NORMAL_ROUNDED = @as(u32, 6); pub const PAN_LETT_NORMAL_OFF_CENTER = @as(u32, 7); pub const PAN_LETT_NORMAL_SQUARE = @as(u32, 8); pub const PAN_LETT_OBLIQUE_CONTACT = @as(u32, 9); pub const PAN_LETT_OBLIQUE_WEIGHTED = @as(u32, 10); pub const PAN_LETT_OBLIQUE_BOXED = @as(u32, 11); pub const PAN_LETT_OBLIQUE_FLATTENED = @as(u32, 12); pub const PAN_LETT_OBLIQUE_ROUNDED = @as(u32, 13); pub const PAN_LETT_OBLIQUE_OFF_CENTER = @as(u32, 14); pub const PAN_LETT_OBLIQUE_SQUARE = @as(u32, 15); pub const PAN_MIDLINE_STANDARD_TRIMMED = @as(u32, 2); pub const PAN_MIDLINE_STANDARD_POINTED = @as(u32, 3); pub const PAN_MIDLINE_STANDARD_SERIFED = @as(u32, 4); pub const PAN_MIDLINE_HIGH_TRIMMED = @as(u32, 5); pub const PAN_MIDLINE_HIGH_POINTED = @as(u32, 6); pub const PAN_MIDLINE_HIGH_SERIFED = @as(u32, 7); pub const PAN_MIDLINE_CONSTANT_TRIMMED = @as(u32, 8); pub const PAN_MIDLINE_CONSTANT_POINTED = @as(u32, 9); pub const PAN_MIDLINE_CONSTANT_SERIFED = @as(u32, 10); pub const PAN_MIDLINE_LOW_TRIMMED = @as(u32, 11); pub const PAN_MIDLINE_LOW_POINTED = @as(u32, 12); pub const PAN_MIDLINE_LOW_SERIFED = @as(u32, 13); pub const PAN_XHEIGHT_CONSTANT_SMALL = @as(u32, 2); pub const PAN_XHEIGHT_CONSTANT_STD = @as(u32, 3); pub const PAN_XHEIGHT_CONSTANT_LARGE = @as(u32, 4); pub const PAN_XHEIGHT_DUCKING_SMALL = @as(u32, 5); pub const PAN_XHEIGHT_DUCKING_STD = @as(u32, 6); pub const PAN_XHEIGHT_DUCKING_LARGE = @as(u32, 7); pub const ELF_VENDOR_SIZE = @as(u32, 4); pub const ELF_VERSION = @as(u32, 0); pub const ELF_CULTURE_LATIN = @as(u32, 0); pub const RASTER_FONTTYPE = @as(u32, 1); pub const DEVICE_FONTTYPE = @as(u32, 2); pub const TRUETYPE_FONTTYPE = @as(u32, 4); pub const PC_RESERVED = @as(u32, 1); pub const PC_EXPLICIT = @as(u32, 2); pub const PC_NOCOLLAPSE = @as(u32, 4); pub const BKMODE_LAST = @as(u32, 2); pub const GM_LAST = @as(u32, 2); pub const PT_CLOSEFIGURE = @as(u32, 1); pub const PT_LINETO = @as(u32, 2); pub const PT_BEZIERTO = @as(u32, 4); pub const PT_MOVETO = @as(u32, 6); pub const ABSOLUTE = @as(u32, 1); pub const RELATIVE = @as(u32, 2); pub const STOCK_LAST = @as(u32, 19); pub const CLR_INVALID = @as(u32, 4294967295); pub const BS_SOLID = @as(u32, 0); pub const BS_NULL = @as(u32, 1); pub const BS_HATCHED = @as(u32, 2); pub const BS_PATTERN = @as(u32, 3); pub const BS_INDEXED = @as(u32, 4); pub const BS_DIBPATTERN = @as(u32, 5); pub const BS_DIBPATTERNPT = @as(u32, 6); pub const BS_PATTERN8X8 = @as(u32, 7); pub const BS_DIBPATTERN8X8 = @as(u32, 8); pub const BS_MONOPATTERN = @as(u32, 9); pub const HS_API_MAX = @as(u32, 12); pub const DT_PLOTTER = @as(u32, 0); pub const DT_RASDISPLAY = @as(u32, 1); pub const DT_RASPRINTER = @as(u32, 2); pub const DT_RASCAMERA = @as(u32, 3); pub const DT_CHARSTREAM = @as(u32, 4); pub const DT_METAFILE = @as(u32, 5); pub const DT_DISPFILE = @as(u32, 6); pub const CC_NONE = @as(u32, 0); pub const CC_CIRCLES = @as(u32, 1); pub const CC_PIE = @as(u32, 2); pub const CC_CHORD = @as(u32, 4); pub const CC_ELLIPSES = @as(u32, 8); pub const CC_WIDE = @as(u32, 16); pub const CC_STYLED = @as(u32, 32); pub const CC_WIDESTYLED = @as(u32, 64); pub const CC_INTERIORS = @as(u32, 128); pub const CC_ROUNDRECT = @as(u32, 256); pub const LC_NONE = @as(u32, 0); pub const LC_POLYLINE = @as(u32, 2); pub const LC_MARKER = @as(u32, 4); pub const LC_POLYMARKER = @as(u32, 8); pub const LC_WIDE = @as(u32, 16); pub const LC_STYLED = @as(u32, 32); pub const LC_WIDESTYLED = @as(u32, 64); pub const LC_INTERIORS = @as(u32, 128); pub const PC_NONE = @as(u32, 0); pub const PC_POLYGON = @as(u32, 1); pub const PC_RECTANGLE = @as(u32, 2); pub const PC_WINDPOLYGON = @as(u32, 4); pub const PC_TRAPEZOID = @as(u32, 4); pub const PC_SCANLINE = @as(u32, 8); pub const PC_WIDE = @as(u32, 16); pub const PC_STYLED = @as(u32, 32); pub const PC_WIDESTYLED = @as(u32, 64); pub const PC_INTERIORS = @as(u32, 128); pub const PC_POLYPOLYGON = @as(u32, 256); pub const PC_PATHS = @as(u32, 512); pub const CP_NONE = @as(u32, 0); pub const CP_RECTANGLE = @as(u32, 1); pub const CP_REGION = @as(u32, 2); pub const TC_OP_CHARACTER = @as(u32, 1); pub const TC_OP_STROKE = @as(u32, 2); pub const TC_CP_STROKE = @as(u32, 4); pub const TC_CR_90 = @as(u32, 8); pub const TC_CR_ANY = @as(u32, 16); pub const TC_SF_X_YINDEP = @as(u32, 32); pub const TC_SA_DOUBLE = @as(u32, 64); pub const TC_SA_INTEGER = @as(u32, 128); pub const TC_SA_CONTIN = @as(u32, 256); pub const TC_EA_DOUBLE = @as(u32, 512); pub const TC_IA_ABLE = @as(u32, 1024); pub const TC_UA_ABLE = @as(u32, 2048); pub const TC_SO_ABLE = @as(u32, 4096); pub const TC_RA_ABLE = @as(u32, 8192); pub const TC_VA_ABLE = @as(u32, 16384); pub const TC_RESERVED = @as(u32, 32768); pub const TC_SCROLLBLT = @as(u32, 65536); pub const RC_BITBLT = @as(u32, 1); pub const RC_BANDING = @as(u32, 2); pub const RC_SCALING = @as(u32, 4); pub const RC_BITMAP64 = @as(u32, 8); pub const RC_GDI20_OUTPUT = @as(u32, 16); pub const RC_GDI20_STATE = @as(u32, 32); pub const RC_SAVEBITMAP = @as(u32, 64); pub const RC_DI_BITMAP = @as(u32, 128); pub const RC_PALETTE = @as(u32, 256); pub const RC_DIBTODEV = @as(u32, 512); pub const RC_BIGFONT = @as(u32, 1024); pub const RC_STRETCHBLT = @as(u32, 2048); pub const RC_FLOODFILL = @as(u32, 4096); pub const RC_STRETCHDIB = @as(u32, 8192); pub const RC_OP_DX_OUTPUT = @as(u32, 16384); pub const RC_DEVBITS = @as(u32, 32768); pub const SB_NONE = @as(u32, 0); pub const SB_CONST_ALPHA = @as(u32, 1); pub const SB_PIXEL_ALPHA = @as(u32, 2); pub const SB_PREMULT_ALPHA = @as(u32, 4); pub const SB_GRAD_RECT = @as(u32, 16); pub const SB_GRAD_TRI = @as(u32, 32); pub const CM_NONE = @as(u32, 0); pub const CM_DEVICE_ICM = @as(u32, 1); pub const CM_GAMMA_RAMP = @as(u32, 2); pub const CM_CMYK_COLOR = @as(u32, 4); pub const SYSPAL_ERROR = @as(u32, 0); pub const CBM_INIT = @as(i32, 4); pub const CCHFORMNAME = @as(u32, 32); pub const DM_SPECVERSION = @as(u32, 1025); pub const DM_ORIENTATION = @as(i32, 1); pub const DM_PAPERSIZE = @as(i32, 2); pub const DM_PAPERLENGTH = @as(i32, 4); pub const DM_PAPERWIDTH = @as(i32, 8); pub const DM_SCALE = @as(i32, 16); pub const DM_POSITION = @as(i32, 32); pub const DM_NUP = @as(i32, 64); pub const DM_DISPLAYORIENTATION = @as(i32, 128); pub const DM_COPIES = @as(i32, 256); pub const DM_DEFAULTSOURCE = @as(i32, 512); pub const DM_PRINTQUALITY = @as(i32, 1024); pub const DM_COLOR = @as(i32, 2048); pub const DM_DUPLEX = @as(i32, 4096); pub const DM_YRESOLUTION = @as(i32, 8192); pub const DM_TTOPTION = @as(i32, 16384); pub const DM_COLLATE = @as(i32, 32768); pub const DM_FORMNAME = @as(i32, 65536); pub const DM_LOGPIXELS = @as(i32, 131072); pub const DM_BITSPERPEL = @as(i32, 262144); pub const DM_PELSWIDTH = @as(i32, 524288); pub const DM_PELSHEIGHT = @as(i32, 1048576); pub const DM_DISPLAYFLAGS = @as(i32, 2097152); pub const DM_DISPLAYFREQUENCY = @as(i32, 4194304); pub const DM_ICMMETHOD = @as(i32, 8388608); pub const DM_ICMINTENT = @as(i32, 16777216); pub const DM_MEDIATYPE = @as(i32, 33554432); pub const DM_DITHERTYPE = @as(i32, 67108864); pub const DM_PANNINGWIDTH = @as(i32, 134217728); pub const DM_PANNINGHEIGHT = @as(i32, 268435456); pub const DM_DISPLAYFIXEDOUTPUT = @as(i32, 536870912); pub const DMORIENT_PORTRAIT = @as(u32, 1); pub const DMORIENT_LANDSCAPE = @as(u32, 2); pub const DMPAPER_LETTER = @as(u32, 1); pub const DMPAPER_LETTERSMALL = @as(u32, 2); pub const DMPAPER_TABLOID = @as(u32, 3); pub const DMPAPER_LEDGER = @as(u32, 4); pub const DMPAPER_LEGAL = @as(u32, 5); pub const DMPAPER_STATEMENT = @as(u32, 6); pub const DMPAPER_EXECUTIVE = @as(u32, 7); pub const DMPAPER_A3 = @as(u32, 8); pub const DMPAPER_A4 = @as(u32, 9); pub const DMPAPER_A4SMALL = @as(u32, 10); pub const DMPAPER_A5 = @as(u32, 11); pub const DMPAPER_B4 = @as(u32, 12); pub const DMPAPER_B5 = @as(u32, 13); pub const DMPAPER_FOLIO = @as(u32, 14); pub const DMPAPER_QUARTO = @as(u32, 15); pub const DMPAPER_10X14 = @as(u32, 16); pub const DMPAPER_11X17 = @as(u32, 17); pub const DMPAPER_NOTE = @as(u32, 18); pub const DMPAPER_ENV_9 = @as(u32, 19); pub const DMPAPER_ENV_10 = @as(u32, 20); pub const DMPAPER_ENV_11 = @as(u32, 21); pub const DMPAPER_ENV_12 = @as(u32, 22); pub const DMPAPER_ENV_14 = @as(u32, 23); pub const DMPAPER_CSHEET = @as(u32, 24); pub const DMPAPER_DSHEET = @as(u32, 25); pub const DMPAPER_ESHEET = @as(u32, 26); pub const DMPAPER_ENV_DL = @as(u32, 27); pub const DMPAPER_ENV_C5 = @as(u32, 28); pub const DMPAPER_ENV_C3 = @as(u32, 29); pub const DMPAPER_ENV_C4 = @as(u32, 30); pub const DMPAPER_ENV_C6 = @as(u32, 31); pub const DMPAPER_ENV_C65 = @as(u32, 32); pub const DMPAPER_ENV_B4 = @as(u32, 33); pub const DMPAPER_ENV_B5 = @as(u32, 34); pub const DMPAPER_ENV_B6 = @as(u32, 35); pub const DMPAPER_ENV_ITALY = @as(u32, 36); pub const DMPAPER_ENV_MONARCH = @as(u32, 37); pub const DMPAPER_ENV_PERSONAL = @as(u32, 38); pub const DMPAPER_FANFOLD_US = @as(u32, 39); pub const DMPAPER_FANFOLD_STD_GERMAN = @as(u32, 40); pub const DMPAPER_FANFOLD_LGL_GERMAN = @as(u32, 41); pub const DMPAPER_ISO_B4 = @as(u32, 42); pub const DMPAPER_JAPANESE_POSTCARD = @as(u32, 43); pub const DMPAPER_9X11 = @as(u32, 44); pub const DMPAPER_10X11 = @as(u32, 45); pub const DMPAPER_15X11 = @as(u32, 46); pub const DMPAPER_ENV_INVITE = @as(u32, 47); pub const DMPAPER_RESERVED_48 = @as(u32, 48); pub const DMPAPER_RESERVED_49 = @as(u32, 49); pub const DMPAPER_LETTER_EXTRA = @as(u32, 50); pub const DMPAPER_LEGAL_EXTRA = @as(u32, 51); pub const DMPAPER_TABLOID_EXTRA = @as(u32, 52); pub const DMPAPER_A4_EXTRA = @as(u32, 53); pub const DMPAPER_LETTER_TRANSVERSE = @as(u32, 54); pub const DMPAPER_A4_TRANSVERSE = @as(u32, 55); pub const DMPAPER_LETTER_EXTRA_TRANSVERSE = @as(u32, 56); pub const DMPAPER_A_PLUS = @as(u32, 57); pub const DMPAPER_B_PLUS = @as(u32, 58); pub const DMPAPER_LETTER_PLUS = @as(u32, 59); pub const DMPAPER_A4_PLUS = @as(u32, 60); pub const DMPAPER_A5_TRANSVERSE = @as(u32, 61); pub const DMPAPER_B5_TRANSVERSE = @as(u32, 62); pub const DMPAPER_A3_EXTRA = @as(u32, 63); pub const DMPAPER_A5_EXTRA = @as(u32, 64); pub const DMPAPER_B5_EXTRA = @as(u32, 65); pub const DMPAPER_A2 = @as(u32, 66); pub const DMPAPER_A3_TRANSVERSE = @as(u32, 67); pub const DMPAPER_A3_EXTRA_TRANSVERSE = @as(u32, 68); pub const DMPAPER_DBL_JAPANESE_POSTCARD = @as(u32, 69); pub const DMPAPER_A6 = @as(u32, 70); pub const DMPAPER_JENV_KAKU2 = @as(u32, 71); pub const DMPAPER_JENV_KAKU3 = @as(u32, 72); pub const DMPAPER_JENV_CHOU3 = @as(u32, 73); pub const DMPAPER_JENV_CHOU4 = @as(u32, 74); pub const DMPAPER_LETTER_ROTATED = @as(u32, 75); pub const DMPAPER_A3_ROTATED = @as(u32, 76); pub const DMPAPER_A4_ROTATED = @as(u32, 77); pub const DMPAPER_A5_ROTATED = @as(u32, 78); pub const DMPAPER_B4_JIS_ROTATED = @as(u32, 79); pub const DMPAPER_B5_JIS_ROTATED = @as(u32, 80); pub const DMPAPER_JAPANESE_POSTCARD_ROTATED = @as(u32, 81); pub const DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED = @as(u32, 82); pub const DMPAPER_A6_ROTATED = @as(u32, 83); pub const DMPAPER_JENV_KAKU2_ROTATED = @as(u32, 84); pub const DMPAPER_JENV_KAKU3_ROTATED = @as(u32, 85); pub const DMPAPER_JENV_CHOU3_ROTATED = @as(u32, 86); pub const DMPAPER_JENV_CHOU4_ROTATED = @as(u32, 87); pub const DMPAPER_B6_JIS = @as(u32, 88); pub const DMPAPER_B6_JIS_ROTATED = @as(u32, 89); pub const DMPAPER_12X11 = @as(u32, 90); pub const DMPAPER_JENV_YOU4 = @as(u32, 91); pub const DMPAPER_JENV_YOU4_ROTATED = @as(u32, 92); pub const DMPAPER_P16K = @as(u32, 93); pub const DMPAPER_P32K = @as(u32, 94); pub const DMPAPER_P32KBIG = @as(u32, 95); pub const DMPAPER_PENV_1 = @as(u32, 96); pub const DMPAPER_PENV_2 = @as(u32, 97); pub const DMPAPER_PENV_3 = @as(u32, 98); pub const DMPAPER_PENV_4 = @as(u32, 99); pub const DMPAPER_PENV_5 = @as(u32, 100); pub const DMPAPER_PENV_6 = @as(u32, 101); pub const DMPAPER_PENV_7 = @as(u32, 102); pub const DMPAPER_PENV_8 = @as(u32, 103); pub const DMPAPER_PENV_9 = @as(u32, 104); pub const DMPAPER_PENV_10 = @as(u32, 105); pub const DMPAPER_P16K_ROTATED = @as(u32, 106); pub const DMPAPER_P32K_ROTATED = @as(u32, 107); pub const DMPAPER_P32KBIG_ROTATED = @as(u32, 108); pub const DMPAPER_PENV_1_ROTATED = @as(u32, 109); pub const DMPAPER_PENV_2_ROTATED = @as(u32, 110); pub const DMPAPER_PENV_3_ROTATED = @as(u32, 111); pub const DMPAPER_PENV_4_ROTATED = @as(u32, 112); pub const DMPAPER_PENV_5_ROTATED = @as(u32, 113); pub const DMPAPER_PENV_6_ROTATED = @as(u32, 114); pub const DMPAPER_PENV_7_ROTATED = @as(u32, 115); pub const DMPAPER_PENV_8_ROTATED = @as(u32, 116); pub const DMPAPER_PENV_9_ROTATED = @as(u32, 117); pub const DMPAPER_PENV_10_ROTATED = @as(u32, 118); pub const DMPAPER_USER = @as(u32, 256); pub const DMBIN_UPPER = @as(u32, 1); pub const DMBIN_ONLYONE = @as(u32, 1); pub const DMBIN_LOWER = @as(u32, 2); pub const DMBIN_MIDDLE = @as(u32, 3); pub const DMBIN_MANUAL = @as(u32, 4); pub const DMBIN_ENVELOPE = @as(u32, 5); pub const DMBIN_ENVMANUAL = @as(u32, 6); pub const DMBIN_AUTO = @as(u32, 7); pub const DMBIN_TRACTOR = @as(u32, 8); pub const DMBIN_SMALLFMT = @as(u32, 9); pub const DMBIN_LARGEFMT = @as(u32, 10); pub const DMBIN_LARGECAPACITY = @as(u32, 11); pub const DMBIN_CASSETTE = @as(u32, 14); pub const DMBIN_FORMSOURCE = @as(u32, 15); pub const DMBIN_USER = @as(u32, 256); pub const DMRES_DRAFT = @as(i32, -1); pub const DMRES_LOW = @as(i32, -2); pub const DMRES_MEDIUM = @as(i32, -3); pub const DMRES_HIGH = @as(i32, -4); pub const DMCOLOR_MONOCHROME = @as(u32, 1); pub const DMCOLOR_COLOR = @as(u32, 2); pub const DMDUP_SIMPLEX = @as(u32, 1); pub const DMDUP_VERTICAL = @as(u32, 2); pub const DMDUP_HORIZONTAL = @as(u32, 3); pub const DMTT_BITMAP = @as(u32, 1); pub const DMTT_DOWNLOAD = @as(u32, 2); pub const DMTT_SUBDEV = @as(u32, 3); pub const DMTT_DOWNLOAD_OUTLINE = @as(u32, 4); pub const DMCOLLATE_FALSE = @as(u32, 0); pub const DMCOLLATE_TRUE = @as(u32, 1); pub const DMDO_DEFAULT = @as(u32, 0); pub const DMDO_90 = @as(u32, 1); pub const DMDO_180 = @as(u32, 2); pub const DMDO_270 = @as(u32, 3); pub const DMDFO_DEFAULT = @as(u32, 0); pub const DMDFO_STRETCH = @as(u32, 1); pub const DMDFO_CENTER = @as(u32, 2); pub const DM_INTERLACED = @as(u32, 2); pub const DMDISPLAYFLAGS_TEXTMODE = @as(u32, 4); pub const DMNUP_SYSTEM = @as(u32, 1); pub const DMNUP_ONEUP = @as(u32, 2); pub const DMICMMETHOD_NONE = @as(u32, 1); pub const DMICMMETHOD_SYSTEM = @as(u32, 2); pub const DMICMMETHOD_DRIVER = @as(u32, 3); pub const DMICMMETHOD_DEVICE = @as(u32, 4); pub const DMICMMETHOD_USER = @as(u32, 256); pub const DMICM_SATURATE = @as(u32, 1); pub const DMICM_CONTRAST = @as(u32, 2); pub const DMICM_COLORIMETRIC = @as(u32, 3); pub const DMICM_ABS_COLORIMETRIC = @as(u32, 4); pub const DMICM_USER = @as(u32, 256); pub const DMMEDIA_STANDARD = @as(u32, 1); pub const DMMEDIA_TRANSPARENCY = @as(u32, 2); pub const DMMEDIA_GLOSSY = @as(u32, 3); pub const DMMEDIA_USER = @as(u32, 256); pub const DMDITHER_NONE = @as(u32, 1); pub const DMDITHER_COARSE = @as(u32, 2); pub const DMDITHER_FINE = @as(u32, 3); pub const DMDITHER_LINEART = @as(u32, 4); pub const DMDITHER_ERRORDIFFUSION = @as(u32, 5); pub const DMDITHER_RESERVED6 = @as(u32, 6); pub const DMDITHER_RESERVED7 = @as(u32, 7); pub const DMDITHER_RESERVED8 = @as(u32, 8); pub const DMDITHER_RESERVED9 = @as(u32, 9); pub const DMDITHER_GRAYSCALE = @as(u32, 10); pub const DMDITHER_USER = @as(u32, 256); pub const DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = @as(u32, 1); pub const DISPLAY_DEVICE_MULTI_DRIVER = @as(u32, 2); pub const DISPLAY_DEVICE_PRIMARY_DEVICE = @as(u32, 4); pub const DISPLAY_DEVICE_MIRRORING_DRIVER = @as(u32, 8); pub const DISPLAY_DEVICE_VGA_COMPATIBLE = @as(u32, 16); pub const DISPLAY_DEVICE_REMOVABLE = @as(u32, 32); pub const DISPLAY_DEVICE_ACC_DRIVER = @as(u32, 64); pub const DISPLAY_DEVICE_MODESPRUNED = @as(u32, 134217728); pub const DISPLAY_DEVICE_RDPUDD = @as(u32, 16777216); pub const DISPLAY_DEVICE_REMOTE = @as(u32, 67108864); pub const DISPLAY_DEVICE_DISCONNECT = @as(u32, 33554432); pub const DISPLAY_DEVICE_TS_COMPATIBLE = @as(u32, 2097152); pub const DISPLAY_DEVICE_UNSAFE_MODES_ON = @as(u32, 524288); pub const DISPLAY_DEVICE_ACTIVE = @as(u32, 1); pub const DISPLAY_DEVICE_ATTACHED = @as(u32, 2); pub const DISPLAYCONFIG_MAXPATH = @as(u32, 1024); pub const DISPLAYCONFIG_PATH_MODE_IDX_INVALID = @as(u32, 4294967295); pub const DISPLAYCONFIG_PATH_TARGET_MODE_IDX_INVALID = @as(u32, 65535); pub const DISPLAYCONFIG_PATH_DESKTOP_IMAGE_IDX_INVALID = @as(u32, 65535); pub const DISPLAYCONFIG_PATH_SOURCE_MODE_IDX_INVALID = @as(u32, 65535); pub const DISPLAYCONFIG_PATH_CLONE_GROUP_INVALID = @as(u32, 65535); pub const DISPLAYCONFIG_SOURCE_IN_USE = @as(u32, 1); pub const DISPLAYCONFIG_TARGET_IN_USE = @as(u32, 1); pub const DISPLAYCONFIG_TARGET_FORCIBLE = @as(u32, 2); pub const DISPLAYCONFIG_TARGET_FORCED_AVAILABILITY_BOOT = @as(u32, 4); pub const DISPLAYCONFIG_TARGET_FORCED_AVAILABILITY_PATH = @as(u32, 8); pub const DISPLAYCONFIG_TARGET_FORCED_AVAILABILITY_SYSTEM = @as(u32, 16); pub const DISPLAYCONFIG_TARGET_IS_HMD = @as(u32, 32); pub const DISPLAYCONFIG_PATH_ACTIVE = @as(u32, 1); pub const DISPLAYCONFIG_PATH_PREFERRED_UNSCALED = @as(u32, 4); pub const DISPLAYCONFIG_PATH_SUPPORT_VIRTUAL_MODE = @as(u32, 8); pub const DISPLAYCONFIG_PATH_VALID_FLAGS = @as(u32, 13); pub const QDC_ALL_PATHS = @as(u32, 1); pub const QDC_ONLY_ACTIVE_PATHS = @as(u32, 2); pub const QDC_DATABASE_CURRENT = @as(u32, 4); pub const QDC_VIRTUAL_MODE_AWARE = @as(u32, 16); pub const QDC_INCLUDE_HMD = @as(u32, 32); pub const SDC_TOPOLOGY_INTERNAL = @as(u32, 1); pub const SDC_TOPOLOGY_CLONE = @as(u32, 2); pub const SDC_TOPOLOGY_EXTEND = @as(u32, 4); pub const SDC_TOPOLOGY_EXTERNAL = @as(u32, 8); pub const SDC_TOPOLOGY_SUPPLIED = @as(u32, 16); pub const SDC_USE_SUPPLIED_DISPLAY_CONFIG = @as(u32, 32); pub const SDC_VALIDATE = @as(u32, 64); pub const SDC_APPLY = @as(u32, 128); pub const SDC_NO_OPTIMIZATION = @as(u32, 256); pub const SDC_SAVE_TO_DATABASE = @as(u32, 512); pub const SDC_ALLOW_CHANGES = @as(u32, 1024); pub const SDC_PATH_PERSIST_IF_REQUIRED = @as(u32, 2048); pub const SDC_FORCE_MODE_ENUMERATION = @as(u32, 4096); pub const SDC_ALLOW_PATH_ORDER_CHANGES = @as(u32, 8192); pub const SDC_VIRTUAL_MODE_AWARE = @as(u32, 32768); pub const RDH_RECTANGLES = @as(u32, 1); pub const SYSRGN = @as(u32, 4); pub const TT_POLYGON_TYPE = @as(u32, 24); pub const TT_PRIM_LINE = @as(u32, 1); pub const TT_PRIM_QSPLINE = @as(u32, 2); pub const TT_PRIM_CSPLINE = @as(u32, 3); pub const GCP_DBCS = @as(u32, 1); pub const GCP_ERROR = @as(u32, 32768); pub const FLI_MASK = @as(u32, 4155); pub const FLI_GLYPHS = @as(i32, 262144); pub const GCP_JUSTIFYIN = @as(i32, 2097152); pub const GCPCLASS_LATIN = @as(u32, 1); pub const GCPCLASS_HEBREW = @as(u32, 2); pub const GCPCLASS_ARABIC = @as(u32, 2); pub const GCPCLASS_NEUTRAL = @as(u32, 3); pub const GCPCLASS_LOCALNUMBER = @as(u32, 4); pub const GCPCLASS_LATINNUMBER = @as(u32, 5); pub const GCPCLASS_LATINNUMERICTERMINATOR = @as(u32, 6); pub const GCPCLASS_LATINNUMERICSEPARATOR = @as(u32, 7); pub const GCPCLASS_NUMERICSEPARATOR = @as(u32, 8); pub const GCPCLASS_PREBOUNDLTR = @as(u32, 128); pub const GCPCLASS_PREBOUNDRTL = @as(u32, 64); pub const GCPCLASS_POSTBOUNDLTR = @as(u32, 32); pub const GCPCLASS_POSTBOUNDRTL = @as(u32, 16); pub const GCPGLYPH_LINKBEFORE = @as(u32, 32768); pub const GCPGLYPH_LINKAFTER = @as(u32, 16384); pub const TT_AVAILABLE = @as(u32, 1); pub const TT_ENABLED = @as(u32, 2); pub const PFD_TYPE_RGBA = @as(u32, 0); pub const PFD_TYPE_COLORINDEX = @as(u32, 1); pub const PFD_MAIN_PLANE = @as(u32, 0); pub const PFD_OVERLAY_PLANE = @as(u32, 1); pub const PFD_UNDERLAY_PLANE = @as(i32, -1); pub const PFD_DOUBLEBUFFER = @as(u32, 1); pub const PFD_STEREO = @as(u32, 2); pub const PFD_DRAW_TO_WINDOW = @as(u32, 4); pub const PFD_DRAW_TO_BITMAP = @as(u32, 8); pub const PFD_SUPPORT_GDI = @as(u32, 16); pub const PFD_SUPPORT_OPENGL = @as(u32, 32); pub const PFD_GENERIC_FORMAT = @as(u32, 64); pub const PFD_NEED_PALETTE = @as(u32, 128); pub const PFD_NEED_SYSTEM_PALETTE = @as(u32, 256); pub const PFD_SWAP_EXCHANGE = @as(u32, 512); pub const PFD_SWAP_COPY = @as(u32, 1024); pub const PFD_SWAP_LAYER_BUFFERS = @as(u32, 2048); pub const PFD_GENERIC_ACCELERATED = @as(u32, 4096); pub const PFD_SUPPORT_DIRECTDRAW = @as(u32, 8192); pub const PFD_DIRECT3D_ACCELERATED = @as(u32, 16384); pub const PFD_SUPPORT_COMPOSITION = @as(u32, 32768); pub const PFD_DEPTH_DONTCARE = @as(u32, 536870912); pub const PFD_DOUBLEBUFFER_DONTCARE = @as(u32, 1073741824); pub const PFD_STEREO_DONTCARE = @as(u32, 2147483648); pub const DC_BINADJUST = @as(u32, 19); pub const DC_EMF_COMPLIANT = @as(u32, 20); pub const DC_DATATYPE_PRODUCED = @as(u32, 21); pub const DC_MANUFACTURER = @as(u32, 23); pub const DC_MODEL = @as(u32, 24); pub const PRINTRATEUNIT_PPM = @as(u32, 1); pub const PRINTRATEUNIT_CPS = @as(u32, 2); pub const PRINTRATEUNIT_LPM = @as(u32, 3); pub const PRINTRATEUNIT_IPM = @as(u32, 4); pub const DCTT_BITMAP = @as(i32, 1); pub const DCTT_DOWNLOAD = @as(i32, 2); pub const DCTT_SUBDEV = @as(i32, 4); pub const DCTT_DOWNLOAD_OUTLINE = @as(i32, 8); pub const DCBA_FACEUPNONE = @as(u32, 0); pub const DCBA_FACEUPCENTER = @as(u32, 1); pub const DCBA_FACEUPLEFT = @as(u32, 2); pub const DCBA_FACEUPRIGHT = @as(u32, 3); pub const DCBA_FACEDOWNNONE = @as(u32, 256); pub const DCBA_FACEDOWNCENTER = @as(u32, 257); pub const DCBA_FACEDOWNLEFT = @as(u32, 258); pub const DCBA_FACEDOWNRIGHT = @as(u32, 259); pub const GS_8BIT_INDICES = @as(u32, 1); pub const GGI_MARK_NONEXISTING_GLYPHS = @as(u32, 1); pub const MM_MAX_NUMAXES = @as(u32, 16); pub const MM_MAX_AXES_NAMELEN = @as(u32, 16); pub const GDIREGISTERDDRAWPACKETVERSION = @as(u32, 1); pub const AC_SRC_OVER = @as(u32, 0); pub const AC_SRC_ALPHA = @as(u32, 1); pub const GRADIENT_FILL_OP_FLAG = @as(u32, 255); pub const CA_NEGATIVE = @as(u32, 1); pub const CA_LOG_FILTER = @as(u32, 2); pub const ILLUMINANT_DEVICE_DEFAULT = @as(u32, 0); pub const ILLUMINANT_A = @as(u32, 1); pub const ILLUMINANT_B = @as(u32, 2); pub const ILLUMINANT_C = @as(u32, 3); pub const ILLUMINANT_D50 = @as(u32, 4); pub const ILLUMINANT_D55 = @as(u32, 5); pub const ILLUMINANT_D65 = @as(u32, 6); pub const ILLUMINANT_D75 = @as(u32, 7); pub const ILLUMINANT_F2 = @as(u32, 8); pub const DI_APPBANDING = @as(u32, 1); pub const DI_ROPS_READ_DESTINATION = @as(u32, 2); pub const FONTMAPPER_MAX = @as(u32, 10); pub const ICM_OFF = @as(u32, 1); pub const ICM_ON = @as(u32, 2); pub const ICM_QUERY = @as(u32, 3); pub const ICM_DONE_OUTSIDEDC = @as(u32, 4); pub const ENHMETA_SIGNATURE = @as(u32, 1179469088); pub const ENHMETA_STOCK_OBJECT = @as(u32, 2147483648); pub const EMR_HEADER = @as(u32, 1); pub const EMR_POLYBEZIER = @as(u32, 2); pub const EMR_POLYGON = @as(u32, 3); pub const EMR_POLYLINE = @as(u32, 4); pub const EMR_POLYBEZIERTO = @as(u32, 5); pub const EMR_POLYLINETO = @as(u32, 6); pub const EMR_POLYPOLYLINE = @as(u32, 7); pub const EMR_POLYPOLYGON = @as(u32, 8); pub const EMR_SETWINDOWEXTEX = @as(u32, 9); pub const EMR_SETWINDOWORGEX = @as(u32, 10); pub const EMR_SETVIEWPORTEXTEX = @as(u32, 11); pub const EMR_SETVIEWPORTORGEX = @as(u32, 12); pub const EMR_SETBRUSHORGEX = @as(u32, 13); pub const EMR_EOF = @as(u32, 14); pub const EMR_SETPIXELV = @as(u32, 15); pub const EMR_SETMAPPERFLAGS = @as(u32, 16); pub const EMR_SETMAPMODE = @as(u32, 17); pub const EMR_SETBKMODE = @as(u32, 18); pub const EMR_SETPOLYFILLMODE = @as(u32, 19); pub const EMR_SETROP2 = @as(u32, 20); pub const EMR_SETSTRETCHBLTMODE = @as(u32, 21); pub const EMR_SETTEXTALIGN = @as(u32, 22); pub const EMR_SETCOLORADJUSTMENT = @as(u32, 23); pub const EMR_SETTEXTCOLOR = @as(u32, 24); pub const EMR_SETBKCOLOR = @as(u32, 25); pub const EMR_OFFSETCLIPRGN = @as(u32, 26); pub const EMR_MOVETOEX = @as(u32, 27); pub const EMR_SETMETARGN = @as(u32, 28); pub const EMR_EXCLUDECLIPRECT = @as(u32, 29); pub const EMR_INTERSECTCLIPRECT = @as(u32, 30); pub const EMR_SCALEVIEWPORTEXTEX = @as(u32, 31); pub const EMR_SCALEWINDOWEXTEX = @as(u32, 32); pub const EMR_SAVEDC = @as(u32, 33); pub const EMR_RESTOREDC = @as(u32, 34); pub const EMR_SETWORLDTRANSFORM = @as(u32, 35); pub const EMR_MODIFYWORLDTRANSFORM = @as(u32, 36); pub const EMR_SELECTOBJECT = @as(u32, 37); pub const EMR_CREATEPEN = @as(u32, 38); pub const EMR_CREATEBRUSHINDIRECT = @as(u32, 39); pub const EMR_DELETEOBJECT = @as(u32, 40); pub const EMR_ANGLEARC = @as(u32, 41); pub const EMR_ELLIPSE = @as(u32, 42); pub const EMR_RECTANGLE = @as(u32, 43); pub const EMR_ROUNDRECT = @as(u32, 44); pub const EMR_ARC = @as(u32, 45); pub const EMR_CHORD = @as(u32, 46); pub const EMR_PIE = @as(u32, 47); pub const EMR_SELECTPALETTE = @as(u32, 48); pub const EMR_CREATEPALETTE = @as(u32, 49); pub const EMR_SETPALETTEENTRIES = @as(u32, 50); pub const EMR_RESIZEPALETTE = @as(u32, 51); pub const EMR_REALIZEPALETTE = @as(u32, 52); pub const EMR_EXTFLOODFILL = @as(u32, 53); pub const EMR_LINETO = @as(u32, 54); pub const EMR_ARCTO = @as(u32, 55); pub const EMR_POLYDRAW = @as(u32, 56); pub const EMR_SETARCDIRECTION = @as(u32, 57); pub const EMR_SETMITERLIMIT = @as(u32, 58); pub const EMR_BEGINPATH = @as(u32, 59); pub const EMR_ENDPATH = @as(u32, 60); pub const EMR_CLOSEFIGURE = @as(u32, 61); pub const EMR_FILLPATH = @as(u32, 62); pub const EMR_STROKEANDFILLPATH = @as(u32, 63); pub const EMR_STROKEPATH = @as(u32, 64); pub const EMR_FLATTENPATH = @as(u32, 65); pub const EMR_WIDENPATH = @as(u32, 66); pub const EMR_SELECTCLIPPATH = @as(u32, 67); pub const EMR_ABORTPATH = @as(u32, 68); pub const EMR_GDICOMMENT = @as(u32, 70); pub const EMR_FILLRGN = @as(u32, 71); pub const EMR_FRAMERGN = @as(u32, 72); pub const EMR_INVERTRGN = @as(u32, 73); pub const EMR_PAINTRGN = @as(u32, 74); pub const EMR_EXTSELECTCLIPRGN = @as(u32, 75); pub const EMR_BITBLT = @as(u32, 76); pub const EMR_STRETCHBLT = @as(u32, 77); pub const EMR_MASKBLT = @as(u32, 78); pub const EMR_PLGBLT = @as(u32, 79); pub const EMR_SETDIBITSTODEVICE = @as(u32, 80); pub const EMR_STRETCHDIBITS = @as(u32, 81); pub const EMR_EXTCREATEFONTINDIRECTW = @as(u32, 82); pub const EMR_EXTTEXTOUTA = @as(u32, 83); pub const EMR_EXTTEXTOUTW = @as(u32, 84); pub const EMR_POLYBEZIER16 = @as(u32, 85); pub const EMR_POLYGON16 = @as(u32, 86); pub const EMR_POLYLINE16 = @as(u32, 87); pub const EMR_POLYBEZIERTO16 = @as(u32, 88); pub const EMR_POLYLINETO16 = @as(u32, 89); pub const EMR_POLYPOLYLINE16 = @as(u32, 90); pub const EMR_POLYPOLYGON16 = @as(u32, 91); pub const EMR_POLYDRAW16 = @as(u32, 92); pub const EMR_CREATEMONOBRUSH = @as(u32, 93); pub const EMR_CREATEDIBPATTERNBRUSHPT = @as(u32, 94); pub const EMR_EXTCREATEPEN = @as(u32, 95); pub const EMR_POLYTEXTOUTA = @as(u32, 96); pub const EMR_POLYTEXTOUTW = @as(u32, 97); pub const EMR_SETICMMODE = @as(u32, 98); pub const EMR_CREATECOLORSPACE = @as(u32, 99); pub const EMR_SETCOLORSPACE = @as(u32, 100); pub const EMR_DELETECOLORSPACE = @as(u32, 101); pub const EMR_GLSRECORD = @as(u32, 102); pub const EMR_GLSBOUNDEDRECORD = @as(u32, 103); pub const EMR_PIXELFORMAT = @as(u32, 104); pub const EMR_RESERVED_105 = @as(u32, 105); pub const EMR_RESERVED_106 = @as(u32, 106); pub const EMR_RESERVED_107 = @as(u32, 107); pub const EMR_RESERVED_108 = @as(u32, 108); pub const EMR_RESERVED_109 = @as(u32, 109); pub const EMR_RESERVED_110 = @as(u32, 110); pub const EMR_COLORCORRECTPALETTE = @as(u32, 111); pub const EMR_SETICMPROFILEA = @as(u32, 112); pub const EMR_SETICMPROFILEW = @as(u32, 113); pub const EMR_ALPHABLEND = @as(u32, 114); pub const EMR_SETLAYOUT = @as(u32, 115); pub const EMR_TRANSPARENTBLT = @as(u32, 116); pub const EMR_RESERVED_117 = @as(u32, 117); pub const EMR_GRADIENTFILL = @as(u32, 118); pub const EMR_RESERVED_119 = @as(u32, 119); pub const EMR_RESERVED_120 = @as(u32, 120); pub const EMR_COLORMATCHTOTARGETW = @as(u32, 121); pub const EMR_CREATECOLORSPACEW = @as(u32, 122); pub const EMR_MIN = @as(u32, 1); pub const EMR_MAX = @as(u32, 122); pub const SETICMPROFILE_EMBEDED = @as(u32, 1); pub const CREATECOLORSPACE_EMBEDED = @as(u32, 1); pub const COLORMATCHTOTARGET_EMBEDED = @as(u32, 1); pub const GDICOMMENT_IDENTIFIER = @as(u32, 1128875079); pub const GDICOMMENT_WINDOWS_METAFILE = @as(u32, 2147483649); pub const GDICOMMENT_BEGINGROUP = @as(u32, 2); pub const GDICOMMENT_ENDGROUP = @as(u32, 3); pub const GDICOMMENT_MULTIFORMATS = @as(u32, 1073741828); pub const EPS_SIGNATURE = @as(u32, 1179865157); pub const GDICOMMENT_UNICODE_STRING = @as(u32, 64); pub const GDICOMMENT_UNICODE_END = @as(u32, 128); pub const WGL_FONT_LINES = @as(u32, 0); pub const WGL_FONT_POLYGONS = @as(u32, 1); pub const LPD_DOUBLEBUFFER = @as(u32, 1); pub const LPD_STEREO = @as(u32, 2); pub const LPD_SUPPORT_GDI = @as(u32, 16); pub const LPD_SUPPORT_OPENGL = @as(u32, 32); pub const LPD_SHARE_DEPTH = @as(u32, 64); pub const LPD_SHARE_STENCIL = @as(u32, 128); pub const LPD_SHARE_ACCUM = @as(u32, 256); pub const LPD_SWAP_EXCHANGE = @as(u32, 512); pub const LPD_SWAP_COPY = @as(u32, 1024); pub const LPD_TRANSPARENT = @as(u32, 4096); pub const LPD_TYPE_RGBA = @as(u32, 0); pub const LPD_TYPE_COLORINDEX = @as(u32, 1); pub const WGL_SWAP_MAIN_PLANE = @as(u32, 1); pub const WGL_SWAP_OVERLAY1 = @as(u32, 2); pub const WGL_SWAP_OVERLAY2 = @as(u32, 4); pub const WGL_SWAP_OVERLAY3 = @as(u32, 8); pub const WGL_SWAP_OVERLAY4 = @as(u32, 16); pub const WGL_SWAP_OVERLAY5 = @as(u32, 32); pub const WGL_SWAP_OVERLAY6 = @as(u32, 64); pub const WGL_SWAP_OVERLAY7 = @as(u32, 128); pub const WGL_SWAP_OVERLAY8 = @as(u32, 256); pub const WGL_SWAP_OVERLAY9 = @as(u32, 512); pub const WGL_SWAP_OVERLAY10 = @as(u32, 1024); pub const WGL_SWAP_OVERLAY11 = @as(u32, 2048); pub const WGL_SWAP_OVERLAY12 = @as(u32, 4096); pub const WGL_SWAP_OVERLAY13 = @as(u32, 8192); pub const WGL_SWAP_OVERLAY14 = @as(u32, 16384); pub const WGL_SWAP_OVERLAY15 = @as(u32, 32768); pub const WGL_SWAP_UNDERLAY1 = @as(u32, 65536); pub const WGL_SWAP_UNDERLAY2 = @as(u32, 131072); pub const WGL_SWAP_UNDERLAY3 = @as(u32, 262144); pub const WGL_SWAP_UNDERLAY4 = @as(u32, 524288); pub const WGL_SWAP_UNDERLAY5 = @as(u32, 1048576); pub const WGL_SWAP_UNDERLAY6 = @as(u32, 2097152); pub const WGL_SWAP_UNDERLAY7 = @as(u32, 4194304); pub const WGL_SWAP_UNDERLAY8 = @as(u32, 8388608); pub const WGL_SWAP_UNDERLAY9 = @as(u32, 16777216); pub const WGL_SWAP_UNDERLAY10 = @as(u32, 33554432); pub const WGL_SWAP_UNDERLAY11 = @as(u32, 67108864); pub const WGL_SWAP_UNDERLAY12 = @as(u32, 134217728); pub const WGL_SWAP_UNDERLAY13 = @as(u32, 268435456); pub const WGL_SWAP_UNDERLAY14 = @as(u32, 536870912); pub const WGL_SWAP_UNDERLAY15 = @as(u32, 1073741824); pub const WGL_SWAPMULTIPLE_MAX = @as(u32, 16); pub const SELECTDIB = @as(u32, 41); pub const TTFCFP_SUBSET = @as(u32, 0); pub const TTFCFP_SUBSET1 = @as(u32, 1); pub const TTFCFP_DELTA = @as(u32, 2); pub const TTFCFP_APPLE_PLATFORMID = @as(u32, 1); pub const TTFCFP_MS_PLATFORMID = @as(u32, 3); pub const TTFCFP_DONT_CARE = @as(u32, 65535); pub const TTFCFP_LANG_KEEP_ALL = @as(u32, 0); pub const TTFCFP_FLAGS_SUBSET = @as(u32, 1); pub const TTFCFP_FLAGS_COMPRESS = @as(u32, 2); pub const TTFCFP_FLAGS_TTC = @as(u32, 4); pub const TTFCFP_FLAGS_GLYPHLIST = @as(u32, 8); pub const TTFMFP_SUBSET = @as(u32, 0); pub const TTFMFP_SUBSET1 = @as(u32, 1); pub const TTFMFP_DELTA = @as(u32, 2); pub const ERR_GENERIC = @as(u32, 1000); pub const ERR_READOUTOFBOUNDS = @as(u32, 1001); pub const ERR_WRITEOUTOFBOUNDS = @as(u32, 1002); pub const ERR_READCONTROL = @as(u32, 1003); pub const ERR_WRITECONTROL = @as(u32, 1004); pub const ERR_MEM = @as(u32, 1005); pub const ERR_FORMAT = @as(u32, 1006); pub const ERR_WOULD_GROW = @as(u32, 1007); pub const ERR_VERSION = @as(u32, 1008); pub const ERR_NO_GLYPHS = @as(u32, 1009); pub const ERR_INVALID_MERGE_FORMATS = @as(u32, 1010); pub const ERR_INVALID_MERGE_CHECKSUMS = @as(u32, 1011); pub const ERR_INVALID_MERGE_NUMGLYPHS = @as(u32, 1012); pub const ERR_INVALID_DELTA_FORMAT = @as(u32, 1013); pub const ERR_NOT_TTC = @as(u32, 1014); pub const ERR_INVALID_TTC_INDEX = @as(u32, 1015); pub const ERR_MISSING_CMAP = @as(u32, 1030); pub const ERR_MISSING_GLYF = @as(u32, 1031); pub const ERR_MISSING_HEAD = @as(u32, 1032); pub const ERR_MISSING_HHEA = @as(u32, 1033); pub const ERR_MISSING_HMTX = @as(u32, 1034); pub const ERR_MISSING_LOCA = @as(u32, 1035); pub const ERR_MISSING_MAXP = @as(u32, 1036); pub const ERR_MISSING_NAME = @as(u32, 1037); pub const ERR_MISSING_POST = @as(u32, 1038); pub const ERR_MISSING_OS2 = @as(u32, 1039); pub const ERR_MISSING_VHEA = @as(u32, 1040); pub const ERR_MISSING_VMTX = @as(u32, 1041); pub const ERR_MISSING_HHEA_OR_VHEA = @as(u32, 1042); pub const ERR_MISSING_HMTX_OR_VMTX = @as(u32, 1043); pub const ERR_MISSING_EBDT = @as(u32, 1044); pub const ERR_INVALID_CMAP = @as(u32, 1060); pub const ERR_INVALID_GLYF = @as(u32, 1061); pub const ERR_INVALID_HEAD = @as(u32, 1062); pub const ERR_INVALID_HHEA = @as(u32, 1063); pub const ERR_INVALID_HMTX = @as(u32, 1064); pub const ERR_INVALID_LOCA = @as(u32, 1065); pub const ERR_INVALID_MAXP = @as(u32, 1066); pub const ERR_INVALID_NAME = @as(u32, 1067); pub const ERR_INVALID_POST = @as(u32, 1068); pub const ERR_INVALID_OS2 = @as(u32, 1069); pub const ERR_INVALID_VHEA = @as(u32, 1070); pub const ERR_INVALID_VMTX = @as(u32, 1071); pub const ERR_INVALID_HHEA_OR_VHEA = @as(u32, 1072); pub const ERR_INVALID_HMTX_OR_VMTX = @as(u32, 1073); pub const ERR_INVALID_TTO = @as(u32, 1080); pub const ERR_INVALID_GSUB = @as(u32, 1081); pub const ERR_INVALID_GPOS = @as(u32, 1082); pub const ERR_INVALID_GDEF = @as(u32, 1083); pub const ERR_INVALID_JSTF = @as(u32, 1084); pub const ERR_INVALID_BASE = @as(u32, 1085); pub const ERR_INVALID_EBLC = @as(u32, 1086); pub const ERR_INVALID_LTSH = @as(u32, 1087); pub const ERR_INVALID_VDMX = @as(u32, 1088); pub const ERR_INVALID_HDMX = @as(u32, 1089); pub const ERR_PARAMETER0 = @as(u32, 1100); pub const ERR_PARAMETER1 = @as(u32, 1101); pub const ERR_PARAMETER2 = @as(u32, 1102); pub const ERR_PARAMETER3 = @as(u32, 1103); pub const ERR_PARAMETER4 = @as(u32, 1104); pub const ERR_PARAMETER5 = @as(u32, 1105); pub const ERR_PARAMETER6 = @as(u32, 1106); pub const ERR_PARAMETER7 = @as(u32, 1107); pub const ERR_PARAMETER8 = @as(u32, 1108); pub const ERR_PARAMETER9 = @as(u32, 1109); pub const ERR_PARAMETER10 = @as(u32, 1110); pub const ERR_PARAMETER11 = @as(u32, 1111); pub const ERR_PARAMETER12 = @as(u32, 1112); pub const ERR_PARAMETER13 = @as(u32, 1113); pub const ERR_PARAMETER14 = @as(u32, 1114); pub const ERR_PARAMETER15 = @as(u32, 1115); pub const ERR_PARAMETER16 = @as(u32, 1116); pub const CHARSET_DEFAULT = @as(u32, 1); pub const CHARSET_GLYPHIDX = @as(u32, 3); pub const TTEMBED_FAILIFVARIATIONSIMULATED = @as(u32, 16); pub const TTEMBED_WEBOBJECT = @as(u32, 128); pub const TTEMBED_XORENCRYPTDATA = @as(u32, 268435456); pub const TTEMBED_VARIATIONSIMULATED = @as(u32, 1); pub const TTEMBED_EUDCEMBEDDED = @as(u32, 2); pub const TTEMBED_SUBSETCANCEL = @as(u32, 4); pub const TTLOAD_PRIVATE = @as(u32, 1); pub const TTLOAD_EUDC_OVERWRITE = @as(u32, 2); pub const TTLOAD_EUDC_SET = @as(u32, 4); pub const TTDELETE_DONTREMOVEFONT = @as(u32, 1); pub const E_NONE = @as(i32, 0); pub const E_API_NOTIMPL = @as(i32, 1); pub const E_CHARCODECOUNTINVALID = @as(i32, 2); pub const E_CHARCODESETINVALID = @as(i32, 3); pub const E_DEVICETRUETYPEFONT = @as(i32, 4); pub const E_HDCINVALID = @as(i32, 6); pub const E_NOFREEMEMORY = @as(i32, 7); pub const E_FONTREFERENCEINVALID = @as(i32, 8); pub const E_NOTATRUETYPEFONT = @as(i32, 10); pub const E_ERRORACCESSINGFONTDATA = @as(i32, 12); pub const E_ERRORACCESSINGFACENAME = @as(i32, 13); pub const E_ERRORUNICODECONVERSION = @as(i32, 17); pub const E_ERRORCONVERTINGCHARS = @as(i32, 18); pub const E_EXCEPTION = @as(i32, 19); pub const E_RESERVEDPARAMNOTNULL = @as(i32, 20); pub const E_CHARSETINVALID = @as(i32, 21); pub const E_FILE_NOT_FOUND = @as(i32, 23); pub const E_TTC_INDEX_OUT_OF_RANGE = @as(i32, 24); pub const E_INPUTPARAMINVALID = @as(i32, 25); pub const E_ERRORCOMPRESSINGFONTDATA = @as(i32, 256); pub const E_FONTDATAINVALID = @as(i32, 258); pub const E_NAMECHANGEFAILED = @as(i32, 259); pub const E_FONTNOTEMBEDDABLE = @as(i32, 260); pub const E_PRIVSINVALID = @as(i32, 261); pub const E_SUBSETTINGFAILED = @as(i32, 262); pub const E_READFROMSTREAMFAILED = @as(i32, 263); pub const E_SAVETOSTREAMFAILED = @as(i32, 264); pub const E_NOOS2 = @as(i32, 265); pub const E_T2NOFREEMEMORY = @as(i32, 266); pub const E_ERRORREADINGFONTDATA = @as(i32, 267); pub const E_FLAGSINVALID = @as(i32, 268); pub const E_ERRORCREATINGFONTFILE = @as(i32, 269); pub const E_FONTALREADYEXISTS = @as(i32, 270); pub const E_FONTNAMEALREADYEXISTS = @as(i32, 271); pub const E_FONTINSTALLFAILED = @as(i32, 272); pub const E_ERRORDECOMPRESSINGFONTDATA = @as(i32, 273); pub const E_ERRORACCESSINGEXCLUDELIST = @as(i32, 274); pub const E_FACENAMEINVALID = @as(i32, 275); pub const E_STREAMINVALID = @as(i32, 276); pub const E_STATUSINVALID = @as(i32, 277); pub const E_PRIVSTATUSINVALID = @as(i32, 278); pub const E_PERMISSIONSINVALID = @as(i32, 279); pub const E_PBENABLEDINVALID = @as(i32, 280); pub const E_SUBSETTINGEXCEPTION = @as(i32, 281); pub const E_SUBSTRING_TEST_FAIL = @as(i32, 282); pub const E_FONTVARIATIONSIMULATED = @as(i32, 283); pub const E_FONTFAMILYNAMENOTINFULL = @as(i32, 285); pub const E_ADDFONTFAILED = @as(i32, 512); pub const E_COULDNTCREATETEMPFILE = @as(i32, 513); pub const E_FONTFILECREATEFAILED = @as(i32, 515); pub const E_WINDOWSAPI = @as(i32, 516); pub const E_FONTFILENOTFOUND = @as(i32, 517); pub const E_RESOURCEFILECREATEFAILED = @as(i32, 518); pub const E_ERROREXPANDINGFONTDATA = @as(i32, 519); pub const E_ERRORGETTINGDC = @as(i32, 520); pub const E_EXCEPTIONINDECOMPRESSION = @as(i32, 521); pub const E_EXCEPTIONINCOMPRESSION = @as(i32, 522); //-------------------------------------------------------------------------------- // Section: Types (240) //-------------------------------------------------------------------------------- pub const R2_MODE = enum(i32) { BLACK = 1, NOTMERGEPEN = 2, MASKNOTPEN = 3, NOTCOPYPEN = 4, MASKPENNOT = 5, NOT = 6, XORPEN = 7, NOTMASKPEN = 8, MASKPEN = 9, NOTXORPEN = 10, NOP = 11, MERGENOTPEN = 12, COPYPEN = 13, MERGEPENNOT = 14, MERGEPEN = 15, WHITE = 16, // LAST = 16, this enum value conflicts with WHITE }; pub const R2_BLACK = R2_MODE.BLACK; pub const R2_NOTMERGEPEN = R2_MODE.NOTMERGEPEN; pub const R2_MASKNOTPEN = R2_MODE.MASKNOTPEN; pub const R2_NOTCOPYPEN = R2_MODE.NOTCOPYPEN; pub const R2_MASKPENNOT = R2_MODE.MASKPENNOT; pub const R2_NOT = R2_MODE.NOT; pub const R2_XORPEN = R2_MODE.XORPEN; pub const R2_NOTMASKPEN = R2_MODE.NOTMASKPEN; pub const R2_MASKPEN = R2_MODE.MASKPEN; pub const R2_NOTXORPEN = R2_MODE.NOTXORPEN; pub const R2_NOP = R2_MODE.NOP; pub const R2_MERGENOTPEN = R2_MODE.MERGENOTPEN; pub const R2_COPYPEN = R2_MODE.COPYPEN; pub const R2_MERGEPENNOT = R2_MODE.MERGEPENNOT; pub const R2_MERGEPEN = R2_MODE.MERGEPEN; pub const R2_WHITE = R2_MODE.WHITE; pub const R2_LAST = R2_MODE.WHITE; pub const RGN_COMBINE_MODE = enum(i32) { AND = 1, OR = 2, XOR = 3, DIFF = 4, COPY = 5, // MIN = 1, this enum value conflicts with AND // MAX = 5, this enum value conflicts with COPY }; pub const RGN_AND = RGN_COMBINE_MODE.AND; pub const RGN_OR = RGN_COMBINE_MODE.OR; pub const RGN_XOR = RGN_COMBINE_MODE.XOR; pub const RGN_DIFF = RGN_COMBINE_MODE.DIFF; pub const RGN_COPY = RGN_COMBINE_MODE.COPY; pub const RGN_MIN = RGN_COMBINE_MODE.AND; pub const RGN_MAX = RGN_COMBINE_MODE.COPY; pub const ETO_OPTIONS = enum(u32) { OPAQUE = 2, CLIPPED = 4, GLYPH_INDEX = 16, RTLREADING = 128, NUMERICSLOCAL = 1024, NUMERICSLATIN = 2048, IGNORELANGUAGE = 4096, PDY = 8192, REVERSE_INDEX_MAP = 65536, _, pub fn initFlags(o: struct { OPAQUE: u1 = 0, CLIPPED: u1 = 0, GLYPH_INDEX: u1 = 0, RTLREADING: u1 = 0, NUMERICSLOCAL: u1 = 0, NUMERICSLATIN: u1 = 0, IGNORELANGUAGE: u1 = 0, PDY: u1 = 0, REVERSE_INDEX_MAP: u1 = 0, }) ETO_OPTIONS { return @intToEnum(ETO_OPTIONS, (if (o.OPAQUE == 1) @enumToInt(ETO_OPTIONS.OPAQUE) else 0) | (if (o.CLIPPED == 1) @enumToInt(ETO_OPTIONS.CLIPPED) else 0) | (if (o.GLYPH_INDEX == 1) @enumToInt(ETO_OPTIONS.GLYPH_INDEX) else 0) | (if (o.RTLREADING == 1) @enumToInt(ETO_OPTIONS.RTLREADING) else 0) | (if (o.NUMERICSLOCAL == 1) @enumToInt(ETO_OPTIONS.NUMERICSLOCAL) else 0) | (if (o.NUMERICSLATIN == 1) @enumToInt(ETO_OPTIONS.NUMERICSLATIN) else 0) | (if (o.IGNORELANGUAGE == 1) @enumToInt(ETO_OPTIONS.IGNORELANGUAGE) else 0) | (if (o.PDY == 1) @enumToInt(ETO_OPTIONS.PDY) else 0) | (if (o.REVERSE_INDEX_MAP == 1) @enumToInt(ETO_OPTIONS.REVERSE_INDEX_MAP) else 0) ); } }; pub const ETO_OPAQUE = ETO_OPTIONS.OPAQUE; pub const ETO_CLIPPED = ETO_OPTIONS.CLIPPED; pub const ETO_GLYPH_INDEX = ETO_OPTIONS.GLYPH_INDEX; pub const ETO_RTLREADING = ETO_OPTIONS.RTLREADING; pub const ETO_NUMERICSLOCAL = ETO_OPTIONS.NUMERICSLOCAL; pub const ETO_NUMERICSLATIN = ETO_OPTIONS.NUMERICSLATIN; pub const ETO_IGNORELANGUAGE = ETO_OPTIONS.IGNORELANGUAGE; pub const ETO_PDY = ETO_OPTIONS.PDY; pub const ETO_REVERSE_INDEX_MAP = ETO_OPTIONS.REVERSE_INDEX_MAP; pub const OBJ_TYPE = enum(i32) { PEN = 1, BRUSH = 2, DC = 3, METADC = 4, PAL = 5, FONT = 6, BITMAP = 7, REGION = 8, METAFILE = 9, MEMDC = 10, EXTPEN = 11, ENHMETADC = 12, ENHMETAFILE = 13, COLORSPACE = 14, }; pub const OBJ_PEN = OBJ_TYPE.PEN; pub const OBJ_BRUSH = OBJ_TYPE.BRUSH; pub const OBJ_DC = OBJ_TYPE.DC; pub const OBJ_METADC = OBJ_TYPE.METADC; pub const OBJ_PAL = OBJ_TYPE.PAL; pub const OBJ_FONT = OBJ_TYPE.FONT; pub const OBJ_BITMAP = OBJ_TYPE.BITMAP; pub const OBJ_REGION = OBJ_TYPE.REGION; pub const OBJ_METAFILE = OBJ_TYPE.METAFILE; pub const OBJ_MEMDC = OBJ_TYPE.MEMDC; pub const OBJ_EXTPEN = OBJ_TYPE.EXTPEN; pub const OBJ_ENHMETADC = OBJ_TYPE.ENHMETADC; pub const OBJ_ENHMETAFILE = OBJ_TYPE.ENHMETAFILE; pub const OBJ_COLORSPACE = OBJ_TYPE.COLORSPACE; pub const ROP_CODE = enum(u32) { SRCCOPY = 13369376, SRCPAINT = 15597702, SRCAND = 8913094, SRCINVERT = 6684742, SRCERASE = 4457256, NOTSRCCOPY = 3342344, NOTSRCERASE = 1114278, MERGECOPY = 12583114, MERGEPAINT = 12255782, PATCOPY = 15728673, PATPAINT = 16452105, PATINVERT = 5898313, DSTINVERT = 5570569, BLACKNESS = 66, WHITENESS = 16711778, NOMIRRORBITMAP = 2147483648, CAPTUREBLT = 1073741824, }; pub const SRCCOPY = ROP_CODE.SRCCOPY; pub const SRCPAINT = ROP_CODE.SRCPAINT; pub const SRCAND = ROP_CODE.SRCAND; pub const SRCINVERT = ROP_CODE.SRCINVERT; pub const SRCERASE = ROP_CODE.SRCERASE; pub const NOTSRCCOPY = ROP_CODE.NOTSRCCOPY; pub const NOTSRCERASE = ROP_CODE.NOTSRCERASE; pub const MERGECOPY = ROP_CODE.MERGECOPY; pub const MERGEPAINT = ROP_CODE.MERGEPAINT; pub const PATCOPY = ROP_CODE.PATCOPY; pub const PATPAINT = ROP_CODE.PATPAINT; pub const PATINVERT = ROP_CODE.PATINVERT; pub const DSTINVERT = ROP_CODE.DSTINVERT; pub const BLACKNESS = ROP_CODE.BLACKNESS; pub const WHITENESS = ROP_CODE.WHITENESS; pub const NOMIRRORBITMAP = ROP_CODE.NOMIRRORBITMAP; pub const CAPTUREBLT = ROP_CODE.CAPTUREBLT; pub const DIB_USAGE = enum(u32) { RGB_COLORS = 0, PAL_COLORS = 1, }; pub const DIB_RGB_COLORS = DIB_USAGE.RGB_COLORS; pub const DIB_PAL_COLORS = DIB_USAGE.PAL_COLORS; pub const DRAWEDGE_FLAGS = enum(u32) { BDR_RAISEDOUTER = 1, BDR_SUNKENOUTER = 2, BDR_RAISEDINNER = 4, BDR_SUNKENINNER = 8, BDR_OUTER = 3, BDR_INNER = 12, BDR_RAISED = 5, BDR_SUNKEN = 10, // EDGE_RAISED = 5, this enum value conflicts with BDR_RAISED // EDGE_SUNKEN = 10, this enum value conflicts with BDR_SUNKEN EDGE_ETCHED = 6, EDGE_BUMP = 9, _, pub fn initFlags(o: struct { BDR_RAISEDOUTER: u1 = 0, BDR_SUNKENOUTER: u1 = 0, BDR_RAISEDINNER: u1 = 0, BDR_SUNKENINNER: u1 = 0, BDR_OUTER: u1 = 0, BDR_INNER: u1 = 0, BDR_RAISED: u1 = 0, BDR_SUNKEN: u1 = 0, EDGE_ETCHED: u1 = 0, EDGE_BUMP: u1 = 0, }) DRAWEDGE_FLAGS { return @intToEnum(DRAWEDGE_FLAGS, (if (o.BDR_RAISEDOUTER == 1) @enumToInt(DRAWEDGE_FLAGS.BDR_RAISEDOUTER) else 0) | (if (o.BDR_SUNKENOUTER == 1) @enumToInt(DRAWEDGE_FLAGS.BDR_SUNKENOUTER) else 0) | (if (o.BDR_RAISEDINNER == 1) @enumToInt(DRAWEDGE_FLAGS.BDR_RAISEDINNER) else 0) | (if (o.BDR_SUNKENINNER == 1) @enumToInt(DRAWEDGE_FLAGS.BDR_SUNKENINNER) else 0) | (if (o.BDR_OUTER == 1) @enumToInt(DRAWEDGE_FLAGS.BDR_OUTER) else 0) | (if (o.BDR_INNER == 1) @enumToInt(DRAWEDGE_FLAGS.BDR_INNER) else 0) | (if (o.BDR_RAISED == 1) @enumToInt(DRAWEDGE_FLAGS.BDR_RAISED) else 0) | (if (o.BDR_SUNKEN == 1) @enumToInt(DRAWEDGE_FLAGS.BDR_SUNKEN) else 0) | (if (o.EDGE_ETCHED == 1) @enumToInt(DRAWEDGE_FLAGS.EDGE_ETCHED) else 0) | (if (o.EDGE_BUMP == 1) @enumToInt(DRAWEDGE_FLAGS.EDGE_BUMP) else 0) ); } }; pub const BDR_RAISEDOUTER = DRAWEDGE_FLAGS.BDR_RAISEDOUTER; pub const BDR_SUNKENOUTER = DRAWEDGE_FLAGS.BDR_SUNKENOUTER; pub const BDR_RAISEDINNER = DRAWEDGE_FLAGS.BDR_RAISEDINNER; pub const BDR_SUNKENINNER = DRAWEDGE_FLAGS.BDR_SUNKENINNER; pub const BDR_OUTER = DRAWEDGE_FLAGS.BDR_OUTER; pub const BDR_INNER = DRAWEDGE_FLAGS.BDR_INNER; pub const BDR_RAISED = DRAWEDGE_FLAGS.BDR_RAISED; pub const BDR_SUNKEN = DRAWEDGE_FLAGS.BDR_SUNKEN; pub const EDGE_RAISED = DRAWEDGE_FLAGS.BDR_RAISED; pub const EDGE_SUNKEN = DRAWEDGE_FLAGS.BDR_SUNKEN; pub const EDGE_ETCHED = DRAWEDGE_FLAGS.EDGE_ETCHED; pub const EDGE_BUMP = DRAWEDGE_FLAGS.EDGE_BUMP; pub const DFC_TYPE = enum(u32) { CAPTION = 1, MENU = 2, SCROLL = 3, BUTTON = 4, POPUPMENU = 5, }; pub const DFC_CAPTION = DFC_TYPE.CAPTION; pub const DFC_MENU = DFC_TYPE.MENU; pub const DFC_SCROLL = DFC_TYPE.SCROLL; pub const DFC_BUTTON = DFC_TYPE.BUTTON; pub const DFC_POPUPMENU = DFC_TYPE.POPUPMENU; pub const DFCS_STATE = enum(u32) { CAPTIONCLOSE = 0, CAPTIONMIN = 1, CAPTIONMAX = 2, CAPTIONRESTORE = 3, CAPTIONHELP = 4, // MENUARROW = 0, this enum value conflicts with CAPTIONCLOSE // MENUCHECK = 1, this enum value conflicts with CAPTIONMIN // MENUBULLET = 2, this enum value conflicts with CAPTIONMAX // MENUARROWRIGHT = 4, this enum value conflicts with CAPTIONHELP // SCROLLUP = 0, this enum value conflicts with CAPTIONCLOSE // SCROLLDOWN = 1, this enum value conflicts with CAPTIONMIN // SCROLLLEFT = 2, this enum value conflicts with CAPTIONMAX // SCROLLRIGHT = 3, this enum value conflicts with CAPTIONRESTORE SCROLLCOMBOBOX = 5, SCROLLSIZEGRIP = 8, SCROLLSIZEGRIPRIGHT = 16, // BUTTONCHECK = 0, this enum value conflicts with CAPTIONCLOSE // BUTTONRADIOIMAGE = 1, this enum value conflicts with CAPTIONMIN // BUTTONRADIOMASK = 2, this enum value conflicts with CAPTIONMAX // BUTTONRADIO = 4, this enum value conflicts with CAPTIONHELP // BUTTON3STATE = 8, this enum value conflicts with SCROLLSIZEGRIP // BUTTONPUSH = 16, this enum value conflicts with SCROLLSIZEGRIPRIGHT INACTIVE = 256, PUSHED = 512, CHECKED = 1024, TRANSPARENT = 2048, HOT = 4096, ADJUSTRECT = 8192, FLAT = 16384, MONO = 32768, _, pub fn initFlags(o: struct { CAPTIONCLOSE: u1 = 0, CAPTIONMIN: u1 = 0, CAPTIONMAX: u1 = 0, CAPTIONRESTORE: u1 = 0, CAPTIONHELP: u1 = 0, SCROLLCOMBOBOX: u1 = 0, SCROLLSIZEGRIP: u1 = 0, SCROLLSIZEGRIPRIGHT: u1 = 0, INACTIVE: u1 = 0, PUSHED: u1 = 0, CHECKED: u1 = 0, TRANSPARENT: u1 = 0, HOT: u1 = 0, ADJUSTRECT: u1 = 0, FLAT: u1 = 0, MONO: u1 = 0, }) DFCS_STATE { return @intToEnum(DFCS_STATE, (if (o.CAPTIONCLOSE == 1) @enumToInt(DFCS_STATE.CAPTIONCLOSE) else 0) | (if (o.CAPTIONMIN == 1) @enumToInt(DFCS_STATE.CAPTIONMIN) else 0) | (if (o.CAPTIONMAX == 1) @enumToInt(DFCS_STATE.CAPTIONMAX) else 0) | (if (o.CAPTIONRESTORE == 1) @enumToInt(DFCS_STATE.CAPTIONRESTORE) else 0) | (if (o.CAPTIONHELP == 1) @enumToInt(DFCS_STATE.CAPTIONHELP) else 0) | (if (o.SCROLLCOMBOBOX == 1) @enumToInt(DFCS_STATE.SCROLLCOMBOBOX) else 0) | (if (o.SCROLLSIZEGRIP == 1) @enumToInt(DFCS_STATE.SCROLLSIZEGRIP) else 0) | (if (o.SCROLLSIZEGRIPRIGHT == 1) @enumToInt(DFCS_STATE.SCROLLSIZEGRIPRIGHT) else 0) | (if (o.INACTIVE == 1) @enumToInt(DFCS_STATE.INACTIVE) else 0) | (if (o.PUSHED == 1) @enumToInt(DFCS_STATE.PUSHED) else 0) | (if (o.CHECKED == 1) @enumToInt(DFCS_STATE.CHECKED) else 0) | (if (o.TRANSPARENT == 1) @enumToInt(DFCS_STATE.TRANSPARENT) else 0) | (if (o.HOT == 1) @enumToInt(DFCS_STATE.HOT) else 0) | (if (o.ADJUSTRECT == 1) @enumToInt(DFCS_STATE.ADJUSTRECT) else 0) | (if (o.FLAT == 1) @enumToInt(DFCS_STATE.FLAT) else 0) | (if (o.MONO == 1) @enumToInt(DFCS_STATE.MONO) else 0) ); } }; pub const DFCS_CAPTIONCLOSE = DFCS_STATE.CAPTIONCLOSE; pub const DFCS_CAPTIONMIN = DFCS_STATE.CAPTIONMIN; pub const DFCS_CAPTIONMAX = DFCS_STATE.CAPTIONMAX; pub const DFCS_CAPTIONRESTORE = DFCS_STATE.CAPTIONRESTORE; pub const DFCS_CAPTIONHELP = DFCS_STATE.CAPTIONHELP; pub const DFCS_MENUARROW = DFCS_STATE.CAPTIONCLOSE; pub const DFCS_MENUCHECK = DFCS_STATE.CAPTIONMIN; pub const DFCS_MENUBULLET = DFCS_STATE.CAPTIONMAX; pub const DFCS_MENUARROWRIGHT = DFCS_STATE.CAPTIONHELP; pub const DFCS_SCROLLUP = DFCS_STATE.CAPTIONCLOSE; pub const DFCS_SCROLLDOWN = DFCS_STATE.CAPTIONMIN; pub const DFCS_SCROLLLEFT = DFCS_STATE.CAPTIONMAX; pub const DFCS_SCROLLRIGHT = DFCS_STATE.CAPTIONRESTORE; pub const DFCS_SCROLLCOMBOBOX = DFCS_STATE.SCROLLCOMBOBOX; pub const DFCS_SCROLLSIZEGRIP = DFCS_STATE.SCROLLSIZEGRIP; pub const DFCS_SCROLLSIZEGRIPRIGHT = DFCS_STATE.SCROLLSIZEGRIPRIGHT; pub const DFCS_BUTTONCHECK = DFCS_STATE.CAPTIONCLOSE; pub const DFCS_BUTTONRADIOIMAGE = DFCS_STATE.CAPTIONMIN; pub const DFCS_BUTTONRADIOMASK = DFCS_STATE.CAPTIONMAX; pub const DFCS_BUTTONRADIO = DFCS_STATE.CAPTIONHELP; pub const DFCS_BUTTON3STATE = DFCS_STATE.SCROLLSIZEGRIP; pub const DFCS_BUTTONPUSH = DFCS_STATE.SCROLLSIZEGRIPRIGHT; pub const DFCS_INACTIVE = DFCS_STATE.INACTIVE; pub const DFCS_PUSHED = DFCS_STATE.PUSHED; pub const DFCS_CHECKED = DFCS_STATE.CHECKED; pub const DFCS_TRANSPARENT = DFCS_STATE.TRANSPARENT; pub const DFCS_HOT = DFCS_STATE.HOT; pub const DFCS_ADJUSTRECT = DFCS_STATE.ADJUSTRECT; pub const DFCS_FLAT = DFCS_STATE.FLAT; pub const DFCS_MONO = DFCS_STATE.MONO; pub const CDS_TYPE = enum(u32) { FULLSCREEN = 4, GLOBAL = 8, NORESET = 268435456, RESET = 1073741824, SET_PRIMARY = 16, TEST = 2, UPDATEREGISTRY = 1, VIDEOPARAMETERS = 32, ENABLE_UNSAFE_MODES = 256, DISABLE_UNSAFE_MODES = 512, RESET_EX = 536870912, _, pub fn initFlags(o: struct { FULLSCREEN: u1 = 0, GLOBAL: u1 = 0, NORESET: u1 = 0, RESET: u1 = 0, SET_PRIMARY: u1 = 0, TEST: u1 = 0, UPDATEREGISTRY: u1 = 0, VIDEOPARAMETERS: u1 = 0, ENABLE_UNSAFE_MODES: u1 = 0, DISABLE_UNSAFE_MODES: u1 = 0, RESET_EX: u1 = 0, }) CDS_TYPE { return @intToEnum(CDS_TYPE, (if (o.FULLSCREEN == 1) @enumToInt(CDS_TYPE.FULLSCREEN) else 0) | (if (o.GLOBAL == 1) @enumToInt(CDS_TYPE.GLOBAL) else 0) | (if (o.NORESET == 1) @enumToInt(CDS_TYPE.NORESET) else 0) | (if (o.RESET == 1) @enumToInt(CDS_TYPE.RESET) else 0) | (if (o.SET_PRIMARY == 1) @enumToInt(CDS_TYPE.SET_PRIMARY) else 0) | (if (o.TEST == 1) @enumToInt(CDS_TYPE.TEST) else 0) | (if (o.UPDATEREGISTRY == 1) @enumToInt(CDS_TYPE.UPDATEREGISTRY) else 0) | (if (o.VIDEOPARAMETERS == 1) @enumToInt(CDS_TYPE.VIDEOPARAMETERS) else 0) | (if (o.ENABLE_UNSAFE_MODES == 1) @enumToInt(CDS_TYPE.ENABLE_UNSAFE_MODES) else 0) | (if (o.DISABLE_UNSAFE_MODES == 1) @enumToInt(CDS_TYPE.DISABLE_UNSAFE_MODES) else 0) | (if (o.RESET_EX == 1) @enumToInt(CDS_TYPE.RESET_EX) else 0) ); } }; pub const CDS_FULLSCREEN = CDS_TYPE.FULLSCREEN; pub const CDS_GLOBAL = CDS_TYPE.GLOBAL; pub const CDS_NORESET = CDS_TYPE.NORESET; pub const CDS_RESET = CDS_TYPE.RESET; pub const CDS_SET_PRIMARY = CDS_TYPE.SET_PRIMARY; pub const CDS_TEST = CDS_TYPE.TEST; pub const CDS_UPDATEREGISTRY = CDS_TYPE.UPDATEREGISTRY; pub const CDS_VIDEOPARAMETERS = CDS_TYPE.VIDEOPARAMETERS; pub const CDS_ENABLE_UNSAFE_MODES = CDS_TYPE.ENABLE_UNSAFE_MODES; pub const CDS_DISABLE_UNSAFE_MODES = CDS_TYPE.DISABLE_UNSAFE_MODES; pub const CDS_RESET_EX = CDS_TYPE.RESET_EX; pub const DISP_CHANGE = enum(i32) { SUCCESSFUL = 0, RESTART = 1, FAILED = -1, BADMODE = -2, NOTUPDATED = -3, BADFLAGS = -4, BADPARAM = -5, BADDUALVIEW = -6, }; pub const DISP_CHANGE_SUCCESSFUL = DISP_CHANGE.SUCCESSFUL; pub const DISP_CHANGE_RESTART = DISP_CHANGE.RESTART; pub const DISP_CHANGE_FAILED = DISP_CHANGE.FAILED; pub const DISP_CHANGE_BADMODE = DISP_CHANGE.BADMODE; pub const DISP_CHANGE_NOTUPDATED = DISP_CHANGE.NOTUPDATED; pub const DISP_CHANGE_BADFLAGS = DISP_CHANGE.BADFLAGS; pub const DISP_CHANGE_BADPARAM = DISP_CHANGE.BADPARAM; pub const DISP_CHANGE_BADDUALVIEW = DISP_CHANGE.BADDUALVIEW; pub const DRAWSTATE_FLAGS = enum(u32) { T_COMPLEX = 0, T_TEXT = 1, T_PREFIXTEXT = 2, T_ICON = 3, T_BITMAP = 4, // S_NORMAL = 0, this enum value conflicts with T_COMPLEX S_UNION = 16, S_DISABLED = 32, S_MONO = 128, S_HIDEPREFIX = 512, S_PREFIXONLY = 1024, S_RIGHT = 32768, _, pub fn initFlags(o: struct { T_COMPLEX: u1 = 0, T_TEXT: u1 = 0, T_PREFIXTEXT: u1 = 0, T_ICON: u1 = 0, T_BITMAP: u1 = 0, S_UNION: u1 = 0, S_DISABLED: u1 = 0, S_MONO: u1 = 0, S_HIDEPREFIX: u1 = 0, S_PREFIXONLY: u1 = 0, S_RIGHT: u1 = 0, }) DRAWSTATE_FLAGS { return @intToEnum(DRAWSTATE_FLAGS, (if (o.T_COMPLEX == 1) @enumToInt(DRAWSTATE_FLAGS.T_COMPLEX) else 0) | (if (o.T_TEXT == 1) @enumToInt(DRAWSTATE_FLAGS.T_TEXT) else 0) | (if (o.T_PREFIXTEXT == 1) @enumToInt(DRAWSTATE_FLAGS.T_PREFIXTEXT) else 0) | (if (o.T_ICON == 1) @enumToInt(DRAWSTATE_FLAGS.T_ICON) else 0) | (if (o.T_BITMAP == 1) @enumToInt(DRAWSTATE_FLAGS.T_BITMAP) else 0) | (if (o.S_UNION == 1) @enumToInt(DRAWSTATE_FLAGS.S_UNION) else 0) | (if (o.S_DISABLED == 1) @enumToInt(DRAWSTATE_FLAGS.S_DISABLED) else 0) | (if (o.S_MONO == 1) @enumToInt(DRAWSTATE_FLAGS.S_MONO) else 0) | (if (o.S_HIDEPREFIX == 1) @enumToInt(DRAWSTATE_FLAGS.S_HIDEPREFIX) else 0) | (if (o.S_PREFIXONLY == 1) @enumToInt(DRAWSTATE_FLAGS.S_PREFIXONLY) else 0) | (if (o.S_RIGHT == 1) @enumToInt(DRAWSTATE_FLAGS.S_RIGHT) else 0) ); } }; pub const DST_COMPLEX = DRAWSTATE_FLAGS.T_COMPLEX; pub const DST_TEXT = DRAWSTATE_FLAGS.T_TEXT; pub const DST_PREFIXTEXT = DRAWSTATE_FLAGS.T_PREFIXTEXT; pub const DST_ICON = DRAWSTATE_FLAGS.T_ICON; pub const DST_BITMAP = DRAWSTATE_FLAGS.T_BITMAP; pub const DSS_NORMAL = DRAWSTATE_FLAGS.T_COMPLEX; pub const DSS_UNION = DRAWSTATE_FLAGS.S_UNION; pub const DSS_DISABLED = DRAWSTATE_FLAGS.S_DISABLED; pub const DSS_MONO = DRAWSTATE_FLAGS.S_MONO; pub const DSS_HIDEPREFIX = DRAWSTATE_FLAGS.S_HIDEPREFIX; pub const DSS_PREFIXONLY = DRAWSTATE_FLAGS.S_PREFIXONLY; pub const DSS_RIGHT = DRAWSTATE_FLAGS.S_RIGHT; pub const REDRAW_WINDOW_FLAGS = enum(u32) { INVALIDATE = 1, INTERNALPAINT = 2, ERASE = 4, VALIDATE = 8, NOINTERNALPAINT = 16, NOERASE = 32, NOCHILDREN = 64, ALLCHILDREN = 128, UPDATENOW = 256, ERASENOW = 512, FRAME = 1024, NOFRAME = 2048, _, pub fn initFlags(o: struct { INVALIDATE: u1 = 0, INTERNALPAINT: u1 = 0, ERASE: u1 = 0, VALIDATE: u1 = 0, NOINTERNALPAINT: u1 = 0, NOERASE: u1 = 0, NOCHILDREN: u1 = 0, ALLCHILDREN: u1 = 0, UPDATENOW: u1 = 0, ERASENOW: u1 = 0, FRAME: u1 = 0, NOFRAME: u1 = 0, }) REDRAW_WINDOW_FLAGS { return @intToEnum(REDRAW_WINDOW_FLAGS, (if (o.INVALIDATE == 1) @enumToInt(REDRAW_WINDOW_FLAGS.INVALIDATE) else 0) | (if (o.INTERNALPAINT == 1) @enumToInt(REDRAW_WINDOW_FLAGS.INTERNALPAINT) else 0) | (if (o.ERASE == 1) @enumToInt(REDRAW_WINDOW_FLAGS.ERASE) else 0) | (if (o.VALIDATE == 1) @enumToInt(REDRAW_WINDOW_FLAGS.VALIDATE) else 0) | (if (o.NOINTERNALPAINT == 1) @enumToInt(REDRAW_WINDOW_FLAGS.NOINTERNALPAINT) else 0) | (if (o.NOERASE == 1) @enumToInt(REDRAW_WINDOW_FLAGS.NOERASE) else 0) | (if (o.NOCHILDREN == 1) @enumToInt(REDRAW_WINDOW_FLAGS.NOCHILDREN) else 0) | (if (o.ALLCHILDREN == 1) @enumToInt(REDRAW_WINDOW_FLAGS.ALLCHILDREN) else 0) | (if (o.UPDATENOW == 1) @enumToInt(REDRAW_WINDOW_FLAGS.UPDATENOW) else 0) | (if (o.ERASENOW == 1) @enumToInt(REDRAW_WINDOW_FLAGS.ERASENOW) else 0) | (if (o.FRAME == 1) @enumToInt(REDRAW_WINDOW_FLAGS.FRAME) else 0) | (if (o.NOFRAME == 1) @enumToInt(REDRAW_WINDOW_FLAGS.NOFRAME) else 0) ); } }; pub const RDW_INVALIDATE = REDRAW_WINDOW_FLAGS.INVALIDATE; pub const RDW_INTERNALPAINT = REDRAW_WINDOW_FLAGS.INTERNALPAINT; pub const RDW_ERASE = REDRAW_WINDOW_FLAGS.ERASE; pub const RDW_VALIDATE = REDRAW_WINDOW_FLAGS.VALIDATE; pub const RDW_NOINTERNALPAINT = REDRAW_WINDOW_FLAGS.NOINTERNALPAINT; pub const RDW_NOERASE = REDRAW_WINDOW_FLAGS.NOERASE; pub const RDW_NOCHILDREN = REDRAW_WINDOW_FLAGS.NOCHILDREN; pub const RDW_ALLCHILDREN = REDRAW_WINDOW_FLAGS.ALLCHILDREN; pub const RDW_UPDATENOW = REDRAW_WINDOW_FLAGS.UPDATENOW; pub const RDW_ERASENOW = REDRAW_WINDOW_FLAGS.ERASENOW; pub const RDW_FRAME = REDRAW_WINDOW_FLAGS.FRAME; pub const RDW_NOFRAME = REDRAW_WINDOW_FLAGS.NOFRAME; pub const ENUM_DISPLAY_SETTINGS_MODE = enum(u32) { CURRENT_SETTINGS = 4294967295, REGISTRY_SETTINGS = 4294967294, }; pub const ENUM_CURRENT_SETTINGS = ENUM_DISPLAY_SETTINGS_MODE.CURRENT_SETTINGS; pub const ENUM_REGISTRY_SETTINGS = ENUM_DISPLAY_SETTINGS_MODE.REGISTRY_SETTINGS; pub const PEN_STYLE = enum(u32) { GEOMETRIC = 65536, COSMETIC = 0, // SOLID = 0, this enum value conflicts with COSMETIC DASH = 1, DOT = 2, DASHDOT = 3, DASHDOTDOT = 4, NULL = 5, INSIDEFRAME = 6, USERSTYLE = 7, ALTERNATE = 8, STYLE_MASK = 15, // ENDCAP_ROUND = 0, this enum value conflicts with COSMETIC ENDCAP_SQUARE = 256, ENDCAP_FLAT = 512, ENDCAP_MASK = 3840, // JOIN_ROUND = 0, this enum value conflicts with COSMETIC JOIN_BEVEL = 4096, JOIN_MITER = 8192, JOIN_MASK = 61440, TYPE_MASK = 983040, _, pub fn initFlags(o: struct { GEOMETRIC: u1 = 0, COSMETIC: u1 = 0, DASH: u1 = 0, DOT: u1 = 0, DASHDOT: u1 = 0, DASHDOTDOT: u1 = 0, NULL: u1 = 0, INSIDEFRAME: u1 = 0, USERSTYLE: u1 = 0, ALTERNATE: u1 = 0, STYLE_MASK: u1 = 0, ENDCAP_SQUARE: u1 = 0, ENDCAP_FLAT: u1 = 0, ENDCAP_MASK: u1 = 0, JOIN_BEVEL: u1 = 0, JOIN_MITER: u1 = 0, JOIN_MASK: u1 = 0, TYPE_MASK: u1 = 0, }) PEN_STYLE { return @intToEnum(PEN_STYLE, (if (o.GEOMETRIC == 1) @enumToInt(PEN_STYLE.GEOMETRIC) else 0) | (if (o.COSMETIC == 1) @enumToInt(PEN_STYLE.COSMETIC) else 0) | (if (o.DASH == 1) @enumToInt(PEN_STYLE.DASH) else 0) | (if (o.DOT == 1) @enumToInt(PEN_STYLE.DOT) else 0) | (if (o.DASHDOT == 1) @enumToInt(PEN_STYLE.DASHDOT) else 0) | (if (o.DASHDOTDOT == 1) @enumToInt(PEN_STYLE.DASHDOTDOT) else 0) | (if (o.NULL == 1) @enumToInt(PEN_STYLE.NULL) else 0) | (if (o.INSIDEFRAME == 1) @enumToInt(PEN_STYLE.INSIDEFRAME) else 0) | (if (o.USERSTYLE == 1) @enumToInt(PEN_STYLE.USERSTYLE) else 0) | (if (o.ALTERNATE == 1) @enumToInt(PEN_STYLE.ALTERNATE) else 0) | (if (o.STYLE_MASK == 1) @enumToInt(PEN_STYLE.STYLE_MASK) else 0) | (if (o.ENDCAP_SQUARE == 1) @enumToInt(PEN_STYLE.ENDCAP_SQUARE) else 0) | (if (o.ENDCAP_FLAT == 1) @enumToInt(PEN_STYLE.ENDCAP_FLAT) else 0) | (if (o.ENDCAP_MASK == 1) @enumToInt(PEN_STYLE.ENDCAP_MASK) else 0) | (if (o.JOIN_BEVEL == 1) @enumToInt(PEN_STYLE.JOIN_BEVEL) else 0) | (if (o.JOIN_MITER == 1) @enumToInt(PEN_STYLE.JOIN_MITER) else 0) | (if (o.JOIN_MASK == 1) @enumToInt(PEN_STYLE.JOIN_MASK) else 0) | (if (o.TYPE_MASK == 1) @enumToInt(PEN_STYLE.TYPE_MASK) else 0) ); } }; pub const PS_GEOMETRIC = PEN_STYLE.GEOMETRIC; pub const PS_COSMETIC = PEN_STYLE.COSMETIC; pub const PS_SOLID = PEN_STYLE.COSMETIC; pub const PS_DASH = PEN_STYLE.DASH; pub const PS_DOT = PEN_STYLE.DOT; pub const PS_DASHDOT = PEN_STYLE.DASHDOT; pub const PS_DASHDOTDOT = PEN_STYLE.DASHDOTDOT; pub const PS_NULL = PEN_STYLE.NULL; pub const PS_INSIDEFRAME = PEN_STYLE.INSIDEFRAME; pub const PS_USERSTYLE = PEN_STYLE.USERSTYLE; pub const PS_ALTERNATE = PEN_STYLE.ALTERNATE; pub const PS_STYLE_MASK = PEN_STYLE.STYLE_MASK; pub const PS_ENDCAP_ROUND = PEN_STYLE.COSMETIC; pub const PS_ENDCAP_SQUARE = PEN_STYLE.ENDCAP_SQUARE; pub const PS_ENDCAP_FLAT = PEN_STYLE.ENDCAP_FLAT; pub const PS_ENDCAP_MASK = PEN_STYLE.ENDCAP_MASK; pub const PS_JOIN_ROUND = PEN_STYLE.COSMETIC; pub const PS_JOIN_BEVEL = PEN_STYLE.JOIN_BEVEL; pub const PS_JOIN_MITER = PEN_STYLE.JOIN_MITER; pub const PS_JOIN_MASK = PEN_STYLE.JOIN_MASK; pub const PS_TYPE_MASK = PEN_STYLE.TYPE_MASK; pub const TTEMBED_FLAGS = enum(u32) { EMBEDEUDC = 32, RAW = 0, SUBSET = 1, TTCOMPRESSED = 4, _, pub fn initFlags(o: struct { EMBEDEUDC: u1 = 0, RAW: u1 = 0, SUBSET: u1 = 0, TTCOMPRESSED: u1 = 0, }) TTEMBED_FLAGS { return @intToEnum(TTEMBED_FLAGS, (if (o.EMBEDEUDC == 1) @enumToInt(TTEMBED_FLAGS.EMBEDEUDC) else 0) | (if (o.RAW == 1) @enumToInt(TTEMBED_FLAGS.RAW) else 0) | (if (o.SUBSET == 1) @enumToInt(TTEMBED_FLAGS.SUBSET) else 0) | (if (o.TTCOMPRESSED == 1) @enumToInt(TTEMBED_FLAGS.TTCOMPRESSED) else 0) ); } }; pub const TTEMBED_EMBEDEUDC = TTEMBED_FLAGS.EMBEDEUDC; pub const TTEMBED_RAW = TTEMBED_FLAGS.RAW; pub const TTEMBED_SUBSET = TTEMBED_FLAGS.SUBSET; pub const TTEMBED_TTCOMPRESSED = TTEMBED_FLAGS.TTCOMPRESSED; pub const DRAW_TEXT_FORMAT = enum(u32) { BOTTOM = 8, CALCRECT = 1024, CENTER = 1, EDITCONTROL = 8192, END_ELLIPSIS = 32768, EXPANDTABS = 64, EXTERNALLEADING = 512, HIDEPREFIX = 1048576, INTERNAL = 4096, LEFT = 0, MODIFYSTRING = 65536, NOCLIP = 256, NOFULLWIDTHCHARBREAK = 524288, NOPREFIX = 2048, PATH_ELLIPSIS = 16384, PREFIXONLY = 2097152, RIGHT = 2, RTLREADING = 131072, SINGLELINE = 32, TABSTOP = 128, // TOP = 0, this enum value conflicts with LEFT VCENTER = 4, WORDBREAK = 16, WORD_ELLIPSIS = 262144, _, pub fn initFlags(o: struct { BOTTOM: u1 = 0, CALCRECT: u1 = 0, CENTER: u1 = 0, EDITCONTROL: u1 = 0, END_ELLIPSIS: u1 = 0, EXPANDTABS: u1 = 0, EXTERNALLEADING: u1 = 0, HIDEPREFIX: u1 = 0, INTERNAL: u1 = 0, LEFT: u1 = 0, MODIFYSTRING: u1 = 0, NOCLIP: u1 = 0, NOFULLWIDTHCHARBREAK: u1 = 0, NOPREFIX: u1 = 0, PATH_ELLIPSIS: u1 = 0, PREFIXONLY: u1 = 0, RIGHT: u1 = 0, RTLREADING: u1 = 0, SINGLELINE: u1 = 0, TABSTOP: u1 = 0, VCENTER: u1 = 0, WORDBREAK: u1 = 0, WORD_ELLIPSIS: u1 = 0, }) DRAW_TEXT_FORMAT { return @intToEnum(DRAW_TEXT_FORMAT, (if (o.BOTTOM == 1) @enumToInt(DRAW_TEXT_FORMAT.BOTTOM) else 0) | (if (o.CALCRECT == 1) @enumToInt(DRAW_TEXT_FORMAT.CALCRECT) else 0) | (if (o.CENTER == 1) @enumToInt(DRAW_TEXT_FORMAT.CENTER) else 0) | (if (o.EDITCONTROL == 1) @enumToInt(DRAW_TEXT_FORMAT.EDITCONTROL) else 0) | (if (o.END_ELLIPSIS == 1) @enumToInt(DRAW_TEXT_FORMAT.END_ELLIPSIS) else 0) | (if (o.EXPANDTABS == 1) @enumToInt(DRAW_TEXT_FORMAT.EXPANDTABS) else 0) | (if (o.EXTERNALLEADING == 1) @enumToInt(DRAW_TEXT_FORMAT.EXTERNALLEADING) else 0) | (if (o.HIDEPREFIX == 1) @enumToInt(DRAW_TEXT_FORMAT.HIDEPREFIX) else 0) | (if (o.INTERNAL == 1) @enumToInt(DRAW_TEXT_FORMAT.INTERNAL) else 0) | (if (o.LEFT == 1) @enumToInt(DRAW_TEXT_FORMAT.LEFT) else 0) | (if (o.MODIFYSTRING == 1) @enumToInt(DRAW_TEXT_FORMAT.MODIFYSTRING) else 0) | (if (o.NOCLIP == 1) @enumToInt(DRAW_TEXT_FORMAT.NOCLIP) else 0) | (if (o.NOFULLWIDTHCHARBREAK == 1) @enumToInt(DRAW_TEXT_FORMAT.NOFULLWIDTHCHARBREAK) else 0) | (if (o.NOPREFIX == 1) @enumToInt(DRAW_TEXT_FORMAT.NOPREFIX) else 0) | (if (o.PATH_ELLIPSIS == 1) @enumToInt(DRAW_TEXT_FORMAT.PATH_ELLIPSIS) else 0) | (if (o.PREFIXONLY == 1) @enumToInt(DRAW_TEXT_FORMAT.PREFIXONLY) else 0) | (if (o.RIGHT == 1) @enumToInt(DRAW_TEXT_FORMAT.RIGHT) else 0) | (if (o.RTLREADING == 1) @enumToInt(DRAW_TEXT_FORMAT.RTLREADING) else 0) | (if (o.SINGLELINE == 1) @enumToInt(DRAW_TEXT_FORMAT.SINGLELINE) else 0) | (if (o.TABSTOP == 1) @enumToInt(DRAW_TEXT_FORMAT.TABSTOP) else 0) | (if (o.VCENTER == 1) @enumToInt(DRAW_TEXT_FORMAT.VCENTER) else 0) | (if (o.WORDBREAK == 1) @enumToInt(DRAW_TEXT_FORMAT.WORDBREAK) else 0) | (if (o.WORD_ELLIPSIS == 1) @enumToInt(DRAW_TEXT_FORMAT.WORD_ELLIPSIS) else 0) ); } }; pub const DT_BOTTOM = DRAW_TEXT_FORMAT.BOTTOM; pub const DT_CALCRECT = DRAW_TEXT_FORMAT.CALCRECT; pub const DT_CENTER = DRAW_TEXT_FORMAT.CENTER; pub const DT_EDITCONTROL = DRAW_TEXT_FORMAT.EDITCONTROL; pub const DT_END_ELLIPSIS = DRAW_TEXT_FORMAT.END_ELLIPSIS; pub const DT_EXPANDTABS = DRAW_TEXT_FORMAT.EXPANDTABS; pub const DT_EXTERNALLEADING = DRAW_TEXT_FORMAT.EXTERNALLEADING; pub const DT_HIDEPREFIX = DRAW_TEXT_FORMAT.HIDEPREFIX; pub const DT_INTERNAL = DRAW_TEXT_FORMAT.INTERNAL; pub const DT_LEFT = DRAW_TEXT_FORMAT.LEFT; pub const DT_MODIFYSTRING = DRAW_TEXT_FORMAT.MODIFYSTRING; pub const DT_NOCLIP = DRAW_TEXT_FORMAT.NOCLIP; pub const DT_NOFULLWIDTHCHARBREAK = DRAW_TEXT_FORMAT.NOFULLWIDTHCHARBREAK; pub const DT_NOPREFIX = DRAW_TEXT_FORMAT.NOPREFIX; pub const DT_PATH_ELLIPSIS = DRAW_TEXT_FORMAT.PATH_ELLIPSIS; pub const DT_PREFIXONLY = DRAW_TEXT_FORMAT.PREFIXONLY; pub const DT_RIGHT = DRAW_TEXT_FORMAT.RIGHT; pub const DT_RTLREADING = DRAW_TEXT_FORMAT.RTLREADING; pub const DT_SINGLELINE = DRAW_TEXT_FORMAT.SINGLELINE; pub const DT_TABSTOP = DRAW_TEXT_FORMAT.TABSTOP; pub const DT_TOP = DRAW_TEXT_FORMAT.LEFT; pub const DT_VCENTER = DRAW_TEXT_FORMAT.VCENTER; pub const DT_WORDBREAK = DRAW_TEXT_FORMAT.WORDBREAK; pub const DT_WORD_ELLIPSIS = DRAW_TEXT_FORMAT.WORD_ELLIPSIS; pub const EMBED_FONT_CHARSET = enum(u32) { UNICODE = 1, SYMBOL = 2, }; pub const CHARSET_UNICODE = EMBED_FONT_CHARSET.UNICODE; pub const CHARSET_SYMBOL = EMBED_FONT_CHARSET.SYMBOL; pub const GET_DCX_FLAGS = enum(u32) { WINDOW = 1, CACHE = 2, PARENTCLIP = 32, CLIPSIBLINGS = 16, CLIPCHILDREN = 8, NORESETATTRS = 4, LOCKWINDOWUPDATE = 1024, EXCLUDERGN = 64, INTERSECTRGN = 128, INTERSECTUPDATE = 512, VALIDATE = 2097152, _, pub fn initFlags(o: struct { WINDOW: u1 = 0, CACHE: u1 = 0, PARENTCLIP: u1 = 0, CLIPSIBLINGS: u1 = 0, CLIPCHILDREN: u1 = 0, NORESETATTRS: u1 = 0, LOCKWINDOWUPDATE: u1 = 0, EXCLUDERGN: u1 = 0, INTERSECTRGN: u1 = 0, INTERSECTUPDATE: u1 = 0, VALIDATE: u1 = 0, }) GET_DCX_FLAGS { return @intToEnum(GET_DCX_FLAGS, (if (o.WINDOW == 1) @enumToInt(GET_DCX_FLAGS.WINDOW) else 0) | (if (o.CACHE == 1) @enumToInt(GET_DCX_FLAGS.CACHE) else 0) | (if (o.PARENTCLIP == 1) @enumToInt(GET_DCX_FLAGS.PARENTCLIP) else 0) | (if (o.CLIPSIBLINGS == 1) @enumToInt(GET_DCX_FLAGS.CLIPSIBLINGS) else 0) | (if (o.CLIPCHILDREN == 1) @enumToInt(GET_DCX_FLAGS.CLIPCHILDREN) else 0) | (if (o.NORESETATTRS == 1) @enumToInt(GET_DCX_FLAGS.NORESETATTRS) else 0) | (if (o.LOCKWINDOWUPDATE == 1) @enumToInt(GET_DCX_FLAGS.LOCKWINDOWUPDATE) else 0) | (if (o.EXCLUDERGN == 1) @enumToInt(GET_DCX_FLAGS.EXCLUDERGN) else 0) | (if (o.INTERSECTRGN == 1) @enumToInt(GET_DCX_FLAGS.INTERSECTRGN) else 0) | (if (o.INTERSECTUPDATE == 1) @enumToInt(GET_DCX_FLAGS.INTERSECTUPDATE) else 0) | (if (o.VALIDATE == 1) @enumToInt(GET_DCX_FLAGS.VALIDATE) else 0) ); } }; pub const DCX_WINDOW = GET_DCX_FLAGS.WINDOW; pub const DCX_CACHE = GET_DCX_FLAGS.CACHE; pub const DCX_PARENTCLIP = GET_DCX_FLAGS.PARENTCLIP; pub const DCX_CLIPSIBLINGS = GET_DCX_FLAGS.CLIPSIBLINGS; pub const DCX_CLIPCHILDREN = GET_DCX_FLAGS.CLIPCHILDREN; pub const DCX_NORESETATTRS = GET_DCX_FLAGS.NORESETATTRS; pub const DCX_LOCKWINDOWUPDATE = GET_DCX_FLAGS.LOCKWINDOWUPDATE; pub const DCX_EXCLUDERGN = GET_DCX_FLAGS.EXCLUDERGN; pub const DCX_INTERSECTRGN = GET_DCX_FLAGS.INTERSECTRGN; pub const DCX_INTERSECTUPDATE = GET_DCX_FLAGS.INTERSECTUPDATE; pub const DCX_VALIDATE = GET_DCX_FLAGS.VALIDATE; pub const GET_GLYPH_OUTLINE_FORMAT = enum(u32) { BEZIER = 3, BITMAP = 1, GLYPH_INDEX = 128, GRAY2_BITMAP = 4, GRAY4_BITMAP = 5, GRAY8_BITMAP = 6, METRICS = 0, NATIVE = 2, UNHINTED = 256, }; pub const GGO_BEZIER = GET_GLYPH_OUTLINE_FORMAT.BEZIER; pub const GGO_BITMAP = GET_GLYPH_OUTLINE_FORMAT.BITMAP; pub const GGO_GLYPH_INDEX = GET_GLYPH_OUTLINE_FORMAT.GLYPH_INDEX; pub const GGO_GRAY2_BITMAP = GET_GLYPH_OUTLINE_FORMAT.GRAY2_BITMAP; pub const GGO_GRAY4_BITMAP = GET_GLYPH_OUTLINE_FORMAT.GRAY4_BITMAP; pub const GGO_GRAY8_BITMAP = GET_GLYPH_OUTLINE_FORMAT.GRAY8_BITMAP; pub const GGO_METRICS = GET_GLYPH_OUTLINE_FORMAT.METRICS; pub const GGO_NATIVE = GET_GLYPH_OUTLINE_FORMAT.NATIVE; pub const GGO_UNHINTED = GET_GLYPH_OUTLINE_FORMAT.UNHINTED; pub const SET_BOUNDS_RECT_FLAGS = enum(u32) { ACCUMULATE = 2, DISABLE = 8, ENABLE = 4, RESET = 1, }; pub const DCB_ACCUMULATE = SET_BOUNDS_RECT_FLAGS.ACCUMULATE; pub const DCB_DISABLE = SET_BOUNDS_RECT_FLAGS.DISABLE; pub const DCB_ENABLE = SET_BOUNDS_RECT_FLAGS.ENABLE; pub const DCB_RESET = SET_BOUNDS_RECT_FLAGS.RESET; pub const GET_STOCK_OBJECT_FLAGS = enum(u32) { BLACK_BRUSH = 4, DKGRAY_BRUSH = 3, DC_BRUSH = 18, GRAY_BRUSH = 2, HOLLOW_BRUSH = 5, LTGRAY_BRUSH = 1, // NULL_BRUSH = 5, this enum value conflicts with HOLLOW_BRUSH WHITE_BRUSH = 0, BLACK_PEN = 7, DC_PEN = 19, NULL_PEN = 8, WHITE_PEN = 6, ANSI_FIXED_FONT = 11, ANSI_VAR_FONT = 12, DEVICE_DEFAULT_FONT = 14, DEFAULT_GUI_FONT = 17, OEM_FIXED_FONT = 10, SYSTEM_FONT = 13, SYSTEM_FIXED_FONT = 16, DEFAULT_PALETTE = 15, }; pub const BLACK_BRUSH = GET_STOCK_OBJECT_FLAGS.BLACK_BRUSH; pub const DKGRAY_BRUSH = GET_STOCK_OBJECT_FLAGS.DKGRAY_BRUSH; pub const DC_BRUSH = GET_STOCK_OBJECT_FLAGS.DC_BRUSH; pub const GRAY_BRUSH = GET_STOCK_OBJECT_FLAGS.GRAY_BRUSH; pub const HOLLOW_BRUSH = GET_STOCK_OBJECT_FLAGS.HOLLOW_BRUSH; pub const LTGRAY_BRUSH = GET_STOCK_OBJECT_FLAGS.LTGRAY_BRUSH; pub const NULL_BRUSH = GET_STOCK_OBJECT_FLAGS.HOLLOW_BRUSH; pub const WHITE_BRUSH = GET_STOCK_OBJECT_FLAGS.WHITE_BRUSH; pub const BLACK_PEN = GET_STOCK_OBJECT_FLAGS.BLACK_PEN; pub const DC_PEN = GET_STOCK_OBJECT_FLAGS.DC_PEN; pub const NULL_PEN = GET_STOCK_OBJECT_FLAGS.NULL_PEN; pub const WHITE_PEN = GET_STOCK_OBJECT_FLAGS.WHITE_PEN; pub const ANSI_FIXED_FONT = GET_STOCK_OBJECT_FLAGS.ANSI_FIXED_FONT; pub const ANSI_VAR_FONT = GET_STOCK_OBJECT_FLAGS.ANSI_VAR_FONT; pub const DEVICE_DEFAULT_FONT = GET_STOCK_OBJECT_FLAGS.DEVICE_DEFAULT_FONT; pub const DEFAULT_GUI_FONT = GET_STOCK_OBJECT_FLAGS.DEFAULT_GUI_FONT; pub const OEM_FIXED_FONT = GET_STOCK_OBJECT_FLAGS.OEM_FIXED_FONT; pub const SYSTEM_FONT = GET_STOCK_OBJECT_FLAGS.SYSTEM_FONT; pub const SYSTEM_FIXED_FONT = GET_STOCK_OBJECT_FLAGS.SYSTEM_FIXED_FONT; pub const DEFAULT_PALETTE = GET_STOCK_OBJECT_FLAGS.DEFAULT_PALETTE; pub const MODIFY_WORLD_TRANSFORM_MODE = enum(u32) { IDENTITY = 1, LEFTMULTIPLY = 2, RIGHTMULTIPLY = 3, }; pub const MWT_IDENTITY = MODIFY_WORLD_TRANSFORM_MODE.IDENTITY; pub const MWT_LEFTMULTIPLY = MODIFY_WORLD_TRANSFORM_MODE.LEFTMULTIPLY; pub const MWT_RIGHTMULTIPLY = MODIFY_WORLD_TRANSFORM_MODE.RIGHTMULTIPLY; pub const FONT_CLIP_PRECISION = enum(u32) { CHARACTER_PRECIS = 1, DEFAULT_PRECIS = 0, DFA_DISABLE = 64, EMBEDDED = 128, LH_ANGLES = 16, MASK = 15, STROKE_PRECIS = 2, TT_ALWAYS = 32, _, pub fn initFlags(o: struct { CHARACTER_PRECIS: u1 = 0, DEFAULT_PRECIS: u1 = 0, DFA_DISABLE: u1 = 0, EMBEDDED: u1 = 0, LH_ANGLES: u1 = 0, MASK: u1 = 0, STROKE_PRECIS: u1 = 0, TT_ALWAYS: u1 = 0, }) FONT_CLIP_PRECISION { return @intToEnum(FONT_CLIP_PRECISION, (if (o.CHARACTER_PRECIS == 1) @enumToInt(FONT_CLIP_PRECISION.CHARACTER_PRECIS) else 0) | (if (o.DEFAULT_PRECIS == 1) @enumToInt(FONT_CLIP_PRECISION.DEFAULT_PRECIS) else 0) | (if (o.DFA_DISABLE == 1) @enumToInt(FONT_CLIP_PRECISION.DFA_DISABLE) else 0) | (if (o.EMBEDDED == 1) @enumToInt(FONT_CLIP_PRECISION.EMBEDDED) else 0) | (if (o.LH_ANGLES == 1) @enumToInt(FONT_CLIP_PRECISION.LH_ANGLES) else 0) | (if (o.MASK == 1) @enumToInt(FONT_CLIP_PRECISION.MASK) else 0) | (if (o.STROKE_PRECIS == 1) @enumToInt(FONT_CLIP_PRECISION.STROKE_PRECIS) else 0) | (if (o.TT_ALWAYS == 1) @enumToInt(FONT_CLIP_PRECISION.TT_ALWAYS) else 0) ); } }; pub const CLIP_CHARACTER_PRECIS = FONT_CLIP_PRECISION.CHARACTER_PRECIS; pub const CLIP_DEFAULT_PRECIS = FONT_CLIP_PRECISION.DEFAULT_PRECIS; pub const CLIP_DFA_DISABLE = FONT_CLIP_PRECISION.DFA_DISABLE; pub const CLIP_EMBEDDED = FONT_CLIP_PRECISION.EMBEDDED; pub const CLIP_LH_ANGLES = FONT_CLIP_PRECISION.LH_ANGLES; pub const CLIP_MASK = FONT_CLIP_PRECISION.MASK; pub const CLIP_STROKE_PRECIS = FONT_CLIP_PRECISION.STROKE_PRECIS; pub const CLIP_TT_ALWAYS = FONT_CLIP_PRECISION.TT_ALWAYS; pub const CREATE_POLYGON_RGN_MODE = enum(u32) { ALTERNATE = 1, WINDING = 2, }; pub const ALTERNATE = CREATE_POLYGON_RGN_MODE.ALTERNATE; pub const WINDING = CREATE_POLYGON_RGN_MODE.WINDING; pub const EMBEDDED_FONT_PRIV_STATUS = enum(u32) { PREVIEWPRINT = 1, EDITABLE = 2, INSTALLABLE = 3, NOEMBEDDING = 4, }; pub const EMBED_PREVIEWPRINT = EMBEDDED_FONT_PRIV_STATUS.PREVIEWPRINT; pub const EMBED_EDITABLE = EMBEDDED_FONT_PRIV_STATUS.EDITABLE; pub const EMBED_INSTALLABLE = EMBEDDED_FONT_PRIV_STATUS.INSTALLABLE; pub const EMBED_NOEMBEDDING = EMBEDDED_FONT_PRIV_STATUS.NOEMBEDDING; pub const MONITOR_FROM_FLAGS = enum(u32) { NEAREST = 2, NULL = 0, PRIMARY = 1, }; pub const MONITOR_DEFAULTTONEAREST = MONITOR_FROM_FLAGS.NEAREST; pub const MONITOR_DEFAULTTONULL = MONITOR_FROM_FLAGS.NULL; pub const MONITOR_DEFAULTTOPRIMARY = MONITOR_FROM_FLAGS.PRIMARY; pub const FONT_RESOURCE_CHARACTERISTICS = enum(u32) { PRIVATE = 16, NOT_ENUM = 32, }; pub const FR_PRIVATE = FONT_RESOURCE_CHARACTERISTICS.PRIVATE; pub const FR_NOT_ENUM = FONT_RESOURCE_CHARACTERISTICS.NOT_ENUM; pub const DC_LAYOUT = enum(u32) { BITMAPORIENTATIONPRESERVED = 8, RTL = 1, _, pub fn initFlags(o: struct { BITMAPORIENTATIONPRESERVED: u1 = 0, RTL: u1 = 0, }) DC_LAYOUT { return @intToEnum(DC_LAYOUT, (if (o.BITMAPORIENTATIONPRESERVED == 1) @enumToInt(DC_LAYOUT.BITMAPORIENTATIONPRESERVED) else 0) | (if (o.RTL == 1) @enumToInt(DC_LAYOUT.RTL) else 0) ); } }; pub const LAYOUT_BITMAPORIENTATIONPRESERVED = DC_LAYOUT.BITMAPORIENTATIONPRESERVED; pub const LAYOUT_RTL = DC_LAYOUT.RTL; pub const GET_DEVICE_CAPS_INDEX = enum(u32) { DRIVERVERSION = 0, TECHNOLOGY = 2, HORZSIZE = 4, VERTSIZE = 6, HORZRES = 8, VERTRES = 10, BITSPIXEL = 12, PLANES = 14, NUMBRUSHES = 16, NUMPENS = 18, NUMMARKERS = 20, NUMFONTS = 22, NUMCOLORS = 24, PDEVICESIZE = 26, CURVECAPS = 28, LINECAPS = 30, POLYGONALCAPS = 32, TEXTCAPS = 34, CLIPCAPS = 36, RASTERCAPS = 38, ASPECTX = 40, ASPECTY = 42, ASPECTXY = 44, LOGPIXELSX = 88, LOGPIXELSY = 90, SIZEPALETTE = 104, NUMRESERVED = 106, COLORRES = 108, PHYSICALWIDTH = 110, PHYSICALHEIGHT = 111, PHYSICALOFFSETX = 112, PHYSICALOFFSETY = 113, SCALINGFACTORX = 114, SCALINGFACTORY = 115, VREFRESH = 116, DESKTOPVERTRES = 117, DESKTOPHORZRES = 118, BLTALIGNMENT = 119, SHADEBLENDCAPS = 120, COLORMGMTCAPS = 121, }; pub const DRIVERVERSION = GET_DEVICE_CAPS_INDEX.DRIVERVERSION; pub const TECHNOLOGY = GET_DEVICE_CAPS_INDEX.TECHNOLOGY; pub const HORZSIZE = GET_DEVICE_CAPS_INDEX.HORZSIZE; pub const VERTSIZE = GET_DEVICE_CAPS_INDEX.VERTSIZE; pub const HORZRES = GET_DEVICE_CAPS_INDEX.HORZRES; pub const VERTRES = GET_DEVICE_CAPS_INDEX.VERTRES; pub const BITSPIXEL = GET_DEVICE_CAPS_INDEX.BITSPIXEL; pub const PLANES = GET_DEVICE_CAPS_INDEX.PLANES; pub const NUMBRUSHES = GET_DEVICE_CAPS_INDEX.NUMBRUSHES; pub const NUMPENS = GET_DEVICE_CAPS_INDEX.NUMPENS; pub const NUMMARKERS = GET_DEVICE_CAPS_INDEX.NUMMARKERS; pub const NUMFONTS = GET_DEVICE_CAPS_INDEX.NUMFONTS; pub const NUMCOLORS = GET_DEVICE_CAPS_INDEX.NUMCOLORS; pub const PDEVICESIZE = GET_DEVICE_CAPS_INDEX.PDEVICESIZE; pub const CURVECAPS = GET_DEVICE_CAPS_INDEX.CURVECAPS; pub const LINECAPS = GET_DEVICE_CAPS_INDEX.LINECAPS; pub const POLYGONALCAPS = GET_DEVICE_CAPS_INDEX.POLYGONALCAPS; pub const TEXTCAPS = GET_DEVICE_CAPS_INDEX.TEXTCAPS; pub const CLIPCAPS = GET_DEVICE_CAPS_INDEX.CLIPCAPS; pub const RASTERCAPS = GET_DEVICE_CAPS_INDEX.RASTERCAPS; pub const ASPECTX = GET_DEVICE_CAPS_INDEX.ASPECTX; pub const ASPECTY = GET_DEVICE_CAPS_INDEX.ASPECTY; pub const ASPECTXY = GET_DEVICE_CAPS_INDEX.ASPECTXY; pub const LOGPIXELSX = GET_DEVICE_CAPS_INDEX.LOGPIXELSX; pub const LOGPIXELSY = GET_DEVICE_CAPS_INDEX.LOGPIXELSY; pub const SIZEPALETTE = GET_DEVICE_CAPS_INDEX.SIZEPALETTE; pub const NUMRESERVED = GET_DEVICE_CAPS_INDEX.NUMRESERVED; pub const COLORRES = GET_DEVICE_CAPS_INDEX.COLORRES; pub const PHYSICALWIDTH = GET_DEVICE_CAPS_INDEX.PHYSICALWIDTH; pub const PHYSICALHEIGHT = GET_DEVICE_CAPS_INDEX.PHYSICALHEIGHT; pub const PHYSICALOFFSETX = GET_DEVICE_CAPS_INDEX.PHYSICALOFFSETX; pub const PHYSICALOFFSETY = GET_DEVICE_CAPS_INDEX.PHYSICALOFFSETY; pub const SCALINGFACTORX = GET_DEVICE_CAPS_INDEX.SCALINGFACTORX; pub const SCALINGFACTORY = GET_DEVICE_CAPS_INDEX.SCALINGFACTORY; pub const VREFRESH = GET_DEVICE_CAPS_INDEX.VREFRESH; pub const DESKTOPVERTRES = GET_DEVICE_CAPS_INDEX.DESKTOPVERTRES; pub const DESKTOPHORZRES = GET_DEVICE_CAPS_INDEX.DESKTOPHORZRES; pub const BLTALIGNMENT = GET_DEVICE_CAPS_INDEX.BLTALIGNMENT; pub const SHADEBLENDCAPS = GET_DEVICE_CAPS_INDEX.SHADEBLENDCAPS; pub const COLORMGMTCAPS = GET_DEVICE_CAPS_INDEX.COLORMGMTCAPS; pub const FONT_OUTPUT_PRECISION = enum(u32) { CHARACTER_PRECIS = 2, DEFAULT_PRECIS = 0, DEVICE_PRECIS = 5, OUTLINE_PRECIS = 8, PS_ONLY_PRECIS = 10, RASTER_PRECIS = 6, STRING_PRECIS = 1, STROKE_PRECIS = 3, TT_ONLY_PRECIS = 7, TT_PRECIS = 4, }; pub const OUT_CHARACTER_PRECIS = FONT_OUTPUT_PRECISION.CHARACTER_PRECIS; pub const OUT_DEFAULT_PRECIS = FONT_OUTPUT_PRECISION.DEFAULT_PRECIS; pub const OUT_DEVICE_PRECIS = FONT_OUTPUT_PRECISION.DEVICE_PRECIS; pub const OUT_OUTLINE_PRECIS = FONT_OUTPUT_PRECISION.OUTLINE_PRECIS; pub const OUT_PS_ONLY_PRECIS = FONT_OUTPUT_PRECISION.PS_ONLY_PRECIS; pub const OUT_RASTER_PRECIS = FONT_OUTPUT_PRECISION.RASTER_PRECIS; pub const OUT_STRING_PRECIS = FONT_OUTPUT_PRECISION.STRING_PRECIS; pub const OUT_STROKE_PRECIS = FONT_OUTPUT_PRECISION.STROKE_PRECIS; pub const OUT_TT_ONLY_PRECIS = FONT_OUTPUT_PRECISION.TT_ONLY_PRECIS; pub const OUT_TT_PRECIS = FONT_OUTPUT_PRECISION.TT_PRECIS; pub const ARC_DIRECTION = enum(u32) { OUNTERCLOCKWISE = 1, LOCKWISE = 2, }; pub const AD_COUNTERCLOCKWISE = ARC_DIRECTION.OUNTERCLOCKWISE; pub const AD_CLOCKWISE = ARC_DIRECTION.LOCKWISE; pub const TTLOAD_EMBEDDED_FONT_STATUS = enum(u32) { SUBSETTED = 1, IN_SYSSTARTUP = 2, _, pub fn initFlags(o: struct { SUBSETTED: u1 = 0, IN_SYSSTARTUP: u1 = 0, }) TTLOAD_EMBEDDED_FONT_STATUS { return @intToEnum(TTLOAD_EMBEDDED_FONT_STATUS, (if (o.SUBSETTED == 1) @enumToInt(TTLOAD_EMBEDDED_FONT_STATUS.SUBSETTED) else 0) | (if (o.IN_SYSSTARTUP == 1) @enumToInt(TTLOAD_EMBEDDED_FONT_STATUS.IN_SYSSTARTUP) else 0) ); } }; pub const TTLOAD_FONT_SUBSETTED = TTLOAD_EMBEDDED_FONT_STATUS.SUBSETTED; pub const TTLOAD_FONT_IN_SYSSTARTUP = TTLOAD_EMBEDDED_FONT_STATUS.IN_SYSSTARTUP; pub const STRETCH_BLT_MODE = enum(u32) { BLACKONWHITE = 1, COLORONCOLOR = 3, HALFTONE = 4, // STRETCH_ANDSCANS = 1, this enum value conflicts with BLACKONWHITE // STRETCH_DELETESCANS = 3, this enum value conflicts with COLORONCOLOR // STRETCH_HALFTONE = 4, this enum value conflicts with HALFTONE STRETCH_ORSCANS = 2, // WHITEONBLACK = 2, this enum value conflicts with STRETCH_ORSCANS }; pub const BLACKONWHITE = STRETCH_BLT_MODE.BLACKONWHITE; pub const COLORONCOLOR = STRETCH_BLT_MODE.COLORONCOLOR; pub const HALFTONE = STRETCH_BLT_MODE.HALFTONE; pub const STRETCH_ANDSCANS = STRETCH_BLT_MODE.BLACKONWHITE; pub const STRETCH_DELETESCANS = STRETCH_BLT_MODE.COLORONCOLOR; pub const STRETCH_HALFTONE = STRETCH_BLT_MODE.HALFTONE; pub const STRETCH_ORSCANS = STRETCH_BLT_MODE.STRETCH_ORSCANS; pub const WHITEONBLACK = STRETCH_BLT_MODE.STRETCH_ORSCANS; pub const FONT_QUALITY = enum(u32) { ANTIALIASED_QUALITY = 4, CLEARTYPE_QUALITY = 5, DEFAULT_QUALITY = 0, DRAFT_QUALITY = 1, NONANTIALIASED_QUALITY = 3, PROOF_QUALITY = 2, }; pub const ANTIALIASED_QUALITY = FONT_QUALITY.ANTIALIASED_QUALITY; pub const CLEARTYPE_QUALITY = FONT_QUALITY.CLEARTYPE_QUALITY; pub const DEFAULT_QUALITY = FONT_QUALITY.DEFAULT_QUALITY; pub const DRAFT_QUALITY = FONT_QUALITY.DRAFT_QUALITY; pub const NONANTIALIASED_QUALITY = FONT_QUALITY.NONANTIALIASED_QUALITY; pub const PROOF_QUALITY = FONT_QUALITY.PROOF_QUALITY; pub const BACKGROUND_MODE = enum(u32) { OPAQUE = 2, TRANSPARENT = 1, }; pub const OPAQUE = BACKGROUND_MODE.OPAQUE; pub const TRANSPARENT = BACKGROUND_MODE.TRANSPARENT; pub const GET_CHARACTER_PLACEMENT_FLAGS = enum(u32) { CLASSIN = 524288, DIACRITIC = 256, DISPLAYZWG = 4194304, GLYPHSHAPE = 16, JUSTIFY = 65536, KASHIDA = 1024, LIGATE = 32, MAXEXTENT = 1048576, NEUTRALOVERRIDE = 33554432, NUMERICOVERRIDE = 16777216, NUMERICSLATIN = 67108864, NUMERICSLOCAL = 134217728, REORDER = 2, SYMSWAPOFF = 8388608, USEKERNING = 8, _, pub fn initFlags(o: struct { CLASSIN: u1 = 0, DIACRITIC: u1 = 0, DISPLAYZWG: u1 = 0, GLYPHSHAPE: u1 = 0, JUSTIFY: u1 = 0, KASHIDA: u1 = 0, LIGATE: u1 = 0, MAXEXTENT: u1 = 0, NEUTRALOVERRIDE: u1 = 0, NUMERICOVERRIDE: u1 = 0, NUMERICSLATIN: u1 = 0, NUMERICSLOCAL: u1 = 0, REORDER: u1 = 0, SYMSWAPOFF: u1 = 0, USEKERNING: u1 = 0, }) GET_CHARACTER_PLACEMENT_FLAGS { return @intToEnum(GET_CHARACTER_PLACEMENT_FLAGS, (if (o.CLASSIN == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.CLASSIN) else 0) | (if (o.DIACRITIC == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.DIACRITIC) else 0) | (if (o.DISPLAYZWG == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.DISPLAYZWG) else 0) | (if (o.GLYPHSHAPE == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.GLYPHSHAPE) else 0) | (if (o.JUSTIFY == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.JUSTIFY) else 0) | (if (o.KASHIDA == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.KASHIDA) else 0) | (if (o.LIGATE == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.LIGATE) else 0) | (if (o.MAXEXTENT == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.MAXEXTENT) else 0) | (if (o.NEUTRALOVERRIDE == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.NEUTRALOVERRIDE) else 0) | (if (o.NUMERICOVERRIDE == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.NUMERICOVERRIDE) else 0) | (if (o.NUMERICSLATIN == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.NUMERICSLATIN) else 0) | (if (o.NUMERICSLOCAL == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.NUMERICSLOCAL) else 0) | (if (o.REORDER == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.REORDER) else 0) | (if (o.SYMSWAPOFF == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.SYMSWAPOFF) else 0) | (if (o.USEKERNING == 1) @enumToInt(GET_CHARACTER_PLACEMENT_FLAGS.USEKERNING) else 0) ); } }; pub const GCP_CLASSIN = GET_CHARACTER_PLACEMENT_FLAGS.CLASSIN; pub const GCP_DIACRITIC = GET_CHARACTER_PLACEMENT_FLAGS.DIACRITIC; pub const GCP_DISPLAYZWG = GET_CHARACTER_PLACEMENT_FLAGS.DISPLAYZWG; pub const GCP_GLYPHSHAPE = GET_CHARACTER_PLACEMENT_FLAGS.GLYPHSHAPE; pub const GCP_JUSTIFY = GET_CHARACTER_PLACEMENT_FLAGS.JUSTIFY; pub const GCP_KASHIDA = GET_CHARACTER_PLACEMENT_FLAGS.KASHIDA; pub const GCP_LIGATE = GET_CHARACTER_PLACEMENT_FLAGS.LIGATE; pub const GCP_MAXEXTENT = GET_CHARACTER_PLACEMENT_FLAGS.MAXEXTENT; pub const GCP_NEUTRALOVERRIDE = GET_CHARACTER_PLACEMENT_FLAGS.NEUTRALOVERRIDE; pub const GCP_NUMERICOVERRIDE = GET_CHARACTER_PLACEMENT_FLAGS.NUMERICOVERRIDE; pub const GCP_NUMERICSLATIN = GET_CHARACTER_PLACEMENT_FLAGS.NUMERICSLATIN; pub const GCP_NUMERICSLOCAL = GET_CHARACTER_PLACEMENT_FLAGS.NUMERICSLOCAL; pub const GCP_REORDER = GET_CHARACTER_PLACEMENT_FLAGS.REORDER; pub const GCP_SYMSWAPOFF = GET_CHARACTER_PLACEMENT_FLAGS.SYMSWAPOFF; pub const GCP_USEKERNING = GET_CHARACTER_PLACEMENT_FLAGS.USEKERNING; pub const DRAW_EDGE_FLAGS = enum(u32) { ADJUST = 8192, BOTTOM = 8, BOTTOMLEFT = 9, BOTTOMRIGHT = 12, DIAGONAL = 16, DIAGONAL_ENDBOTTOMLEFT = 25, DIAGONAL_ENDBOTTOMRIGHT = 28, DIAGONAL_ENDTOPLEFT = 19, DIAGONAL_ENDTOPRIGHT = 22, FLAT = 16384, LEFT = 1, MIDDLE = 2048, MONO = 32768, RECT = 15, RIGHT = 4, SOFT = 4096, TOP = 2, TOPLEFT = 3, TOPRIGHT = 6, _, pub fn initFlags(o: struct { ADJUST: u1 = 0, BOTTOM: u1 = 0, BOTTOMLEFT: u1 = 0, BOTTOMRIGHT: u1 = 0, DIAGONAL: u1 = 0, DIAGONAL_ENDBOTTOMLEFT: u1 = 0, DIAGONAL_ENDBOTTOMRIGHT: u1 = 0, DIAGONAL_ENDTOPLEFT: u1 = 0, DIAGONAL_ENDTOPRIGHT: u1 = 0, FLAT: u1 = 0, LEFT: u1 = 0, MIDDLE: u1 = 0, MONO: u1 = 0, RECT: u1 = 0, RIGHT: u1 = 0, SOFT: u1 = 0, TOP: u1 = 0, TOPLEFT: u1 = 0, TOPRIGHT: u1 = 0, }) DRAW_EDGE_FLAGS { return @intToEnum(DRAW_EDGE_FLAGS, (if (o.ADJUST == 1) @enumToInt(DRAW_EDGE_FLAGS.ADJUST) else 0) | (if (o.BOTTOM == 1) @enumToInt(DRAW_EDGE_FLAGS.BOTTOM) else 0) | (if (o.BOTTOMLEFT == 1) @enumToInt(DRAW_EDGE_FLAGS.BOTTOMLEFT) else 0) | (if (o.BOTTOMRIGHT == 1) @enumToInt(DRAW_EDGE_FLAGS.BOTTOMRIGHT) else 0) | (if (o.DIAGONAL == 1) @enumToInt(DRAW_EDGE_FLAGS.DIAGONAL) else 0) | (if (o.DIAGONAL_ENDBOTTOMLEFT == 1) @enumToInt(DRAW_EDGE_FLAGS.DIAGONAL_ENDBOTTOMLEFT) else 0) | (if (o.DIAGONAL_ENDBOTTOMRIGHT == 1) @enumToInt(DRAW_EDGE_FLAGS.DIAGONAL_ENDBOTTOMRIGHT) else 0) | (if (o.DIAGONAL_ENDTOPLEFT == 1) @enumToInt(DRAW_EDGE_FLAGS.DIAGONAL_ENDTOPLEFT) else 0) | (if (o.DIAGONAL_ENDTOPRIGHT == 1) @enumToInt(DRAW_EDGE_FLAGS.DIAGONAL_ENDTOPRIGHT) else 0) | (if (o.FLAT == 1) @enumToInt(DRAW_EDGE_FLAGS.FLAT) else 0) | (if (o.LEFT == 1) @enumToInt(DRAW_EDGE_FLAGS.LEFT) else 0) | (if (o.MIDDLE == 1) @enumToInt(DRAW_EDGE_FLAGS.MIDDLE) else 0) | (if (o.MONO == 1) @enumToInt(DRAW_EDGE_FLAGS.MONO) else 0) | (if (o.RECT == 1) @enumToInt(DRAW_EDGE_FLAGS.RECT) else 0) | (if (o.RIGHT == 1) @enumToInt(DRAW_EDGE_FLAGS.RIGHT) else 0) | (if (o.SOFT == 1) @enumToInt(DRAW_EDGE_FLAGS.SOFT) else 0) | (if (o.TOP == 1) @enumToInt(DRAW_EDGE_FLAGS.TOP) else 0) | (if (o.TOPLEFT == 1) @enumToInt(DRAW_EDGE_FLAGS.TOPLEFT) else 0) | (if (o.TOPRIGHT == 1) @enumToInt(DRAW_EDGE_FLAGS.TOPRIGHT) else 0) ); } }; pub const BF_ADJUST = DRAW_EDGE_FLAGS.ADJUST; pub const BF_BOTTOM = DRAW_EDGE_FLAGS.BOTTOM; pub const BF_BOTTOMLEFT = DRAW_EDGE_FLAGS.BOTTOMLEFT; pub const BF_BOTTOMRIGHT = DRAW_EDGE_FLAGS.BOTTOMRIGHT; pub const BF_DIAGONAL = DRAW_EDGE_FLAGS.DIAGONAL; pub const BF_DIAGONAL_ENDBOTTOMLEFT = DRAW_EDGE_FLAGS.DIAGONAL_ENDBOTTOMLEFT; pub const BF_DIAGONAL_ENDBOTTOMRIGHT = DRAW_EDGE_FLAGS.DIAGONAL_ENDBOTTOMRIGHT; pub const BF_DIAGONAL_ENDTOPLEFT = DRAW_EDGE_FLAGS.DIAGONAL_ENDTOPLEFT; pub const BF_DIAGONAL_ENDTOPRIGHT = DRAW_EDGE_FLAGS.DIAGONAL_ENDTOPRIGHT; pub const BF_FLAT = DRAW_EDGE_FLAGS.FLAT; pub const BF_LEFT = DRAW_EDGE_FLAGS.LEFT; pub const BF_MIDDLE = DRAW_EDGE_FLAGS.MIDDLE; pub const BF_MONO = DRAW_EDGE_FLAGS.MONO; pub const BF_RECT = DRAW_EDGE_FLAGS.RECT; pub const BF_RIGHT = DRAW_EDGE_FLAGS.RIGHT; pub const BF_SOFT = DRAW_EDGE_FLAGS.SOFT; pub const BF_TOP = DRAW_EDGE_FLAGS.TOP; pub const BF_TOPLEFT = DRAW_EDGE_FLAGS.TOPLEFT; pub const BF_TOPRIGHT = DRAW_EDGE_FLAGS.TOPRIGHT; pub const FONT_LICENSE_PRIVS = enum(u32) { PREVIEWPRINT = 4, EDITABLE = 8, INSTALLABLE = 0, NOEMBEDDING = 2, // DEFAULT = 0, this enum value conflicts with INSTALLABLE }; pub const LICENSE_PREVIEWPRINT = FONT_LICENSE_PRIVS.PREVIEWPRINT; pub const LICENSE_EDITABLE = FONT_LICENSE_PRIVS.EDITABLE; pub const LICENSE_INSTALLABLE = FONT_LICENSE_PRIVS.INSTALLABLE; pub const LICENSE_NOEMBEDDING = FONT_LICENSE_PRIVS.NOEMBEDDING; pub const LICENSE_DEFAULT = FONT_LICENSE_PRIVS.INSTALLABLE; pub const GRADIENT_FILL = enum(u32) { RECT_H = 0, RECT_V = 1, TRIANGLE = 2, }; pub const GRADIENT_FILL_RECT_H = GRADIENT_FILL.RECT_H; pub const GRADIENT_FILL_RECT_V = GRADIENT_FILL.RECT_V; pub const GRADIENT_FILL_TRIANGLE = GRADIENT_FILL.TRIANGLE; pub const CREATE_FONT_PACKAGE_SUBSET_ENCODING = enum(u32) { STD_MAC_CHAR_SET = 0, // SYMBOL_CHAR_SET = 0, this enum value conflicts with STD_MAC_CHAR_SET UNICODE_CHAR_SET = 1, }; pub const TTFCFP_STD_MAC_CHAR_SET = CREATE_FONT_PACKAGE_SUBSET_ENCODING.STD_MAC_CHAR_SET; pub const TTFCFP_SYMBOL_CHAR_SET = CREATE_FONT_PACKAGE_SUBSET_ENCODING.STD_MAC_CHAR_SET; pub const TTFCFP_UNICODE_CHAR_SET = CREATE_FONT_PACKAGE_SUBSET_ENCODING.UNICODE_CHAR_SET; pub const EXT_FLOOD_FILL_TYPE = enum(u32) { BORDER = 0, SURFACE = 1, }; pub const FLOODFILLBORDER = EXT_FLOOD_FILL_TYPE.BORDER; pub const FLOODFILLSURFACE = EXT_FLOOD_FILL_TYPE.SURFACE; pub const HATCH_BRUSH_STYLE = enum(u32) { BDIAGONAL = 3, CROSS = 4, DIAGCROSS = 5, FDIAGONAL = 2, HORIZONTAL = 0, VERTICAL = 1, }; pub const HS_BDIAGONAL = HATCH_BRUSH_STYLE.BDIAGONAL; pub const HS_CROSS = HATCH_BRUSH_STYLE.CROSS; pub const HS_DIAGCROSS = HATCH_BRUSH_STYLE.DIAGCROSS; pub const HS_FDIAGONAL = HATCH_BRUSH_STYLE.FDIAGONAL; pub const HS_HORIZONTAL = HATCH_BRUSH_STYLE.HORIZONTAL; pub const HS_VERTICAL = HATCH_BRUSH_STYLE.VERTICAL; pub const DRAW_CAPTION_FLAGS = enum(u32) { ACTIVE = 1, BUTTONS = 4096, GRADIENT = 32, ICON = 4, INBUTTON = 16, SMALLCAP = 2, TEXT = 8, _, pub fn initFlags(o: struct { ACTIVE: u1 = 0, BUTTONS: u1 = 0, GRADIENT: u1 = 0, ICON: u1 = 0, INBUTTON: u1 = 0, SMALLCAP: u1 = 0, TEXT: u1 = 0, }) DRAW_CAPTION_FLAGS { return @intToEnum(DRAW_CAPTION_FLAGS, (if (o.ACTIVE == 1) @enumToInt(DRAW_CAPTION_FLAGS.ACTIVE) else 0) | (if (o.BUTTONS == 1) @enumToInt(DRAW_CAPTION_FLAGS.BUTTONS) else 0) | (if (o.GRADIENT == 1) @enumToInt(DRAW_CAPTION_FLAGS.GRADIENT) else 0) | (if (o.ICON == 1) @enumToInt(DRAW_CAPTION_FLAGS.ICON) else 0) | (if (o.INBUTTON == 1) @enumToInt(DRAW_CAPTION_FLAGS.INBUTTON) else 0) | (if (o.SMALLCAP == 1) @enumToInt(DRAW_CAPTION_FLAGS.SMALLCAP) else 0) | (if (o.TEXT == 1) @enumToInt(DRAW_CAPTION_FLAGS.TEXT) else 0) ); } }; pub const DC_ACTIVE = DRAW_CAPTION_FLAGS.ACTIVE; pub const DC_BUTTONS = DRAW_CAPTION_FLAGS.BUTTONS; pub const DC_GRADIENT = DRAW_CAPTION_FLAGS.GRADIENT; pub const DC_ICON = DRAW_CAPTION_FLAGS.ICON; pub const DC_INBUTTON = DRAW_CAPTION_FLAGS.INBUTTON; pub const DC_SMALLCAP = DRAW_CAPTION_FLAGS.SMALLCAP; pub const DC_TEXT = DRAW_CAPTION_FLAGS.TEXT; pub const SYSTEM_PALETTE_USE = enum(u32) { NOSTATIC = 2, NOSTATIC256 = 3, STATIC = 1, }; pub const SYSPAL_NOSTATIC = SYSTEM_PALETTE_USE.NOSTATIC; pub const SYSPAL_NOSTATIC256 = SYSTEM_PALETTE_USE.NOSTATIC256; pub const SYSPAL_STATIC = SYSTEM_PALETTE_USE.STATIC; pub const GRAPHICS_MODE = enum(u32) { COMPATIBLE = 1, ADVANCED = 2, }; pub const GM_COMPATIBLE = GRAPHICS_MODE.COMPATIBLE; pub const GM_ADVANCED = GRAPHICS_MODE.ADVANCED; pub const FONT_PITCH_AND_FAMILY = enum(u32) { DECORATIVE = 80, DONTCARE = 0, MODERN = 48, ROMAN = 16, SCRIPT = 64, SWISS = 32, }; pub const FF_DECORATIVE = FONT_PITCH_AND_FAMILY.DECORATIVE; pub const FF_DONTCARE = FONT_PITCH_AND_FAMILY.DONTCARE; pub const FF_MODERN = FONT_PITCH_AND_FAMILY.MODERN; pub const FF_ROMAN = FONT_PITCH_AND_FAMILY.ROMAN; pub const FF_SCRIPT = FONT_PITCH_AND_FAMILY.SCRIPT; pub const FF_SWISS = FONT_PITCH_AND_FAMILY.SWISS; pub const CREATE_FONT_PACKAGE_SUBSET_PLATFORM = enum(u32) { UNICODE_PLATFORMID = 0, ISO_PLATFORMID = 2, }; pub const TTFCFP_UNICODE_PLATFORMID = CREATE_FONT_PACKAGE_SUBSET_PLATFORM.UNICODE_PLATFORMID; pub const TTFCFP_ISO_PLATFORMID = CREATE_FONT_PACKAGE_SUBSET_PLATFORM.ISO_PLATFORMID; pub const HDC_MAP_MODE = enum(u32) { ANISOTROPIC = 8, HIENGLISH = 5, HIMETRIC = 3, ISOTROPIC = 7, LOENGLISH = 4, LOMETRIC = 2, TEXT = 1, TWIPS = 6, }; pub const MM_ANISOTROPIC = HDC_MAP_MODE.ANISOTROPIC; pub const MM_HIENGLISH = HDC_MAP_MODE.HIENGLISH; pub const MM_HIMETRIC = HDC_MAP_MODE.HIMETRIC; pub const MM_ISOTROPIC = HDC_MAP_MODE.ISOTROPIC; pub const MM_LOENGLISH = HDC_MAP_MODE.LOENGLISH; pub const MM_LOMETRIC = HDC_MAP_MODE.LOMETRIC; pub const MM_TEXT = HDC_MAP_MODE.TEXT; pub const MM_TWIPS = HDC_MAP_MODE.TWIPS; // TODO: this type has a FreeFunc 'ReleaseDC', what can Zig do with this information? pub const HDC = *opaque{}; // TODO: this type has a FreeFunc 'DeleteDC', what can Zig do with this information? //TODO: type 'CreatedHDC' is "AlsoUsableFor" 'HDC' which means this type is implicitly // convertible to 'HDC' but not the other way around. I don't know how to do this // in Zig so for now I'm just defining it as an alias pub const CreatedHDC = HDC; // TODO: this type has a FreeFunc 'DeleteObject', what can Zig do with this information? //TODO: type 'HBITMAP' is "AlsoUsableFor" 'HGDIOBJ' which means this type is implicitly // convertible to 'HGDIOBJ' but not the other way around. I don't know how to do this // in Zig so for now I'm just defining it as an alias pub const HBITMAP = HGDIOBJ; // TODO: this type has a FreeFunc 'DeleteObject', what can Zig do with this information? //TODO: type 'HRGN' is "AlsoUsableFor" 'HGDIOBJ' which means this type is implicitly // convertible to 'HGDIOBJ' but not the other way around. I don't know how to do this // in Zig so for now I'm just defining it as an alias pub const HRGN = HGDIOBJ; // TODO: this type has a FreeFunc 'DeleteObject', what can Zig do with this information? //TODO: type 'HPEN' is "AlsoUsableFor" 'HGDIOBJ' which means this type is implicitly // convertible to 'HGDIOBJ' but not the other way around. I don't know how to do this // in Zig so for now I'm just defining it as an alias pub const HPEN = HGDIOBJ; // TODO: this type has a FreeFunc 'DeleteObject', what can Zig do with this information? //TODO: type 'HBRUSH' is "AlsoUsableFor" 'HGDIOBJ' which means this type is implicitly // convertible to 'HGDIOBJ' but not the other way around. I don't know how to do this // in Zig so for now I'm just defining it as an alias pub const HBRUSH = HGDIOBJ; // TODO: this type has a FreeFunc 'DeleteObject', what can Zig do with this information? //TODO: type 'HFONT' is "AlsoUsableFor" 'HGDIOBJ' which means this type is implicitly // convertible to 'HGDIOBJ' but not the other way around. I don't know how to do this // in Zig so for now I'm just defining it as an alias pub const HFONT = HGDIOBJ; // TODO: this type has a FreeFunc 'DeleteMetaFile', what can Zig do with this information? pub const HMETAFILE = *opaque{}; // TODO: this type has a FreeFunc 'DeleteEnhMetaFile', what can Zig do with this information? pub const HENHMETAFILE = *opaque{}; // TODO: this type has a FreeFunc 'DeleteObject', what can Zig do with this information? //TODO: type 'HPALETTE' is "AlsoUsableFor" 'HGDIOBJ' which means this type is implicitly // convertible to 'HGDIOBJ' but not the other way around. I don't know how to do this // in Zig so for now I'm just defining it as an alias pub const HPALETTE = HGDIOBJ; // TODO: this type has a FreeFunc 'DeleteMetaFile', what can Zig do with this information? pub const HdcMetdataFileHandle = isize; // TODO: this type has a FreeFunc 'DeleteEnhMetaFile', what can Zig do with this information? pub const HdcMetdataEnhFileHandle = isize; pub const HGDIOBJ = *opaque{}; pub const HMONITOR = *opaque{}; pub const XFORM = extern struct { eM11: f32, eM12: f32, eM21: f32, eM22: f32, eDx: f32, eDy: f32, }; pub const BITMAP = extern struct { bmType: i32, bmWidth: i32, bmHeight: i32, bmWidthBytes: i32, bmPlanes: u16, bmBitsPixel: u16, bmBits: ?*c_void, }; pub const RGBTRIPLE = extern struct { rgbtBlue: u8, rgbtGreen: u8, rgbtRed: u8, }; pub const RGBQUAD = extern struct { rgbBlue: u8, rgbGreen: u8, rgbRed: u8, rgbReserved: u8, }; pub const BITMAPCOREHEADER = extern struct { bcSize: u32, bcWidth: u16, bcHeight: u16, bcPlanes: u16, bcBitCount: u16, }; pub const BITMAPINFOHEADER = extern struct { biSize: u32, biWidth: i32, biHeight: i32, biPlanes: u16, biBitCount: u16, biCompression: u32, biSizeImage: u32, biXPelsPerMeter: i32, biYPelsPerMeter: i32, biClrUsed: u32, biClrImportant: u32, }; pub const BITMAPV4HEADER = extern struct { bV4Size: u32, bV4Width: i32, bV4Height: i32, bV4Planes: u16, bV4BitCount: u16, bV4V4Compression: u32, bV4SizeImage: u32, bV4XPelsPerMeter: i32, bV4YPelsPerMeter: i32, bV4ClrUsed: u32, bV4ClrImportant: u32, bV4RedMask: u32, bV4GreenMask: u32, bV4BlueMask: u32, bV4AlphaMask: u32, bV4CSType: u32, bV4Endpoints: CIEXYZTRIPLE, bV4GammaRed: u32, bV4GammaGreen: u32, bV4GammaBlue: u32, }; pub const BITMAPV5HEADER = extern struct { bV5Size: u32, bV5Width: i32, bV5Height: i32, bV5Planes: u16, bV5BitCount: u16, bV5Compression: u32, bV5SizeImage: u32, bV5XPelsPerMeter: i32, bV5YPelsPerMeter: i32, bV5ClrUsed: u32, bV5ClrImportant: u32, bV5RedMask: u32, bV5GreenMask: u32, bV5BlueMask: u32, bV5AlphaMask: u32, bV5CSType: u32, bV5Endpoints: CIEXYZTRIPLE, bV5GammaRed: u32, bV5GammaGreen: u32, bV5GammaBlue: u32, bV5Intent: u32, bV5ProfileData: u32, bV5ProfileSize: u32, bV5Reserved: u32, }; pub const BITMAPINFO = extern struct { bmiHeader: BITMAPINFOHEADER, bmiColors: [1]RGBQUAD, }; pub const BITMAPCOREINFO = extern struct { bmciHeader: BITMAPCOREHEADER, bmciColors: [1]RGBTRIPLE, }; pub const BITMAPFILEHEADER = extern struct { // WARNING: unable to add field alignment because it's causing a compiler bug bfType: u16, bfSize: u32, bfReserved1: u16, bfReserved2: u16, bfOffBits: u32, }; pub const HANDLETABLE = extern struct { objectHandle: [1]?HGDIOBJ, }; pub const METARECORD = extern struct { rdSize: u32, rdFunction: u16, rdParm: [1]u16, }; pub const METAHEADER = extern struct { // WARNING: unable to add field alignment because it's causing a compiler bug mtType: u16, mtHeaderSize: u16, mtVersion: u16, mtSize: u32, mtNoObjects: u16, mtMaxRecord: u32, mtNoParameters: u16, }; pub const ENHMETARECORD = extern struct { iType: u32, nSize: u32, dParm: [1]u32, }; pub const ENHMETAHEADER = extern struct { iType: u32, nSize: u32, rclBounds: RECTL, rclFrame: RECTL, dSignature: u32, nVersion: u32, nBytes: u32, nRecords: u32, nHandles: u16, sReserved: u16, nDescription: u32, offDescription: u32, nPalEntries: u32, szlDevice: SIZE, szlMillimeters: SIZE, cbPixelFormat: u32, offPixelFormat: u32, bOpenGL: u32, szlMicrometers: SIZE, }; pub const TEXTMETRICA = extern struct { tmHeight: i32, tmAscent: i32, tmDescent: i32, tmInternalLeading: i32, tmExternalLeading: i32, tmAveCharWidth: i32, tmMaxCharWidth: i32, tmWeight: i32, tmOverhang: i32, tmDigitizedAspectX: i32, tmDigitizedAspectY: i32, tmFirstChar: u8, tmLastChar: u8, tmDefaultChar: u8, tmBreakChar: u8, tmItalic: u8, tmUnderlined: u8, tmStruckOut: u8, tmPitchAndFamily: u8, tmCharSet: u8, }; pub const TEXTMETRICW = extern struct { tmHeight: i32, tmAscent: i32, tmDescent: i32, tmInternalLeading: i32, tmExternalLeading: i32, tmAveCharWidth: i32, tmMaxCharWidth: i32, tmWeight: i32, tmOverhang: i32, tmDigitizedAspectX: i32, tmDigitizedAspectY: i32, tmFirstChar: u16, tmLastChar: u16, tmDefaultChar: u16, tmBreakChar: u16, tmItalic: u8, tmUnderlined: u8, tmStruckOut: u8, tmPitchAndFamily: u8, tmCharSet: u8, }; pub const NEWTEXTMETRICA = extern struct { tmHeight: i32, tmAscent: i32, tmDescent: i32, tmInternalLeading: i32, tmExternalLeading: i32, tmAveCharWidth: i32, tmMaxCharWidth: i32, tmWeight: i32, tmOverhang: i32, tmDigitizedAspectX: i32, tmDigitizedAspectY: i32, tmFirstChar: u8, tmLastChar: u8, tmDefaultChar: u8, tmBreakChar: u8, tmItalic: u8, tmUnderlined: u8, tmStruckOut: u8, tmPitchAndFamily: u8, tmCharSet: u8, ntmFlags: u32, ntmSizeEM: u32, ntmCellHeight: u32, ntmAvgWidth: u32, }; pub const NEWTEXTMETRICW = extern struct { tmHeight: i32, tmAscent: i32, tmDescent: i32, tmInternalLeading: i32, tmExternalLeading: i32, tmAveCharWidth: i32, tmMaxCharWidth: i32, tmWeight: i32, tmOverhang: i32, tmDigitizedAspectX: i32, tmDigitizedAspectY: i32, tmFirstChar: u16, tmLastChar: u16, tmDefaultChar: u16, tmBreakChar: u16, tmItalic: u8, tmUnderlined: u8, tmStruckOut: u8, tmPitchAndFamily: u8, tmCharSet: u8, ntmFlags: u32, ntmSizeEM: u32, ntmCellHeight: u32, ntmAvgWidth: u32, }; pub const NEWTEXTMETRICEXA = extern struct { ntmTm: NEWTEXTMETRICA, ntmFontSig: FONTSIGNATURE, }; pub const NEWTEXTMETRICEXW = extern struct { ntmTm: NEWTEXTMETRICW, ntmFontSig: FONTSIGNATURE, }; pub const PELARRAY = extern struct { paXCount: i32, paYCount: i32, paXExt: i32, paYExt: i32, paRGBs: u8, }; pub const LOGBRUSH = extern struct { lbStyle: u32, lbColor: u32, lbHatch: usize, }; pub const LOGBRUSH32 = extern struct { lbStyle: u32, lbColor: u32, lbHatch: u32, }; pub const LOGPEN = extern struct { lopnStyle: u32, lopnWidth: POINT, lopnColor: u32, }; pub const EXTLOGPEN = extern struct { elpPenStyle: u32, elpWidth: u32, elpBrushStyle: u32, elpColor: u32, elpHatch: usize, elpNumEntries: u32, elpStyleEntry: [1]u32, }; pub const EXTLOGPEN32 = extern struct { elpPenStyle: u32, elpWidth: u32, elpBrushStyle: u32, elpColor: u32, elpHatch: u32, elpNumEntries: u32, elpStyleEntry: [1]u32, }; pub const PALETTEENTRY = extern struct { peRed: u8, peGreen: u8, peBlue: u8, peFlags: u8, }; pub const LOGPALETTE = extern struct { palVersion: u16, palNumEntries: u16, palPalEntry: [1]PALETTEENTRY, }; pub const LOGFONTA = extern struct { lfHeight: i32, lfWidth: i32, lfEscapement: i32, lfOrientation: i32, lfWeight: i32, lfItalic: u8, lfUnderline: u8, lfStrikeOut: u8, lfCharSet: u8, lfOutPrecision: u8, lfClipPrecision: u8, lfQuality: u8, lfPitchAndFamily: u8, lfFaceName: [32]CHAR, }; pub const LOGFONTW = extern struct { lfHeight: i32, lfWidth: i32, lfEscapement: i32, lfOrientation: i32, lfWeight: i32, lfItalic: u8, lfUnderline: u8, lfStrikeOut: u8, lfCharSet: u8, lfOutPrecision: u8, lfClipPrecision: u8, lfQuality: u8, lfPitchAndFamily: u8, lfFaceName: [32]u16, }; pub const ENUMLOGFONTA = extern struct { elfLogFont: LOGFONTA, elfFullName: [64]u8, elfStyle: [32]u8, }; pub const ENUMLOGFONTW = extern struct { elfLogFont: LOGFONTW, elfFullName: [64]u16, elfStyle: [32]u16, }; pub const ENUMLOGFONTEXA = extern struct { elfLogFont: LOGFONTA, elfFullName: [64]u8, elfStyle: [32]u8, elfScript: [32]u8, }; pub const ENUMLOGFONTEXW = extern struct { elfLogFont: LOGFONTW, elfFullName: [64]u16, elfStyle: [32]u16, elfScript: [32]u16, }; pub const PANOSE = extern struct { bFamilyType: u8, bSerifStyle: u8, bWeight: u8, bProportion: u8, bContrast: u8, bStrokeVariation: u8, bArmStyle: u8, bLetterform: u8, bMidline: u8, bXHeight: u8, }; pub const EXTLOGFONTA = extern struct { elfLogFont: LOGFONTA, elfFullName: [64]u8, elfStyle: [32]u8, elfVersion: u32, elfStyleSize: u32, elfMatch: u32, elfReserved: u32, elfVendorId: [4]u8, elfCulture: u32, elfPanose: PANOSE, }; pub const EXTLOGFONTW = extern struct { elfLogFont: LOGFONTW, elfFullName: [64]u16, elfStyle: [32]u16, elfVersion: u32, elfStyleSize: u32, elfMatch: u32, elfReserved: u32, elfVendorId: [4]u8, elfCulture: u32, elfPanose: PANOSE, }; pub const DISPLAY_DEVICEA = extern struct { cb: u32, DeviceName: [32]CHAR, DeviceString: [128]CHAR, StateFlags: u32, DeviceID: [128]CHAR, DeviceKey: [128]CHAR, }; pub const DISPLAY_DEVICEW = extern struct { cb: u32, DeviceName: [32]u16, DeviceString: [128]u16, StateFlags: u32, DeviceID: [128]u16, DeviceKey: [128]u16, }; pub const DISPLAYCONFIG_COLOR_ENCODING = enum(i32) { RGB = 0, YCBCR444 = 1, YCBCR422 = 2, YCBCR420 = 3, INTENSITY = 4, FORCE_UINT32 = -1, }; pub const DISPLAYCONFIG_COLOR_ENCODING_RGB = DISPLAYCONFIG_COLOR_ENCODING.RGB; pub const DISPLAYCONFIG_COLOR_ENCODING_YCBCR444 = DISPLAYCONFIG_COLOR_ENCODING.YCBCR444; pub const DISPLAYCONFIG_COLOR_ENCODING_YCBCR422 = DISPLAYCONFIG_COLOR_ENCODING.YCBCR422; pub const DISPLAYCONFIG_COLOR_ENCODING_YCBCR420 = DISPLAYCONFIG_COLOR_ENCODING.YCBCR420; pub const DISPLAYCONFIG_COLOR_ENCODING_INTENSITY = DISPLAYCONFIG_COLOR_ENCODING.INTENSITY; pub const DISPLAYCONFIG_COLOR_ENCODING_FORCE_UINT32 = DISPLAYCONFIG_COLOR_ENCODING.FORCE_UINT32; pub const DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO = extern struct { header: DISPLAYCONFIG_DEVICE_INFO_HEADER, Anonymous: extern union { Anonymous: extern struct { _bitfield: u32, }, value: u32, }, colorEncoding: DISPLAYCONFIG_COLOR_ENCODING, bitsPerColorChannel: u32, }; pub const DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE = extern struct { header: DISPLAYCONFIG_DEVICE_INFO_HEADER, Anonymous: extern union { Anonymous: extern struct { _bitfield: u32, }, value: u32, }, }; pub const DISPLAYCONFIG_SDR_WHITE_LEVEL = extern struct { header: DISPLAYCONFIG_DEVICE_INFO_HEADER, SDRWhiteLevel: u32, }; pub const RGNDATAHEADER = extern struct { dwSize: u32, iType: u32, nCount: u32, nRgnSize: u32, rcBound: RECT, }; pub const RGNDATA = extern struct { rdh: RGNDATAHEADER, Buffer: [1]CHAR, }; pub const ABC = extern struct { abcA: i32, abcB: u32, abcC: i32, }; pub const ABCFLOAT = extern struct { abcfA: f32, abcfB: f32, abcfC: f32, }; pub const OUTLINETEXTMETRICA = extern struct { otmSize: u32, otmTextMetrics: TEXTMETRICA, otmFiller: u8, otmPanoseNumber: PANOSE, otmfsSelection: u32, otmfsType: u32, otmsCharSlopeRise: i32, otmsCharSlopeRun: i32, otmItalicAngle: i32, otmEMSquare: u32, otmAscent: i32, otmDescent: i32, otmLineGap: u32, otmsCapEmHeight: u32, otmsXHeight: u32, otmrcFontBox: RECT, otmMacAscent: i32, otmMacDescent: i32, otmMacLineGap: u32, otmusMinimumPPEM: u32, otmptSubscriptSize: POINT, otmptSubscriptOffset: POINT, otmptSuperscriptSize: POINT, otmptSuperscriptOffset: POINT, otmsStrikeoutSize: u32, otmsStrikeoutPosition: i32, otmsUnderscoreSize: i32, otmsUnderscorePosition: i32, otmpFamilyName: ?PSTR, otmpFaceName: ?PSTR, otmpStyleName: ?PSTR, otmpFullName: ?PSTR, }; pub const OUTLINETEXTMETRICW = extern struct { otmSize: u32, otmTextMetrics: TEXTMETRICW, otmFiller: u8, otmPanoseNumber: PANOSE, otmfsSelection: u32, otmfsType: u32, otmsCharSlopeRise: i32, otmsCharSlopeRun: i32, otmItalicAngle: i32, otmEMSquare: u32, otmAscent: i32, otmDescent: i32, otmLineGap: u32, otmsCapEmHeight: u32, otmsXHeight: u32, otmrcFontBox: RECT, otmMacAscent: i32, otmMacDescent: i32, otmMacLineGap: u32, otmusMinimumPPEM: u32, otmptSubscriptSize: POINT, otmptSubscriptOffset: POINT, otmptSuperscriptSize: POINT, otmptSuperscriptOffset: POINT, otmsStrikeoutSize: u32, otmsStrikeoutPosition: i32, otmsUnderscoreSize: i32, otmsUnderscorePosition: i32, otmpFamilyName: ?PSTR, otmpFaceName: ?PSTR, otmpStyleName: ?PSTR, otmpFullName: ?PSTR, }; pub const POLYTEXTA = extern struct { x: i32, y: i32, n: u32, lpstr: ?[*:0]const u8, uiFlags: u32, rcl: RECT, pdx: ?*i32, }; pub const POLYTEXTW = extern struct { x: i32, y: i32, n: u32, lpstr: ?[*:0]const u16, uiFlags: u32, rcl: RECT, pdx: ?*i32, }; pub const FIXED = extern struct { fract: u16, value: i16, }; pub const MAT2 = extern struct { eM11: FIXED, eM12: FIXED, eM21: FIXED, eM22: FIXED, }; pub const GLYPHMETRICS = extern struct { gmBlackBoxX: u32, gmBlackBoxY: u32, gmptGlyphOrigin: POINT, gmCellIncX: i16, gmCellIncY: i16, }; pub const POINTFX = extern struct { x: FIXED, y: FIXED, }; pub const TTPOLYCURVE = extern struct { wType: u16, cpfx: u16, apfx: [1]POINTFX, }; pub const TTPOLYGONHEADER = extern struct { cb: u32, dwType: u32, pfxStart: POINTFX, }; pub const GCP_RESULTSA = extern struct { lStructSize: u32, lpOutString: ?PSTR, lpOrder: ?*u32, lpDx: ?*i32, lpCaretPos: ?*i32, lpClass: ?PSTR, lpGlyphs: ?PWSTR, nGlyphs: u32, nMaxFit: i32, }; pub const GCP_RESULTSW = extern struct { lStructSize: u32, lpOutString: ?PWSTR, lpOrder: ?*u32, lpDx: ?*i32, lpCaretPos: ?*i32, lpClass: ?PSTR, lpGlyphs: ?PWSTR, nGlyphs: u32, nMaxFit: i32, }; pub const RASTERIZER_STATUS = extern struct { nSize: i16, wFlags: i16, nLanguageID: i16, }; pub const FONTENUMPROCA = fn( param0: ?*const LOGFONTA, param1: ?*const TEXTMETRICA, param2: u32, param3: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; pub const FONTENUMPROCW = fn( param0: ?*const LOGFONTW, param1: ?*const TEXTMETRICW, param2: u32, param3: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; pub const GOBJENUMPROC = fn( param0: ?*c_void, param1: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; pub const LINEDDAPROC = fn( param0: i32, param1: i32, param2: LPARAM, ) callconv(@import("std").os.windows.WINAPI) void; pub const LPFNDEVMODE = fn( param0: ?HWND, param1: ?HINSTANCE, param2: ?*DEVMODEA, param3: ?PSTR, param4: ?PSTR, param5: ?*DEVMODEA, param6: ?PSTR, param7: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub const LPFNDEVCAPS = fn( param0: ?PSTR, param1: ?PSTR, param2: u32, param3: ?PSTR, param4: ?*DEVMODEA, ) callconv(@import("std").os.windows.WINAPI) u32; pub const WCRANGE = extern struct { wcLow: u16, cGlyphs: u16, }; pub const GLYPHSET = extern struct { cbThis: u32, flAccel: u32, cGlyphsSupported: u32, cRanges: u32, ranges: [1]WCRANGE, }; pub const DESIGNVECTOR = extern struct { dvReserved: u32, dvNumAxes: u32, dvValues: [16]i32, }; pub const AXISINFOA = extern struct { axMinValue: i32, axMaxValue: i32, axAxisName: [16]u8, }; pub const AXISINFOW = extern struct { axMinValue: i32, axMaxValue: i32, axAxisName: [16]u16, }; pub const AXESLISTA = extern struct { axlReserved: u32, axlNumAxes: u32, axlAxisInfo: [16]AXISINFOA, }; pub const AXESLISTW = extern struct { axlReserved: u32, axlNumAxes: u32, axlAxisInfo: [16]AXISINFOW, }; pub const ENUMLOGFONTEXDVA = extern struct { elfEnumLogfontEx: ENUMLOGFONTEXA, elfDesignVector: DESIGNVECTOR, }; pub const ENUMLOGFONTEXDVW = extern struct { elfEnumLogfontEx: ENUMLOGFONTEXW, elfDesignVector: DESIGNVECTOR, }; pub const ENUMTEXTMETRICA = extern struct { etmNewTextMetricEx: NEWTEXTMETRICEXA, etmAxesList: AXESLISTA, }; pub const ENUMTEXTMETRICW = extern struct { etmNewTextMetricEx: NEWTEXTMETRICEXW, etmAxesList: AXESLISTW, }; pub const TRIVERTEX = extern struct { x: i32, y: i32, Red: u16, Green: u16, Blue: u16, Alpha: u16, }; pub const GRADIENT_TRIANGLE = extern struct { Vertex1: u32, Vertex2: u32, Vertex3: u32, }; pub const GRADIENT_RECT = extern struct { UpperLeft: u32, LowerRight: u32, }; pub const BLENDFUNCTION = extern struct { BlendOp: u8, BlendFlags: u8, SourceConstantAlpha: u8, AlphaFormat: u8, }; pub const MFENUMPROC = fn( hdc: ?HDC, lpht: [*]HANDLETABLE, lpMR: ?*METARECORD, nObj: i32, param4: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; pub const ENHMFENUMPROC = fn( hdc: ?HDC, lpht: [*]HANDLETABLE, lpmr: ?*const ENHMETARECORD, nHandles: i32, data: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; pub const DIBSECTION = extern struct { dsBm: BITMAP, dsBmih: BITMAPINFOHEADER, dsBitfields: [3]u32, dshSection: ?HANDLE, dsOffset: u32, }; pub const COLORADJUSTMENT = extern struct { caSize: u16, caFlags: u16, caIlluminantIndex: u16, caRedGamma: u16, caGreenGamma: u16, caBlueGamma: u16, caReferenceBlack: u16, caReferenceWhite: u16, caContrast: i16, caBrightness: i16, caColorfulness: i16, caRedGreenTint: i16, }; pub const KERNINGPAIR = extern struct { wFirst: u16, wSecond: u16, iKernAmount: i32, }; pub const EMR = extern struct { iType: u32, nSize: u32, }; pub const EMRTEXT = extern struct { ptlReference: POINTL, nChars: u32, offString: u32, fOptions: u32, rcl: RECTL, offDx: u32, }; pub const ABORTPATH = extern struct { emr: EMR, }; pub const EMRSELECTCLIPPATH = extern struct { emr: EMR, iMode: u32, }; pub const EMRSETMITERLIMIT = extern struct { emr: EMR, eMiterLimit: f32, }; pub const EMRRESTOREDC = extern struct { emr: EMR, iRelative: i32, }; pub const EMRSETARCDIRECTION = extern struct { emr: EMR, iArcDirection: u32, }; pub const EMRSETMAPPERFLAGS = extern struct { emr: EMR, dwFlags: u32, }; pub const EMRSETTEXTCOLOR = extern struct { emr: EMR, crColor: u32, }; pub const EMRSELECTOBJECT = extern struct { emr: EMR, ihObject: u32, }; pub const EMRSELECTPALETTE = extern struct { emr: EMR, ihPal: u32, }; pub const EMRRESIZEPALETTE = extern struct { emr: EMR, ihPal: u32, cEntries: u32, }; pub const EMRSETPALETTEENTRIES = extern struct { emr: EMR, ihPal: u32, iStart: u32, cEntries: u32, aPalEntries: [1]PALETTEENTRY, }; pub const EMRSETCOLORADJUSTMENT = extern struct { emr: EMR, ColorAdjustment: COLORADJUSTMENT, }; pub const EMRGDICOMMENT = extern struct { emr: EMR, cbData: u32, Data: [1]u8, }; pub const EMREOF = extern struct { emr: EMR, nPalEntries: u32, offPalEntries: u32, nSizeLast: u32, }; pub const EMRLINETO = extern struct { emr: EMR, ptl: POINTL, }; pub const EMROFFSETCLIPRGN = extern struct { emr: EMR, ptlOffset: POINTL, }; pub const EMRFILLPATH = extern struct { emr: EMR, rclBounds: RECTL, }; pub const EMREXCLUDECLIPRECT = extern struct { emr: EMR, rclClip: RECTL, }; pub const EMRSETVIEWPORTORGEX = extern struct { emr: EMR, ptlOrigin: POINTL, }; pub const EMRSETVIEWPORTEXTEX = extern struct { emr: EMR, szlExtent: SIZE, }; pub const EMRSCALEVIEWPORTEXTEX = extern struct { emr: EMR, xNum: i32, xDenom: i32, yNum: i32, yDenom: i32, }; pub const EMRSETWORLDTRANSFORM = extern struct { emr: EMR, xform: XFORM, }; pub const EMRMODIFYWORLDTRANSFORM = extern struct { emr: EMR, xform: XFORM, iMode: u32, }; pub const EMRSETPIXELV = extern struct { emr: EMR, ptlPixel: POINTL, crColor: u32, }; pub const EMREXTFLOODFILL = extern struct { emr: EMR, ptlStart: POINTL, crColor: u32, iMode: u32, }; pub const EMRELLIPSE = extern struct { emr: EMR, rclBox: RECTL, }; pub const EMRROUNDRECT = extern struct { emr: EMR, rclBox: RECTL, szlCorner: SIZE, }; pub const EMRARC = extern struct { emr: EMR, rclBox: RECTL, ptlStart: POINTL, ptlEnd: POINTL, }; pub const EMRANGLEARC = extern struct { emr: EMR, ptlCenter: POINTL, nRadius: u32, eStartAngle: f32, eSweepAngle: f32, }; pub const EMRPOLYLINE = extern struct { emr: EMR, rclBounds: RECTL, cptl: u32, aptl: [1]POINTL, }; pub const EMRPOLYLINE16 = extern struct { emr: EMR, rclBounds: RECTL, cpts: u32, apts: [1]POINTS, }; pub const EMRPOLYDRAW = extern struct { emr: EMR, rclBounds: RECTL, cptl: u32, aptl: [1]POINTL, abTypes: [1]u8, }; pub const EMRPOLYDRAW16 = extern struct { emr: EMR, rclBounds: RECTL, cpts: u32, apts: [1]POINTS, abTypes: [1]u8, }; pub const EMRPOLYPOLYLINE = extern struct { emr: EMR, rclBounds: RECTL, nPolys: u32, cptl: u32, aPolyCounts: [1]u32, aptl: [1]POINTL, }; pub const EMRPOLYPOLYLINE16 = extern struct { emr: EMR, rclBounds: RECTL, nPolys: u32, cpts: u32, aPolyCounts: [1]u32, apts: [1]POINTS, }; pub const EMRINVERTRGN = extern struct { emr: EMR, rclBounds: RECTL, cbRgnData: u32, RgnData: [1]u8, }; pub const EMRFILLRGN = extern struct { emr: EMR, rclBounds: RECTL, cbRgnData: u32, ihBrush: u32, RgnData: [1]u8, }; pub const EMRFRAMERGN = extern struct { emr: EMR, rclBounds: RECTL, cbRgnData: u32, ihBrush: u32, szlStroke: SIZE, RgnData: [1]u8, }; pub const EMREXTSELECTCLIPRGN = extern struct { emr: EMR, cbRgnData: u32, iMode: u32, RgnData: [1]u8, }; pub const EMREXTTEXTOUTA = extern struct { emr: EMR, rclBounds: RECTL, iGraphicsMode: u32, exScale: f32, eyScale: f32, emrtext: EMRTEXT, }; pub const EMRPOLYTEXTOUTA = extern struct { emr: EMR, rclBounds: RECTL, iGraphicsMode: u32, exScale: f32, eyScale: f32, cStrings: i32, aemrtext: [1]EMRTEXT, }; pub const EMRBITBLT = extern struct { emr: EMR, rclBounds: RECTL, xDest: i32, yDest: i32, cxDest: i32, cyDest: i32, dwRop: u32, xSrc: i32, ySrc: i32, xformSrc: XFORM, crBkColorSrc: u32, iUsageSrc: u32, offBmiSrc: u32, cbBmiSrc: u32, offBitsSrc: u32, cbBitsSrc: u32, }; pub const EMRSTRETCHBLT = extern struct { emr: EMR, rclBounds: RECTL, xDest: i32, yDest: i32, cxDest: i32, cyDest: i32, dwRop: u32, xSrc: i32, ySrc: i32, xformSrc: XFORM, crBkColorSrc: u32, iUsageSrc: u32, offBmiSrc: u32, cbBmiSrc: u32, offBitsSrc: u32, cbBitsSrc: u32, cxSrc: i32, cySrc: i32, }; pub const EMRMASKBLT = extern struct { emr: EMR, rclBounds: RECTL, xDest: i32, yDest: i32, cxDest: i32, cyDest: i32, dwRop: u32, xSrc: i32, ySrc: i32, xformSrc: XFORM, crBkColorSrc: u32, iUsageSrc: u32, offBmiSrc: u32, cbBmiSrc: u32, offBitsSrc: u32, cbBitsSrc: u32, xMask: i32, yMask: i32, iUsageMask: u32, offBmiMask: u32, cbBmiMask: u32, offBitsMask: u32, cbBitsMask: u32, }; pub const EMRPLGBLT = extern struct { emr: EMR, rclBounds: RECTL, aptlDest: [3]POINTL, xSrc: i32, ySrc: i32, cxSrc: i32, cySrc: i32, xformSrc: XFORM, crBkColorSrc: u32, iUsageSrc: u32, offBmiSrc: u32, cbBmiSrc: u32, offBitsSrc: u32, cbBitsSrc: u32, xMask: i32, yMask: i32, iUsageMask: u32, offBmiMask: u32, cbBmiMask: u32, offBitsMask: u32, cbBitsMask: u32, }; pub const EMRSETDIBITSTODEVICE = extern struct { emr: EMR, rclBounds: RECTL, xDest: i32, yDest: i32, xSrc: i32, ySrc: i32, cxSrc: i32, cySrc: i32, offBmiSrc: u32, cbBmiSrc: u32, offBitsSrc: u32, cbBitsSrc: u32, iUsageSrc: u32, iStartScan: u32, cScans: u32, }; pub const EMRSTRETCHDIBITS = extern struct { emr: EMR, rclBounds: RECTL, xDest: i32, yDest: i32, xSrc: i32, ySrc: i32, cxSrc: i32, cySrc: i32, offBmiSrc: u32, cbBmiSrc: u32, offBitsSrc: u32, cbBitsSrc: u32, iUsageSrc: u32, dwRop: u32, cxDest: i32, cyDest: i32, }; pub const EMREXTCREATEFONTINDIRECTW = extern struct { emr: EMR, ihFont: u32, elfw: EXTLOGFONTW, }; pub const EMRCREATEPALETTE = extern struct { emr: EMR, ihPal: u32, lgpl: LOGPALETTE, }; pub const EMRCREATEPEN = extern struct { emr: EMR, ihPen: u32, lopn: LOGPEN, }; pub const EMREXTCREATEPEN = extern struct { emr: EMR, ihPen: u32, offBmi: u32, cbBmi: u32, offBits: u32, cbBits: u32, elp: EXTLOGPEN32, }; pub const EMRCREATEBRUSHINDIRECT = extern struct { emr: EMR, ihBrush: u32, lb: LOGBRUSH32, }; pub const EMRCREATEMONOBRUSH = extern struct { emr: EMR, ihBrush: u32, iUsage: u32, offBmi: u32, cbBmi: u32, offBits: u32, cbBits: u32, }; pub const EMRCREATEDIBPATTERNBRUSHPT = extern struct { emr: EMR, ihBrush: u32, iUsage: u32, offBmi: u32, cbBmi: u32, offBits: u32, cbBits: u32, }; pub const EMRFORMAT = extern struct { dSignature: u32, nVersion: u32, cbData: u32, offData: u32, }; pub const EMRGLSRECORD = extern struct { emr: EMR, cbData: u32, Data: [1]u8, }; pub const EMRGLSBOUNDEDRECORD = extern struct { emr: EMR, rclBounds: RECTL, cbData: u32, Data: [1]u8, }; pub const EMRPIXELFORMAT = extern struct { emr: EMR, pfd: PIXELFORMATDESCRIPTOR, }; pub const EMRCREATECOLORSPACE = extern struct { emr: EMR, ihCS: u32, lcs: LOGCOLORSPACEA, }; pub const EMRSETCOLORSPACE = extern struct { emr: EMR, ihCS: u32, }; pub const EMREXTESCAPE = extern struct { emr: EMR, iEscape: i32, cbEscData: i32, EscData: [1]u8, }; pub const EMRNAMEDESCAPE = extern struct { emr: EMR, iEscape: i32, cbDriver: i32, cbEscData: i32, EscData: [1]u8, }; pub const EMRSETICMPROFILE = extern struct { emr: EMR, dwFlags: u32, cbName: u32, cbData: u32, Data: [1]u8, }; pub const EMRCREATECOLORSPACEW = extern struct { emr: EMR, ihCS: u32, lcs: LOGCOLORSPACEW, dwFlags: u32, cbData: u32, Data: [1]u8, }; pub const COLORMATCHTOTARGET = extern struct { emr: EMR, dwAction: u32, dwFlags: u32, cbName: u32, cbData: u32, Data: [1]u8, }; pub const COLORCORRECTPALETTE = extern struct { emr: EMR, ihPalette: u32, nFirstEntry: u32, nPalEntries: u32, nReserved: u32, }; pub const EMRALPHABLEND = extern struct { emr: EMR, rclBounds: RECTL, xDest: i32, yDest: i32, cxDest: i32, cyDest: i32, dwRop: u32, xSrc: i32, ySrc: i32, xformSrc: XFORM, crBkColorSrc: u32, iUsageSrc: u32, offBmiSrc: u32, cbBmiSrc: u32, offBitsSrc: u32, cbBitsSrc: u32, cxSrc: i32, cySrc: i32, }; pub const EMRGRADIENTFILL = extern struct { emr: EMR, rclBounds: RECTL, nVer: u32, nTri: u32, ulMode: GRADIENT_FILL, Ver: [1]TRIVERTEX, }; pub const EMRTRANSPARENTBLT = extern struct { emr: EMR, rclBounds: RECTL, xDest: i32, yDest: i32, cxDest: i32, cyDest: i32, dwRop: u32, xSrc: i32, ySrc: i32, xformSrc: XFORM, crBkColorSrc: u32, iUsageSrc: u32, offBmiSrc: u32, cbBmiSrc: u32, offBitsSrc: u32, cbBitsSrc: u32, cxSrc: i32, cySrc: i32, }; pub const WGLSWAP = extern struct { hdc: ?HDC, uiFlags: u32, }; pub const CFP_ALLOCPROC = fn( param0: usize, ) callconv(@import("std").os.windows.WINAPI) ?*c_void; pub const CFP_REALLOCPROC = fn( param0: ?*c_void, param1: usize, ) callconv(@import("std").os.windows.WINAPI) ?*c_void; pub const CFP_FREEPROC = fn( param0: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) void; pub const READEMBEDPROC = fn( param0: ?*c_void, param1: ?*c_void, param2: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub const WRITEEMBEDPROC = fn( param0: ?*c_void, param1: ?*const c_void, param2: u32, ) callconv(@import("std").os.windows.WINAPI) u32; pub const TTLOADINFO = extern struct { usStructSize: u16, usRefStrSize: u16, pusRefStr: ?*u16, }; pub const TTEMBEDINFO = extern struct { usStructSize: u16, usRootStrSize: u16, pusRootStr: ?*u16, }; pub const TTVALIDATIONTESTSPARAMS = extern struct { ulStructSize: u32, lTestFromSize: i32, lTestToSize: i32, ulCharSet: u32, usReserved1: u16, usCharCodeCount: u16, pusCharCodeSet: ?*u16, }; pub const TTVALIDATIONTESTSPARAMSEX = extern struct { ulStructSize: u32, lTestFromSize: i32, lTestToSize: i32, ulCharSet: u32, usReserved1: u16, usCharCodeCount: u16, pulCharCodeSet: ?*u32, }; pub const GRAYSTRINGPROC = fn( param0: ?HDC, param1: LPARAM, param2: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub const DRAWSTATEPROC = fn( hdc: ?HDC, lData: LPARAM, wData: WPARAM, cx: i32, cy: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub const PAINTSTRUCT = extern struct { hdc: ?HDC, fErase: BOOL, rcPaint: RECT, fRestore: BOOL, fIncUpdate: BOOL, rgbReserved: [32]u8, }; pub const DRAWTEXTPARAMS = extern struct { cbSize: u32, iTabLength: i32, iLeftMargin: i32, iRightMargin: i32, uiLengthDrawn: u32, }; pub const MONITORINFO = extern struct { cbSize: u32, rcMonitor: RECT, rcWork: RECT, dwFlags: u32, }; pub const MONITORINFOEXA = extern struct { __AnonymousBase_winuser_L13554_C43: MONITORINFO, szDevice: [32]CHAR, }; pub const MONITORINFOEXW = extern struct { __AnonymousBase_winuser_L13558_C43: MONITORINFO, szDevice: [32]u16, }; pub const MONITORENUMPROC = fn( param0: ?HMONITOR, param1: ?HDC, param2: ?*RECT, param3: LPARAM, ) callconv(@import("std").os.windows.WINAPI) BOOL; //-------------------------------------------------------------------------------- // Section: Functions (395) //-------------------------------------------------------------------------------- pub extern "GDI32" fn GetObjectA( h: ?HGDIOBJ, c: i32, // TODO: what to do with BytesParamIndex 1? pv: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn AddFontResourceA( param0: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn AddFontResourceW( param0: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn AnimatePalette( hPal: ?HPALETTE, iStartIndex: u32, cEntries: u32, ppe: [*]const PALETTEENTRY, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn Arc( hdc: ?HDC, x1: i32, y1: i32, x2: i32, y2: i32, x3: i32, y3: i32, x4: i32, y4: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn BitBlt( hdc: ?HDC, x: i32, y: i32, cx: i32, cy: i32, hdcSrc: ?HDC, x1: i32, y1: i32, rop: ROP_CODE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CancelDC( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn Chord( hdc: ?HDC, x1: i32, y1: i32, x2: i32, y2: i32, x3: i32, y3: i32, x4: i32, y4: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CloseMetaFile( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) ?HMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CombineRgn( hrgnDst: ?HRGN, hrgnSrc1: ?HRGN, hrgnSrc2: ?HRGN, iMode: RGN_COMBINE_MODE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CopyMetaFileA( param0: ?HMETAFILE, param1: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) ?HMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CopyMetaFileW( param0: ?HMETAFILE, param1: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) ?HMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateBitmap( nWidth: i32, nHeight: i32, nPlanes: u32, nBitCount: u32, lpBits: ?*const c_void, ) callconv(@import("std").os.windows.WINAPI) ?HBITMAP; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateBitmapIndirect( pbm: ?*const BITMAP, ) callconv(@import("std").os.windows.WINAPI) ?HBITMAP; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateBrushIndirect( plbrush: ?*const LOGBRUSH, ) callconv(@import("std").os.windows.WINAPI) ?HBRUSH; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateCompatibleBitmap( hdc: ?HDC, cx: i32, cy: i32, ) callconv(@import("std").os.windows.WINAPI) ?HBITMAP; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateDiscardableBitmap( hdc: ?HDC, cx: i32, cy: i32, ) callconv(@import("std").os.windows.WINAPI) ?HBITMAP; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateCompatibleDC( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) CreatedHDC; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateDCA( pwszDriver: ?[*:0]const u8, pwszDevice: ?[*:0]const u8, pszPort: ?[*:0]const u8, pdm: ?*const DEVMODEA, ) callconv(@import("std").os.windows.WINAPI) CreatedHDC; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateDCW( pwszDriver: ?[*:0]const u16, pwszDevice: ?[*:0]const u16, pszPort: ?[*:0]const u16, pdm: ?*const DEVMODEW, ) callconv(@import("std").os.windows.WINAPI) CreatedHDC; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateDIBitmap( hdc: ?HDC, pbmih: ?*const BITMAPINFOHEADER, flInit: u32, pjBits: ?*const c_void, pbmi: ?*const BITMAPINFO, iUsage: DIB_USAGE, ) callconv(@import("std").os.windows.WINAPI) ?HBITMAP; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateDIBPatternBrush( h: isize, iUsage: DIB_USAGE, ) callconv(@import("std").os.windows.WINAPI) ?HBRUSH; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateDIBPatternBrushPt( lpPackedDIB: ?*const c_void, iUsage: DIB_USAGE, ) callconv(@import("std").os.windows.WINAPI) ?HBRUSH; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateEllipticRgn( x1: i32, y1: i32, x2: i32, y2: i32, ) callconv(@import("std").os.windows.WINAPI) ?HRGN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateEllipticRgnIndirect( lprect: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) ?HRGN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateFontIndirectA( lplf: ?*const LOGFONTA, ) callconv(@import("std").os.windows.WINAPI) ?HFONT; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateFontIndirectW( lplf: ?*const LOGFONTW, ) callconv(@import("std").os.windows.WINAPI) ?HFONT; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateFontA( cHeight: i32, cWidth: i32, cEscapement: i32, cOrientation: i32, cWeight: i32, bItalic: u32, bUnderline: u32, bStrikeOut: u32, iCharSet: u32, iOutPrecision: FONT_OUTPUT_PRECISION, iClipPrecision: FONT_CLIP_PRECISION, iQuality: FONT_QUALITY, iPitchAndFamily: FONT_PITCH_AND_FAMILY, pszFaceName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) ?HFONT; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateFontW( cHeight: i32, cWidth: i32, cEscapement: i32, cOrientation: i32, cWeight: i32, bItalic: u32, bUnderline: u32, bStrikeOut: u32, iCharSet: u32, iOutPrecision: FONT_OUTPUT_PRECISION, iClipPrecision: FONT_CLIP_PRECISION, iQuality: FONT_QUALITY, iPitchAndFamily: FONT_PITCH_AND_FAMILY, pszFaceName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) ?HFONT; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateHatchBrush( iHatch: HATCH_BRUSH_STYLE, color: u32, ) callconv(@import("std").os.windows.WINAPI) ?HBRUSH; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateICA( pszDriver: ?[*:0]const u8, pszDevice: ?[*:0]const u8, pszPort: ?[*:0]const u8, pdm: ?*const DEVMODEA, ) callconv(@import("std").os.windows.WINAPI) CreatedHDC; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateICW( pszDriver: ?[*:0]const u16, pszDevice: ?[*:0]const u16, pszPort: ?[*:0]const u16, pdm: ?*const DEVMODEW, ) callconv(@import("std").os.windows.WINAPI) CreatedHDC; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateMetaFileA( pszFile: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) HdcMetdataFileHandle; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateMetaFileW( pszFile: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HdcMetdataFileHandle; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreatePalette( plpal: ?*const LOGPALETTE, ) callconv(@import("std").os.windows.WINAPI) ?HPALETTE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreatePen( iStyle: PEN_STYLE, cWidth: i32, color: u32, ) callconv(@import("std").os.windows.WINAPI) ?HPEN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreatePenIndirect( plpen: ?*const LOGPEN, ) callconv(@import("std").os.windows.WINAPI) ?HPEN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreatePolyPolygonRgn( pptl: ?*const POINT, pc: [*]const i32, cPoly: i32, iMode: CREATE_POLYGON_RGN_MODE, ) callconv(@import("std").os.windows.WINAPI) ?HRGN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreatePatternBrush( hbm: ?HBITMAP, ) callconv(@import("std").os.windows.WINAPI) ?HBRUSH; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateRectRgn( x1: i32, y1: i32, x2: i32, y2: i32, ) callconv(@import("std").os.windows.WINAPI) ?HRGN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateRectRgnIndirect( lprect: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) ?HRGN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateRoundRectRgn( x1: i32, y1: i32, x2: i32, y2: i32, w: i32, h: i32, ) callconv(@import("std").os.windows.WINAPI) ?HRGN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateScalableFontResourceA( fdwHidden: u32, lpszFont: ?[*:0]const u8, lpszFile: ?[*:0]const u8, lpszPath: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateScalableFontResourceW( fdwHidden: u32, lpszFont: ?[*:0]const u16, lpszFile: ?[*:0]const u16, lpszPath: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateSolidBrush( color: u32, ) callconv(@import("std").os.windows.WINAPI) ?HBRUSH; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn DeleteDC( hdc: CreatedHDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn DeleteMetaFile( hmf: ?HMETAFILE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn DeleteObject( ho: ?HGDIOBJ, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn DrawEscape( hdc: ?HDC, iEscape: i32, cjIn: i32, // TODO: what to do with BytesParamIndex 2? lpIn: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows6.1' pub extern "GDI32" fn Ellipse( hdc: ?HDC, left: i32, top: i32, right: i32, bottom: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EnumFontFamiliesExA( hdc: ?HDC, lpLogfont: ?*LOGFONTA, lpProc: ?FONTENUMPROCA, lParam: LPARAM, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EnumFontFamiliesExW( hdc: ?HDC, lpLogfont: ?*LOGFONTW, lpProc: ?FONTENUMPROCW, lParam: LPARAM, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EnumFontFamiliesA( hdc: ?HDC, lpLogfont: ?[*:0]const u8, lpProc: ?FONTENUMPROCA, lParam: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EnumFontFamiliesW( hdc: ?HDC, lpLogfont: ?[*:0]const u16, lpProc: ?FONTENUMPROCW, lParam: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EnumFontsA( hdc: ?HDC, lpLogfont: ?[*:0]const u8, lpProc: ?FONTENUMPROCA, lParam: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EnumFontsW( hdc: ?HDC, lpLogfont: ?[*:0]const u16, lpProc: ?FONTENUMPROCW, lParam: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EnumObjects( hdc: ?HDC, nType: OBJ_TYPE, lpFunc: ?GOBJENUMPROC, lParam: LPARAM, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EqualRgn( hrgn1: ?HRGN, hrgn2: ?HRGN, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ExcludeClipRect( hdc: ?HDC, left: i32, top: i32, right: i32, bottom: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ExtCreateRegion( lpx: ?*const XFORM, nCount: u32, // TODO: what to do with BytesParamIndex 1? lpData: ?*const RGNDATA, ) callconv(@import("std").os.windows.WINAPI) ?HRGN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ExtFloodFill( hdc: ?HDC, x: i32, y: i32, color: u32, type: EXT_FLOOD_FILL_TYPE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn FillRgn( hdc: ?HDC, hrgn: ?HRGN, hbr: ?HBRUSH, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn FloodFill( hdc: ?HDC, x: i32, y: i32, color: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn FrameRgn( hdc: ?HDC, hrgn: ?HRGN, hbr: ?HBRUSH, w: i32, h: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetROP2( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetAspectRatioFilterEx( hdc: ?HDC, lpsize: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetBkColor( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetDCBrushColor( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetDCPenColor( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetBkMode( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetBitmapBits( hbit: ?HBITMAP, cb: i32, // TODO: what to do with BytesParamIndex 1? lpvBits: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetBitmapDimensionEx( hbit: ?HBITMAP, lpsize: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetBoundsRect( hdc: ?HDC, lprect: ?*RECT, flags: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetBrushOrgEx( hdc: ?HDC, lppt: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharWidthA( hdc: ?HDC, iFirst: u32, iLast: u32, lpBuffer: ?*i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharWidthW( hdc: ?HDC, iFirst: u32, iLast: u32, lpBuffer: ?*i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharWidth32A( hdc: ?HDC, iFirst: u32, iLast: u32, lpBuffer: ?*i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharWidth32W( hdc: ?HDC, iFirst: u32, iLast: u32, lpBuffer: ?*i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharWidthFloatA( hdc: ?HDC, iFirst: u32, iLast: u32, lpBuffer: ?*f32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharWidthFloatW( hdc: ?HDC, iFirst: u32, iLast: u32, lpBuffer: ?*f32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharABCWidthsA( hdc: ?HDC, wFirst: u32, wLast: u32, lpABC: ?*ABC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharABCWidthsW( hdc: ?HDC, wFirst: u32, wLast: u32, lpABC: ?*ABC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharABCWidthsFloatA( hdc: ?HDC, iFirst: u32, iLast: u32, lpABC: ?*ABCFLOAT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharABCWidthsFloatW( hdc: ?HDC, iFirst: u32, iLast: u32, lpABC: ?*ABCFLOAT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetClipBox( hdc: ?HDC, lprect: ?*RECT, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetClipRgn( hdc: ?HDC, hrgn: ?HRGN, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetMetaRgn( hdc: ?HDC, hrgn: ?HRGN, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCurrentObject( hdc: ?HDC, type: OBJ_TYPE, ) callconv(@import("std").os.windows.WINAPI) ?HGDIOBJ; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCurrentPositionEx( hdc: ?HDC, lppt: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetDeviceCaps( hdc: ?HDC, index: GET_DEVICE_CAPS_INDEX, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetDIBits( hdc: ?HDC, hbm: ?HBITMAP, start: u32, cLines: u32, lpvBits: ?*c_void, lpbmi: ?*BITMAPINFO, usage: DIB_USAGE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetFontData( hdc: ?HDC, dwTable: u32, dwOffset: u32, // TODO: what to do with BytesParamIndex 4? pvBuffer: ?*c_void, cjBuffer: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetGlyphOutlineA( hdc: ?HDC, uChar: u32, fuFormat: GET_GLYPH_OUTLINE_FORMAT, lpgm: ?*GLYPHMETRICS, cjBuffer: u32, // TODO: what to do with BytesParamIndex 4? pvBuffer: ?*c_void, lpmat2: ?*const MAT2, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetGlyphOutlineW( hdc: ?HDC, uChar: u32, fuFormat: GET_GLYPH_OUTLINE_FORMAT, lpgm: ?*GLYPHMETRICS, cjBuffer: u32, // TODO: what to do with BytesParamIndex 4? pvBuffer: ?*c_void, lpmat2: ?*const MAT2, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetGraphicsMode( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetMapMode( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetMetaFileBitsEx( hMF: ?HMETAFILE, cbBuffer: u32, // TODO: what to do with BytesParamIndex 1? lpData: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "GDI32" fn GetMetaFileA( lpName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) ?HMETAFILE; pub extern "GDI32" fn GetMetaFileW( lpName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) ?HMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetNearestColor( hdc: ?HDC, color: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetNearestPaletteIndex( h: ?HPALETTE, color: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetObjectType( h: ?HGDIOBJ, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetOutlineTextMetricsA( hdc: ?HDC, cjCopy: u32, // TODO: what to do with BytesParamIndex 1? potm: ?*OUTLINETEXTMETRICA, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetOutlineTextMetricsW( hdc: ?HDC, cjCopy: u32, // TODO: what to do with BytesParamIndex 1? potm: ?*OUTLINETEXTMETRICW, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetPaletteEntries( hpal: ?HPALETTE, iStart: u32, cEntries: u32, pPalEntries: ?[*]PALETTEENTRY, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetPixel( hdc: ?HDC, x: i32, y: i32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetPolyFillMode( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetRasterizerCaps( // TODO: what to do with BytesParamIndex 1? lpraststat: ?*RASTERIZER_STATUS, cjBytes: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetRandomRgn( hdc: ?HDC, hrgn: ?HRGN, i: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetRegionData( hrgn: ?HRGN, nCount: u32, // TODO: what to do with BytesParamIndex 1? lpRgnData: ?*RGNDATA, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetRgnBox( hrgn: ?HRGN, lprc: ?*RECT, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetStockObject( i: GET_STOCK_OBJECT_FLAGS, ) callconv(@import("std").os.windows.WINAPI) ?HGDIOBJ; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetStretchBltMode( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetSystemPaletteEntries( hdc: ?HDC, iStart: u32, cEntries: u32, pPalEntries: ?[*]PALETTEENTRY, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetSystemPaletteUse( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextCharacterExtra( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextAlign( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextColor( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextExtentPointA( hdc: ?HDC, lpString: [*:0]const u8, c: i32, lpsz: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextExtentPointW( hdc: ?HDC, lpString: [*:0]const u16, c: i32, lpsz: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextExtentPoint32A( hdc: ?HDC, lpString: [*:0]const u8, c: i32, psizl: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextExtentPoint32W( hdc: ?HDC, lpString: [*:0]const u16, c: i32, psizl: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextExtentExPointA( hdc: ?HDC, lpszString: [*:0]const u8, cchString: i32, nMaxExtent: i32, lpnFit: ?*i32, lpnDx: ?[*]i32, lpSize: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextExtentExPointW( hdc: ?HDC, lpszString: [*:0]const u16, cchString: i32, nMaxExtent: i32, lpnFit: ?*i32, lpnDx: ?[*]i32, lpSize: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetFontLanguageInfo( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharacterPlacementA( hdc: ?HDC, lpString: [*:0]const u8, nCount: i32, nMexExtent: i32, lpResults: ?*GCP_RESULTSA, dwFlags: GET_CHARACTER_PLACEMENT_FLAGS, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharacterPlacementW( hdc: ?HDC, lpString: [*:0]const u16, nCount: i32, nMexExtent: i32, lpResults: ?*GCP_RESULTSW, dwFlags: GET_CHARACTER_PLACEMENT_FLAGS, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetFontUnicodeRanges( hdc: ?HDC, lpgs: ?*GLYPHSET, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetGlyphIndicesA( hdc: ?HDC, lpstr: [*:0]const u8, c: i32, pgi: [*:0]u16, fl: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetGlyphIndicesW( hdc: ?HDC, lpstr: [*:0]const u16, c: i32, pgi: [*:0]u16, fl: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextExtentPointI( hdc: ?HDC, pgiIn: [*:0]u16, cgi: i32, psize: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextExtentExPointI( hdc: ?HDC, lpwszString: [*:0]u16, cwchString: i32, nMaxExtent: i32, lpnFit: ?*i32, lpnDx: ?[*]i32, lpSize: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharWidthI( hdc: ?HDC, giFirst: u32, cgi: u32, pgi: ?[*:0]u16, piWidths: [*]i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetCharABCWidthsI( hdc: ?HDC, giFirst: u32, cgi: u32, pgi: ?[*:0]u16, pabc: [*]ABC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn AddFontResourceExA( name: ?[*:0]const u8, fl: FONT_RESOURCE_CHARACTERISTICS, res: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn AddFontResourceExW( name: ?[*:0]const u16, fl: FONT_RESOURCE_CHARACTERISTICS, res: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RemoveFontResourceExA( name: ?[*:0]const u8, fl: u32, pdv: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RemoveFontResourceExW( name: ?[*:0]const u16, fl: u32, pdv: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn AddFontMemResourceEx( // TODO: what to do with BytesParamIndex 1? pFileView: ?*c_void, cjSize: u32, pvResrved: ?*c_void, pNumFonts: ?*u32, ) callconv(@import("std").os.windows.WINAPI) ?HANDLE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RemoveFontMemResourceEx( h: ?HANDLE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateFontIndirectExA( param0: ?*const ENUMLOGFONTEXDVA, ) callconv(@import("std").os.windows.WINAPI) ?HFONT; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateFontIndirectExW( param0: ?*const ENUMLOGFONTEXDVW, ) callconv(@import("std").os.windows.WINAPI) ?HFONT; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetViewportExtEx( hdc: ?HDC, lpsize: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetViewportOrgEx( hdc: ?HDC, lppoint: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetWindowExtEx( hdc: ?HDC, lpsize: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetWindowOrgEx( hdc: ?HDC, lppoint: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn IntersectClipRect( hdc: ?HDC, left: i32, top: i32, right: i32, bottom: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn InvertRgn( hdc: ?HDC, hrgn: ?HRGN, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn LineDDA( xStart: i32, yStart: i32, xEnd: i32, yEnd: i32, lpProc: ?LINEDDAPROC, data: LPARAM, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn LineTo( hdc: ?HDC, x: i32, y: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn MaskBlt( hdcDest: ?HDC, xDest: i32, yDest: i32, width: i32, height: i32, hdcSrc: ?HDC, xSrc: i32, ySrc: i32, hbmMask: ?HBITMAP, xMask: i32, yMask: i32, rop: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PlgBlt( hdcDest: ?HDC, lpPoint: *[3]POINT, hdcSrc: ?HDC, xSrc: i32, ySrc: i32, width: i32, height: i32, hbmMask: ?HBITMAP, xMask: i32, yMask: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn OffsetClipRgn( hdc: ?HDC, x: i32, y: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn OffsetRgn( hrgn: ?HRGN, x: i32, y: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PatBlt( hdc: ?HDC, x: i32, y: i32, w: i32, h: i32, rop: ROP_CODE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn Pie( hdc: ?HDC, left: i32, top: i32, right: i32, bottom: i32, xr1: i32, yr1: i32, xr2: i32, yr2: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PlayMetaFile( hdc: ?HDC, hmf: ?HMETAFILE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PaintRgn( hdc: ?HDC, hrgn: ?HRGN, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PolyPolygon( hdc: ?HDC, apt: ?*const POINT, asz: [*]const i32, csz: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PtInRegion( hrgn: ?HRGN, x: i32, y: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PtVisible( hdc: ?HDC, x: i32, y: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RectInRegion( hrgn: ?HRGN, lprect: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RectVisible( hdc: ?HDC, lprect: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn Rectangle( hdc: ?HDC, left: i32, top: i32, right: i32, bottom: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RestoreDC( hdc: ?HDC, nSavedDC: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ResetDCA( hdc: ?HDC, lpdm: ?*const DEVMODEA, ) callconv(@import("std").os.windows.WINAPI) ?HDC; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ResetDCW( hdc: ?HDC, lpdm: ?*const DEVMODEW, ) callconv(@import("std").os.windows.WINAPI) ?HDC; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RealizePalette( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RemoveFontResourceA( lpFileName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RemoveFontResourceW( lpFileName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn RoundRect( hdc: ?HDC, left: i32, top: i32, right: i32, bottom: i32, width: i32, height: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ResizePalette( hpal: ?HPALETTE, n: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SaveDC( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SelectClipRgn( hdc: ?HDC, hrgn: ?HRGN, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ExtSelectClipRgn( hdc: ?HDC, hrgn: ?HRGN, mode: RGN_COMBINE_MODE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetMetaRgn( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SelectObject( hdc: ?HDC, h: ?HGDIOBJ, ) callconv(@import("std").os.windows.WINAPI) ?HGDIOBJ; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SelectPalette( hdc: ?HDC, hPal: ?HPALETTE, bForceBkgd: BOOL, ) callconv(@import("std").os.windows.WINAPI) ?HPALETTE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetBkColor( hdc: ?HDC, color: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetDCBrushColor( hdc: ?HDC, color: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetDCPenColor( hdc: ?HDC, color: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetBkMode( hdc: ?HDC, mode: BACKGROUND_MODE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetBitmapBits( hbm: ?HBITMAP, cb: u32, // TODO: what to do with BytesParamIndex 1? pvBits: ?*const c_void, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetBoundsRect( hdc: ?HDC, lprect: ?*const RECT, flags: SET_BOUNDS_RECT_FLAGS, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetDIBits( hdc: ?HDC, hbm: ?HBITMAP, start: u32, cLines: u32, lpBits: ?*const c_void, lpbmi: ?*const BITMAPINFO, ColorUse: DIB_USAGE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetDIBitsToDevice( hdc: ?HDC, xDest: i32, yDest: i32, w: u32, h: u32, xSrc: i32, ySrc: i32, StartScan: u32, cLines: u32, lpvBits: ?*const c_void, lpbmi: ?*const BITMAPINFO, ColorUse: DIB_USAGE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetMapperFlags( hdc: ?HDC, flags: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetGraphicsMode( hdc: ?HDC, iMode: GRAPHICS_MODE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetMapMode( hdc: ?HDC, iMode: HDC_MAP_MODE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetLayout( hdc: ?HDC, l: DC_LAYOUT, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetLayout( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetMetaFileBitsEx( cbBuffer: u32, // TODO: what to do with BytesParamIndex 0? lpData: ?*const u8, ) callconv(@import("std").os.windows.WINAPI) ?HMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetPaletteEntries( hpal: ?HPALETTE, iStart: u32, cEntries: u32, pPalEntries: [*]const PALETTEENTRY, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetPixel( hdc: ?HDC, x: i32, y: i32, color: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetPixelV( hdc: ?HDC, x: i32, y: i32, color: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetPolyFillMode( hdc: ?HDC, mode: CREATE_POLYGON_RGN_MODE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn StretchBlt( hdcDest: ?HDC, xDest: i32, yDest: i32, wDest: i32, hDest: i32, hdcSrc: ?HDC, xSrc: i32, ySrc: i32, wSrc: i32, hSrc: i32, rop: ROP_CODE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetRectRgn( hrgn: ?HRGN, left: i32, top: i32, right: i32, bottom: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn StretchDIBits( hdc: ?HDC, xDest: i32, yDest: i32, DestWidth: i32, DestHeight: i32, xSrc: i32, ySrc: i32, SrcWidth: i32, SrcHeight: i32, lpBits: ?*const c_void, lpbmi: ?*const BITMAPINFO, iUsage: DIB_USAGE, rop: ROP_CODE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetROP2( hdc: ?HDC, rop2: R2_MODE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetStretchBltMode( hdc: ?HDC, mode: STRETCH_BLT_MODE, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetSystemPaletteUse( hdc: ?HDC, use: SYSTEM_PALETTE_USE, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetTextCharacterExtra( hdc: ?HDC, extra: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetTextColor( hdc: ?HDC, color: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetTextAlign( hdc: ?HDC, @"align": TEXT_ALIGN_OPTIONS, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetTextJustification( hdc: ?HDC, extra: i32, count: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn UpdateColors( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "MSIMG32" fn AlphaBlend( hdcDest: ?HDC, xoriginDest: i32, yoriginDest: i32, wDest: i32, hDest: i32, hdcSrc: ?HDC, xoriginSrc: i32, yoriginSrc: i32, wSrc: i32, hSrc: i32, ftn: BLENDFUNCTION, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "MSIMG32" fn TransparentBlt( hdcDest: ?HDC, xoriginDest: i32, yoriginDest: i32, wDest: i32, hDest: i32, hdcSrc: ?HDC, xoriginSrc: i32, yoriginSrc: i32, wSrc: i32, hSrc: i32, crTransparent: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "MSIMG32" fn GradientFill( hdc: ?HDC, pVertex: [*]TRIVERTEX, nVertex: u32, pMesh: ?*c_void, nMesh: u32, ulMode: GRADIENT_FILL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GdiAlphaBlend( hdcDest: ?HDC, xoriginDest: i32, yoriginDest: i32, wDest: i32, hDest: i32, hdcSrc: ?HDC, xoriginSrc: i32, yoriginSrc: i32, wSrc: i32, hSrc: i32, ftn: BLENDFUNCTION, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GdiTransparentBlt( hdcDest: ?HDC, xoriginDest: i32, yoriginDest: i32, wDest: i32, hDest: i32, hdcSrc: ?HDC, xoriginSrc: i32, yoriginSrc: i32, wSrc: i32, hSrc: i32, crTransparent: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GdiGradientFill( hdc: ?HDC, pVertex: [*]TRIVERTEX, nVertex: u32, pMesh: ?*c_void, nCount: u32, ulMode: GRADIENT_FILL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PlayMetaFileRecord( hdc: ?HDC, lpHandleTable: [*]HANDLETABLE, lpMR: ?*METARECORD, noObjs: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EnumMetaFile( hdc: ?HDC, hmf: ?HMETAFILE, proc: ?MFENUMPROC, param3: LPARAM, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CloseEnhMetaFile( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) ?HENHMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CopyEnhMetaFileA( hEnh: ?HENHMETAFILE, lpFileName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) ?HENHMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CopyEnhMetaFileW( hEnh: ?HENHMETAFILE, lpFileName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) ?HENHMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateEnhMetaFileA( hdc: ?HDC, lpFilename: ?[*:0]const u8, lprc: ?*const RECT, lpDesc: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) HdcMetdataEnhFileHandle; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateEnhMetaFileW( hdc: ?HDC, lpFilename: ?[*:0]const u16, lprc: ?*const RECT, lpDesc: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) HdcMetdataEnhFileHandle; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn DeleteEnhMetaFile( hmf: ?HENHMETAFILE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EnumEnhMetaFile( hdc: ?HDC, hmf: ?HENHMETAFILE, proc: ?ENHMFENUMPROC, param3: ?*c_void, lpRect: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetEnhMetaFileA( lpName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) ?HENHMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetEnhMetaFileW( lpName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) ?HENHMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetEnhMetaFileBits( hEMF: ?HENHMETAFILE, nSize: u32, // TODO: what to do with BytesParamIndex 1? lpData: ?*u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetEnhMetaFileDescriptionA( hemf: ?HENHMETAFILE, cchBuffer: u32, lpDescription: ?[*:0]u8, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetEnhMetaFileDescriptionW( hemf: ?HENHMETAFILE, cchBuffer: u32, lpDescription: ?[*:0]u16, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetEnhMetaFileHeader( hemf: ?HENHMETAFILE, nSize: u32, // TODO: what to do with BytesParamIndex 1? lpEnhMetaHeader: ?*ENHMETAHEADER, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetEnhMetaFilePaletteEntries( hemf: ?HENHMETAFILE, nNumEntries: u32, lpPaletteEntries: ?[*]PALETTEENTRY, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetWinMetaFileBits( hemf: ?HENHMETAFILE, cbData16: u32, // TODO: what to do with BytesParamIndex 1? pData16: ?*u8, iMapMode: i32, hdcRef: ?HDC, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PlayEnhMetaFile( hdc: ?HDC, hmf: ?HENHMETAFILE, lprect: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PlayEnhMetaFileRecord( hdc: ?HDC, pht: [*]HANDLETABLE, pmr: ?*const ENHMETARECORD, cht: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetEnhMetaFileBits( nSize: u32, // TODO: what to do with BytesParamIndex 0? pb: ?*const u8, ) callconv(@import("std").os.windows.WINAPI) ?HENHMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetWinMetaFileBits( nSize: u32, // TODO: what to do with BytesParamIndex 0? lpMeta16Data: ?*const u8, hdcRef: ?HDC, lpMFP: ?*const METAFILEPICT, ) callconv(@import("std").os.windows.WINAPI) ?HENHMETAFILE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GdiComment( hdc: ?HDC, nSize: u32, // TODO: what to do with BytesParamIndex 1? lpData: ?*const u8, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextMetricsA( hdc: ?HDC, lptm: ?*TEXTMETRICA, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextMetricsW( hdc: ?HDC, lptm: ?*TEXTMETRICW, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn AngleArc( hdc: ?HDC, x: i32, y: i32, r: u32, StartAngle: f32, SweepAngle: f32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PolyPolyline( hdc: ?HDC, apt: ?*const POINT, asz: [*]const u32, csz: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetWorldTransform( hdc: ?HDC, lpxf: ?*XFORM, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetWorldTransform( hdc: ?HDC, lpxf: ?*const XFORM, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ModifyWorldTransform( hdc: ?HDC, lpxf: ?*const XFORM, mode: MODIFY_WORLD_TRANSFORM_MODE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CombineTransform( lpxfOut: ?*XFORM, lpxf1: ?*const XFORM, lpxf2: ?*const XFORM, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateDIBSection( hdc: ?HDC, pbmi: ?*const BITMAPINFO, usage: DIB_USAGE, ppvBits: ?*?*c_void, hSection: ?HANDLE, offset: u32, ) callconv(@import("std").os.windows.WINAPI) ?HBITMAP; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetDIBColorTable( hdc: ?HDC, iStart: u32, cEntries: u32, prgbq: [*]RGBQUAD, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetDIBColorTable( hdc: ?HDC, iStart: u32, cEntries: u32, prgbq: [*]const RGBQUAD, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetColorAdjustment( hdc: ?HDC, lpca: ?*const COLORADJUSTMENT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetColorAdjustment( hdc: ?HDC, lpca: ?*COLORADJUSTMENT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreateHalftonePalette( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) ?HPALETTE; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn AbortPath( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ArcTo( hdc: ?HDC, left: i32, top: i32, right: i32, bottom: i32, xr1: i32, yr1: i32, xr2: i32, yr2: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn BeginPath( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CloseFigure( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn EndPath( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn FillPath( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn FlattenPath( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetPath( hdc: ?HDC, apt: ?[*]POINT, aj: ?[*:0]u8, cpt: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PathToRegion( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) ?HRGN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PolyDraw( hdc: ?HDC, apt: [*]const POINT, aj: [*:0]const u8, cpt: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SelectClipPath( hdc: ?HDC, mode: RGN_COMBINE_MODE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetArcDirection( hdc: ?HDC, dir: ARC_DIRECTION, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetMiterLimit( hdc: ?HDC, limit: f32, old: ?*f32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn StrokeAndFillPath( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn StrokePath( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn WidenPath( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ExtCreatePen( iPenStyle: PEN_STYLE, cWidth: u32, plbrush: ?*const LOGBRUSH, cStyle: u32, pstyle: ?[*]const u32, ) callconv(@import("std").os.windows.WINAPI) ?HPEN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetMiterLimit( hdc: ?HDC, plimit: ?*f32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetArcDirection( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetObjectW( h: ?HGDIOBJ, c: i32, // TODO: what to do with BytesParamIndex 1? pv: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn MoveToEx( hdc: ?HDC, x: i32, y: i32, lppt: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn TextOutA( hdc: ?HDC, x: i32, y: i32, lpString: [*:0]const u8, c: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn TextOutW( hdc: ?HDC, x: i32, y: i32, lpString: [*:0]const u16, c: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ExtTextOutA( hdc: ?HDC, x: i32, y: i32, options: ETO_OPTIONS, lprect: ?*const RECT, lpString: ?[*:0]const u8, c: u32, lpDx: ?[*]const i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ExtTextOutW( hdc: ?HDC, x: i32, y: i32, options: ETO_OPTIONS, lprect: ?*const RECT, lpString: ?[*:0]const u16, c: u32, lpDx: ?[*]const i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PolyTextOutA( hdc: ?HDC, ppt: [*]const POLYTEXTA, nstrings: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PolyTextOutW( hdc: ?HDC, ppt: [*]const POLYTEXTW, nstrings: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn CreatePolygonRgn( pptl: [*]const POINT, cPoint: i32, iMode: CREATE_POLYGON_RGN_MODE, ) callconv(@import("std").os.windows.WINAPI) ?HRGN; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn DPtoLP( hdc: ?HDC, lppt: [*]POINT, c: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn LPtoDP( hdc: ?HDC, lppt: [*]POINT, c: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn Polygon( hdc: ?HDC, apt: [*]const POINT, cpt: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn Polyline( hdc: ?HDC, apt: [*]const POINT, cpt: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PolyBezier( hdc: ?HDC, apt: [*]const POINT, cpt: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PolyBezierTo( hdc: ?HDC, apt: [*]const POINT, cpt: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn PolylineTo( hdc: ?HDC, apt: [*]const POINT, cpt: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetViewportExtEx( hdc: ?HDC, x: i32, y: i32, lpsz: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetViewportOrgEx( hdc: ?HDC, x: i32, y: i32, lppt: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetWindowExtEx( hdc: ?HDC, x: i32, y: i32, lpsz: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetWindowOrgEx( hdc: ?HDC, x: i32, y: i32, lppt: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn OffsetViewportOrgEx( hdc: ?HDC, x: i32, y: i32, lppt: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn OffsetWindowOrgEx( hdc: ?HDC, x: i32, y: i32, lppt: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ScaleViewportExtEx( hdc: ?HDC, xn: i32, dx: i32, yn: i32, yd: i32, lpsz: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn ScaleWindowExtEx( hdc: ?HDC, xn: i32, xd: i32, yn: i32, yd: i32, lpsz: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetBitmapDimensionEx( hbm: ?HBITMAP, w: i32, h: i32, lpsz: ?*SIZE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn SetBrushOrgEx( hdc: ?HDC, x: i32, y: i32, lppt: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextFaceA( hdc: ?HDC, c: i32, lpName: ?[*:0]u8, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetTextFaceW( hdc: ?HDC, c: i32, lpName: ?[*:0]u16, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetKerningPairsA( hdc: ?HDC, nPairs: u32, lpKernPair: ?[*]KERNINGPAIR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetKerningPairsW( hdc: ?HDC, nPairs: u32, lpKernPair: ?[*]KERNINGPAIR, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GetDCOrgEx( hdc: ?HDC, lppt: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; pub extern "GDI32" fn FixBrushOrgEx( hdc: ?HDC, x: i32, y: i32, ptl: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn UnrealizeObject( h: ?HGDIOBJ, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GdiFlush( ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GdiSetBatchLimit( dw: u32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "GDI32" fn GdiGetBatchLimit( ) callconv(@import("std").os.windows.WINAPI) u32; pub extern "OPENGL32" fn wglSwapMultipleBuffers( param0: u32, param1: ?*const WGLSWAP, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "FONTSUB" fn CreateFontPackage( puchSrcBuffer: ?*const u8, ulSrcBufferSize: u32, ppuchFontPackageBuffer: ?*?*u8, pulFontPackageBufferSize: ?*u32, pulBytesWritten: ?*u32, usFlag: u16, usTTCIndex: u16, usSubsetFormat: u16, usSubsetLanguage: u16, usSubsetPlatform: CREATE_FONT_PACKAGE_SUBSET_PLATFORM, usSubsetEncoding: CREATE_FONT_PACKAGE_SUBSET_ENCODING, pusSubsetKeepList: ?*const u16, usSubsetListCount: u16, lpfnAllocate: ?CFP_ALLOCPROC, lpfnReAllocate: ?CFP_REALLOCPROC, lpfnFree: ?CFP_FREEPROC, lpvReserved: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.1.2600' pub extern "FONTSUB" fn MergeFontPackage( puchMergeFontBuffer: ?*const u8, ulMergeFontBufferSize: u32, puchFontPackageBuffer: ?*const u8, ulFontPackageBufferSize: u32, ppuchDestBuffer: ?*?*u8, pulDestBufferSize: ?*u32, pulBytesWritten: ?*u32, usMode: u16, lpfnAllocate: ?CFP_ALLOCPROC, lpfnReAllocate: ?CFP_REALLOCPROC, lpfnFree: ?CFP_FREEPROC, lpvReserved: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTEmbedFont( hDC: ?HDC, ulFlags: TTEMBED_FLAGS, ulCharSet: EMBED_FONT_CHARSET, pulPrivStatus: ?*EMBEDDED_FONT_PRIV_STATUS, pulStatus: ?*u32, lpfnWriteToStream: ?WRITEEMBEDPROC, lpvWriteStream: ?*c_void, pusCharCodeSet: [*:0]u16, usCharCodeCount: u16, usLanguage: u16, pTTEmbedInfo: ?*TTEMBEDINFO, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTEmbedFontFromFileA( hDC: ?HDC, szFontFileName: ?[*:0]const u8, usTTCIndex: u16, ulFlags: TTEMBED_FLAGS, ulCharSet: EMBED_FONT_CHARSET, pulPrivStatus: ?*EMBEDDED_FONT_PRIV_STATUS, pulStatus: ?*u32, lpfnWriteToStream: ?WRITEEMBEDPROC, lpvWriteStream: ?*c_void, pusCharCodeSet: [*:0]u16, usCharCodeCount: u16, usLanguage: u16, pTTEmbedInfo: ?*TTEMBEDINFO, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTLoadEmbeddedFont( phFontReference: ?*?HANDLE, ulFlags: u32, pulPrivStatus: ?*EMBEDDED_FONT_PRIV_STATUS, ulPrivs: FONT_LICENSE_PRIVS, pulStatus: ?*TTLOAD_EMBEDDED_FONT_STATUS, lpfnReadFromStream: ?READEMBEDPROC, lpvReadStream: ?*c_void, szWinFamilyName: ?PWSTR, szMacFamilyName: ?PSTR, pTTLoadInfo: ?*TTLOADINFO, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTGetEmbeddedFontInfo( ulFlags: TTEMBED_FLAGS, pulPrivStatus: ?*u32, ulPrivs: FONT_LICENSE_PRIVS, pulStatus: ?*u32, lpfnReadFromStream: ?READEMBEDPROC, lpvReadStream: ?*c_void, pTTLoadInfo: ?*TTLOADINFO, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTDeleteEmbeddedFont( hFontReference: ?HANDLE, ulFlags: u32, pulStatus: ?*u32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTGetEmbeddingType( hDC: ?HDC, pulEmbedType: ?*EMBEDDED_FONT_PRIV_STATUS, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTCharToUnicode( hDC: ?HDC, pucCharCodes: [*:0]u8, ulCharCodeSize: u32, pusShortCodes: [*:0]u16, ulShortCodeSize: u32, ulFlags: u32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTRunValidationTests( hDC: ?HDC, pTestParam: ?*TTVALIDATIONTESTSPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTIsEmbeddingEnabled( hDC: ?HDC, pbEnabled: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTIsEmbeddingEnabledForFacename( lpszFacename: ?[*:0]const u8, pbEnabled: ?*BOOL, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTEnableEmbeddingForFacename( lpszFacename: ?[*:0]const u8, bEnable: BOOL, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTEmbedFontEx( hDC: ?HDC, ulFlags: TTEMBED_FLAGS, ulCharSet: EMBED_FONT_CHARSET, pulPrivStatus: ?*EMBEDDED_FONT_PRIV_STATUS, pulStatus: ?*u32, lpfnWriteToStream: ?WRITEEMBEDPROC, lpvWriteStream: ?*c_void, pulCharCodeSet: [*]u32, usCharCodeCount: u16, usLanguage: u16, pTTEmbedInfo: ?*TTEMBEDINFO, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTRunValidationTestsEx( hDC: ?HDC, pTestParam: ?*TTVALIDATIONTESTSPARAMSEX, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "t2embed" fn TTGetNewFontName( phFontReference: ?*?HANDLE, wzWinFamilyName: [*:0]u16, cchMaxWinName: i32, szMacFamilyName: [*:0]u8, cchMaxMacName: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawEdge( hdc: ?HDC, qrc: ?*RECT, edge: DRAWEDGE_FLAGS, grfFlags: DRAW_EDGE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawFrameControl( param0: ?HDC, param1: ?*RECT, param2: DFC_TYPE, param3: DFCS_STATE, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawCaption( hwnd: ?HWND, hdc: ?HDC, lprect: ?*const RECT, flags: DRAW_CAPTION_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawAnimatedRects( hwnd: ?HWND, idAni: i32, lprcFrom: ?*const RECT, lprcTo: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawTextA( hdc: ?HDC, lpchText: [*:0]const u8, cchText: i32, lprc: ?*RECT, format: DRAW_TEXT_FORMAT, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawTextW( hdc: ?HDC, lpchText: [*:0]const u16, cchText: i32, lprc: ?*RECT, format: DRAW_TEXT_FORMAT, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawTextExA( hdc: ?HDC, lpchText: [*:0]u8, cchText: i32, lprc: ?*RECT, format: DRAW_TEXT_FORMAT, lpdtp: ?*DRAWTEXTPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawTextExW( hdc: ?HDC, lpchText: [*:0]u16, cchText: i32, lprc: ?*RECT, format: DRAW_TEXT_FORMAT, lpdtp: ?*DRAWTEXTPARAMS, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GrayStringA( hDC: ?HDC, hBrush: ?HBRUSH, lpOutputFunc: ?GRAYSTRINGPROC, lpData: LPARAM, nCount: i32, X: i32, Y: i32, nWidth: i32, nHeight: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GrayStringW( hDC: ?HDC, hBrush: ?HBRUSH, lpOutputFunc: ?GRAYSTRINGPROC, lpData: LPARAM, nCount: i32, X: i32, Y: i32, nWidth: i32, nHeight: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawStateA( hdc: ?HDC, hbrFore: ?HBRUSH, qfnCallBack: ?DRAWSTATEPROC, lData: LPARAM, wData: WPARAM, x: i32, y: i32, cx: i32, cy: i32, uFlags: DRAWSTATE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawStateW( hdc: ?HDC, hbrFore: ?HBRUSH, qfnCallBack: ?DRAWSTATEPROC, lData: LPARAM, wData: WPARAM, x: i32, y: i32, cx: i32, cy: i32, uFlags: DRAWSTATE_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn TabbedTextOutA( hdc: ?HDC, x: i32, y: i32, lpString: [*:0]const u8, chCount: i32, nTabPositions: i32, lpnTabStopPositions: ?[*]const i32, nTabOrigin: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn TabbedTextOutW( hdc: ?HDC, x: i32, y: i32, lpString: [*:0]const u16, chCount: i32, nTabPositions: i32, lpnTabStopPositions: ?[*]const i32, nTabOrigin: i32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetTabbedTextExtentA( hdc: ?HDC, lpString: [*:0]const u8, chCount: i32, nTabPositions: i32, lpnTabStopPositions: ?[*]const i32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetTabbedTextExtentW( hdc: ?HDC, lpString: [*:0]const u16, chCount: i32, nTabPositions: i32, lpnTabStopPositions: ?[*]const i32, ) callconv(@import("std").os.windows.WINAPI) u32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn UpdateWindow( hWnd: ?HWND, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn PaintDesktop( hdc: ?HDC, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn WindowFromDC( hDC: ?HDC, ) callconv(@import("std").os.windows.WINAPI) ?HWND; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetDC( hWnd: ?HWND, ) callconv(@import("std").os.windows.WINAPI) ?HDC; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetDCEx( hWnd: ?HWND, hrgnClip: ?HRGN, flags: GET_DCX_FLAGS, ) callconv(@import("std").os.windows.WINAPI) ?HDC; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetWindowDC( hWnd: ?HWND, ) callconv(@import("std").os.windows.WINAPI) ?HDC; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ReleaseDC( hWnd: ?HWND, hDC: ?HDC, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn BeginPaint( hWnd: ?HWND, lpPaint: ?*PAINTSTRUCT, ) callconv(@import("std").os.windows.WINAPI) ?HDC; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn EndPaint( hWnd: ?HWND, lpPaint: ?*const PAINTSTRUCT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetUpdateRect( hWnd: ?HWND, lpRect: ?*RECT, bErase: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetUpdateRgn( hWnd: ?HWND, hRgn: ?HRGN, bErase: BOOL, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn SetWindowRgn( hWnd: ?HWND, hRgn: ?HRGN, bRedraw: BOOL, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetWindowRgn( hWnd: ?HWND, hRgn: ?HRGN, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetWindowRgnBox( hWnd: ?HWND, lprc: ?*RECT, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ExcludeUpdateRgn( hDC: ?HDC, hWnd: ?HWND, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn InvalidateRect( hWnd: ?HWND, lpRect: ?*const RECT, bErase: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ValidateRect( hWnd: ?HWND, lpRect: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn InvalidateRgn( hWnd: ?HWND, hRgn: ?HRGN, bErase: BOOL, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ValidateRgn( hWnd: ?HWND, hRgn: ?HRGN, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn RedrawWindow( hWnd: ?HWND, lprcUpdate: ?*const RECT, hrgnUpdate: ?HRGN, flags: REDRAW_WINDOW_FLAGS, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn LockWindowUpdate( hWndLock: ?HWND, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ClientToScreen( hWnd: ?HWND, lpPoint: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ScreenToClient( hWnd: ?HWND, lpPoint: ?*POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn MapWindowPoints( hWndFrom: ?HWND, hWndTo: ?HWND, lpPoints: [*]POINT, cPoints: u32, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetSysColorBrush( nIndex: i32, ) callconv(@import("std").os.windows.WINAPI) ?HBRUSH; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn DrawFocusRect( hDC: ?HDC, lprc: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn FillRect( hDC: ?HDC, lprc: ?*const RECT, hbr: ?HBRUSH, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn FrameRect( hDC: ?HDC, lprc: ?*const RECT, hbr: ?HBRUSH, ) callconv(@import("std").os.windows.WINAPI) i32; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn InvertRect( hDC: ?HDC, lprc: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn SetRect( lprc: ?*RECT, xLeft: i32, yTop: i32, xRight: i32, yBottom: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn SetRectEmpty( lprc: ?*RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn CopyRect( lprcDst: ?*RECT, lprcSrc: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn InflateRect( lprc: ?*RECT, dx: i32, dy: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn IntersectRect( lprcDst: ?*RECT, lprcSrc1: ?*const RECT, lprcSrc2: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn UnionRect( lprcDst: ?*RECT, lprcSrc1: ?*const RECT, lprcSrc2: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn SubtractRect( lprcDst: ?*RECT, lprcSrc1: ?*const RECT, lprcSrc2: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn OffsetRect( lprc: ?*RECT, dx: i32, dy: i32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn IsRectEmpty( lprc: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn EqualRect( lprc1: ?*const RECT, lprc2: ?*const RECT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn PtInRect( lprc: ?*const RECT, pt: POINT, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn LoadBitmapA( hInstance: ?HINSTANCE, lpBitmapName: ?[*:0]const u8, ) callconv(@import("std").os.windows.WINAPI) ?HBITMAP; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn LoadBitmapW( hInstance: ?HINSTANCE, lpBitmapName: ?[*:0]const u16, ) callconv(@import("std").os.windows.WINAPI) ?HBITMAP; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ChangeDisplaySettingsA( lpDevMode: ?*DEVMODEA, dwFlags: CDS_TYPE, ) callconv(@import("std").os.windows.WINAPI) DISP_CHANGE; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ChangeDisplaySettingsW( lpDevMode: ?*DEVMODEW, dwFlags: CDS_TYPE, ) callconv(@import("std").os.windows.WINAPI) DISP_CHANGE; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ChangeDisplaySettingsExA( lpszDeviceName: ?[*:0]const u8, lpDevMode: ?*DEVMODEA, hwnd: ?HWND, dwflags: CDS_TYPE, lParam: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) DISP_CHANGE; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn ChangeDisplaySettingsExW( lpszDeviceName: ?[*:0]const u16, lpDevMode: ?*DEVMODEW, hwnd: ?HWND, dwflags: CDS_TYPE, lParam: ?*c_void, ) callconv(@import("std").os.windows.WINAPI) DISP_CHANGE; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn EnumDisplaySettingsA( lpszDeviceName: ?[*:0]const u8, iModeNum: ENUM_DISPLAY_SETTINGS_MODE, lpDevMode: ?*DEVMODEA, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn EnumDisplaySettingsW( lpszDeviceName: ?[*:0]const u16, iModeNum: ENUM_DISPLAY_SETTINGS_MODE, lpDevMode: ?*DEVMODEW, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn EnumDisplaySettingsExA( lpszDeviceName: ?[*:0]const u8, iModeNum: ENUM_DISPLAY_SETTINGS_MODE, lpDevMode: ?*DEVMODEA, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn EnumDisplaySettingsExW( lpszDeviceName: ?[*:0]const u16, iModeNum: ENUM_DISPLAY_SETTINGS_MODE, lpDevMode: ?*DEVMODEW, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn EnumDisplayDevicesA( lpDevice: ?[*:0]const u8, iDevNum: u32, lpDisplayDevice: ?*DISPLAY_DEVICEA, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn EnumDisplayDevicesW( lpDevice: ?[*:0]const u16, iDevNum: u32, lpDisplayDevice: ?*DISPLAY_DEVICEW, dwFlags: u32, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn MonitorFromPoint( pt: POINT, dwFlags: MONITOR_FROM_FLAGS, ) callconv(@import("std").os.windows.WINAPI) ?HMONITOR; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn MonitorFromRect( lprc: ?*RECT, dwFlags: MONITOR_FROM_FLAGS, ) callconv(@import("std").os.windows.WINAPI) ?HMONITOR; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn MonitorFromWindow( hwnd: ?HWND, dwFlags: MONITOR_FROM_FLAGS, ) callconv(@import("std").os.windows.WINAPI) ?HMONITOR; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetMonitorInfoA( hMonitor: ?HMONITOR, lpmi: ?*MONITORINFO, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn GetMonitorInfoW( hMonitor: ?HMONITOR, lpmi: ?*MONITORINFO, ) callconv(@import("std").os.windows.WINAPI) BOOL; // TODO: this type is limited to platform 'windows5.0' pub extern "USER32" fn EnumDisplayMonitors( hdc: ?HDC, lprcClip: ?*RECT, lpfnEnum: ?MONITORENUMPROC, dwData: LPARAM, ) callconv(@import("std").os.windows.WINAPI) BOOL; //-------------------------------------------------------------------------------- // Section: Unicode Aliases (70) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { pub const TEXTMETRIC = thismodule.TEXTMETRICA; pub const NEWTEXTMETRIC = thismodule.NEWTEXTMETRICA; pub const NEWTEXTMETRICEX = thismodule.NEWTEXTMETRICEXA; pub const LOGFONT = thismodule.LOGFONTA; pub const ENUMLOGFONT = thismodule.ENUMLOGFONTA; pub const ENUMLOGFONTEX = thismodule.ENUMLOGFONTEXA; pub const EXTLOGFONT = thismodule.EXTLOGFONTA; pub const DISPLAY_DEVICE = thismodule.DISPLAY_DEVICEA; pub const OUTLINETEXTMETRIC = thismodule.OUTLINETEXTMETRICA; pub const POLYTEXT = thismodule.POLYTEXTA; pub const GCP_RESULTS = thismodule.GCP_RESULTSA; pub const FONTENUMPROC = thismodule.FONTENUMPROCA; pub const AXISINFO = thismodule.AXISINFOA; pub const AXESLIST = thismodule.AXESLISTA; pub const ENUMLOGFONTEXDV = thismodule.ENUMLOGFONTEXDVA; pub const ENUMTEXTMETRIC = thismodule.ENUMTEXTMETRICA; pub const MONITORINFOEX = thismodule.MONITORINFOEXA; pub const GetObject = thismodule.GetObjectA; pub const AddFontResource = thismodule.AddFontResourceA; pub const CopyMetaFile = thismodule.CopyMetaFileA; pub const CreateDC = thismodule.CreateDCA; pub const CreateFontIndirect = thismodule.CreateFontIndirectA; pub const CreateFont = thismodule.CreateFontA; pub const CreateIC = thismodule.CreateICA; pub const CreateMetaFile = thismodule.CreateMetaFileA; pub const CreateScalableFontResource = thismodule.CreateScalableFontResourceA; pub const EnumFontFamiliesEx = thismodule.EnumFontFamiliesExA; pub const EnumFontFamilies = thismodule.EnumFontFamiliesA; pub const EnumFonts = thismodule.EnumFontsA; pub const GetCharWidth = thismodule.GetCharWidthA; pub const GetCharWidth32 = thismodule.GetCharWidth32A; pub const GetCharWidthFloat = thismodule.GetCharWidthFloatA; pub const GetCharABCWidths = thismodule.GetCharABCWidthsA; pub const GetCharABCWidthsFloat = thismodule.GetCharABCWidthsFloatA; pub const GetGlyphOutline = thismodule.GetGlyphOutlineA; pub const GetMetaFile = thismodule.GetMetaFileA; pub const GetOutlineTextMetrics = thismodule.GetOutlineTextMetricsA; pub const GetTextExtentPoint = thismodule.GetTextExtentPointA; pub const GetTextExtentPoint32 = thismodule.GetTextExtentPoint32A; pub const GetTextExtentExPoint = thismodule.GetTextExtentExPointA; pub const GetCharacterPlacement = thismodule.GetCharacterPlacementA; pub const GetGlyphIndices = thismodule.GetGlyphIndicesA; pub const AddFontResourceEx = thismodule.AddFontResourceExA; pub const RemoveFontResourceEx = thismodule.RemoveFontResourceExA; pub const CreateFontIndirectEx = thismodule.CreateFontIndirectExA; pub const ResetDC = thismodule.ResetDCA; pub const RemoveFontResource = thismodule.RemoveFontResourceA; pub const CopyEnhMetaFile = thismodule.CopyEnhMetaFileA; pub const CreateEnhMetaFile = thismodule.CreateEnhMetaFileA; pub const GetEnhMetaFile = thismodule.GetEnhMetaFileA; pub const GetEnhMetaFileDescription = thismodule.GetEnhMetaFileDescriptionA; pub const GetTextMetrics = thismodule.GetTextMetricsA; pub const TextOut = thismodule.TextOutA; pub const ExtTextOut = thismodule.ExtTextOutA; pub const PolyTextOut = thismodule.PolyTextOutA; pub const GetTextFace = thismodule.GetTextFaceA; pub const GetKerningPairs = thismodule.GetKerningPairsA; pub const DrawText = thismodule.DrawTextA; pub const DrawTextEx = thismodule.DrawTextExA; pub const GrayString = thismodule.GrayStringA; pub const DrawState = thismodule.DrawStateA; pub const TabbedTextOut = thismodule.TabbedTextOutA; pub const GetTabbedTextExtent = thismodule.GetTabbedTextExtentA; pub const LoadBitmap = thismodule.LoadBitmapA; pub const ChangeDisplaySettings = thismodule.ChangeDisplaySettingsA; pub const ChangeDisplaySettingsEx = thismodule.ChangeDisplaySettingsExA; pub const EnumDisplaySettings = thismodule.EnumDisplaySettingsA; pub const EnumDisplaySettingsEx = thismodule.EnumDisplaySettingsExA; pub const EnumDisplayDevices = thismodule.EnumDisplayDevicesA; pub const GetMonitorInfo = thismodule.GetMonitorInfoA; }, .wide => struct { pub const TEXTMETRIC = thismodule.TEXTMETRICW; pub const NEWTEXTMETRIC = thismodule.NEWTEXTMETRICW; pub const NEWTEXTMETRICEX = thismodule.NEWTEXTMETRICEXW; pub const LOGFONT = thismodule.LOGFONTW; pub const ENUMLOGFONT = thismodule.ENUMLOGFONTW; pub const ENUMLOGFONTEX = thismodule.ENUMLOGFONTEXW; pub const EXTLOGFONT = thismodule.EXTLOGFONTW; pub const DISPLAY_DEVICE = thismodule.DISPLAY_DEVICEW; pub const OUTLINETEXTMETRIC = thismodule.OUTLINETEXTMETRICW; pub const POLYTEXT = thismodule.POLYTEXTW; pub const GCP_RESULTS = thismodule.GCP_RESULTSW; pub const FONTENUMPROC = thismodule.FONTENUMPROCW; pub const AXISINFO = thismodule.AXISINFOW; pub const AXESLIST = thismodule.AXESLISTW; pub const ENUMLOGFONTEXDV = thismodule.ENUMLOGFONTEXDVW; pub const ENUMTEXTMETRIC = thismodule.ENUMTEXTMETRICW; pub const MONITORINFOEX = thismodule.MONITORINFOEXW; pub const GetObject = thismodule.GetObjectW; pub const AddFontResource = thismodule.AddFontResourceW; pub const CopyMetaFile = thismodule.CopyMetaFileW; pub const CreateDC = thismodule.CreateDCW; pub const CreateFontIndirect = thismodule.CreateFontIndirectW; pub const CreateFont = thismodule.CreateFontW; pub const CreateIC = thismodule.CreateICW; pub const CreateMetaFile = thismodule.CreateMetaFileW; pub const CreateScalableFontResource = thismodule.CreateScalableFontResourceW; pub const EnumFontFamiliesEx = thismodule.EnumFontFamiliesExW; pub const EnumFontFamilies = thismodule.EnumFontFamiliesW; pub const EnumFonts = thismodule.EnumFontsW; pub const GetCharWidth = thismodule.GetCharWidthW; pub const GetCharWidth32 = thismodule.GetCharWidth32W; pub const GetCharWidthFloat = thismodule.GetCharWidthFloatW; pub const GetCharABCWidths = thismodule.GetCharABCWidthsW; pub const GetCharABCWidthsFloat = thismodule.GetCharABCWidthsFloatW; pub const GetGlyphOutline = thismodule.GetGlyphOutlineW; pub const GetMetaFile = thismodule.GetMetaFileW; pub const GetOutlineTextMetrics = thismodule.GetOutlineTextMetricsW; pub const GetTextExtentPoint = thismodule.GetTextExtentPointW; pub const GetTextExtentPoint32 = thismodule.GetTextExtentPoint32W; pub const GetTextExtentExPoint = thismodule.GetTextExtentExPointW; pub const GetCharacterPlacement = thismodule.GetCharacterPlacementW; pub const GetGlyphIndices = thismodule.GetGlyphIndicesW; pub const AddFontResourceEx = thismodule.AddFontResourceExW; pub const RemoveFontResourceEx = thismodule.RemoveFontResourceExW; pub const CreateFontIndirectEx = thismodule.CreateFontIndirectExW; pub const ResetDC = thismodule.ResetDCW; pub const RemoveFontResource = thismodule.RemoveFontResourceW; pub const CopyEnhMetaFile = thismodule.CopyEnhMetaFileW; pub const CreateEnhMetaFile = thismodule.CreateEnhMetaFileW; pub const GetEnhMetaFile = thismodule.GetEnhMetaFileW; pub const GetEnhMetaFileDescription = thismodule.GetEnhMetaFileDescriptionW; pub const GetTextMetrics = thismodule.GetTextMetricsW; pub const TextOut = thismodule.TextOutW; pub const ExtTextOut = thismodule.ExtTextOutW; pub const PolyTextOut = thismodule.PolyTextOutW; pub const GetTextFace = thismodule.GetTextFaceW; pub const GetKerningPairs = thismodule.GetKerningPairsW; pub const DrawText = thismodule.DrawTextW; pub const DrawTextEx = thismodule.DrawTextExW; pub const GrayString = thismodule.GrayStringW; pub const DrawState = thismodule.DrawStateW; pub const TabbedTextOut = thismodule.TabbedTextOutW; pub const GetTabbedTextExtent = thismodule.GetTabbedTextExtentW; pub const LoadBitmap = thismodule.LoadBitmapW; pub const ChangeDisplaySettings = thismodule.ChangeDisplaySettingsW; pub const ChangeDisplaySettingsEx = thismodule.ChangeDisplaySettingsExW; pub const EnumDisplaySettings = thismodule.EnumDisplaySettingsW; pub const EnumDisplaySettingsEx = thismodule.EnumDisplaySettingsExW; pub const EnumDisplayDevices = thismodule.EnumDisplayDevicesW; pub const GetMonitorInfo = thismodule.GetMonitorInfoW; }, .unspecified => if (@import("builtin").is_test) struct { pub const TEXTMETRIC = *opaque{}; pub const NEWTEXTMETRIC = *opaque{}; pub const NEWTEXTMETRICEX = *opaque{}; pub const LOGFONT = *opaque{}; pub const ENUMLOGFONT = *opaque{}; pub const ENUMLOGFONTEX = *opaque{}; pub const EXTLOGFONT = *opaque{}; pub const DISPLAY_DEVICE = *opaque{}; pub const OUTLINETEXTMETRIC = *opaque{}; pub const POLYTEXT = *opaque{}; pub const GCP_RESULTS = *opaque{}; pub const FONTENUMPROC = *opaque{}; pub const AXISINFO = *opaque{}; pub const AXESLIST = *opaque{}; pub const ENUMLOGFONTEXDV = *opaque{}; pub const ENUMTEXTMETRIC = *opaque{}; pub const MONITORINFOEX = *opaque{}; pub const GetObject = *opaque{}; pub const AddFontResource = *opaque{}; pub const CopyMetaFile = *opaque{}; pub const CreateDC = *opaque{}; pub const CreateFontIndirect = *opaque{}; pub const CreateFont = *opaque{}; pub const CreateIC = *opaque{}; pub const CreateMetaFile = *opaque{}; pub const CreateScalableFontResource = *opaque{}; pub const EnumFontFamiliesEx = *opaque{}; pub const EnumFontFamilies = *opaque{}; pub const EnumFonts = *opaque{}; pub const GetCharWidth = *opaque{}; pub const GetCharWidth32 = *opaque{}; pub const GetCharWidthFloat = *opaque{}; pub const GetCharABCWidths = *opaque{}; pub const GetCharABCWidthsFloat = *opaque{}; pub const GetGlyphOutline = *opaque{}; pub const GetMetaFile = *opaque{}; pub const GetOutlineTextMetrics = *opaque{}; pub const GetTextExtentPoint = *opaque{}; pub const GetTextExtentPoint32 = *opaque{}; pub const GetTextExtentExPoint = *opaque{}; pub const GetCharacterPlacement = *opaque{}; pub const GetGlyphIndices = *opaque{}; pub const AddFontResourceEx = *opaque{}; pub const RemoveFontResourceEx = *opaque{}; pub const CreateFontIndirectEx = *opaque{}; pub const ResetDC = *opaque{}; pub const RemoveFontResource = *opaque{}; pub const CopyEnhMetaFile = *opaque{}; pub const CreateEnhMetaFile = *opaque{}; pub const GetEnhMetaFile = *opaque{}; pub const GetEnhMetaFileDescription = *opaque{}; pub const GetTextMetrics = *opaque{}; pub const TextOut = *opaque{}; pub const ExtTextOut = *opaque{}; pub const PolyTextOut = *opaque{}; pub const GetTextFace = *opaque{}; pub const GetKerningPairs = *opaque{}; pub const DrawText = *opaque{}; pub const DrawTextEx = *opaque{}; pub const GrayString = *opaque{}; pub const DrawState = *opaque{}; pub const TabbedTextOut = *opaque{}; pub const GetTabbedTextExtent = *opaque{}; pub const LoadBitmap = *opaque{}; pub const ChangeDisplaySettings = *opaque{}; pub const ChangeDisplaySettingsEx = *opaque{}; pub const EnumDisplaySettings = *opaque{}; pub const EnumDisplaySettingsEx = *opaque{}; pub const EnumDisplayDevices = *opaque{}; pub const GetMonitorInfo = *opaque{}; } else struct { pub const TEXTMETRIC = @compileError("'TEXTMETRIC' requires that UNICODE be set to true or false in the root module"); pub const NEWTEXTMETRIC = @compileError("'NEWTEXTMETRIC' requires that UNICODE be set to true or false in the root module"); pub const NEWTEXTMETRICEX = @compileError("'NEWTEXTMETRICEX' requires that UNICODE be set to true or false in the root module"); pub const LOGFONT = @compileError("'LOGFONT' requires that UNICODE be set to true or false in the root module"); pub const ENUMLOGFONT = @compileError("'ENUMLOGFONT' requires that UNICODE be set to true or false in the root module"); pub const ENUMLOGFONTEX = @compileError("'ENUMLOGFONTEX' requires that UNICODE be set to true or false in the root module"); pub const EXTLOGFONT = @compileError("'EXTLOGFONT' requires that UNICODE be set to true or false in the root module"); pub const DISPLAY_DEVICE = @compileError("'DISPLAY_DEVICE' requires that UNICODE be set to true or false in the root module"); pub const OUTLINETEXTMETRIC = @compileError("'OUTLINETEXTMETRIC' requires that UNICODE be set to true or false in the root module"); pub const POLYTEXT = @compileError("'POLYTEXT' requires that UNICODE be set to true or false in the root module"); pub const GCP_RESULTS = @compileError("'GCP_RESULTS' requires that UNICODE be set to true or false in the root module"); pub const FONTENUMPROC = @compileError("'FONTENUMPROC' requires that UNICODE be set to true or false in the root module"); pub const AXISINFO = @compileError("'AXISINFO' requires that UNICODE be set to true or false in the root module"); pub const AXESLIST = @compileError("'AXESLIST' requires that UNICODE be set to true or false in the root module"); pub const ENUMLOGFONTEXDV = @compileError("'ENUMLOGFONTEXDV' requires that UNICODE be set to true or false in the root module"); pub const ENUMTEXTMETRIC = @compileError("'ENUMTEXTMETRIC' requires that UNICODE be set to true or false in the root module"); pub const MONITORINFOEX = @compileError("'MONITORINFOEX' requires that UNICODE be set to true or false in the root module"); pub const GetObject = @compileError("'GetObject' requires that UNICODE be set to true or false in the root module"); pub const AddFontResource = @compileError("'AddFontResource' requires that UNICODE be set to true or false in the root module"); pub const CopyMetaFile = @compileError("'CopyMetaFile' requires that UNICODE be set to true or false in the root module"); pub const CreateDC = @compileError("'CreateDC' requires that UNICODE be set to true or false in the root module"); pub const CreateFontIndirect = @compileError("'CreateFontIndirect' requires that UNICODE be set to true or false in the root module"); pub const CreateFont = @compileError("'CreateFont' requires that UNICODE be set to true or false in the root module"); pub const CreateIC = @compileError("'CreateIC' requires that UNICODE be set to true or false in the root module"); pub const CreateMetaFile = @compileError("'CreateMetaFile' requires that UNICODE be set to true or false in the root module"); pub const CreateScalableFontResource = @compileError("'CreateScalableFontResource' requires that UNICODE be set to true or false in the root module"); pub const EnumFontFamiliesEx = @compileError("'EnumFontFamiliesEx' requires that UNICODE be set to true or false in the root module"); pub const EnumFontFamilies = @compileError("'EnumFontFamilies' requires that UNICODE be set to true or false in the root module"); pub const EnumFonts = @compileError("'EnumFonts' requires that UNICODE be set to true or false in the root module"); pub const GetCharWidth = @compileError("'GetCharWidth' requires that UNICODE be set to true or false in the root module"); pub const GetCharWidth32 = @compileError("'GetCharWidth32' requires that UNICODE be set to true or false in the root module"); pub const GetCharWidthFloat = @compileError("'GetCharWidthFloat' requires that UNICODE be set to true or false in the root module"); pub const GetCharABCWidths = @compileError("'GetCharABCWidths' requires that UNICODE be set to true or false in the root module"); pub const GetCharABCWidthsFloat = @compileError("'GetCharABCWidthsFloat' requires that UNICODE be set to true or false in the root module"); pub const GetGlyphOutline = @compileError("'GetGlyphOutline' requires that UNICODE be set to true or false in the root module"); pub const GetMetaFile = @compileError("'GetMetaFile' requires that UNICODE be set to true or false in the root module"); pub const GetOutlineTextMetrics = @compileError("'GetOutlineTextMetrics' requires that UNICODE be set to true or false in the root module"); pub const GetTextExtentPoint = @compileError("'GetTextExtentPoint' requires that UNICODE be set to true or false in the root module"); pub const GetTextExtentPoint32 = @compileError("'GetTextExtentPoint32' requires that UNICODE be set to true or false in the root module"); pub const GetTextExtentExPoint = @compileError("'GetTextExtentExPoint' requires that UNICODE be set to true or false in the root module"); pub const GetCharacterPlacement = @compileError("'GetCharacterPlacement' requires that UNICODE be set to true or false in the root module"); pub const GetGlyphIndices = @compileError("'GetGlyphIndices' requires that UNICODE be set to true or false in the root module"); pub const AddFontResourceEx = @compileError("'AddFontResourceEx' requires that UNICODE be set to true or false in the root module"); pub const RemoveFontResourceEx = @compileError("'RemoveFontResourceEx' requires that UNICODE be set to true or false in the root module"); pub const CreateFontIndirectEx = @compileError("'CreateFontIndirectEx' requires that UNICODE be set to true or false in the root module"); pub const ResetDC = @compileError("'ResetDC' requires that UNICODE be set to true or false in the root module"); pub const RemoveFontResource = @compileError("'RemoveFontResource' requires that UNICODE be set to true or false in the root module"); pub const CopyEnhMetaFile = @compileError("'CopyEnhMetaFile' requires that UNICODE be set to true or false in the root module"); pub const CreateEnhMetaFile = @compileError("'CreateEnhMetaFile' requires that UNICODE be set to true or false in the root module"); pub const GetEnhMetaFile = @compileError("'GetEnhMetaFile' requires that UNICODE be set to true or false in the root module"); pub const GetEnhMetaFileDescription = @compileError("'GetEnhMetaFileDescription' requires that UNICODE be set to true or false in the root module"); pub const GetTextMetrics = @compileError("'GetTextMetrics' requires that UNICODE be set to true or false in the root module"); pub const TextOut = @compileError("'TextOut' requires that UNICODE be set to true or false in the root module"); pub const ExtTextOut = @compileError("'ExtTextOut' requires that UNICODE be set to true or false in the root module"); pub const PolyTextOut = @compileError("'PolyTextOut' requires that UNICODE be set to true or false in the root module"); pub const GetTextFace = @compileError("'GetTextFace' requires that UNICODE be set to true or false in the root module"); pub const GetKerningPairs = @compileError("'GetKerningPairs' requires that UNICODE be set to true or false in the root module"); pub const DrawText = @compileError("'DrawText' requires that UNICODE be set to true or false in the root module"); pub const DrawTextEx = @compileError("'DrawTextEx' requires that UNICODE be set to true or false in the root module"); pub const GrayString = @compileError("'GrayString' requires that UNICODE be set to true or false in the root module"); pub const DrawState = @compileError("'DrawState' requires that UNICODE be set to true or false in the root module"); pub const TabbedTextOut = @compileError("'TabbedTextOut' requires that UNICODE be set to true or false in the root module"); pub const GetTabbedTextExtent = @compileError("'GetTabbedTextExtent' requires that UNICODE be set to true or false in the root module"); pub const LoadBitmap = @compileError("'LoadBitmap' requires that UNICODE be set to true or false in the root module"); pub const ChangeDisplaySettings = @compileError("'ChangeDisplaySettings' requires that UNICODE be set to true or false in the root module"); pub const ChangeDisplaySettingsEx = @compileError("'ChangeDisplaySettingsEx' requires that UNICODE be set to true or false in the root module"); pub const EnumDisplaySettings = @compileError("'EnumDisplaySettings' requires that UNICODE be set to true or false in the root module"); pub const EnumDisplaySettingsEx = @compileError("'EnumDisplaySettingsEx' requires that UNICODE be set to true or false in the root module"); pub const EnumDisplayDevices = @compileError("'EnumDisplayDevices' requires that UNICODE be set to true or false in the root module"); pub const GetMonitorInfo = @compileError("'GetMonitorInfo' requires that UNICODE be set to true or false in the root module"); }, }; //-------------------------------------------------------------------------------- // Section: Imports (25) //-------------------------------------------------------------------------------- const BOOL = @import("../foundation.zig").BOOL; const CHAR = @import("../system/system_services.zig").CHAR; const CIEXYZTRIPLE = @import("../ui/color_system.zig").CIEXYZTRIPLE; const DEVMODEA = @import("../ui/display_devices.zig").DEVMODEA; const DEVMODEW = @import("../ui/display_devices.zig").DEVMODEW; const DISPLAYCONFIG_DEVICE_INFO_HEADER = @import("../ui/display_devices.zig").DISPLAYCONFIG_DEVICE_INFO_HEADER; const FONTSIGNATURE = @import("../globalization.zig").FONTSIGNATURE; const HANDLE = @import("../foundation.zig").HANDLE; const HINSTANCE = @import("../foundation.zig").HINSTANCE; const HWND = @import("../foundation.zig").HWND; const LOGCOLORSPACEA = @import("../ui/color_system.zig").LOGCOLORSPACEA; const LOGCOLORSPACEW = @import("../ui/color_system.zig").LOGCOLORSPACEW; const LPARAM = @import("../foundation.zig").LPARAM; const METAFILEPICT = @import("../system/data_exchange.zig").METAFILEPICT; const PIXELFORMATDESCRIPTOR = @import("../graphics/open_gl.zig").PIXELFORMATDESCRIPTOR; const POINT = @import("../foundation.zig").POINT; const POINTL = @import("../foundation.zig").POINTL; const POINTS = @import("../foundation.zig").POINTS; const PSTR = @import("../foundation.zig").PSTR; const PWSTR = @import("../foundation.zig").PWSTR; const RECT = @import("../foundation.zig").RECT; const RECTL = @import("../foundation.zig").RECTL; const SIZE = @import("../foundation.zig").SIZE; const TEXT_ALIGN_OPTIONS = @import("../ui/controls.zig").TEXT_ALIGN_OPTIONS; const WPARAM = @import("../foundation.zig").WPARAM; test { // The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476 if (@hasDecl(@This(), "FONTENUMPROCA")) { _ = FONTENUMPROCA; } if (@hasDecl(@This(), "FONTENUMPROCW")) { _ = FONTENUMPROCW; } if (@hasDecl(@This(), "GOBJENUMPROC")) { _ = GOBJENUMPROC; } if (@hasDecl(@This(), "LINEDDAPROC")) { _ = LINEDDAPROC; } if (@hasDecl(@This(), "LPFNDEVMODE")) { _ = LPFNDEVMODE; } if (@hasDecl(@This(), "LPFNDEVCAPS")) { _ = LPFNDEVCAPS; } if (@hasDecl(@This(), "MFENUMPROC")) { _ = MFENUMPROC; } if (@hasDecl(@This(), "ENHMFENUMPROC")) { _ = ENHMFENUMPROC; } if (@hasDecl(@This(), "CFP_ALLOCPROC")) { _ = CFP_ALLOCPROC; } if (@hasDecl(@This(), "CFP_REALLOCPROC")) { _ = CFP_REALLOCPROC; } if (@hasDecl(@This(), "CFP_FREEPROC")) { _ = CFP_FREEPROC; } if (@hasDecl(@This(), "READEMBEDPROC")) { _ = READEMBEDPROC; } if (@hasDecl(@This(), "WRITEEMBEDPROC")) { _ = WRITEEMBEDPROC; } if (@hasDecl(@This(), "GRAYSTRINGPROC")) { _ = GRAYSTRINGPROC; } if (@hasDecl(@This(), "DRAWSTATEPROC")) { _ = DRAWSTATEPROC; } if (@hasDecl(@This(), "MONITORENUMPROC")) { _ = MONITORENUMPROC; } @setEvalBranchQuota( @import("std").meta.declarations(@This()).len * 3 ); // reference all the pub declarations if (!@import("builtin").is_test) return; inline for (@import("std").meta.declarations(@This())) |decl| { if (decl.is_pub) { _ = decl; } } }
deps/zigwin32/win32/graphics/gdi.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const assert = std.debug.assert; const leb = std.leb; const mem = std.mem; const Module = @import("../Module.zig"); const Decl = Module.Decl; const Inst = @import("../ir.zig").Inst; const Type = @import("../type.zig").Type; const Value = @import("../value.zig").Value; fn genValtype(ty: Type) u8 { return switch (ty.tag()) { .u32, .i32 => 0x7F, .u64, .i64 => 0x7E, .f32 => 0x7D, .f64 => 0x7C, else => @panic("TODO: Implement more types for wasm."), }; } pub fn genFunctype(buf: *ArrayList(u8), decl: *Decl) !void { const ty = decl.typed_value.most_recent.typed_value.ty; const writer = buf.writer(); // functype magic try writer.writeByte(0x60); // param types try leb.writeULEB128(writer, @intCast(u32, ty.fnParamLen())); if (ty.fnParamLen() != 0) { const params = try buf.allocator.alloc(Type, ty.fnParamLen()); defer buf.allocator.free(params); ty.fnParamTypes(params); for (params) |param_type| try writer.writeByte(genValtype(param_type)); } // return type const return_type = ty.fnReturnType(); switch (return_type.tag()) { .void, .noreturn => try leb.writeULEB128(writer, @as(u32, 0)), else => { try leb.writeULEB128(writer, @as(u32, 1)); try writer.writeByte(genValtype(return_type)); }, } } pub fn genCode(buf: *ArrayList(u8), decl: *Decl) !void { assert(buf.items.len == 0); const writer = buf.writer(); // Reserve space to write the size after generating the code try buf.resize(5); // Write the size of the locals vec // TODO: implement locals try leb.writeULEB128(writer, @as(u32, 0)); // Write instructions // TODO: check for and handle death of instructions const tv = decl.typed_value.most_recent.typed_value; const mod_fn = tv.val.cast(Value.Payload.Function).?.func; for (mod_fn.analysis.success.instructions) |inst| try genInst(buf, decl, inst); // Write 'end' opcode try writer.writeByte(0x0B); // Fill in the size of the generated code to the reserved space at the // beginning of the buffer. const size = buf.items.len - 5 + decl.fn_link.wasm.?.idx_refs.items.len * 5; leb.writeUnsignedFixed(5, buf.items[0..5], @intCast(u32, size)); } fn genInst(buf: *ArrayList(u8), decl: *Decl, inst: *Inst) !void { return switch (inst.tag) { .call => genCall(buf, decl, inst.castTag(.call).?), .constant => genConstant(buf, decl, inst.castTag(.constant).?), .dbg_stmt => {}, .ret => genRet(buf, decl, inst.castTag(.ret).?), .retvoid => {}, else => error.TODOImplementMoreWasmCodegen, }; } fn genConstant(buf: *ArrayList(u8), decl: *Decl, inst: *Inst.Constant) !void { const writer = buf.writer(); switch (inst.base.ty.tag()) { .u32 => { try writer.writeByte(0x41); // i32.const try leb.writeILEB128(writer, inst.val.toUnsignedInt()); }, .i32 => { try writer.writeByte(0x41); // i32.const try leb.writeILEB128(writer, inst.val.toSignedInt()); }, .u64 => { try writer.writeByte(0x42); // i64.const try leb.writeILEB128(writer, inst.val.toUnsignedInt()); }, .i64 => { try writer.writeByte(0x42); // i64.const try leb.writeILEB128(writer, inst.val.toSignedInt()); }, .f32 => { try writer.writeByte(0x43); // f32.const // TODO: enforce LE byte order try writer.writeAll(mem.asBytes(&inst.val.toFloat(f32))); }, .f64 => { try writer.writeByte(0x44); // f64.const // TODO: enforce LE byte order try writer.writeAll(mem.asBytes(&inst.val.toFloat(f64))); }, .void => {}, else => return error.TODOImplementMoreWasmCodegen, } } fn genRet(buf: *ArrayList(u8), decl: *Decl, inst: *Inst.UnOp) !void { try genInst(buf, decl, inst.operand); } fn genCall(buf: *ArrayList(u8), decl: *Decl, inst: *Inst.Call) !void { const func_inst = inst.func.castTag(.constant).?; const func_val = func_inst.val.cast(Value.Payload.Function).?; const target = func_val.func.owner_decl; const target_ty = target.typed_value.most_recent.typed_value.ty; if (inst.args.len != 0) return error.TODOImplementMoreWasmCodegen; try buf.append(0x10); // call // The function index immediate argument will be filled in using this data // in link.Wasm.flush(). try decl.fn_link.wasm.?.idx_refs.append(buf.allocator, .{ .offset = @intCast(u32, buf.items.len), .decl = target, }); }
src/codegen/wasm.zig
const std = @import("std"); const fs = std.fs; const io = std.io; const info = std.log.info; const print = std.debug.print; const fmt = std.fmt; const ArrayList = std.ArrayList; const assert = std.debug.assert; const utils = @import("utils.zig"); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const DIM: usize = 10; const Edge = enum { left, right, top, bot }; const Tile = struct { id: usize, data: [DIM][DIM]u8 = undefined, top_link: ?*Tile = null, bot_link: ?*Tile = null, left_link: ?*Tile = null, right_link: ?*Tile = null, pub fn init(line: []const u8) !Tile { const id = try std.fmt.parseInt(usize, line[5 .. line.len - 1], 10); return Tile{ .id = id }; } pub fn load_line(self: *Tile, line: []const u8, row: usize) !void { std.mem.copy(u8, self.data[row][0..], line[0..line.len]); } fn can_transform(self: *Tile) bool { return self.top_link == null and self.left_link == null and self.right_link == null and self.bot_link == null; } fn rotate_r(self: *Tile) void { var new_data: [DIM][DIM]u8 = undefined; var i: usize = 0; while (i < DIM) : (i += 1) { var j: usize = 0; while (j < DIM) : (j += 1) { new_data[i][j] = self.data[DIM - j - 1][i]; } } var k: usize = 0; while (k < DIM) : (k += 1) { std.mem.copy(u8, &self.data[k], &new_data[k]); } } fn flip_v(self: *Tile) void { for (self.data) |*row| { std.mem.reverse(u8, row); } } fn flip_h(self: *Tile) void { std.mem.reverse([DIM]u8, &self.data); } pub fn match_edge(self: *Tile, target: [DIM]u8, edge: Edge) bool { var buf: [DIM]u8 = undefined; var i: usize = 0; while (i < 4) : (i += 1) { self.get_edge(edge, &buf); if (std.mem.eql(u8, &target, &buf)) return true; if (!self.can_transform()) { // can't transform this piece break; } self.flip_v(); self.get_edge(edge, &buf); if (std.mem.eql(u8, &target, &buf)) return true; self.flip_h(); self.get_edge(edge, &buf); if (std.mem.eql(u8, &target, &buf)) return true; self.flip_v(); self.get_edge(edge, &buf); if (std.mem.eql(u8, &target, &buf)) return true; self.flip_h(); // restore self.rotate_r(); } return false; } pub fn get_edge(self: *Tile, edge: Edge, output: []u8) void { _ = switch (edge) { .top => std.mem.copy(u8, output, &self.data[0]), .bot => std.mem.copy(u8, output, &self.data[DIM - 1]), .left => for (self.data) |row, i| { output[i] = row[0]; }, .right => for (self.data) |row, i| { output[i] = row[DIM - 1]; }, }; } pub fn count_neighbors(self: *Tile) usize { var result: usize = 0; if (self.top_link != null) result += 1; if (self.bot_link != null) result += 1; if (self.left_link != null) result += 1; if (self.right_link != null) result += 1; return result; } pub fn process(self: *Tile, others: []Tile) void { var buf: [DIM]u8 = undefined; for (others) |*other| { if (other.id == self.id) continue; // the 4 blocks are _ugly_ self.get_edge(.top, &buf); if (self.top_link == null and other.bot_link == null and other.match_edge(buf, .bot)) { assert(other.bot_link == null); self.top_link = other; other.bot_link = self; other.process(others); continue; } self.get_edge(.bot, &buf); if (self.bot_link == null and other.top_link == null and other.match_edge(buf, .top)) { assert(other.top_link == null); self.bot_link = other; other.top_link = self; other.process(others); continue; } self.get_edge(.left, &buf); if (self.left_link == null and other.right_link == null and other.match_edge(buf, .right)) { assert(other.right_link == null); self.left_link = other; other.right_link = self; other.process(others); continue; } self.get_edge(.right, &buf); if (self.right_link == null and other.left_link == null and other.match_edge(buf, .left)) { assert(other.left_link == null); self.right_link = other; other.left_link = self; other.process(others); continue; } } } pub fn distance_from_top(self: *Tile) usize { if (self.top_link == null) { return 0; } else { return (self.top_link orelse unreachable).distance_from_top() + 1; } } pub fn distance_from_left(self: *Tile) usize { if (self.left_link == null) { return 0; } else { return (self.left_link orelse unreachable).distance_from_left() + 1; } } }; pub fn rotate_2d_matrix(allo: *std.mem.Allocator, data: [][]u8) !void { var result = try allo.alloc([]u8, data[0].len); for (result) |_, i_| { result[i_] = try allo.alloc(u8, data.len); } for (data) |row, i| { for (row) |col, j| { result[i][j] = data[data.len - j - 1][i]; } } for (data) |row, i| { std.mem.copy(u8, data[i], result[i]); allo.free(result[i]); } allo.free(result); } pub fn trace_dragon(data: [][]u8, y: usize, x: usize, steps: [][2]i32) bool { if (steps.len == 0) { return true; } const new_x = @intCast(i32, x) + steps[0][0]; const new_y = @intCast(i32, y) + steps[0][1]; if (new_y < 0 or new_y >= data.len or new_x < 0 or new_x >= data[0].len) { return false; } const tile = data[@intCast(usize, new_y)][@intCast(usize, new_x)]; if (tile != '#') { return false; } return trace_dragon(data, @intCast(usize, new_y), @intCast(usize, new_x), steps[1..]); } pub fn part2(data: [][]u8, steps: [][2]i32) usize { var dragon_count: usize = 0; var y: usize = 0; while (y < data.len) : (y += 1) { var x: usize = 0; while (x < data[0].len) : (x += 1) { const is_dragon_tail_tip = trace_dragon(data, y, x, steps); if (is_dragon_tail_tip) dragon_count += 1; } } return dragon_count; } pub fn main() !void { const begin = @divTrunc(std.time.nanoTimestamp(), 1000); // setup // var p1: usize = 1; defer _ = gpa.deinit(); var allo = &gpa.allocator; var lines: std.mem.TokenIterator = try utils.readInputLines(allo, "./input1"); defer allo.free(lines.buffer); var tiles = try allo.alloc(Tile, 0); defer allo.free(tiles); var row: usize = 0; var cur_tile: Tile = undefined; while (lines.next()) |line| { if (std.mem.indexOf(u8, line, "Tile")) |_| { cur_tile = try Tile.init(line); tiles = try allo.realloc(tiles, tiles.len + 1); tiles[tiles.len - 1] = cur_tile; row = 0; continue; } try tiles[tiles.len - 1].load_line(line, row); row += 1; } // do p1 tiles[0].process(tiles); info(" ===================== PROCESS ================================", .{}); for (tiles) |*tile, i| { const neighbors = tile.count_neighbors(); if (neighbors == 2) { p1 *= tile.id; } } print("p1: {}\n", .{p1}); // do p2 var width: usize = 0; var height: usize = 0; // determine large dimensions for (tiles) |*tile| { const dist_top = tile.distance_from_top(); const dist_left = tile.distance_from_left(); if (dist_top > height) { height = dist_top; } if (dist_left > width) { width = dist_left; } } // allocate one big 2d-array var allmap = try allo.alloc([]u8, (height + 1) * (DIM - 2)); for (allmap) |_, i| { allmap[i] = try allo.alloc(u8, (width + 1) * (DIM - 2)); } defer { for (allmap) |_, i| { allo.free(allmap[i]); } allo.free(allmap); } // draw all tiles into correct coordinates for (tiles) |*tile| { const dist_top = tile.distance_from_top(); const dist_left = tile.distance_from_left(); for (tile.data) |row2, i| { if (i == 0 or i == DIM - 1) continue; // skip first and last row const top = dist_top * (DIM - 2); const left = dist_left * (DIM - 2); std.mem.copy(u8, allmap[top + i - 1][left .. left + DIM - 2], row2[1 .. DIM - 1]); } } // the dragon as depicted in task // steps: {x, y} var p2_pattern = [_][2]i32{ [_]i32{ 0, 0 }, [_]i32{ 1, 1 }, [_]i32{ 3, 0 }, [_]i32{ 1, -1 }, [_]i32{ 1, 0 }, [_]i32{ 1, 1 }, [_]i32{ 3, 0 }, [_]i32{ 1, -1 }, [_]i32{ 1, 0 }, [_]i32{ 1, 1 }, [_]i32{ 3, 0 }, [_]i32{ 1, -1 }, [_]i32{ 1, -1 }, [_]i32{ 0, 1 }, [_]i32{ 1, 0 }, }; var monster_count: usize = 0; var rot: usize = 0; while (rot < 4) : (rot += 1) { monster_count += part2(allmap, p2_pattern[0..]); rotate_2d_matrix(allo, allmap) catch unreachable; } print("monster count: {}\n", .{monster_count}); // count all hash signs var hash_count: usize = 0; for (allmap) |row4| { hash_count += std.mem.count(u8, row4, "#"); } // calc p2 from hash signs and dragon symbol count print("p2: {}\n", .{hash_count - (monster_count * p2_pattern.len)}); // end const delta = @divTrunc(std.time.nanoTimestamp(), 1000) - begin; print("all done in {} microseconds\n", .{delta}); }
day_20/src/main.zig
const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const assert = std.debug.assert; const Compilation = @import("Compilation.zig"); const Error = Compilation.Error; const Source = @import("Source.zig"); const Tokenizer = @import("Tokenizer.zig"); const RawToken = Tokenizer.Token; const Parser = @import("Parser.zig"); const Diagnostics = @import("Diagnostics.zig"); const Token = @import("Tree.zig").Token; const Preprocessor = @This(); const DefineMap = std.StringHashMap(Macro); const RawTokenList = std.ArrayList(RawToken); const max_include_depth = 200; const Macro = union(enum) { /// #define FOO empty, /// #define FOO FOO self, /// #define FOO a + b simple: struct { tokens: []const RawToken, loc: Source.Location, }, /// #define FOO(a,b) ((a)+(b)) func: Func, const Func = struct { params: []const []const u8, tokens: []const RawToken, var_args: bool, loc: Source.Location, }; }; comp: *Compilation, arena: std.heap.ArenaAllocator, defines: DefineMap, tokens: Token.List = .{}, generated: std.ArrayList(u8), token_buf: RawTokenList, char_buf: std.ArrayList(u8), pragma_once: std.AutoHashMap(Source.Id, void), // It is safe to have pointers to entries of defines since it // cannot be modified while we are expanding a macro. expansion_log: std.AutoHashMap(*Macro, void), include_depth: u8 = 0, pub fn init(comp: *Compilation) Preprocessor { return .{ .comp = comp, .arena = std.heap.ArenaAllocator.init(comp.gpa), .defines = DefineMap.init(comp.gpa), .generated = std.ArrayList(u8).init(comp.gpa), .token_buf = RawTokenList.init(comp.gpa), .char_buf = std.ArrayList(u8).init(comp.gpa), .pragma_once = std.AutoHashMap(Source.Id, void).init(comp.gpa), .expansion_log = std.AutoHashMap(*Macro, void).init(comp.gpa), }; } pub fn deinit(pp: *Preprocessor) void { pp.defines.deinit(); pp.tokens.deinit(pp.comp.gpa); pp.arena.deinit(); pp.generated.deinit(); pp.token_buf.deinit(); pp.char_buf.deinit(); pp.pragma_once.deinit(); pp.expansion_log.deinit(); } /// Preprocess a source file. pub fn preprocess(pp: *Preprocessor, source: Source) Error!void { var tokenizer = Tokenizer{ .buf = source.buf, .comp = pp.comp, .source = source.id, }; // Estimate how many new tokens this source will contain. const estimated_token_count = source.buf.len / 8; try pp.tokens.ensureCapacity(pp.comp.gpa, pp.tokens.len + estimated_token_count); var if_level: u8 = 0; var if_kind = std.mem.zeroes(std.PackedIntArray(u2, 256)); const until_else = 0; const until_endif = 1; const until_endif_seen_else = 2; var seen_pragma_once = false; var start_of_line = true; while (true) { var tok = tokenizer.next(); switch (tok.id) { .hash => if (start_of_line) { const directive = tokenizer.next(); switch (directive.id) { .keyword_error => { // #error tokens.. const start = tokenizer.index; while (tokenizer.index < tokenizer.buf.len) : (tokenizer.index += 1) { if (tokenizer.buf[tokenizer.index] == '\n') break; } var slice = tokenizer.buf[start..tokenizer.index]; slice = mem.trim(u8, slice, " \t\x0B\x0C"); try pp.comp.diag.add(.{ .tag = .error_directive, .loc = .{ .id = tok.source, .byte_offset = tok.start }, .extra = .{ .str = slice }, }); }, .keyword_if => { if (@addWithOverflow(u8, if_level, 1, &if_level)) return pp.comp.fatal(directive, "too many #if nestings", .{}); if (try pp.expr(&tokenizer)) { if_kind.set(if_level, until_endif); } else { if_kind.set(if_level, until_else); try pp.skip(&tokenizer, .until_else); } }, .keyword_ifdef => { if (@addWithOverflow(u8, if_level, 1, &if_level)) return pp.comp.fatal(directive, "too many #if nestings", .{}); const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue; try pp.expectNl(&tokenizer); if (pp.defines.get(macro_name) != null) { if_kind.set(if_level, until_endif); } else { if_kind.set(if_level, until_else); try pp.skip(&tokenizer, .until_else); } }, .keyword_ifndef => { if (@addWithOverflow(u8, if_level, 1, &if_level)) return pp.comp.fatal(directive, "too many #if nestings", .{}); const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue; try pp.expectNl(&tokenizer); if (pp.defines.get(macro_name) == null) { if_kind.set(if_level, until_endif); } else { if_kind.set(if_level, until_else); try pp.skip(&tokenizer, .until_else); } }, .keyword_elif => { if (if_level == 0) { try pp.err(directive, .elif_without_if); if_level += 1; if_kind.set(if_level, until_else); } switch (if_kind.get(if_level)) { until_else => if (try pp.expr(&tokenizer)) { if_kind.set(if_level, until_endif); } else { try pp.skip(&tokenizer, .until_else); }, until_endif => try pp.skip(&tokenizer, .until_endif), until_endif_seen_else => { try pp.err(directive, .elif_after_else); skipToNl(&tokenizer); }, else => unreachable, } }, .keyword_else => { try pp.expectNl(&tokenizer); if (if_level == 0) { try pp.err(directive, .else_without_if); continue; } switch (if_kind.get(if_level)) { until_else => if_kind.set(if_level, until_endif_seen_else), until_endif => try pp.skip(&tokenizer, .until_endif_seen_else), until_endif_seen_else => { try pp.err(directive, .else_after_else); skipToNl(&tokenizer); }, else => unreachable, } }, .keyword_endif => { try pp.expectNl(&tokenizer); if (if_level == 0) { try pp.err(directive, .endif_without_if); continue; } if_level -= 1; }, .keyword_define => try pp.define(&tokenizer), .keyword_undef => { const macro_name = (try pp.expectMacroName(&tokenizer)) orelse continue; _ = pp.defines.remove(macro_name); try pp.expectNl(&tokenizer); }, .keyword_include => try pp.include(&tokenizer), .keyword_pragma => { // #pragma tokens... const start = tokenizer.index; while (tokenizer.index < tokenizer.buf.len) : (tokenizer.index += 1) { if (tokenizer.buf[tokenizer.index] == '\n') break; } var slice = tokenizer.buf[start..tokenizer.index]; slice = mem.trim(u8, slice, " \t\x0B\x0C"); if (mem.eql(u8, slice, "once")) { const prev = try pp.pragma_once.fetchPut(tokenizer.source, {}); if (prev != null and !seen_pragma_once) { return; } else { seen_pragma_once = true; } } else { try pp.comp.diag.add(.{ .tag = .unsupported_pragma, .loc = .{ .id = tok.source, .byte_offset = tok.start }, .extra = .{ .str = slice }, }); } }, .keyword_line => { // #line number "file" const digits = tokenizer.next(); if (digits.id != .integer_literal) try pp.err(digits, .line_simple_digit); if (digits.id == .eof or digits.id == .nl) continue; const name = tokenizer.next(); if (name.id == .eof or name.id == .nl) continue; if (name.id != .string_literal) try pp.err(name, .line_invalid_filename); try pp.expectNl(&tokenizer); }, .nl => {}, .eof => { if (if_level != 0) try pp.err(tok, .unterminated_conditional_directive); return; }, else => { try pp.err(tok, .invalid_preprocessing_directive); try pp.expectNl(&tokenizer); }, } }, .nl => start_of_line = true, .eof => { if (if_level != 0) try pp.err(tok, .unterminated_conditional_directive); return; }, else => { // Add the token to the buffer doing any necessary expansions. start_of_line = false; tok.id.simplifyMacroKeyword(); try pp.expandMacro(&tokenizer, tok); }, } } } pub fn tokSliceSafe(pp: *Preprocessor, token: RawToken) []const u8 { if (token.id.lexeme()) |some| return some; assert(token.source != .generated); return pp.comp.getSource(token.source).buf[token.start..token.end]; } /// Returned slice is invalidated when generated is updated. fn tokSlice(pp: *Preprocessor, token: RawToken) []const u8 { if (token.id.lexeme()) |some| return some; if (token.source == .generated) { return pp.generated.items[token.start..token.end]; } else { const source = pp.comp.getSource(token.source); return source.buf[token.start..token.end]; } } /// Convert a token from the Tokenizer into a token used by the parser. fn tokFromRaw(raw: RawToken) Token { return .{ .id = raw.id, .loc = .{ .id = raw.source, .byte_offset = raw.start, }, }; } fn err(pp: *Preprocessor, raw: RawToken, tag: Diagnostics.Tag) !void { try pp.comp.diag.add(.{ .tag = tag, .loc = .{ .id = raw.source, .byte_offset = raw.start, }, }); } /// Consume next token, error if it is not an identifier. fn expectMacroName(pp: *Preprocessor, tokenizer: *Tokenizer) Error!?[]const u8 { const macro_name = tokenizer.next(); if (!macro_name.id.isMacroIdentifier()) { try pp.err(macro_name, .macro_name_missing); skipToNl(tokenizer); return null; } return pp.tokSliceSafe(macro_name); } /// Skip until after a newline, error if extra tokens before it. fn expectNl(pp: *Preprocessor, tokenizer: *Tokenizer) Error!void { var sent_err = false; while (true) { const tok = tokenizer.next(); if (tok.id == .nl or tok.id == .eof) return; if (!sent_err) { sent_err = true; try pp.err(tok, .extra_tokens_directive_end); } } } /// Consume all tokens until a newline and parse the result into a boolean. fn expr(pp: *Preprocessor, tokenizer: *Tokenizer) Error!bool { const start = pp.tokens.len; defer pp.tokens.len = start; while (true) { var tok = tokenizer.next(); if (tok.id == .nl or tok.id == .eof) { if (pp.tokens.len == start) { try pp.err(tok, .expected_value_in_expr); try pp.expectNl(tokenizer); return false; } tok.id = .eof; try pp.tokens.append(pp.comp.gpa, tokFromRaw(tok)); break; } else if (tok.id == .keyword_defined) { const first = tokenizer.next(); const macro_tok = if (first.id == .l_paren) tokenizer.next() else first; if (!macro_tok.id.isMacroIdentifier()) try pp.err(macro_tok, .macro_name_missing); if (first.id == .l_paren) { const r_paren = tokenizer.next(); if (r_paren.id != .r_paren) { try pp.err(r_paren, .closing_paren); try pp.err(first, .to_match_paren); } } if (pp.defines.get(pp.tokSliceSafe(macro_tok))) |_| { tok.id = .one; } else { tok.id = .zero; } } try pp.expandMacro(tokenizer, tok); } // validate the tokens in the expression for (pp.tokens.items(.id)[start..]) |*id, i| { switch (id.*) { .string_literal, .string_literal_utf_16, .string_literal_utf_8, .string_literal_utf_32, .string_literal_wide, => { try pp.comp.diag.add(.{ .tag = .string_literal_in_pp_expr, .loc = pp.tokens.items(.loc)[i], }); return false; }, .float_literal, .float_literal_f, .float_literal_l, => { try pp.comp.diag.add(.{ .tag = .float_literal_in_pp_expr, .loc = pp.tokens.items(.loc)[i], }); return false; }, else => if (id.isMacroIdentifier()) { id.* = .zero; // undefined macro }, } } // Actually parse it. var parser = Parser{ .pp = pp, .tok_ids = pp.tokens.items(.id), .tok_i = @intCast(u32, start), .arena = &pp.arena.allocator, .in_macro = true, .data = undefined, .strings = undefined, .value_map = undefined, .scopes = undefined, .labels = undefined, .decl_buf = undefined, .list_buf = undefined, .param_buf = undefined, .enum_buf = undefined, .record_buf = undefined, }; return parser.macroExpr(); } /// Skip until #else #elif #endif, return last directive token id. /// Also skips nested #if ... #endifs. fn skip( pp: *Preprocessor, tokenizer: *Tokenizer, cont: enum { until_else, until_endif, until_endif_seen_else }, ) Error!void { var ifs_seen: u32 = 0; var line_start = true; while (tokenizer.index < tokenizer.buf.len) { if (line_start) { const dir_start = tokenizer.index; const hash = tokenizer.next(); if (hash.id == .nl) continue; line_start = false; if (hash.id != .hash) continue; const directive = tokenizer.next(); switch (directive.id) { .keyword_else => { if (ifs_seen != 0) continue; if (cont == .until_endif_seen_else) { try pp.err(directive, .else_after_else); continue; } tokenizer.index = dir_start; return; }, .keyword_elif => { if (ifs_seen != 0 or cont == .until_endif) continue; if (cont == .until_endif_seen_else) { try pp.err(directive, .elif_after_else); continue; } tokenizer.index = dir_start; return; }, .keyword_endif => { if (ifs_seen == 0) { tokenizer.index = dir_start; return; } ifs_seen -= 1; }, .keyword_if, .keyword_ifdef, .keyword_ifndef => ifs_seen += 1, else => {}, } } else if (tokenizer.buf[tokenizer.index] == '\n') { line_start = true; tokenizer.index += 1; } else { line_start = false; tokenizer.index += 1; } } else { const eof = tokenizer.next(); return pp.err(eof, .unterminated_conditional_directive); } } // Skip until newline, ignore other tokens. fn skipToNl(tokenizer: *Tokenizer) void { while (true) { const tok = tokenizer.next(); if (tok.id == .nl or tok.id == .eof) return; } } const ExpandBuf = std.ArrayList(Token); /// Try to expand a macro. fn expandMacro(pp: *Preprocessor, tokenizer: *Tokenizer, raw: RawToken) Error!void { if (pp.defines.getPtr(pp.tokSliceSafe(raw))) |some| switch (some.*) { .empty => return, .self => {}, .simple => { pp.expansion_log.clearRetainingCapacity(); var buf = ExpandBuf.init(pp.comp.gpa); defer buf.deinit(); // Add the token to a new buffer and expand it. try buf.append(tokFromRaw(raw)); var start_index: usize = 0; try pp.expandExtra(&buf, &start_index); // Add the resulting tokens to the token list and mark that they were expanded. try pp.tokens.ensureCapacity(pp.comp.gpa, pp.tokens.len + buf.items.len); const loc = Source.Location{ .id = raw.source, .byte_offset = raw.start }; for (buf.items) |*r| { try pp.markExpandedFrom(r, loc); pp.tokens.appendAssumeCapacity(r.*); } return; }, .func => |macro| blk: { const start = tokenizer.index; const l_paren = tokenizer.next(); if (l_paren.id != .l_paren) { // If not followed by an argument list, continue as usual. tokenizer.index = start; break :blk; } pp.expansion_log.clearRetainingCapacity(); var buf = ExpandBuf.init(pp.comp.gpa); defer buf.deinit(); // Collect the macro name and arguments into a new buffer. try buf.append(tokFromRaw(raw)); try buf.append(tokFromRaw(l_paren)); var parens: u32 = 0; while (true) { const tok = tokenizer.next(); switch (tok.id) { .nl => continue, .eof => { try pp.err(tok, .unterminated_macro_arg_list); return; }, .l_paren => parens += 1, .r_paren => { if (parens == 0) { try buf.append(tokFromRaw(tok)); break; } parens -= 1; }, else => {}, } try buf.append(tokFromRaw(tok)); } var start_index: usize = 0; // Mark that we have seen this macro. try pp.expansion_log.putNoClobber(some, {}); try pp.expandFunc(&buf, &start_index, macro); // Add the resulting tokens to the token list and mark that they were expanded. try pp.tokens.ensureCapacity(pp.comp.gpa, pp.tokens.len + buf.items.len); const loc = Source.Location{ .id = raw.source, .byte_offset = raw.start }; for (buf.items) |*r| { try pp.markExpandedFrom(r, loc); pp.tokens.appendAssumeCapacity(r.*); } return; }, }; // Not a macro, continue as usual. try pp.tokens.append(pp.comp.gpa, tokFromRaw(raw)); } /// Try to expand a macro in the `source` buffer at `start_index`. fn expandExtra(pp: *Preprocessor, source: *ExpandBuf, start_index: *usize) Error!void { if (pp.defines.getPtr(pp.expandedSlice(source.items[start_index.*]))) |some| { if (pp.expansion_log.get(some)) |_| { // If we have already expanded this macro, do not recursively expand it. start_index.* += 1; return; } // Mark that we have seen this macro. try pp.expansion_log.putNoClobber(some, {}); switch (some.*) { .empty => _ = source.orderedRemove(start_index.*), // Simply remove the token. .self => start_index.* += 1, // Just go over the token. .simple => |macro| { // Remove the token from the source and setup a new buffer. _ = source.orderedRemove(start_index.*); var buf = ExpandBuf.init(pp.comp.gpa); defer buf.deinit(); try buf.ensureCapacity(macro.tokens.len); // Add all of the macros tokens to the new buffer handling any concats. var i: usize = 0; while (i < macro.tokens.len) : (i += 1) { const raw = macro.tokens[i]; if (raw.id == .hash_hash) { _ = buf.pop(); const lhs = tokFromRaw(macro.tokens[i - 1]); const rhs = tokFromRaw(macro.tokens[i + 1]); i += 1; buf.appendAssumeCapacity(try pp.pasteTokens(lhs, rhs)); } else { buf.appendAssumeCapacity(tokFromRaw(raw)); } } // Try to expand the resulting tokens. i = 0; while (i < buf.items.len) { if (buf.items[i].id.isMacroIdentifier()) { try pp.expandExtra(&buf, &i); } else { i += 1; } } // Mark all the tokens before adding them to the source buffer. for (buf.items) |*tok| try pp.markExpandedFrom(tok, macro.loc); try source.insertSlice(start_index.*, buf.items); start_index.* += buf.items.len; }, .func => |macro| return pp.expandFunc(source, start_index, macro), } } else start_index.* += 1; // go over normal identifiers } /// Try to expand a function like macro in the `source` buffer at `start_index`. fn expandFunc(pp: *Preprocessor, source: *ExpandBuf, start_index: *usize, macro: Macro.Func) Error!void { const name_tok = source.items[start_index.*]; const l_paren_index = start_index.* + 1; if (source.items.len <= l_paren_index or source.items[l_paren_index].id != .l_paren) { // Not a macro function call, go over normal identifier. start_index.* += 1; return; } // collect the arguments. // `args_count` starts with 1 since whitespace counts as an argument. var args_count: u32 = 0; var parens: u32 = 0; const args = for (source.items[l_paren_index + 1 ..]) |tok, i| { switch (tok.id) { .comma => if (parens == 0) { if (args_count == 0) args_count = 2 else args_count += 1; }, .l_paren => parens += 1, .r_paren => { if (parens == 0) break source.items[l_paren_index + 1 ..][0..i]; parens -= 1; }, else => {}, } } else { try pp.comp.diag.add(.{ .tag = .unterminated_macro_arg_list, .loc = name_tok.loc }); start_index.* += 1; return; }; if (args_count == 0 and args.len != 0) args_count = 1; // Validate argument count. const extra = Diagnostics.Message.Extra{ .arguments = .{ .expected = @intCast(u32, macro.params.len), .actual = args_count } }; if (macro.var_args and args_count < macro.params.len) { try pp.comp.diag.add(.{ .tag = .expected_at_least_arguments, .loc = name_tok.loc, .extra = extra }); start_index.* += 1; return; } if (!macro.var_args and args_count != macro.params.len) { try pp.comp.diag.add(.{ .tag = .expected_arguments, .loc = name_tok.loc, .extra = extra }); start_index.* += 1; return; } var buf = ExpandBuf.init(pp.comp.gpa); defer buf.deinit(); try buf.ensureCapacity(macro.tokens.len); // 1. Stringification and 2. Parameter replacement var tok_i: usize = 0; while (tok_i < macro.tokens.len) : (tok_i += 1) { const raw = macro.tokens[tok_i]; switch (raw.id) { .stringify_param, .stringify_va_args => { const target_arg = if (raw.id == .stringify_va_args) vaArgSlice(args, macro.params.len) else argSlice(args, raw.end); pp.char_buf.items.len = 0; // Safe since we can only be stringifying one parameter at a time. // TODO pretty print these try pp.char_buf.append('"'); for (target_arg) |a, i| { if (i != 0) try pp.char_buf.append(' '); for (pp.expandedSlice(a)) |c| { if (c == '"') try pp.char_buf.appendSlice("\\\"") else try pp.char_buf.append(c); } } try pp.char_buf.appendSlice("\"\n"); const start = pp.generated.items.len; try pp.generated.appendSlice(pp.char_buf.items); try buf.append(.{ .id = .string_literal, .loc = .{ // location of token slice in the generated buffer .id = .generated, .byte_offset = @intCast(u32, start), }, }); }, .macro_param, .keyword_va_args => { const target_arg = if (raw.id == .keyword_va_args) vaArgSlice(args, macro.params.len) else argSlice(args, raw.end); if (target_arg.len == 0) // This is needed so that we can properly do token pasting. try buf.append(.{ .id = .empty_arg, .loc = .{ .id = raw.source, .byte_offset = raw.start } }) else { try buf.ensureCapacity(buf.items.len + target_arg.len); for (target_arg) |arg| { var copy = arg; if (copy.id.isMacroIdentifier()) copy.id = .identifier_from_param else if (copy.id == .hash_hash) copy.id = .hash_hash_from_param; buf.appendAssumeCapacity(copy); } } }, else => try buf.append(tokFromRaw(raw)), } } // 3. Concatenation tok_i = 0; while (tok_i < buf.items.len) : (tok_i += 1) { switch (buf.items[tok_i].id) { .hash_hash_from_param => buf.items[tok_i].id = .hash_hash, .hash_hash => { const prev = buf.items[tok_i - 1]; const next = buf.items[tok_i + 1]; buf.items[tok_i - 1] = try pp.pasteTokens(prev, next); mem.copy(Token, buf.items[tok_i..], buf.items[tok_i + 2 ..]); buf.items.len -= 2; tok_i -= 1; }, else => {}, } } // 4. Expand tokens from parameters tok_i = 0; while (tok_i < buf.items.len) { const tok = &buf.items[tok_i]; switch (tok.id) { .empty_arg => _ = buf.orderedRemove(tok_i), .identifier_from_param => { tok.id = Tokenizer.Token.getTokenId(pp.comp, pp.expandedSlice(tok.*)); try pp.expandExtra(&buf, &tok_i); }, else => tok_i += 1, } } // 5. Expand resulting tokens tok_i = 0; while (tok_i < buf.items.len) { if (buf.items[tok_i].id.isMacroIdentifier()) { try pp.expandExtra(&buf, &tok_i); } else { tok_i += 1; } } // Mark all the tokens before adding them to the source buffer. for (buf.items) |*tok| try pp.markExpandedFrom(tok, macro.loc); // Move tokens after the call out of the way. const input_len = args.len + 3; // +3 for identifier, ( and ) if (input_len == buf.items.len) { // do nothing } else if (input_len > buf.items.len) { mem.copy(Token, source.items[start_index.* + buf.items.len ..], source.items[start_index.* + input_len ..]); source.items.len -= input_len - buf.items.len; } else { const new_len = source.items.len - input_len + buf.items.len; try source.ensureCapacity(new_len); const start_len = source.items.len; source.items.len = new_len; mem.copyBackwards(Token, source.items[start_index.* + buf.items.len ..], source.items[start_index.* + input_len .. start_len]); } // Insert resulting tokens to the source mem.copy(Token, source.items[start_index.*..], buf.items); start_index.* += buf.items.len; } /// Get var args from after index. fn vaArgSlice(args: []const Token, index: usize) []const Token { if (index == 0) return args; // TODO this is a mess var commas_seen: usize = 0; var i: usize = 0; var parens: u32 = 0; while (i < args.len) : (i += 1) { switch (args[i].id) { .l_paren => parens += 1, .r_paren => parens -= 1, else => if (parens != 0) continue, } if (args[i].id == .comma) commas_seen += 1; if (commas_seen == index) return args[i + 1 ..]; } return args[i..]; } /// get argument at index from a list of tokens. fn argSlice(args: []const Token, index: u32) []const Token { // TODO this is a mess var commas_seen: usize = 0; var i: usize = 0; var parens: u32 = 0; while (i < args.len) : (i += 1) { switch (args[i].id) { .l_paren => parens += 1, .r_paren => parens -= 1, else => if (parens != 0) continue, } if (args[i].id == .comma) { if (index == 0) return args[0..i]; commas_seen += 1; continue; } if (commas_seen == index) for (args[i..]) |a_2, j| { if (a_2.id == .comma) { return args[i..][0..j]; } } else return args[i..]; } else return args[i..]; unreachable; } // mark that this token has been expanded from `loc` fn markExpandedFrom(pp: *Preprocessor, tok: *Token, loc: Source.Location) !void { const new_loc = try pp.arena.allocator.create(Source.Location); new_loc.* = loc; new_loc.next = tok.loc.next; tok.loc.next = new_loc; } // TODO there are like 5 tokSlice functions, can we combine them somehow. pub fn expandedSlice(pp: *Preprocessor, tok: Token) []const u8 { if (tok.id.lexeme()) |some| return some; var tmp_tokenizer = Tokenizer{ .buf = if (tok.loc.id == .generated) pp.generated.items else pp.comp.getSource(tok.loc.id).buf, .comp = pp.comp, .index = tok.loc.byte_offset, .source = .generated, }; if (tok.id == .macro_string) { while (true) : (tmp_tokenizer.index += 1) { if (tmp_tokenizer.buf[tmp_tokenizer.index] == '>') break; } return tmp_tokenizer.buf[tok.loc.byte_offset .. tmp_tokenizer.index + 1]; } const res = tmp_tokenizer.next(); return tmp_tokenizer.buf[res.start..res.end]; } /// Concat two tokens and add the result to pp.generated fn pasteTokens(pp: *Preprocessor, lhs: Token, rhs: Token) Error!Token { const start = pp.generated.items.len; const end = start + pp.expandedSlice(lhs).len + pp.expandedSlice(rhs).len; try pp.generated.ensureCapacity(end + 1); // +1 for a newline // We cannot use the same slices here since they might be invalidated by `ensureCapacity` pp.generated.appendSliceAssumeCapacity(pp.expandedSlice(lhs)); pp.generated.appendSliceAssumeCapacity(pp.expandedSlice(rhs)); pp.generated.appendAssumeCapacity('\n'); // Try to tokenize the result. var tmp_tokenizer = Tokenizer{ .buf = pp.generated.items, .comp = pp.comp, .index = @intCast(u32, start), .source = .generated, }; const pasted_token = tmp_tokenizer.next(); const next = tmp_tokenizer.next().id; if (next != .nl and next != .eof) { try pp.comp.diag.add(.{ .tag = .pasting_formed_invalid, .loc = .{ .id = lhs.loc.id, .byte_offset = lhs.loc.byte_offset }, .extra = .{ .str = try pp.arena.allocator.dupe(u8, pp.generated.items[start..end]) }, }); } return Token{ .id = pasted_token.id, .loc = .{ // location of token slice in the generated buffer .id = .generated, .byte_offset = @intCast(u32, start), }, }; } /// Defines a new macro and warns if it is a duplicate fn defineMacro(pp: *Preprocessor, name_tok: RawToken, macro: Macro) Error!void { const name_str = pp.tokSliceSafe(name_tok); if (try pp.defines.fetchPut(name_str, macro)) |_| { try pp.comp.diag.add(.{ .tag = .macro_redefined, .loc = .{ .id = name_tok.source, .byte_offset = name_tok.start }, .extra = .{ .str = name_str }, }); // TODO add a previous definition note } } /// Handle a #define directive. fn define(pp: *Preprocessor, tokenizer: *Tokenizer) Error!void { // Get macro name and validate it. const macro_name = tokenizer.next(); if (macro_name.id == .keyword_defined) { try pp.err(macro_name, .defined_as_macro_name); return skipToNl(tokenizer); } if (!macro_name.id.isMacroIdentifier()) { try pp.err(macro_name, .macro_name_must_be_identifier); return skipToNl(tokenizer); } // Check for function macros and empty defines. var first = tokenizer.next(); first.id.simplifyMacroKeyword(); if (first.id == .nl or first.id == .eof) { return pp.defineMacro(macro_name, .empty); } else if (first.start == macro_name.end) { if (first.id == .l_paren) return pp.defineFn(tokenizer, macro_name, first); try pp.err(first, .whitespace_after_macro_name); } else if (first.id == .hash_hash) { try pp.err(first, .hash_hash_at_start); } { // Check for #define FOO FOO const start = tokenizer.index; const second = tokenizer.next(); if (second.id == .nl or second.id == .eof) { if (mem.eql(u8, pp.tokSliceSafe(first), pp.tokSliceSafe(macro_name))) { // #define FOO FOO return pp.defineMacro(macro_name, .self); } } tokenizer.index = start; } pp.token_buf.items.len = 0; // Safe to use since we can only be in one directive at a time. try pp.token_buf.append(first); // Collect the token body and validate any ## found. while (true) { var tok = tokenizer.next(); tok.id.simplifyMacroKeyword(); switch (tok.id) { .hash_hash => { const next = tokenizer.next(); if (next.id == .nl or next.id == .eof) { try pp.err(tok, .hash_hash_at_end); break; } try pp.token_buf.append(tok); try pp.token_buf.append(next); }, .nl, .eof => break, else => try pp.token_buf.append(tok), } } const list = try pp.arena.allocator.dupe(RawToken, pp.token_buf.items); try pp.defineMacro(macro_name, .{ .simple = .{ .loc = .{ .id = macro_name.source, .byte_offset = macro_name.start }, .tokens = list, } }); } /// Handle a function like #define directive. fn defineFn(pp: *Preprocessor, tokenizer: *Tokenizer, macro_name: RawToken, l_paren: RawToken) Error!void { assert(macro_name.id.isMacroIdentifier()); var params = std.ArrayList([]const u8).init(pp.comp.gpa); defer params.deinit(); // Parse the parameter list. var var_args = false; while (true) { var tok = tokenizer.next(); if (tok.id == .r_paren) break; if (params.items.len != 0) { if (tok.id != .comma) try pp.err(tok, .invalid_token_param_list) else tok = tokenizer.next(); } if (tok.id == .eof) return pp.err(tok, .unterminated_macro_param_list); if (tok.id == .ellipsis) { var_args = true; const r_paren = tokenizer.next(); if (r_paren.id != .r_paren) { try pp.err(r_paren, .missing_paren_param_list); try pp.err(l_paren, .to_match_paren); } break; } if (!tok.id.isMacroIdentifier()) { try pp.err(tok, .invalid_token_param_list); continue; } try params.append(pp.tokSliceSafe(tok)); } // Collect the body tokens and validate # and ##'s found. pp.token_buf.items.len = 0; // Safe to use since we can only be in one directive at a time. tok_loop: while (true) { var tok = tokenizer.next(); switch (tok.id) { .nl, .eof => break, .hash => { const param = tokenizer.next(); blk: { if (var_args and param.id == .keyword_va_args) { tok.id = .stringify_va_args; try pp.token_buf.append(tok); continue :tok_loop; } if (!param.id.isMacroIdentifier()) break :blk; const s = pp.tokSliceSafe(param); for (params.items) |p, i| { if (mem.eql(u8, p, s)) { tok.id = .stringify_param; tok.end = @intCast(u32, i); try pp.token_buf.append(tok); continue :tok_loop; } } } try pp.err(param, .hash_not_followed_param); tok = param; }, .hash_hash => { const start = tokenizer.index; const next = tokenizer.next(); if (next.id == .nl or next.id == .eof) { try pp.err(tok, .hash_hash_at_end); continue; } tokenizer.index = start; try pp.token_buf.append(tok); }, else => { if (var_args and tok.id == .keyword_va_args) { // do nothing } else if (tok.id.isMacroIdentifier()) { tok.id.simplifyMacroKeyword(); const s = pp.tokSliceSafe(tok); for (params.items) |param, i| { if (mem.eql(u8, param, s)) { tok.id = .macro_param; tok.end = @intCast(u32, i); break; } } } try pp.token_buf.append(tok); }, } } const param_list = try pp.arena.allocator.dupe([]const u8, params.items); const token_list = try pp.arena.allocator.dupe(RawToken, pp.token_buf.items); try pp.defineMacro(macro_name, .{ .func = .{ .params = param_list, .var_args = var_args, .tokens = token_list, .loc = .{ .id = macro_name.source, .byte_offset = macro_name.start }, } }); } // Handle a #include directive. fn include(pp: *Preprocessor, tokenizer: *Tokenizer) Error!void { const new_source = findIncludeSource(pp, tokenizer) catch |er| switch (er) { error.InvalidInclude => return, else => |e| return e, }; // Prevent stack overflow pp.include_depth += 1; defer pp.include_depth -= 1; if (pp.include_depth > max_include_depth) return; try pp.preprocess(new_source); } fn findIncludeSource(pp: *Preprocessor, tokenizer: *Tokenizer) !Source { const start = pp.tokens.len; defer pp.tokens.len = start; var first = tokenizer.next(); if (first.id == .angle_bracket_left) to_end: { // The tokenizer does not handle <foo> include strings so do it here. while (tokenizer.index < tokenizer.buf.len) : (tokenizer.index += 1) { switch (tokenizer.buf[tokenizer.index]) { '>' => { tokenizer.index += 1; first.end = tokenizer.index; first.id = .macro_string; break :to_end; }, '\n' => break, else => {}, } } try pp.comp.diag.add(.{ .tag = .header_str_closing, .loc = .{ .id = first.source, .byte_offset = first.start }, }); try pp.err(first, .header_str_match); } // Try to expand if the argument is a macro. try pp.expandMacro(tokenizer, first); // Check that we actually got a string. const filename_tok = pp.tokens.get(start); switch (filename_tok.id) { .string_literal, .macro_string => {}, else => { try pp.err(first, .expected_filename); try pp.expectNl(tokenizer); return error.InvalidInclude; }, } // Error on extra tokens. const nl = tokenizer.next(); if ((nl.id != .nl and nl.id != .eof) or pp.tokens.len > start + 1) { skipToNl(tokenizer); try pp.err(first, .extra_tokens_directive_end); } // Check for empty filename. const tok_slice = pp.expandedSlice(filename_tok); if (tok_slice.len < 3) { try pp.err(first, .empty_filename); return error.InvalidInclude; } // Find the file. const filename = tok_slice[1 .. tok_slice.len - 1]; return pp.comp.findInclude(first, filename, filename_tok.id == .string_literal); } /// Pretty print tokens and try to preserve whitespace. pub fn prettyPrintTokens(pp: *Preprocessor, w: anytype) !void { var i: usize = 0; var cur: Token = pp.tokens.get(i); while (true) { if (cur.id == .eof) break; const slice = pp.expandedSlice(cur); try w.writeAll(slice); i += 1; const next = pp.tokens.get(i); if (next.id == .eof) { try w.writeByte('\n'); } else if (next.loc.next != null or next.loc.id == .generated) { // next was expanded from a macro try w.writeByte(' '); } else if (next.loc.id == cur.loc.id) { // TODO fix this // const source = pp.comp.getSource(cur.loc.id).buf; // const cur_end = cur.loc.byte_offset + slice.len; // try printInBetween(source[cur_end..next.loc.byte_offset], w); try w.writeByte(' '); } else { // next was included from another file try w.writeByte('\n'); } cur = next; } } fn printInBetween(slice: []const u8, w: anytype) !void { var in_between = slice; while (true) { if (mem.indexOfScalar(u8, in_between, '#') orelse mem.indexOf(u8, in_between, "//")) |some| { try w.writeAll(in_between[0..some]); in_between = in_between[some..]; const nl = mem.indexOfScalar(u8, in_between, '\n') orelse in_between.len; in_between = in_between[nl..]; } else if (mem.indexOf(u8, in_between, "/*")) |some| { try w.writeAll(in_between[0..some]); in_between = in_between[some..]; const nl = mem.indexOf(u8, in_between, "*/") orelse in_between.len; in_between = in_between[nl + 2 ..]; } else break; } try w.writeAll(in_between); }
src/Preprocessor.zig
const Core = @This(); const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const types = @import("../main.zig"); const js = @import("js_interop.zig"); pub const Window = @import("Window.zig"); allocator: std.mem.Allocator, window: *Window = undefined, pub fn init(allocator: std.mem.Allocator) !*Core { const core = try allocator.create(Core); core.* = Core{ .allocator = allocator, }; return core; } pub fn deinit(core: *Core) void { core.allocator.destroy(core); } pub fn createWindow(core: *Core, info: types.WindowInfo) !*Window { core.window = try Window.init(core, info); return core.window; } pub fn pollEvent(core: *Core) ?types.Event { const ev_type = js.wzEventShift(); if (ev_type == 0) return null; const window = core.wasmCanvasToWindow(@intCast(u32, js.wzEventShift())); return switch (ev_type) { // Key Press // ISSUE: it currently spams keydown when a key is already down, // like how a key state work, i.e key repeat handling is needed. 1 => types.Event{ .window = window, .ev = .{ .key_press = .{ .key = @intToEnum(types.Key, js.wzEventShift()), }, }, }, // Key Release 2 => types.Event{ .window = window, .ev = .{ .key_release = .{ .key = @intToEnum(types.Key, js.wzEventShift()), }, }, }, // Mouse Down 3 => types.Event{ .window = window, .ev = .{ .button_press = .{ .button = wasmTranslateButton(@intCast(u2, js.wzEventShift())), }, }, }, // Mouse Up 4 => types.Event{ .window = window, .ev = .{ .button_release = .{ .button = wasmTranslateButton( @intCast(u2, js.wzEventShift()), ) }, }, }, // Mouse Motion 5 => types.Event{ .window = window, .ev = .{ .mouse_motion = .{ .x = @intCast(i16, js.wzEventShift()), .y = @intCast(i16, js.wzEventShift()), }, }, }, // Mouse Enter 6 => types.Event{ .window = window, .ev = .{ .mouse_enter = .{ .x = @intCast(i16, js.wzEventShift()), .y = @intCast(i16, js.wzEventShift()), }, }, }, // Mouse Leave 7 => types.Event{ .window = window, .ev = .{ .mouse_leave = .{ .x = @intCast(i16, js.wzEventShift()), .y = @intCast(i16, js.wzEventShift()), }, }, }, // Mouse Scroll 8 => types.Event{ .window = window, .ev = .{ .mouse_scroll = .{ .scroll_x = signum(@intCast(i16, js.wzEventShift())), .scroll_y = signum(@intCast(i16, js.wzEventShift())), }, }, }, else => unreachable, }; } pub fn waitEvent(core: *Core) ?types.Event { // We cannot wait/halt in wasm, so its no different return core.pollEvent(); } fn wasmTranslateButton(button: u2) types.Button { return switch (button) { 0 => .left, 1 => .middle, 2 => .right, else => unreachable, }; } fn wasmCanvasToWindow(core: *Core, canvas: js.CanvasId) types.Window { _ = canvas; return types.Window.initFromInternal(core.window); } fn signum(n: i16) i2 { if (n > 0) { return 1; } else if (n < 0) { return -1; } return 0; }
src/wasm/Core.zig
// mikdusan // ah got it to work. but you have to take a special step. consider this case: // 1. spawn "cat" and write some lines to it. let it just inherit stdout/stderr. // 2. waiting on child won't return until stdin pipe is closed // 3. you can child.stdin.?.close() but I had to follow it up with child.stdin = null; so the regular child_process code doesn't try to close it in cleanupAfterWait() // this simple just-write to child seems to work: // https://zigbin.io/0f4af2 const std = @import("std"); pub fn main() !void { var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena_state.deinit(); const arena = &arena_state.allocator; var args = std.ArrayList([]const u8).init(arena); try args.append("/bin/cat"); const child = try std.ChildProcess.init(args.items, arena); defer child.deinit(); child.stdin_behavior = .Pipe; child.stdout_behavior = .Inherit; child.stderr_behavior = .Inherit; child.spawn() catch |err| std.debug.panic("unable to spawn {s}: {s}\n", .{ args.items[0], @errorName(err) }); const out = child.stdin.?.writer(); try out.print("hello {s}.\n", .{"world"}); try out.print("done.\n", .{}); child.stdin.?.close(); child.stdin = null; const term = child.wait() catch |err| std.debug.panic("unable to spawn {s}: {s}\n", .{ args.items[0], @errorName(err) }); switch (term) { .Exited => |code| { const expect_code: u32 = 0; if (code != expect_code) { std.debug.warn("process {s} exited with error code {d} but expected code {d}\n", .{ args.items[0], code, expect_code, }); return error.SpawnExitedWithError; } }, .Signal => |signum| { std.debug.warn("process {s} terminated on signal {d}\n", .{ args.items[0], signum }); return error.SpawnWasSignalled; }, .Stopped => |signum| { std.debug.warn("process {s} stopped on signal {d}\n", .{ args.items[0], signum }); return error.SpawnWasStopped; }, .Unknown => |code| { std.debug.warn("process {s} terminated unexpectedly with error code {d}\n", .{ args.items[0], code }); return error.SpawnWasTerminated; }, } }
src/executable_and_stdin.zig
pub const FSRM_DISPID_FEATURE_MASK = @as(u32, 251658240); pub const FSRM_DISPID_INTERFACE_A_MASK = @as(u32, 15728640); pub const FSRM_DISPID_INTERFACE_B_MASK = @as(u32, 983040); pub const FSRM_DISPID_INTERFACE_C_MASK = @as(u32, 61440); pub const FSRM_DISPID_INTERFACE_D_MASK = @as(u32, 3840); pub const FSRM_DISPID_IS_PROPERTY = @as(u32, 128); pub const FSRM_DISPID_METHOD_NUM_MASK = @as(u32, 127); pub const FSRM_DISPID_FEATURE_GENERAL = @as(u32, 16777216); pub const FSRM_DISPID_FEATURE_QUOTA = @as(u32, 33554432); pub const FSRM_DISPID_FEATURE_FILESCREEN = @as(u32, 50331648); pub const FSRM_DISPID_FEATURE_REPORTS = @as(u32, 67108864); pub const FSRM_DISPID_FEATURE_CLASSIFICATION = @as(u32, 83886080); pub const FSRM_DISPID_FEATURE_PIPELINE = @as(u32, 100663296); pub const FsrmMaxNumberThresholds = @as(u32, 16); pub const FsrmMinThresholdValue = @as(u32, 1); pub const FsrmMaxThresholdValue = @as(u32, 250); pub const FsrmMinQuotaLimit = @as(u32, 1024); pub const FsrmMaxExcludeFolders = @as(u32, 32); pub const FsrmMaxNumberPropertyDefinitions = @as(u32, 100); pub const MessageSizeLimit = @as(u32, 4096); pub const FsrmDaysNotSpecified = @as(i32, -1); pub const FSRM_S_PARTIAL_BATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, 283396)); pub const FSRM_S_PARTIAL_CLASSIFICATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, 283397)); pub const FSRM_S_CLASSIFICATION_SCAN_FAILURES = @import("../zig.zig").typedConst(HRESULT, @as(i32, 283398)); pub const FSRM_E_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200255)); pub const FSRM_E_INVALID_SCHEDULER_ARGUMENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200254)); pub const FSRM_E_ALREADY_EXISTS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200253)); pub const FSRM_E_PATH_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200252)); pub const FSRM_E_INVALID_USER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200251)); pub const FSRM_E_INVALID_PATH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200250)); pub const FSRM_E_INVALID_LIMIT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200249)); pub const FSRM_E_INVALID_NAME = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200248)); pub const FSRM_E_FAIL_BATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200247)); pub const FSRM_E_INVALID_TEXT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200246)); pub const FSRM_E_INVALID_IMPORT_VERSION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200245)); pub const FSRM_E_OUT_OF_RANGE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200243)); pub const FSRM_E_REQD_PARAM_MISSING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200242)); pub const FSRM_E_INVALID_COMBINATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200241)); pub const FSRM_E_DUPLICATE_NAME = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200240)); pub const FSRM_E_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200239)); pub const FSRM_E_DRIVER_NOT_READY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200237)); pub const FSRM_E_INSUFFICIENT_DISK = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200236)); pub const FSRM_E_VOLUME_UNSUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200235)); pub const FSRM_E_UNEXPECTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200234)); pub const FSRM_E_INSECURE_PATH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200233)); pub const FSRM_E_INVALID_SMTP_SERVER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200232)); pub const FSRM_E_AUTO_QUOTA = @import("../zig.zig").typedConst(HRESULT, @as(i32, 283419)); pub const FSRM_E_EMAIL_NOT_SENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200228)); pub const FSRM_E_INVALID_EMAIL_ADDRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200226)); pub const FSRM_E_FILE_SYSTEM_CORRUPT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200225)); pub const FSRM_E_LONG_CMDLINE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200224)); pub const FSRM_E_INVALID_FILEGROUP_DEFINITION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200223)); pub const FSRM_E_INVALID_DATASCREEN_DEFINITION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200220)); pub const FSRM_E_INVALID_REPORT_FORMAT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200216)); pub const FSRM_E_INVALID_REPORT_DESC = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200215)); pub const FSRM_E_INVALID_FILENAME = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200214)); pub const FSRM_E_SHADOW_COPY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200212)); pub const FSRM_E_XML_CORRUPTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200211)); pub const FSRM_E_CLUSTER_NOT_RUNNING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200210)); pub const FSRM_E_STORE_NOT_INSTALLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200209)); pub const FSRM_E_NOT_CLUSTER_VOLUME = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200208)); pub const FSRM_E_DIFFERENT_CLUSTER_GROUP = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200207)); pub const FSRM_E_REPORT_TYPE_ALREADY_EXISTS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200206)); pub const FSRM_E_REPORT_JOB_ALREADY_RUNNING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200205)); pub const FSRM_E_REPORT_GENERATION_ERR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200204)); pub const FSRM_E_REPORT_TASK_TRIGGER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200203)); pub const FSRM_E_LOADING_DISABLED_MODULE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200202)); pub const FSRM_E_CANNOT_AGGREGATE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200201)); pub const FSRM_E_MESSAGE_LIMIT_EXCEEDED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200200)); pub const FSRM_E_OBJECT_IN_USE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200199)); pub const FSRM_E_CANNOT_RENAME_PROPERTY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200198)); pub const FSRM_E_CANNOT_CHANGE_PROPERTY_TYPE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200197)); pub const FSRM_E_MAX_PROPERTY_DEFINITIONS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200196)); pub const FSRM_E_CLASSIFICATION_ALREADY_RUNNING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200195)); pub const FSRM_E_CLASSIFICATION_NOT_RUNNING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200194)); pub const FSRM_E_FILE_MANAGEMENT_JOB_ALREADY_RUNNING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200193)); pub const FSRM_E_FILE_MANAGEMENT_JOB_EXPIRATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200192)); pub const FSRM_E_FILE_MANAGEMENT_JOB_CUSTOM = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200191)); pub const FSRM_E_FILE_MANAGEMENT_JOB_NOTIFICATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200190)); pub const FSRM_E_FILE_OPEN_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200189)); pub const FSRM_E_UNSECURE_LINK_TO_HOSTED_MODULE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200188)); pub const FSRM_E_CACHE_INVALID = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200187)); pub const FSRM_E_CACHE_MODULE_ALREADY_EXISTS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200186)); pub const FSRM_E_FILE_MANAGEMENT_EXPIRATION_DIR_IN_SCOPE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200185)); pub const FSRM_E_FILE_MANAGEMENT_JOB_ALREADY_EXISTS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200184)); pub const FSRM_E_PROPERTY_DELETED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200183)); pub const FSRM_E_LAST_ACCESS_UPDATE_DISABLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200176)); pub const FSRM_E_NO_PROPERTY_VALUE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200175)); pub const FSRM_E_INPROC_MODULE_BLOCKED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200174)); pub const FSRM_E_ENUM_PROPERTIES_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200173)); pub const FSRM_E_SET_PROPERTY_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200172)); pub const FSRM_E_CANNOT_STORE_PROPERTIES = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200171)); pub const FSRM_E_CANNOT_ALLOW_REPARSE_POINT_TAG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200170)); pub const FSRM_E_PARTIAL_CLASSIFICATION_PROPERTY_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200169)); pub const FSRM_E_TEXTREADER_NOT_INITIALIZED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200168)); pub const FSRM_E_TEXTREADER_IFILTER_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200167)); pub const FSRM_E_PERSIST_PROPERTIES_FAILED_ENCRYPTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200166)); pub const FSRM_E_TEXTREADER_IFILTER_CLSID_MALFORMED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200160)); pub const FSRM_E_TEXTREADER_STREAM_ERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200159)); pub const FSRM_E_TEXTREADER_FILENAME_TOO_LONG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200158)); pub const FSRM_E_INCOMPATIBLE_FORMAT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200157)); pub const FSRM_E_FILE_ENCRYPTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200156)); pub const FSRM_E_PERSIST_PROPERTIES_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200155)); pub const FSRM_E_VOLUME_OFFLINE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200154)); pub const FSRM_E_FILE_MANAGEMENT_ACTION_TIMEOUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200153)); pub const FSRM_E_FILE_MANAGEMENT_ACTION_GET_EXITCODE_FAILED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200152)); pub const FSRM_E_MODULE_INVALID_PARAM = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200151)); pub const FSRM_E_MODULE_INITIALIZATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200150)); pub const FSRM_E_MODULE_SESSION_INITIALIZATION = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200149)); pub const FSRM_E_CLASSIFICATION_SCAN_FAIL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200148)); pub const FSRM_E_FILE_MANAGEMENT_JOB_NOT_LEGACY_ACCESSIBLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200147)); pub const FSRM_E_FILE_MANAGEMENT_JOB_MAX_FILE_CONDITIONS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200146)); pub const FSRM_E_CANNOT_USE_DEPRECATED_PROPERTY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200145)); pub const FSRM_E_SYNC_TASK_TIMEOUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200144)); pub const FSRM_E_CANNOT_USE_DELETED_PROPERTY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200143)); pub const FSRM_E_INVALID_AD_CLAIM = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200142)); pub const FSRM_E_CLASSIFICATION_CANCELED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200141)); pub const FSRM_E_INVALID_FOLDER_PROPERTY_STORE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200140)); pub const FSRM_E_REBUILDING_FODLER_TYPE_INDEX = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200139)); pub const FSRM_E_PROPERTY_MUST_APPLY_TO_FILES = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200138)); pub const FSRM_E_CLASSIFICATION_TIMEOUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200137)); pub const FSRM_E_CLASSIFICATION_PARTIAL_BATCH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200136)); pub const FSRM_E_CANNOT_DELETE_SYSTEM_PROPERTY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200135)); pub const FSRM_E_FILE_IN_USE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200134)); pub const FSRM_E_ERROR_NOT_ENABLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200133)); pub const FSRM_E_CANNOT_CREATE_TEMP_COPY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200132)); pub const FSRM_E_NO_EMAIL_ADDRESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200131)); pub const FSRM_E_ADR_MAX_EMAILS_SENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200130)); pub const FSRM_E_PATH_NOT_IN_NAMESPACE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200129)); pub const FSRM_E_RMS_TEMPLATE_NOT_FOUND = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200128)); pub const FSRM_E_SECURE_PROPERTIES_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200127)); pub const FSRM_E_RMS_NO_PROTECTORS_INSTALLED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200126)); pub const FSRM_E_RMS_NO_PROTECTOR_INSTALLED_FOR_FILE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200125)); pub const FSRM_E_PROPERTY_MUST_APPLY_TO_FOLDERS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200124)); pub const FSRM_E_PROPERTY_MUST_BE_SECURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200123)); pub const FSRM_E_PROPERTY_MUST_BE_GLOBAL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200122)); pub const FSRM_E_WMI_FAILURE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200121)); pub const FSRM_E_FILE_MANAGEMENT_JOB_RMS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200120)); pub const FSRM_E_SYNC_TASK_HAD_ERRORS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200119)); pub const FSRM_E_ADR_SRV_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200112)); pub const FSRM_E_ADR_PATH_IS_LOCAL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200111)); pub const FSRM_E_ADR_NOT_DOMAIN_JOINED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200110)); pub const FSRM_E_CANNOT_REMOVE_READONLY = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200109)); pub const FSRM_E_FILE_MANAGEMENT_JOB_INVALID_CONTINUOUS_CONFIG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200108)); pub const FSRM_E_LEGACY_SCHEDULE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200107)); pub const FSRM_E_CSC_PATH_NOT_SUPPORTED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200106)); pub const FSRM_E_EXPIRATION_PATH_NOT_WRITEABLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200105)); pub const FSRM_E_EXPIRATION_PATH_TOO_LONG = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200104)); pub const FSRM_E_EXPIRATION_VOLUME_NOT_NTFS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200103)); pub const FSRM_E_FILE_MANAGEMENT_JOB_DEPRECATED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200102)); pub const FSRM_E_MODULE_TIMEOUT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147200101)); //-------------------------------------------------------------------------------- // Section: Types (117) //-------------------------------------------------------------------------------- pub const FsrmQuotaFlags = enum(i32) { Enforce = 256, Disable = 512, StatusIncomplete = 65536, StatusRebuilding = 131072, }; pub const FsrmQuotaFlags_Enforce = FsrmQuotaFlags.Enforce; pub const FsrmQuotaFlags_Disable = FsrmQuotaFlags.Disable; pub const FsrmQuotaFlags_StatusIncomplete = FsrmQuotaFlags.StatusIncomplete; pub const FsrmQuotaFlags_StatusRebuilding = FsrmQuotaFlags.StatusRebuilding; pub const FsrmFileScreenFlags = enum(i32) { e = 1, }; pub const FsrmFileScreenFlags_Enforce = FsrmFileScreenFlags.e; pub const FsrmCollectionState = enum(i32) { Fetching = 1, Committing = 2, Complete = 3, Cancelled = 4, }; pub const FsrmCollectionState_Fetching = FsrmCollectionState.Fetching; pub const FsrmCollectionState_Committing = FsrmCollectionState.Committing; pub const FsrmCollectionState_Complete = FsrmCollectionState.Complete; pub const FsrmCollectionState_Cancelled = FsrmCollectionState.Cancelled; pub const FsrmEnumOptions = enum(i32) { None = 0, Asynchronous = 1, CheckRecycleBin = 2, IncludeClusterNodes = 4, IncludeDeprecatedObjects = 8, }; pub const FsrmEnumOptions_None = FsrmEnumOptions.None; pub const FsrmEnumOptions_Asynchronous = FsrmEnumOptions.Asynchronous; pub const FsrmEnumOptions_CheckRecycleBin = FsrmEnumOptions.CheckRecycleBin; pub const FsrmEnumOptions_IncludeClusterNodes = FsrmEnumOptions.IncludeClusterNodes; pub const FsrmEnumOptions_IncludeDeprecatedObjects = FsrmEnumOptions.IncludeDeprecatedObjects; pub const FsrmCommitOptions = enum(i32) { None = 0, Asynchronous = 1, }; pub const FsrmCommitOptions_None = FsrmCommitOptions.None; pub const FsrmCommitOptions_Asynchronous = FsrmCommitOptions.Asynchronous; pub const FsrmTemplateApplyOptions = enum(i32) { Matching = 1, All = 2, }; pub const FsrmTemplateApplyOptions_ApplyToDerivedMatching = FsrmTemplateApplyOptions.Matching; pub const FsrmTemplateApplyOptions_ApplyToDerivedAll = FsrmTemplateApplyOptions.All; pub const FsrmActionType = enum(i32) { Unknown = 0, EventLog = 1, Email = 2, Command = 3, Report = 4, }; pub const FsrmActionType_Unknown = FsrmActionType.Unknown; pub const FsrmActionType_EventLog = FsrmActionType.EventLog; pub const FsrmActionType_Email = FsrmActionType.Email; pub const FsrmActionType_Command = FsrmActionType.Command; pub const FsrmActionType_Report = FsrmActionType.Report; pub const FsrmEventType = enum(i32) { Unknown = 0, Information = 1, Warning = 2, Error = 3, }; pub const FsrmEventType_Unknown = FsrmEventType.Unknown; pub const FsrmEventType_Information = FsrmEventType.Information; pub const FsrmEventType_Warning = FsrmEventType.Warning; pub const FsrmEventType_Error = FsrmEventType.Error; pub const FsrmAccountType = enum(i32) { Unknown = 0, NetworkService = 1, LocalService = 2, LocalSystem = 3, InProc = 4, External = 5, Automatic = 500, }; pub const FsrmAccountType_Unknown = FsrmAccountType.Unknown; pub const FsrmAccountType_NetworkService = FsrmAccountType.NetworkService; pub const FsrmAccountType_LocalService = FsrmAccountType.LocalService; pub const FsrmAccountType_LocalSystem = FsrmAccountType.LocalSystem; pub const FsrmAccountType_InProc = FsrmAccountType.InProc; pub const FsrmAccountType_External = FsrmAccountType.External; pub const FsrmAccountType_Automatic = FsrmAccountType.Automatic; pub const FsrmReportType = enum(i32) { Unknown = 0, LargeFiles = 1, FilesByType = 2, LeastRecentlyAccessed = 3, MostRecentlyAccessed = 4, QuotaUsage = 5, FilesByOwner = 6, ExportReport = 7, DuplicateFiles = 8, FileScreenAudit = 9, FilesByProperty = 10, AutomaticClassification = 11, Expiration = 12, FoldersByProperty = 13, }; pub const FsrmReportType_Unknown = FsrmReportType.Unknown; pub const FsrmReportType_LargeFiles = FsrmReportType.LargeFiles; pub const FsrmReportType_FilesByType = FsrmReportType.FilesByType; pub const FsrmReportType_LeastRecentlyAccessed = FsrmReportType.LeastRecentlyAccessed; pub const FsrmReportType_MostRecentlyAccessed = FsrmReportType.MostRecentlyAccessed; pub const FsrmReportType_QuotaUsage = FsrmReportType.QuotaUsage; pub const FsrmReportType_FilesByOwner = FsrmReportType.FilesByOwner; pub const FsrmReportType_ExportReport = FsrmReportType.ExportReport; pub const FsrmReportType_DuplicateFiles = FsrmReportType.DuplicateFiles; pub const FsrmReportType_FileScreenAudit = FsrmReportType.FileScreenAudit; pub const FsrmReportType_FilesByProperty = FsrmReportType.FilesByProperty; pub const FsrmReportType_AutomaticClassification = FsrmReportType.AutomaticClassification; pub const FsrmReportType_Expiration = FsrmReportType.Expiration; pub const FsrmReportType_FoldersByProperty = FsrmReportType.FoldersByProperty; pub const FsrmReportFormat = enum(i32) { Unknown = 0, DHtml = 1, Html = 2, Txt = 3, Csv = 4, Xml = 5, }; pub const FsrmReportFormat_Unknown = FsrmReportFormat.Unknown; pub const FsrmReportFormat_DHtml = FsrmReportFormat.DHtml; pub const FsrmReportFormat_Html = FsrmReportFormat.Html; pub const FsrmReportFormat_Txt = FsrmReportFormat.Txt; pub const FsrmReportFormat_Csv = FsrmReportFormat.Csv; pub const FsrmReportFormat_Xml = FsrmReportFormat.Xml; pub const FsrmReportRunningStatus = enum(i32) { Unknown = 0, NotRunning = 1, Queued = 2, Running = 3, }; pub const FsrmReportRunningStatus_Unknown = FsrmReportRunningStatus.Unknown; pub const FsrmReportRunningStatus_NotRunning = FsrmReportRunningStatus.NotRunning; pub const FsrmReportRunningStatus_Queued = FsrmReportRunningStatus.Queued; pub const FsrmReportRunningStatus_Running = FsrmReportRunningStatus.Running; pub const FsrmReportGenerationContext = enum(i32) { Undefined = 1, ScheduledReport = 2, InteractiveReport = 3, IncidentReport = 4, }; pub const FsrmReportGenerationContext_Undefined = FsrmReportGenerationContext.Undefined; pub const FsrmReportGenerationContext_ScheduledReport = FsrmReportGenerationContext.ScheduledReport; pub const FsrmReportGenerationContext_InteractiveReport = FsrmReportGenerationContext.InteractiveReport; pub const FsrmReportGenerationContext_IncidentReport = FsrmReportGenerationContext.IncidentReport; pub const FsrmReportFilter = enum(i32) { MinSize = 1, MinAgeDays = 2, MaxAgeDays = 3, MinQuotaUsage = 4, FileGroups = 5, Owners = 6, NamePattern = 7, Property = 8, }; pub const FsrmReportFilter_MinSize = FsrmReportFilter.MinSize; pub const FsrmReportFilter_MinAgeDays = FsrmReportFilter.MinAgeDays; pub const FsrmReportFilter_MaxAgeDays = FsrmReportFilter.MaxAgeDays; pub const FsrmReportFilter_MinQuotaUsage = FsrmReportFilter.MinQuotaUsage; pub const FsrmReportFilter_FileGroups = FsrmReportFilter.FileGroups; pub const FsrmReportFilter_Owners = FsrmReportFilter.Owners; pub const FsrmReportFilter_NamePattern = FsrmReportFilter.NamePattern; pub const FsrmReportFilter_Property = FsrmReportFilter.Property; pub const FsrmReportLimit = enum(i32) { Files = 1, FileGroups = 2, Owners = 3, FilesPerFileGroup = 4, FilesPerOwner = 5, FilesPerDuplGroup = 6, DuplicateGroups = 7, Quotas = 8, FileScreenEvents = 9, PropertyValues = 10, FilesPerPropertyValue = 11, Folders = 12, }; pub const FsrmReportLimit_MaxFiles = FsrmReportLimit.Files; pub const FsrmReportLimit_MaxFileGroups = FsrmReportLimit.FileGroups; pub const FsrmReportLimit_MaxOwners = FsrmReportLimit.Owners; pub const FsrmReportLimit_MaxFilesPerFileGroup = FsrmReportLimit.FilesPerFileGroup; pub const FsrmReportLimit_MaxFilesPerOwner = FsrmReportLimit.FilesPerOwner; pub const FsrmReportLimit_MaxFilesPerDuplGroup = FsrmReportLimit.FilesPerDuplGroup; pub const FsrmReportLimit_MaxDuplicateGroups = FsrmReportLimit.DuplicateGroups; pub const FsrmReportLimit_MaxQuotas = FsrmReportLimit.Quotas; pub const FsrmReportLimit_MaxFileScreenEvents = FsrmReportLimit.FileScreenEvents; pub const FsrmReportLimit_MaxPropertyValues = FsrmReportLimit.PropertyValues; pub const FsrmReportLimit_MaxFilesPerPropertyValue = FsrmReportLimit.FilesPerPropertyValue; pub const FsrmReportLimit_MaxFolders = FsrmReportLimit.Folders; pub const FsrmPropertyDefinitionType = enum(i32) { Unknown = 0, OrderedList = 1, MultiChoiceList = 2, SingleChoiceList = 3, String = 4, MultiString = 5, Int = 6, Bool = 7, Date = 8, }; pub const FsrmPropertyDefinitionType_Unknown = FsrmPropertyDefinitionType.Unknown; pub const FsrmPropertyDefinitionType_OrderedList = FsrmPropertyDefinitionType.OrderedList; pub const FsrmPropertyDefinitionType_MultiChoiceList = FsrmPropertyDefinitionType.MultiChoiceList; pub const FsrmPropertyDefinitionType_SingleChoiceList = FsrmPropertyDefinitionType.SingleChoiceList; pub const FsrmPropertyDefinitionType_String = FsrmPropertyDefinitionType.String; pub const FsrmPropertyDefinitionType_MultiString = FsrmPropertyDefinitionType.MultiString; pub const FsrmPropertyDefinitionType_Int = FsrmPropertyDefinitionType.Int; pub const FsrmPropertyDefinitionType_Bool = FsrmPropertyDefinitionType.Bool; pub const FsrmPropertyDefinitionType_Date = FsrmPropertyDefinitionType.Date; pub const FsrmPropertyDefinitionFlags = enum(i32) { Global = 1, Deprecated = 2, Secure = 4, }; pub const FsrmPropertyDefinitionFlags_Global = FsrmPropertyDefinitionFlags.Global; pub const FsrmPropertyDefinitionFlags_Deprecated = FsrmPropertyDefinitionFlags.Deprecated; pub const FsrmPropertyDefinitionFlags_Secure = FsrmPropertyDefinitionFlags.Secure; pub const FsrmPropertyDefinitionAppliesTo = enum(i32) { iles = 1, olders = 2, }; pub const FsrmPropertyDefinitionAppliesTo_Files = FsrmPropertyDefinitionAppliesTo.iles; pub const FsrmPropertyDefinitionAppliesTo_Folders = FsrmPropertyDefinitionAppliesTo.olders; pub const FsrmRuleType = enum(i32) { Unknown = 0, Classification = 1, Generic = 2, }; pub const FsrmRuleType_Unknown = FsrmRuleType.Unknown; pub const FsrmRuleType_Classification = FsrmRuleType.Classification; pub const FsrmRuleType_Generic = FsrmRuleType.Generic; pub const FsrmRuleFlags = enum(i32) { Disabled = 256, ClearAutomaticallyClassifiedProperty = 1024, ClearManuallyClassifiedProperty = 2048, Invalid = 4096, }; pub const FsrmRuleFlags_Disabled = FsrmRuleFlags.Disabled; pub const FsrmRuleFlags_ClearAutomaticallyClassifiedProperty = FsrmRuleFlags.ClearAutomaticallyClassifiedProperty; pub const FsrmRuleFlags_ClearManuallyClassifiedProperty = FsrmRuleFlags.ClearManuallyClassifiedProperty; pub const FsrmRuleFlags_Invalid = FsrmRuleFlags.Invalid; pub const FsrmClassificationLoggingFlags = enum(i32) { None = 0, ClassificationsInLogFile = 1, ErrorsInLogFile = 2, ClassificationsInSystemLog = 4, ErrorsInSystemLog = 8, }; pub const FsrmClassificationLoggingFlags_None = FsrmClassificationLoggingFlags.None; pub const FsrmClassificationLoggingFlags_ClassificationsInLogFile = FsrmClassificationLoggingFlags.ClassificationsInLogFile; pub const FsrmClassificationLoggingFlags_ErrorsInLogFile = FsrmClassificationLoggingFlags.ErrorsInLogFile; pub const FsrmClassificationLoggingFlags_ClassificationsInSystemLog = FsrmClassificationLoggingFlags.ClassificationsInSystemLog; pub const FsrmClassificationLoggingFlags_ErrorsInSystemLog = FsrmClassificationLoggingFlags.ErrorsInSystemLog; pub const FsrmExecutionOption = enum(i32) { Unknown = 0, EvaluateUnset = 1, ReEvaluate_ConsiderExistingValue = 2, ReEvaluate_IgnoreExistingValue = 3, }; pub const FsrmExecutionOption_Unknown = FsrmExecutionOption.Unknown; pub const FsrmExecutionOption_EvaluateUnset = FsrmExecutionOption.EvaluateUnset; pub const FsrmExecutionOption_ReEvaluate_ConsiderExistingValue = FsrmExecutionOption.ReEvaluate_ConsiderExistingValue; pub const FsrmExecutionOption_ReEvaluate_IgnoreExistingValue = FsrmExecutionOption.ReEvaluate_IgnoreExistingValue; pub const FsrmStorageModuleCaps = enum(i32) { Unknown = 0, CanGet = 1, CanSet = 2, CanHandleDirectories = 4, CanHandleFiles = 8, }; pub const FsrmStorageModuleCaps_Unknown = FsrmStorageModuleCaps.Unknown; pub const FsrmStorageModuleCaps_CanGet = FsrmStorageModuleCaps.CanGet; pub const FsrmStorageModuleCaps_CanSet = FsrmStorageModuleCaps.CanSet; pub const FsrmStorageModuleCaps_CanHandleDirectories = FsrmStorageModuleCaps.CanHandleDirectories; pub const FsrmStorageModuleCaps_CanHandleFiles = FsrmStorageModuleCaps.CanHandleFiles; pub const FsrmStorageModuleType = enum(i32) { Unknown = 0, Cache = 1, InFile = 2, Database = 3, System = 100, }; pub const FsrmStorageModuleType_Unknown = FsrmStorageModuleType.Unknown; pub const FsrmStorageModuleType_Cache = FsrmStorageModuleType.Cache; pub const FsrmStorageModuleType_InFile = FsrmStorageModuleType.InFile; pub const FsrmStorageModuleType_Database = FsrmStorageModuleType.Database; pub const FsrmStorageModuleType_System = FsrmStorageModuleType.System; pub const FsrmPropertyBagFlags = enum(i32) { UpdatedByClassifier = 1, FailedLoadingProperties = 2, FailedSavingProperties = 4, FailedClassifyingProperties = 8, }; pub const FsrmPropertyBagFlags_UpdatedByClassifier = FsrmPropertyBagFlags.UpdatedByClassifier; pub const FsrmPropertyBagFlags_FailedLoadingProperties = FsrmPropertyBagFlags.FailedLoadingProperties; pub const FsrmPropertyBagFlags_FailedSavingProperties = FsrmPropertyBagFlags.FailedSavingProperties; pub const FsrmPropertyBagFlags_FailedClassifyingProperties = FsrmPropertyBagFlags.FailedClassifyingProperties; pub const FsrmPropertyBagField = enum(i32) { AccessVolume = 0, VolumeGuidName = 1, }; pub const FsrmPropertyBagField_AccessVolume = FsrmPropertyBagField.AccessVolume; pub const FsrmPropertyBagField_VolumeGuidName = FsrmPropertyBagField.VolumeGuidName; pub const FsrmPropertyFlags = enum(i32) { None = 0, Orphaned = 1, RetrievedFromCache = 2, RetrievedFromStorage = 4, SetByClassifier = 8, Deleted = 16, Reclassified = 32, AggregationFailed = 64, Existing = 128, FailedLoadingProperties = 256, FailedClassifyingProperties = 512, FailedSavingProperties = 1024, Secure = 2048, PolicyDerived = 4096, Inherited = 8192, Manual = 16384, ExplicitValueDeleted = 32768, PropertyDeletedFromClear = 65536, PropertySourceMask = 14, PersistentMask = 20480, }; pub const FsrmPropertyFlags_None = FsrmPropertyFlags.None; pub const FsrmPropertyFlags_Orphaned = FsrmPropertyFlags.Orphaned; pub const FsrmPropertyFlags_RetrievedFromCache = FsrmPropertyFlags.RetrievedFromCache; pub const FsrmPropertyFlags_RetrievedFromStorage = FsrmPropertyFlags.RetrievedFromStorage; pub const FsrmPropertyFlags_SetByClassifier = FsrmPropertyFlags.SetByClassifier; pub const FsrmPropertyFlags_Deleted = FsrmPropertyFlags.Deleted; pub const FsrmPropertyFlags_Reclassified = FsrmPropertyFlags.Reclassified; pub const FsrmPropertyFlags_AggregationFailed = FsrmPropertyFlags.AggregationFailed; pub const FsrmPropertyFlags_Existing = FsrmPropertyFlags.Existing; pub const FsrmPropertyFlags_FailedLoadingProperties = FsrmPropertyFlags.FailedLoadingProperties; pub const FsrmPropertyFlags_FailedClassifyingProperties = FsrmPropertyFlags.FailedClassifyingProperties; pub const FsrmPropertyFlags_FailedSavingProperties = FsrmPropertyFlags.FailedSavingProperties; pub const FsrmPropertyFlags_Secure = FsrmPropertyFlags.Secure; pub const FsrmPropertyFlags_PolicyDerived = FsrmPropertyFlags.PolicyDerived; pub const FsrmPropertyFlags_Inherited = FsrmPropertyFlags.Inherited; pub const FsrmPropertyFlags_Manual = FsrmPropertyFlags.Manual; pub const FsrmPropertyFlags_ExplicitValueDeleted = FsrmPropertyFlags.ExplicitValueDeleted; pub const FsrmPropertyFlags_PropertyDeletedFromClear = FsrmPropertyFlags.PropertyDeletedFromClear; pub const FsrmPropertyFlags_PropertySourceMask = FsrmPropertyFlags.PropertySourceMask; pub const FsrmPropertyFlags_PersistentMask = FsrmPropertyFlags.PersistentMask; pub const FsrmPipelineModuleType = enum(i32) { Unknown = 0, Storage = 1, Classifier = 2, }; pub const FsrmPipelineModuleType_Unknown = FsrmPipelineModuleType.Unknown; pub const FsrmPipelineModuleType_Storage = FsrmPipelineModuleType.Storage; pub const FsrmPipelineModuleType_Classifier = FsrmPipelineModuleType.Classifier; pub const FsrmGetFilePropertyOptions = enum(i32) { None = 0, NoRuleEvaluation = 1, Persistent = 2, FailOnPersistErrors = 4, SkipOrphaned = 8, }; pub const FsrmGetFilePropertyOptions_None = FsrmGetFilePropertyOptions.None; pub const FsrmGetFilePropertyOptions_NoRuleEvaluation = FsrmGetFilePropertyOptions.NoRuleEvaluation; pub const FsrmGetFilePropertyOptions_Persistent = FsrmGetFilePropertyOptions.Persistent; pub const FsrmGetFilePropertyOptions_FailOnPersistErrors = FsrmGetFilePropertyOptions.FailOnPersistErrors; pub const FsrmGetFilePropertyOptions_SkipOrphaned = FsrmGetFilePropertyOptions.SkipOrphaned; pub const FsrmFileManagementType = enum(i32) { Unknown = 0, Expiration = 1, Custom = 2, Rms = 3, }; pub const FsrmFileManagementType_Unknown = FsrmFileManagementType.Unknown; pub const FsrmFileManagementType_Expiration = FsrmFileManagementType.Expiration; pub const FsrmFileManagementType_Custom = FsrmFileManagementType.Custom; pub const FsrmFileManagementType_Rms = FsrmFileManagementType.Rms; pub const FsrmFileManagementLoggingFlags = enum(i32) { None = 0, Error = 1, Information = 2, Audit = 4, }; pub const FsrmFileManagementLoggingFlags_None = FsrmFileManagementLoggingFlags.None; pub const FsrmFileManagementLoggingFlags_Error = FsrmFileManagementLoggingFlags.Error; pub const FsrmFileManagementLoggingFlags_Information = FsrmFileManagementLoggingFlags.Information; pub const FsrmFileManagementLoggingFlags_Audit = FsrmFileManagementLoggingFlags.Audit; pub const FsrmPropertyConditionType = enum(i32) { Unknown = 0, Equal = 1, NotEqual = 2, GreaterThan = 3, LessThan = 4, Contain = 5, Exist = 6, NotExist = 7, StartWith = 8, EndWith = 9, ContainedIn = 10, PrefixOf = 11, SuffixOf = 12, MatchesPattern = 13, }; pub const FsrmPropertyConditionType_Unknown = FsrmPropertyConditionType.Unknown; pub const FsrmPropertyConditionType_Equal = FsrmPropertyConditionType.Equal; pub const FsrmPropertyConditionType_NotEqual = FsrmPropertyConditionType.NotEqual; pub const FsrmPropertyConditionType_GreaterThan = FsrmPropertyConditionType.GreaterThan; pub const FsrmPropertyConditionType_LessThan = FsrmPropertyConditionType.LessThan; pub const FsrmPropertyConditionType_Contain = FsrmPropertyConditionType.Contain; pub const FsrmPropertyConditionType_Exist = FsrmPropertyConditionType.Exist; pub const FsrmPropertyConditionType_NotExist = FsrmPropertyConditionType.NotExist; pub const FsrmPropertyConditionType_StartWith = FsrmPropertyConditionType.StartWith; pub const FsrmPropertyConditionType_EndWith = FsrmPropertyConditionType.EndWith; pub const FsrmPropertyConditionType_ContainedIn = FsrmPropertyConditionType.ContainedIn; pub const FsrmPropertyConditionType_PrefixOf = FsrmPropertyConditionType.PrefixOf; pub const FsrmPropertyConditionType_SuffixOf = FsrmPropertyConditionType.SuffixOf; pub const FsrmPropertyConditionType_MatchesPattern = FsrmPropertyConditionType.MatchesPattern; pub const FsrmFileStreamingMode = enum(i32) { Unknown = 0, Read = 1, Write = 2, }; pub const FsrmFileStreamingMode_Unknown = FsrmFileStreamingMode.Unknown; pub const FsrmFileStreamingMode_Read = FsrmFileStreamingMode.Read; pub const FsrmFileStreamingMode_Write = FsrmFileStreamingMode.Write; pub const FsrmFileStreamingInterfaceType = enum(i32) { Unknown = 0, ILockBytes = 1, IStream = 2, }; pub const FsrmFileStreamingInterfaceType_Unknown = FsrmFileStreamingInterfaceType.Unknown; pub const FsrmFileStreamingInterfaceType_ILockBytes = FsrmFileStreamingInterfaceType.ILockBytes; pub const FsrmFileStreamingInterfaceType_IStream = FsrmFileStreamingInterfaceType.IStream; pub const FsrmFileConditionType = enum(i32) { Unknown = 0, Property = 1, }; pub const FsrmFileConditionType_Unknown = FsrmFileConditionType.Unknown; pub const FsrmFileConditionType_Property = FsrmFileConditionType.Property; pub const FsrmFileSystemPropertyId = enum(i32) { Undefined = 0, FileName = 1, DateCreated = 2, DateLastAccessed = 3, DateLastModified = 4, DateNow = 5, }; pub const FsrmFileSystemPropertyId_Undefined = FsrmFileSystemPropertyId.Undefined; pub const FsrmFileSystemPropertyId_FileName = FsrmFileSystemPropertyId.FileName; pub const FsrmFileSystemPropertyId_DateCreated = FsrmFileSystemPropertyId.DateCreated; pub const FsrmFileSystemPropertyId_DateLastAccessed = FsrmFileSystemPropertyId.DateLastAccessed; pub const FsrmFileSystemPropertyId_DateLastModified = FsrmFileSystemPropertyId.DateLastModified; pub const FsrmFileSystemPropertyId_DateNow = FsrmFileSystemPropertyId.DateNow; pub const FsrmPropertyValueType = enum(i32) { Undefined = 0, Literal = 1, DateOffset = 2, }; pub const FsrmPropertyValueType_Undefined = FsrmPropertyValueType.Undefined; pub const FsrmPropertyValueType_Literal = FsrmPropertyValueType.Literal; pub const FsrmPropertyValueType_DateOffset = FsrmPropertyValueType.DateOffset; pub const AdrClientDisplayFlags = enum(i32) { AllowEmailRequests = 1, ShowDeviceTroubleshooting = 2, }; pub const AdrClientDisplayFlags_AllowEmailRequests = AdrClientDisplayFlags.AllowEmailRequests; pub const AdrClientDisplayFlags_ShowDeviceTroubleshooting = AdrClientDisplayFlags.ShowDeviceTroubleshooting; pub const AdrEmailFlags = enum(i32) { PutDataOwnerOnToLine = 1, PutAdminOnToLine = 2, IncludeDeviceClaims = 4, IncludeUserInfo = 8, GenerateEventLog = 16, }; pub const AdrEmailFlags_PutDataOwnerOnToLine = AdrEmailFlags.PutDataOwnerOnToLine; pub const AdrEmailFlags_PutAdminOnToLine = AdrEmailFlags.PutAdminOnToLine; pub const AdrEmailFlags_IncludeDeviceClaims = AdrEmailFlags.IncludeDeviceClaims; pub const AdrEmailFlags_IncludeUserInfo = AdrEmailFlags.IncludeUserInfo; pub const AdrEmailFlags_GenerateEventLog = AdrEmailFlags.GenerateEventLog; pub const AdrClientErrorType = enum(i32) { Unknown = 0, AccessDenied = 1, FileNotFound = 2, }; pub const AdrClientErrorType_Unknown = AdrClientErrorType.Unknown; pub const AdrClientErrorType_AccessDenied = AdrClientErrorType.AccessDenied; pub const AdrClientErrorType_FileNotFound = AdrClientErrorType.FileNotFound; pub const AdrClientFlags = enum(i32) { None = 0, FailForLocalPaths = 1, FailIfNotSupportedByServer = 2, FailIfNotDomainJoined = 4, }; pub const AdrClientFlags_None = AdrClientFlags.None; pub const AdrClientFlags_FailForLocalPaths = AdrClientFlags.FailForLocalPaths; pub const AdrClientFlags_FailIfNotSupportedByServer = AdrClientFlags.FailIfNotSupportedByServer; pub const AdrClientFlags_FailIfNotDomainJoined = AdrClientFlags.FailIfNotDomainJoined; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmObject_Value = Guid.initString("22bcef93-4a3f-4183-89f9-2f8b8a628aee"); pub const IID_IFsrmObject = &IID_IFsrmObject_Value; pub const IFsrmObject = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Id: fn( self: *const IFsrmObject, id: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Description: fn( self: *const IFsrmObject, description: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Description: fn( self: *const IFsrmObject, description: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Delete: fn( self: *const IFsrmObject, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Commit: fn( self: *const IFsrmObject, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmObject_get_Id(self: *const T, id: ?*Guid) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmObject.VTable, self.vtable).get_Id(@ptrCast(*const IFsrmObject, self), id); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmObject_get_Description(self: *const T, description: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmObject.VTable, self.vtable).get_Description(@ptrCast(*const IFsrmObject, self), description); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmObject_put_Description(self: *const T, description: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmObject.VTable, self.vtable).put_Description(@ptrCast(*const IFsrmObject, self), description); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmObject_Delete(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmObject.VTable, self.vtable).Delete(@ptrCast(*const IFsrmObject, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmObject_Commit(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmObject.VTable, self.vtable).Commit(@ptrCast(*const IFsrmObject, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmCollection_Value = Guid.initString("f76fbf3b-8ddd-4b42-b05a-cb1c3ff1fee8"); pub const IID_IFsrmCollection = &IID_IFsrmCollection_Value; pub const IFsrmCollection = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get__NewEnum: fn( self: *const IFsrmCollection, unknown: ?*?*IUnknown, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Item: fn( self: *const IFsrmCollection, index: i32, item: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Count: fn( self: *const IFsrmCollection, count: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_State: fn( self: *const IFsrmCollection, state: ?*FsrmCollectionState, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Cancel: fn( self: *const IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, WaitForCompletion: fn( self: *const IFsrmCollection, waitSeconds: i32, completed: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetById: fn( self: *const IFsrmCollection, id: Guid, entry: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmCollection_get__NewEnum(self: *const T, unknown: ?*?*IUnknown) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmCollection.VTable, self.vtable).get__NewEnum(@ptrCast(*const IFsrmCollection, self), unknown); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmCollection_get_Item(self: *const T, index: i32, item: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmCollection.VTable, self.vtable).get_Item(@ptrCast(*const IFsrmCollection, self), index, item); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmCollection_get_Count(self: *const T, count: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmCollection.VTable, self.vtable).get_Count(@ptrCast(*const IFsrmCollection, self), count); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmCollection_get_State(self: *const T, state: ?*FsrmCollectionState) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmCollection.VTable, self.vtable).get_State(@ptrCast(*const IFsrmCollection, self), state); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmCollection_Cancel(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmCollection.VTable, self.vtable).Cancel(@ptrCast(*const IFsrmCollection, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmCollection_WaitForCompletion(self: *const T, waitSeconds: i32, completed: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmCollection.VTable, self.vtable).WaitForCompletion(@ptrCast(*const IFsrmCollection, self), waitSeconds, completed); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmCollection_GetById(self: *const T, id: Guid, entry: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmCollection.VTable, self.vtable).GetById(@ptrCast(*const IFsrmCollection, self), id, entry); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmMutableCollection_Value = Guid.initString("1bb617b8-3886-49dc-af82-a6c90fa35dda"); pub const IID_IFsrmMutableCollection = &IID_IFsrmMutableCollection_Value; pub const IFsrmMutableCollection = extern struct { pub const VTable = extern struct { base: IFsrmCollection.VTable, Add: fn( self: *const IFsrmMutableCollection, item: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Remove: fn( self: *const IFsrmMutableCollection, index: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RemoveById: fn( self: *const IFsrmMutableCollection, id: Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Clone: fn( self: *const IFsrmMutableCollection, collection: ?*?*IFsrmMutableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmCollection.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmMutableCollection_Add(self: *const T, item: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmMutableCollection.VTable, self.vtable).Add(@ptrCast(*const IFsrmMutableCollection, self), item); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmMutableCollection_Remove(self: *const T, index: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmMutableCollection.VTable, self.vtable).Remove(@ptrCast(*const IFsrmMutableCollection, self), index); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmMutableCollection_RemoveById(self: *const T, id: Guid) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmMutableCollection.VTable, self.vtable).RemoveById(@ptrCast(*const IFsrmMutableCollection, self), id); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmMutableCollection_Clone(self: *const T, collection: ?*?*IFsrmMutableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmMutableCollection.VTable, self.vtable).Clone(@ptrCast(*const IFsrmMutableCollection, self), collection); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmCommittableCollection_Value = Guid.initString("96deb3b5-8b91-4a2a-9d93-80a35d8aa847"); pub const IID_IFsrmCommittableCollection = &IID_IFsrmCommittableCollection_Value; pub const IFsrmCommittableCollection = extern struct { pub const VTable = extern struct { base: IFsrmMutableCollection.VTable, Commit: fn( self: *const IFsrmCommittableCollection, options: FsrmCommitOptions, results: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmMutableCollection.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmCommittableCollection_Commit(self: *const T, options: FsrmCommitOptions, results: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmCommittableCollection.VTable, self.vtable).Commit(@ptrCast(*const IFsrmCommittableCollection, self), options, results); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmAction_Value = Guid.initString("6cd6408a-ae60-463b-9ef1-e117534d69dc"); pub const IID_IFsrmAction = &IID_IFsrmAction_Value; pub const IFsrmAction = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Id: fn( self: *const IFsrmAction, id: ?*Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ActionType: fn( self: *const IFsrmAction, actionType: ?*FsrmActionType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RunLimitInterval: fn( self: *const IFsrmAction, minutes: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_RunLimitInterval: fn( self: *const IFsrmAction, minutes: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Delete: fn( self: *const IFsrmAction, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmAction_get_Id(self: *const T, id: ?*Guid) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmAction.VTable, self.vtable).get_Id(@ptrCast(*const IFsrmAction, self), id); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmAction_get_ActionType(self: *const T, actionType: ?*FsrmActionType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmAction.VTable, self.vtable).get_ActionType(@ptrCast(*const IFsrmAction, self), actionType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmAction_get_RunLimitInterval(self: *const T, minutes: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmAction.VTable, self.vtable).get_RunLimitInterval(@ptrCast(*const IFsrmAction, self), minutes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmAction_put_RunLimitInterval(self: *const T, minutes: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmAction.VTable, self.vtable).put_RunLimitInterval(@ptrCast(*const IFsrmAction, self), minutes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmAction_Delete(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmAction.VTable, self.vtable).Delete(@ptrCast(*const IFsrmAction, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmActionEmail_Value = Guid.initString("d646567d-26ae-4caa-9f84-4e0aad207fca"); pub const IID_IFsrmActionEmail = &IID_IFsrmActionEmail_Value; pub const IFsrmActionEmail = extern struct { pub const VTable = extern struct { base: IFsrmAction.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailFrom: fn( self: *const IFsrmActionEmail, mailFrom: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailFrom: fn( self: *const IFsrmActionEmail, mailFrom: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailReplyTo: fn( self: *const IFsrmActionEmail, mailReplyTo: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailReplyTo: fn( self: *const IFsrmActionEmail, mailReplyTo: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailTo: fn( self: *const IFsrmActionEmail, mailTo: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailTo: fn( self: *const IFsrmActionEmail, mailTo: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailCc: fn( self: *const IFsrmActionEmail, mailCc: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailCc: fn( self: *const IFsrmActionEmail, mailCc: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailBcc: fn( self: *const IFsrmActionEmail, mailBcc: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailBcc: fn( self: *const IFsrmActionEmail, mailBcc: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailSubject: fn( self: *const IFsrmActionEmail, mailSubject: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailSubject: fn( self: *const IFsrmActionEmail, mailSubject: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MessageText: fn( self: *const IFsrmActionEmail, messageText: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MessageText: fn( self: *const IFsrmActionEmail, messageText: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmAction.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_get_MailFrom(self: *const T, mailFrom: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).get_MailFrom(@ptrCast(*const IFsrmActionEmail, self), mailFrom); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_put_MailFrom(self: *const T, mailFrom: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).put_MailFrom(@ptrCast(*const IFsrmActionEmail, self), mailFrom); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_get_MailReplyTo(self: *const T, mailReplyTo: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).get_MailReplyTo(@ptrCast(*const IFsrmActionEmail, self), mailReplyTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_put_MailReplyTo(self: *const T, mailReplyTo: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).put_MailReplyTo(@ptrCast(*const IFsrmActionEmail, self), mailReplyTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_get_MailTo(self: *const T, mailTo: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).get_MailTo(@ptrCast(*const IFsrmActionEmail, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_put_MailTo(self: *const T, mailTo: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).put_MailTo(@ptrCast(*const IFsrmActionEmail, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_get_MailCc(self: *const T, mailCc: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).get_MailCc(@ptrCast(*const IFsrmActionEmail, self), mailCc); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_put_MailCc(self: *const T, mailCc: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).put_MailCc(@ptrCast(*const IFsrmActionEmail, self), mailCc); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_get_MailBcc(self: *const T, mailBcc: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).get_MailBcc(@ptrCast(*const IFsrmActionEmail, self), mailBcc); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_put_MailBcc(self: *const T, mailBcc: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).put_MailBcc(@ptrCast(*const IFsrmActionEmail, self), mailBcc); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_get_MailSubject(self: *const T, mailSubject: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).get_MailSubject(@ptrCast(*const IFsrmActionEmail, self), mailSubject); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_put_MailSubject(self: *const T, mailSubject: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).put_MailSubject(@ptrCast(*const IFsrmActionEmail, self), mailSubject); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_get_MessageText(self: *const T, messageText: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).get_MessageText(@ptrCast(*const IFsrmActionEmail, self), messageText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail_put_MessageText(self: *const T, messageText: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail.VTable, self.vtable).put_MessageText(@ptrCast(*const IFsrmActionEmail, self), messageText); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmActionEmail2_Value = Guid.initString("8276702f-2532-4839-89bf-4872609a2ea4"); pub const IID_IFsrmActionEmail2 = &IID_IFsrmActionEmail2_Value; pub const IFsrmActionEmail2 = extern struct { pub const VTable = extern struct { base: IFsrmActionEmail.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AttachmentFileListSize: fn( self: *const IFsrmActionEmail2, attachmentFileListSize: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AttachmentFileListSize: fn( self: *const IFsrmActionEmail2, attachmentFileListSize: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmActionEmail.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail2_get_AttachmentFileListSize(self: *const T, attachmentFileListSize: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail2.VTable, self.vtable).get_AttachmentFileListSize(@ptrCast(*const IFsrmActionEmail2, self), attachmentFileListSize); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEmail2_put_AttachmentFileListSize(self: *const T, attachmentFileListSize: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEmail2.VTable, self.vtable).put_AttachmentFileListSize(@ptrCast(*const IFsrmActionEmail2, self), attachmentFileListSize); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmActionReport_Value = Guid.initString("2dbe63c4-b340-48a0-a5b0-158e07fc567e"); pub const IID_IFsrmActionReport = &IID_IFsrmActionReport_Value; pub const IFsrmActionReport = extern struct { pub const VTable = extern struct { base: IFsrmAction.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReportTypes: fn( self: *const IFsrmActionReport, reportTypes: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ReportTypes: fn( self: *const IFsrmActionReport, reportTypes: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailTo: fn( self: *const IFsrmActionReport, mailTo: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailTo: fn( self: *const IFsrmActionReport, mailTo: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmAction.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionReport_get_ReportTypes(self: *const T, reportTypes: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionReport.VTable, self.vtable).get_ReportTypes(@ptrCast(*const IFsrmActionReport, self), reportTypes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionReport_put_ReportTypes(self: *const T, reportTypes: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionReport.VTable, self.vtable).put_ReportTypes(@ptrCast(*const IFsrmActionReport, self), reportTypes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionReport_get_MailTo(self: *const T, mailTo: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionReport.VTable, self.vtable).get_MailTo(@ptrCast(*const IFsrmActionReport, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionReport_put_MailTo(self: *const T, mailTo: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionReport.VTable, self.vtable).put_MailTo(@ptrCast(*const IFsrmActionReport, self), mailTo); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmActionEventLog_Value = Guid.initString("4c8f96c3-5d94-4f37-a4f4-f56ab463546f"); pub const IID_IFsrmActionEventLog = &IID_IFsrmActionEventLog_Value; pub const IFsrmActionEventLog = extern struct { pub const VTable = extern struct { base: IFsrmAction.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EventType: fn( self: *const IFsrmActionEventLog, eventType: ?*FsrmEventType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_EventType: fn( self: *const IFsrmActionEventLog, eventType: FsrmEventType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MessageText: fn( self: *const IFsrmActionEventLog, messageText: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MessageText: fn( self: *const IFsrmActionEventLog, messageText: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmAction.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEventLog_get_EventType(self: *const T, eventType: ?*FsrmEventType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEventLog.VTable, self.vtable).get_EventType(@ptrCast(*const IFsrmActionEventLog, self), eventType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEventLog_put_EventType(self: *const T, eventType: FsrmEventType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEventLog.VTable, self.vtable).put_EventType(@ptrCast(*const IFsrmActionEventLog, self), eventType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEventLog_get_MessageText(self: *const T, messageText: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEventLog.VTable, self.vtable).get_MessageText(@ptrCast(*const IFsrmActionEventLog, self), messageText); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionEventLog_put_MessageText(self: *const T, messageText: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionEventLog.VTable, self.vtable).put_MessageText(@ptrCast(*const IFsrmActionEventLog, self), messageText); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmActionCommand_Value = Guid.initString("12937789-e247-4917-9c20-f3ee9c7ee783"); pub const IID_IFsrmActionCommand = &IID_IFsrmActionCommand_Value; pub const IFsrmActionCommand = extern struct { pub const VTable = extern struct { base: IFsrmAction.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ExecutablePath: fn( self: *const IFsrmActionCommand, executablePath: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ExecutablePath: fn( self: *const IFsrmActionCommand, executablePath: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Arguments: fn( self: *const IFsrmActionCommand, arguments: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Arguments: fn( self: *const IFsrmActionCommand, arguments: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Account: fn( self: *const IFsrmActionCommand, account: ?*FsrmAccountType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Account: fn( self: *const IFsrmActionCommand, account: FsrmAccountType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_WorkingDirectory: fn( self: *const IFsrmActionCommand, workingDirectory: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_WorkingDirectory: fn( self: *const IFsrmActionCommand, workingDirectory: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MonitorCommand: fn( self: *const IFsrmActionCommand, monitorCommand: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MonitorCommand: fn( self: *const IFsrmActionCommand, monitorCommand: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_KillTimeOut: fn( self: *const IFsrmActionCommand, minutes: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_KillTimeOut: fn( self: *const IFsrmActionCommand, minutes: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LogResult: fn( self: *const IFsrmActionCommand, logResults: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_LogResult: fn( self: *const IFsrmActionCommand, logResults: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmAction.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_get_ExecutablePath(self: *const T, executablePath: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).get_ExecutablePath(@ptrCast(*const IFsrmActionCommand, self), executablePath); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_put_ExecutablePath(self: *const T, executablePath: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).put_ExecutablePath(@ptrCast(*const IFsrmActionCommand, self), executablePath); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_get_Arguments(self: *const T, arguments: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).get_Arguments(@ptrCast(*const IFsrmActionCommand, self), arguments); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_put_Arguments(self: *const T, arguments: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).put_Arguments(@ptrCast(*const IFsrmActionCommand, self), arguments); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_get_Account(self: *const T, account: ?*FsrmAccountType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).get_Account(@ptrCast(*const IFsrmActionCommand, self), account); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_put_Account(self: *const T, account: FsrmAccountType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).put_Account(@ptrCast(*const IFsrmActionCommand, self), account); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_get_WorkingDirectory(self: *const T, workingDirectory: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).get_WorkingDirectory(@ptrCast(*const IFsrmActionCommand, self), workingDirectory); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_put_WorkingDirectory(self: *const T, workingDirectory: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).put_WorkingDirectory(@ptrCast(*const IFsrmActionCommand, self), workingDirectory); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_get_MonitorCommand(self: *const T, monitorCommand: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).get_MonitorCommand(@ptrCast(*const IFsrmActionCommand, self), monitorCommand); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_put_MonitorCommand(self: *const T, monitorCommand: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).put_MonitorCommand(@ptrCast(*const IFsrmActionCommand, self), monitorCommand); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_get_KillTimeOut(self: *const T, minutes: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).get_KillTimeOut(@ptrCast(*const IFsrmActionCommand, self), minutes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_put_KillTimeOut(self: *const T, minutes: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).put_KillTimeOut(@ptrCast(*const IFsrmActionCommand, self), minutes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_get_LogResult(self: *const T, logResults: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).get_LogResult(@ptrCast(*const IFsrmActionCommand, self), logResults); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmActionCommand_put_LogResult(self: *const T, logResults: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmActionCommand.VTable, self.vtable).put_LogResult(@ptrCast(*const IFsrmActionCommand, self), logResults); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmSetting_Value = Guid.initString("f411d4fd-14be-4260-8c40-03b7c95e608a"); pub const IID_IFsrmSetting = &IID_IFsrmSetting_Value; pub const IFsrmSetting = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SmtpServer: fn( self: *const IFsrmSetting, smtpServer: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SmtpServer: fn( self: *const IFsrmSetting, smtpServer: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailFrom: fn( self: *const IFsrmSetting, mailFrom: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailFrom: fn( self: *const IFsrmSetting, mailFrom: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AdminEmail: fn( self: *const IFsrmSetting, adminEmail: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AdminEmail: fn( self: *const IFsrmSetting, adminEmail: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DisableCommandLine: fn( self: *const IFsrmSetting, disableCommandLine: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DisableCommandLine: fn( self: *const IFsrmSetting, disableCommandLine: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_EnableScreeningAudit: fn( self: *const IFsrmSetting, enableScreeningAudit: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_EnableScreeningAudit: fn( self: *const IFsrmSetting, enableScreeningAudit: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EmailTest: fn( self: *const IFsrmSetting, mailTo: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetActionRunLimitInterval: fn( self: *const IFsrmSetting, actionType: FsrmActionType, delayTimeMinutes: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetActionRunLimitInterval: fn( self: *const IFsrmSetting, actionType: FsrmActionType, delayTimeMinutes: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_get_SmtpServer(self: *const T, smtpServer: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).get_SmtpServer(@ptrCast(*const IFsrmSetting, self), smtpServer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_put_SmtpServer(self: *const T, smtpServer: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).put_SmtpServer(@ptrCast(*const IFsrmSetting, self), smtpServer); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_get_MailFrom(self: *const T, mailFrom: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).get_MailFrom(@ptrCast(*const IFsrmSetting, self), mailFrom); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_put_MailFrom(self: *const T, mailFrom: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).put_MailFrom(@ptrCast(*const IFsrmSetting, self), mailFrom); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_get_AdminEmail(self: *const T, adminEmail: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).get_AdminEmail(@ptrCast(*const IFsrmSetting, self), adminEmail); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_put_AdminEmail(self: *const T, adminEmail: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).put_AdminEmail(@ptrCast(*const IFsrmSetting, self), adminEmail); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_get_DisableCommandLine(self: *const T, disableCommandLine: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).get_DisableCommandLine(@ptrCast(*const IFsrmSetting, self), disableCommandLine); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_put_DisableCommandLine(self: *const T, disableCommandLine: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).put_DisableCommandLine(@ptrCast(*const IFsrmSetting, self), disableCommandLine); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_get_EnableScreeningAudit(self: *const T, enableScreeningAudit: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).get_EnableScreeningAudit(@ptrCast(*const IFsrmSetting, self), enableScreeningAudit); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_put_EnableScreeningAudit(self: *const T, enableScreeningAudit: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).put_EnableScreeningAudit(@ptrCast(*const IFsrmSetting, self), enableScreeningAudit); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_EmailTest(self: *const T, mailTo: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).EmailTest(@ptrCast(*const IFsrmSetting, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_SetActionRunLimitInterval(self: *const T, actionType: FsrmActionType, delayTimeMinutes: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).SetActionRunLimitInterval(@ptrCast(*const IFsrmSetting, self), actionType, delayTimeMinutes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmSetting_GetActionRunLimitInterval(self: *const T, actionType: FsrmActionType, delayTimeMinutes: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmSetting.VTable, self.vtable).GetActionRunLimitInterval(@ptrCast(*const IFsrmSetting, self), actionType, delayTimeMinutes); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmPathMapper_Value = Guid.initString("6f4dbfff-6920-4821-a6c3-b7e94c1fd60c"); pub const IID_IFsrmPathMapper = &IID_IFsrmPathMapper_Value; pub const IFsrmPathMapper = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, GetSharePathsForLocalPath: fn( self: *const IFsrmPathMapper, localPath: ?BSTR, sharePaths: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPathMapper_GetSharePathsForLocalPath(self: *const T, localPath: ?BSTR, sharePaths: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPathMapper.VTable, self.vtable).GetSharePathsForLocalPath(@ptrCast(*const IFsrmPathMapper, self), localPath, sharePaths); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmExportImport_Value = Guid.initString("efcb0ab1-16c4-4a79-812c-725614c3306b"); pub const IID_IFsrmExportImport = &IID_IFsrmExportImport_Value; pub const IFsrmExportImport = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, ExportFileGroups: fn( self: *const IFsrmExportImport, filePath: ?BSTR, fileGroupNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ImportFileGroups: fn( self: *const IFsrmExportImport, filePath: ?BSTR, fileGroupNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR, fileGroups: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ExportFileScreenTemplates: fn( self: *const IFsrmExportImport, filePath: ?BSTR, templateNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ImportFileScreenTemplates: fn( self: *const IFsrmExportImport, filePath: ?BSTR, templateNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR, templates: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ExportQuotaTemplates: fn( self: *const IFsrmExportImport, filePath: ?BSTR, templateNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ImportQuotaTemplates: fn( self: *const IFsrmExportImport, filePath: ?BSTR, templateNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR, templates: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmExportImport_ExportFileGroups(self: *const T, filePath: ?BSTR, fileGroupNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmExportImport.VTable, self.vtable).ExportFileGroups(@ptrCast(*const IFsrmExportImport, self), filePath, fileGroupNamesSafeArray, remoteHost); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmExportImport_ImportFileGroups(self: *const T, filePath: ?BSTR, fileGroupNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR, fileGroups: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmExportImport.VTable, self.vtable).ImportFileGroups(@ptrCast(*const IFsrmExportImport, self), filePath, fileGroupNamesSafeArray, remoteHost, fileGroups); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmExportImport_ExportFileScreenTemplates(self: *const T, filePath: ?BSTR, templateNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmExportImport.VTable, self.vtable).ExportFileScreenTemplates(@ptrCast(*const IFsrmExportImport, self), filePath, templateNamesSafeArray, remoteHost); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmExportImport_ImportFileScreenTemplates(self: *const T, filePath: ?BSTR, templateNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR, templates: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmExportImport.VTable, self.vtable).ImportFileScreenTemplates(@ptrCast(*const IFsrmExportImport, self), filePath, templateNamesSafeArray, remoteHost, templates); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmExportImport_ExportQuotaTemplates(self: *const T, filePath: ?BSTR, templateNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmExportImport.VTable, self.vtable).ExportQuotaTemplates(@ptrCast(*const IFsrmExportImport, self), filePath, templateNamesSafeArray, remoteHost); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmExportImport_ImportQuotaTemplates(self: *const T, filePath: ?BSTR, templateNamesSafeArray: ?*VARIANT, remoteHost: ?BSTR, templates: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmExportImport.VTable, self.vtable).ImportQuotaTemplates(@ptrCast(*const IFsrmExportImport, self), filePath, templateNamesSafeArray, remoteHost, templates); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmDerivedObjectsResult_Value = Guid.initString("39322a2d-38ee-4d0d-8095-421a80849a82"); pub const IID_IFsrmDerivedObjectsResult = &IID_IFsrmDerivedObjectsResult_Value; pub const IFsrmDerivedObjectsResult = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DerivedObjects: fn( self: *const IFsrmDerivedObjectsResult, derivedObjects: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Results: fn( self: *const IFsrmDerivedObjectsResult, results: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmDerivedObjectsResult_get_DerivedObjects(self: *const T, derivedObjects: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmDerivedObjectsResult.VTable, self.vtable).get_DerivedObjects(@ptrCast(*const IFsrmDerivedObjectsResult, self), derivedObjects); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmDerivedObjectsResult_get_Results(self: *const T, results: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmDerivedObjectsResult.VTable, self.vtable).get_Results(@ptrCast(*const IFsrmDerivedObjectsResult, self), results); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2012' const IID_IFsrmAccessDeniedRemediationClient_Value = Guid.initString("40002314-590b-45a5-8e1b-8c05da527e52"); pub const IID_IFsrmAccessDeniedRemediationClient = &IID_IFsrmAccessDeniedRemediationClient_Value; pub const IFsrmAccessDeniedRemediationClient = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, Show: fn( self: *const IFsrmAccessDeniedRemediationClient, parentWnd: usize, accessPath: ?BSTR, errorType: AdrClientErrorType, flags: i32, windowTitle: ?BSTR, windowMessage: ?BSTR, result: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmAccessDeniedRemediationClient_Show(self: *const T, parentWnd: usize, accessPath: ?BSTR, errorType: AdrClientErrorType, flags: i32, windowTitle: ?BSTR, windowMessage: ?BSTR, result: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmAccessDeniedRemediationClient.VTable, self.vtable).Show(@ptrCast(*const IFsrmAccessDeniedRemediationClient, self), parentWnd, accessPath, errorType, flags, windowTitle, windowMessage, result); } };} pub usingnamespace MethodMixin(@This()); }; const CLSID_FsrmSetting_Value = Guid.initString("f556d708-6d4d-4594-9c61-7dbb0dae2a46"); pub const CLSID_FsrmSetting = &CLSID_FsrmSetting_Value; const CLSID_FsrmPathMapper_Value = Guid.initString("f3be42bd-8ac2-409e-bbd8-faf9b6b41feb"); pub const CLSID_FsrmPathMapper = &CLSID_FsrmPathMapper_Value; const CLSID_FsrmExportImport_Value = Guid.initString("1482dc37-fae9-4787-9025-8ce4e024ab56"); pub const CLSID_FsrmExportImport = &CLSID_FsrmExportImport_Value; const CLSID_FsrmQuotaManager_Value = Guid.initString("90dcab7f-347c-4bfc-b543-540326305fbe"); pub const CLSID_FsrmQuotaManager = &CLSID_FsrmQuotaManager_Value; const CLSID_FsrmQuotaTemplateManager_Value = Guid.initString("97d3d443-251c-4337-81e7-b32e8f4ee65e"); pub const CLSID_FsrmQuotaTemplateManager = &CLSID_FsrmQuotaTemplateManager_Value; const CLSID_FsrmFileGroupManager_Value = Guid.initString("8f1363f6-656f-4496-9226-13aecbd7718f"); pub const CLSID_FsrmFileGroupManager = &CLSID_FsrmFileGroupManager_Value; const CLSID_FsrmFileScreenManager_Value = Guid.initString("95941183-db53-4c5f-b37b-7d0921cf9dc7"); pub const CLSID_FsrmFileScreenManager = &CLSID_FsrmFileScreenManager_Value; const CLSID_FsrmFileScreenTemplateManager_Value = Guid.initString("243111df-e474-46aa-a054-eaa33edc292a"); pub const CLSID_FsrmFileScreenTemplateManager = &CLSID_FsrmFileScreenTemplateManager_Value; const CLSID_FsrmReportManager_Value = Guid.initString("0058ef37-aa66-4c48-bd5b-2fce432ab0c8"); pub const CLSID_FsrmReportManager = &CLSID_FsrmReportManager_Value; const CLSID_FsrmReportScheduler_Value = Guid.initString("ea25f1b8-1b8d-4290-8ee8-e17c12c2fe20"); pub const CLSID_FsrmReportScheduler = &CLSID_FsrmReportScheduler_Value; const CLSID_FsrmFileManagementJobManager_Value = Guid.initString("eb18f9b2-4c3a-4321-b203-205120cff614"); pub const CLSID_FsrmFileManagementJobManager = &CLSID_FsrmFileManagementJobManager_Value; const CLSID_FsrmClassificationManager_Value = Guid.initString("b15c0e47-c391-45b9-95c8-eb596c853f3a"); pub const CLSID_FsrmClassificationManager = &CLSID_FsrmClassificationManager_Value; const CLSID_FsrmPipelineModuleConnector_Value = Guid.initString("c7643375-1eb5-44de-a062-623547d933bc"); pub const CLSID_FsrmPipelineModuleConnector = &CLSID_FsrmPipelineModuleConnector_Value; const CLSID_AdSyncTask_Value = Guid.initString("2ae64751-b728-4d6b-97a0-b2da2e7d2a3b"); pub const CLSID_AdSyncTask = &CLSID_AdSyncTask_Value; const CLSID_FsrmAccessDeniedRemediationClient_Value = Guid.initString("100b4fc8-74c1-470f-b1b7-dd7b6bae79bd"); pub const CLSID_FsrmAccessDeniedRemediationClient = &CLSID_FsrmAccessDeniedRemediationClient_Value; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmQuotaBase_Value = Guid.initString("1568a795-3924-4118-b74b-68d8f0fa5daf"); pub const IID_IFsrmQuotaBase = &IID_IFsrmQuotaBase_Value; pub const IFsrmQuotaBase = extern struct { pub const VTable = extern struct { base: IFsrmObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QuotaLimit: fn( self: *const IFsrmQuotaBase, quotaLimit: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_QuotaLimit: fn( self: *const IFsrmQuotaBase, quotaLimit: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QuotaFlags: fn( self: *const IFsrmQuotaBase, quotaFlags: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_QuotaFlags: fn( self: *const IFsrmQuotaBase, quotaFlags: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Thresholds: fn( self: *const IFsrmQuotaBase, thresholds: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AddThreshold: fn( self: *const IFsrmQuotaBase, threshold: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DeleteThreshold: fn( self: *const IFsrmQuotaBase, threshold: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ModifyThreshold: fn( self: *const IFsrmQuotaBase, threshold: i32, newThreshold: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateThresholdAction: fn( self: *const IFsrmQuotaBase, threshold: i32, actionType: FsrmActionType, action: ?*?*IFsrmAction, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumThresholdActions: fn( self: *const IFsrmQuotaBase, threshold: i32, actions: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_get_QuotaLimit(self: *const T, quotaLimit: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).get_QuotaLimit(@ptrCast(*const IFsrmQuotaBase, self), quotaLimit); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_put_QuotaLimit(self: *const T, quotaLimit: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).put_QuotaLimit(@ptrCast(*const IFsrmQuotaBase, self), quotaLimit); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_get_QuotaFlags(self: *const T, quotaFlags: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).get_QuotaFlags(@ptrCast(*const IFsrmQuotaBase, self), quotaFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_put_QuotaFlags(self: *const T, quotaFlags: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).put_QuotaFlags(@ptrCast(*const IFsrmQuotaBase, self), quotaFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_get_Thresholds(self: *const T, thresholds: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).get_Thresholds(@ptrCast(*const IFsrmQuotaBase, self), thresholds); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_AddThreshold(self: *const T, threshold: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).AddThreshold(@ptrCast(*const IFsrmQuotaBase, self), threshold); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_DeleteThreshold(self: *const T, threshold: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).DeleteThreshold(@ptrCast(*const IFsrmQuotaBase, self), threshold); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_ModifyThreshold(self: *const T, threshold: i32, newThreshold: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).ModifyThreshold(@ptrCast(*const IFsrmQuotaBase, self), threshold, newThreshold); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_CreateThresholdAction(self: *const T, threshold: i32, actionType: FsrmActionType, action: ?*?*IFsrmAction) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).CreateThresholdAction(@ptrCast(*const IFsrmQuotaBase, self), threshold, actionType, action); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaBase_EnumThresholdActions(self: *const T, threshold: i32, actions: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaBase.VTable, self.vtable).EnumThresholdActions(@ptrCast(*const IFsrmQuotaBase, self), threshold, actions); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmQuotaObject_Value = Guid.initString("42dc3511-61d5-48ae-b6dc-59fc00c0a8d6"); pub const IID_IFsrmQuotaObject = &IID_IFsrmQuotaObject_Value; pub const IFsrmQuotaObject = extern struct { pub const VTable = extern struct { base: IFsrmQuotaBase.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Path: fn( self: *const IFsrmQuotaObject, path: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UserSid: fn( self: *const IFsrmQuotaObject, userSid: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UserAccount: fn( self: *const IFsrmQuotaObject, userAccount: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SourceTemplateName: fn( self: *const IFsrmQuotaObject, quotaTemplateName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MatchesSourceTemplate: fn( self: *const IFsrmQuotaObject, matches: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ApplyTemplate: fn( self: *const IFsrmQuotaObject, quotaTemplateName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmQuotaBase.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaObject_get_Path(self: *const T, path: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaObject.VTable, self.vtable).get_Path(@ptrCast(*const IFsrmQuotaObject, self), path); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaObject_get_UserSid(self: *const T, userSid: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaObject.VTable, self.vtable).get_UserSid(@ptrCast(*const IFsrmQuotaObject, self), userSid); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaObject_get_UserAccount(self: *const T, userAccount: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaObject.VTable, self.vtable).get_UserAccount(@ptrCast(*const IFsrmQuotaObject, self), userAccount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaObject_get_SourceTemplateName(self: *const T, quotaTemplateName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaObject.VTable, self.vtable).get_SourceTemplateName(@ptrCast(*const IFsrmQuotaObject, self), quotaTemplateName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaObject_get_MatchesSourceTemplate(self: *const T, matches: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaObject.VTable, self.vtable).get_MatchesSourceTemplate(@ptrCast(*const IFsrmQuotaObject, self), matches); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaObject_ApplyTemplate(self: *const T, quotaTemplateName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaObject.VTable, self.vtable).ApplyTemplate(@ptrCast(*const IFsrmQuotaObject, self), quotaTemplateName); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmQuota_Value = Guid.initString("377f739d-9647-4b8e-97d2-5ffce6d759cd"); pub const IID_IFsrmQuota = &IID_IFsrmQuota_Value; pub const IFsrmQuota = extern struct { pub const VTable = extern struct { base: IFsrmQuotaObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QuotaUsed: fn( self: *const IFsrmQuota, used: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QuotaPeakUsage: fn( self: *const IFsrmQuota, peakUsage: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_QuotaPeakUsageTime: fn( self: *const IFsrmQuota, peakUsageDateTime: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ResetPeakUsage: fn( self: *const IFsrmQuota, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RefreshUsageProperties: fn( self: *const IFsrmQuota, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmQuotaObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuota_get_QuotaUsed(self: *const T, used: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuota.VTable, self.vtable).get_QuotaUsed(@ptrCast(*const IFsrmQuota, self), used); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuota_get_QuotaPeakUsage(self: *const T, peakUsage: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuota.VTable, self.vtable).get_QuotaPeakUsage(@ptrCast(*const IFsrmQuota, self), peakUsage); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuota_get_QuotaPeakUsageTime(self: *const T, peakUsageDateTime: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuota.VTable, self.vtable).get_QuotaPeakUsageTime(@ptrCast(*const IFsrmQuota, self), peakUsageDateTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuota_ResetPeakUsage(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuota.VTable, self.vtable).ResetPeakUsage(@ptrCast(*const IFsrmQuota, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuota_RefreshUsageProperties(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuota.VTable, self.vtable).RefreshUsageProperties(@ptrCast(*const IFsrmQuota, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmAutoApplyQuota_Value = Guid.initString("f82e5729-6aba-4740-bfc7-c7f58f75fb7b"); pub const IID_IFsrmAutoApplyQuota = &IID_IFsrmAutoApplyQuota_Value; pub const IFsrmAutoApplyQuota = extern struct { pub const VTable = extern struct { base: IFsrmQuotaObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ExcludeFolders: fn( self: *const IFsrmAutoApplyQuota, folders: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ExcludeFolders: fn( self: *const IFsrmAutoApplyQuota, folders: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CommitAndUpdateDerived: fn( self: *const IFsrmAutoApplyQuota, commitOptions: FsrmCommitOptions, applyOptions: FsrmTemplateApplyOptions, derivedObjectsResult: ?*?*IFsrmDerivedObjectsResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmQuotaObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmAutoApplyQuota_get_ExcludeFolders(self: *const T, folders: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmAutoApplyQuota.VTable, self.vtable).get_ExcludeFolders(@ptrCast(*const IFsrmAutoApplyQuota, self), folders); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmAutoApplyQuota_put_ExcludeFolders(self: *const T, folders: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmAutoApplyQuota.VTable, self.vtable).put_ExcludeFolders(@ptrCast(*const IFsrmAutoApplyQuota, self), folders); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmAutoApplyQuota_CommitAndUpdateDerived(self: *const T, commitOptions: FsrmCommitOptions, applyOptions: FsrmTemplateApplyOptions, derivedObjectsResult: ?*?*IFsrmDerivedObjectsResult) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmAutoApplyQuota.VTable, self.vtable).CommitAndUpdateDerived(@ptrCast(*const IFsrmAutoApplyQuota, self), commitOptions, applyOptions, derivedObjectsResult); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmQuotaManager_Value = Guid.initString("8bb68c7d-19d8-4ffb-809e-be4fc1734014"); pub const IID_IFsrmQuotaManager = &IID_IFsrmQuotaManager_Value; pub const IFsrmQuotaManager = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ActionVariables: fn( self: *const IFsrmQuotaManager, variables: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ActionVariableDescriptions: fn( self: *const IFsrmQuotaManager, descriptions: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateQuota: fn( self: *const IFsrmQuotaManager, path: ?BSTR, quota: ?*?*IFsrmQuota, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateAutoApplyQuota: fn( self: *const IFsrmQuotaManager, quotaTemplateName: ?BSTR, path: ?BSTR, quota: ?*?*IFsrmAutoApplyQuota, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetQuota: fn( self: *const IFsrmQuotaManager, path: ?BSTR, quota: ?*?*IFsrmQuota, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetAutoApplyQuota: fn( self: *const IFsrmQuotaManager, path: ?BSTR, quota: ?*?*IFsrmAutoApplyQuota, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetRestrictiveQuota: fn( self: *const IFsrmQuotaManager, path: ?BSTR, quota: ?*?*IFsrmQuota, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumQuotas: fn( self: *const IFsrmQuotaManager, path: ?BSTR, options: FsrmEnumOptions, quotas: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumAutoApplyQuotas: fn( self: *const IFsrmQuotaManager, path: ?BSTR, options: FsrmEnumOptions, quotas: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumEffectiveQuotas: fn( self: *const IFsrmQuotaManager, path: ?BSTR, options: FsrmEnumOptions, quotas: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Scan: fn( self: *const IFsrmQuotaManager, strPath: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateQuotaCollection: fn( self: *const IFsrmQuotaManager, collection: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_get_ActionVariables(self: *const T, variables: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).get_ActionVariables(@ptrCast(*const IFsrmQuotaManager, self), variables); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_get_ActionVariableDescriptions(self: *const T, descriptions: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).get_ActionVariableDescriptions(@ptrCast(*const IFsrmQuotaManager, self), descriptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_CreateQuota(self: *const T, path: ?BSTR, quota: ?*?*IFsrmQuota) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).CreateQuota(@ptrCast(*const IFsrmQuotaManager, self), path, quota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_CreateAutoApplyQuota(self: *const T, quotaTemplateName: ?BSTR, path: ?BSTR, quota: ?*?*IFsrmAutoApplyQuota) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).CreateAutoApplyQuota(@ptrCast(*const IFsrmQuotaManager, self), quotaTemplateName, path, quota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_GetQuota(self: *const T, path: ?BSTR, quota: ?*?*IFsrmQuota) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).GetQuota(@ptrCast(*const IFsrmQuotaManager, self), path, quota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_GetAutoApplyQuota(self: *const T, path: ?BSTR, quota: ?*?*IFsrmAutoApplyQuota) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).GetAutoApplyQuota(@ptrCast(*const IFsrmQuotaManager, self), path, quota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_GetRestrictiveQuota(self: *const T, path: ?BSTR, quota: ?*?*IFsrmQuota) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).GetRestrictiveQuota(@ptrCast(*const IFsrmQuotaManager, self), path, quota); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_EnumQuotas(self: *const T, path: ?BSTR, options: FsrmEnumOptions, quotas: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).EnumQuotas(@ptrCast(*const IFsrmQuotaManager, self), path, options, quotas); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_EnumAutoApplyQuotas(self: *const T, path: ?BSTR, options: FsrmEnumOptions, quotas: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).EnumAutoApplyQuotas(@ptrCast(*const IFsrmQuotaManager, self), path, options, quotas); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_EnumEffectiveQuotas(self: *const T, path: ?BSTR, options: FsrmEnumOptions, quotas: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).EnumEffectiveQuotas(@ptrCast(*const IFsrmQuotaManager, self), path, options, quotas); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_Scan(self: *const T, strPath: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).Scan(@ptrCast(*const IFsrmQuotaManager, self), strPath); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManager_CreateQuotaCollection(self: *const T, collection: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManager.VTable, self.vtable).CreateQuotaCollection(@ptrCast(*const IFsrmQuotaManager, self), collection); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmQuotaManagerEx_Value = Guid.initString("4846cb01-d430-494f-abb4-b1054999fb09"); pub const IID_IFsrmQuotaManagerEx = &IID_IFsrmQuotaManagerEx_Value; pub const IFsrmQuotaManagerEx = extern struct { pub const VTable = extern struct { base: IFsrmQuotaManager.VTable, IsAffectedByQuota: fn( self: *const IFsrmQuotaManagerEx, path: ?BSTR, options: FsrmEnumOptions, affected: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmQuotaManager.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaManagerEx_IsAffectedByQuota(self: *const T, path: ?BSTR, options: FsrmEnumOptions, affected: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaManagerEx.VTable, self.vtable).IsAffectedByQuota(@ptrCast(*const IFsrmQuotaManagerEx, self), path, options, affected); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmQuotaTemplate_Value = Guid.initString("a2efab31-295e-46bb-b976-e86d58b52e8b"); pub const IID_IFsrmQuotaTemplate = &IID_IFsrmQuotaTemplate_Value; pub const IFsrmQuotaTemplate = extern struct { pub const VTable = extern struct { base: IFsrmQuotaBase.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmQuotaTemplate, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const IFsrmQuotaTemplate, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CopyTemplate: fn( self: *const IFsrmQuotaTemplate, quotaTemplateName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CommitAndUpdateDerived: fn( self: *const IFsrmQuotaTemplate, commitOptions: FsrmCommitOptions, applyOptions: FsrmTemplateApplyOptions, derivedObjectsResult: ?*?*IFsrmDerivedObjectsResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmQuotaBase.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplate_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplate.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmQuotaTemplate, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplate_put_Name(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplate.VTable, self.vtable).put_Name(@ptrCast(*const IFsrmQuotaTemplate, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplate_CopyTemplate(self: *const T, quotaTemplateName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplate.VTable, self.vtable).CopyTemplate(@ptrCast(*const IFsrmQuotaTemplate, self), quotaTemplateName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplate_CommitAndUpdateDerived(self: *const T, commitOptions: FsrmCommitOptions, applyOptions: FsrmTemplateApplyOptions, derivedObjectsResult: ?*?*IFsrmDerivedObjectsResult) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplate.VTable, self.vtable).CommitAndUpdateDerived(@ptrCast(*const IFsrmQuotaTemplate, self), commitOptions, applyOptions, derivedObjectsResult); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmQuotaTemplateImported_Value = Guid.initString("9a2bf113-a329-44cc-809a-5c00fce8da40"); pub const IID_IFsrmQuotaTemplateImported = &IID_IFsrmQuotaTemplateImported_Value; pub const IFsrmQuotaTemplateImported = extern struct { pub const VTable = extern struct { base: IFsrmQuotaTemplate.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_OverwriteOnCommit: fn( self: *const IFsrmQuotaTemplateImported, overwrite: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_OverwriteOnCommit: fn( self: *const IFsrmQuotaTemplateImported, overwrite: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmQuotaTemplate.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplateImported_get_OverwriteOnCommit(self: *const T, overwrite: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplateImported.VTable, self.vtable).get_OverwriteOnCommit(@ptrCast(*const IFsrmQuotaTemplateImported, self), overwrite); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplateImported_put_OverwriteOnCommit(self: *const T, overwrite: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplateImported.VTable, self.vtable).put_OverwriteOnCommit(@ptrCast(*const IFsrmQuotaTemplateImported, self), overwrite); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmQuotaTemplateManager_Value = Guid.initString("4173ac41-172d-4d52-963c-fdc7e415f717"); pub const IID_IFsrmQuotaTemplateManager = &IID_IFsrmQuotaTemplateManager_Value; pub const IFsrmQuotaTemplateManager = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, CreateTemplate: fn( self: *const IFsrmQuotaTemplateManager, quotaTemplate: ?*?*IFsrmQuotaTemplate, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetTemplate: fn( self: *const IFsrmQuotaTemplateManager, name: ?BSTR, quotaTemplate: ?*?*IFsrmQuotaTemplate, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumTemplates: fn( self: *const IFsrmQuotaTemplateManager, options: FsrmEnumOptions, quotaTemplates: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ExportTemplates: fn( self: *const IFsrmQuotaTemplateManager, quotaTemplateNamesArray: ?*VARIANT, serializedQuotaTemplates: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ImportTemplates: fn( self: *const IFsrmQuotaTemplateManager, serializedQuotaTemplates: ?BSTR, quotaTemplateNamesArray: ?*VARIANT, quotaTemplates: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplateManager_CreateTemplate(self: *const T, quotaTemplate: ?*?*IFsrmQuotaTemplate) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplateManager.VTable, self.vtable).CreateTemplate(@ptrCast(*const IFsrmQuotaTemplateManager, self), quotaTemplate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplateManager_GetTemplate(self: *const T, name: ?BSTR, quotaTemplate: ?*?*IFsrmQuotaTemplate) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplateManager.VTable, self.vtable).GetTemplate(@ptrCast(*const IFsrmQuotaTemplateManager, self), name, quotaTemplate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplateManager_EnumTemplates(self: *const T, options: FsrmEnumOptions, quotaTemplates: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplateManager.VTable, self.vtable).EnumTemplates(@ptrCast(*const IFsrmQuotaTemplateManager, self), options, quotaTemplates); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplateManager_ExportTemplates(self: *const T, quotaTemplateNamesArray: ?*VARIANT, serializedQuotaTemplates: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplateManager.VTable, self.vtable).ExportTemplates(@ptrCast(*const IFsrmQuotaTemplateManager, self), quotaTemplateNamesArray, serializedQuotaTemplates); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmQuotaTemplateManager_ImportTemplates(self: *const T, serializedQuotaTemplates: ?BSTR, quotaTemplateNamesArray: ?*VARIANT, quotaTemplates: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmQuotaTemplateManager.VTable, self.vtable).ImportTemplates(@ptrCast(*const IFsrmQuotaTemplateManager, self), serializedQuotaTemplates, quotaTemplateNamesArray, quotaTemplates); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileGroup_Value = Guid.initString("8dd04909-0e34-4d55-afaa-89e1f1a1bbb9"); pub const IID_IFsrmFileGroup = &IID_IFsrmFileGroup_Value; pub const IFsrmFileGroup = extern struct { pub const VTable = extern struct { base: IFsrmObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmFileGroup, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const IFsrmFileGroup, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Members: fn( self: *const IFsrmFileGroup, members: ?*?*IFsrmMutableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Members: fn( self: *const IFsrmFileGroup, members: ?*IFsrmMutableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NonMembers: fn( self: *const IFsrmFileGroup, nonMembers: ?*?*IFsrmMutableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_NonMembers: fn( self: *const IFsrmFileGroup, nonMembers: ?*IFsrmMutableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroup_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroup.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmFileGroup, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroup_put_Name(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroup.VTable, self.vtable).put_Name(@ptrCast(*const IFsrmFileGroup, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroup_get_Members(self: *const T, members: ?*?*IFsrmMutableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroup.VTable, self.vtable).get_Members(@ptrCast(*const IFsrmFileGroup, self), members); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroup_put_Members(self: *const T, members: ?*IFsrmMutableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroup.VTable, self.vtable).put_Members(@ptrCast(*const IFsrmFileGroup, self), members); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroup_get_NonMembers(self: *const T, nonMembers: ?*?*IFsrmMutableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroup.VTable, self.vtable).get_NonMembers(@ptrCast(*const IFsrmFileGroup, self), nonMembers); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroup_put_NonMembers(self: *const T, nonMembers: ?*IFsrmMutableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroup.VTable, self.vtable).put_NonMembers(@ptrCast(*const IFsrmFileGroup, self), nonMembers); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileGroupImported_Value = Guid.initString("ad55f10b-5f11-4be7-94ef-d9ee2e470ded"); pub const IID_IFsrmFileGroupImported = &IID_IFsrmFileGroupImported_Value; pub const IFsrmFileGroupImported = extern struct { pub const VTable = extern struct { base: IFsrmFileGroup.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_OverwriteOnCommit: fn( self: *const IFsrmFileGroupImported, overwrite: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_OverwriteOnCommit: fn( self: *const IFsrmFileGroupImported, overwrite: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmFileGroup.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroupImported_get_OverwriteOnCommit(self: *const T, overwrite: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroupImported.VTable, self.vtable).get_OverwriteOnCommit(@ptrCast(*const IFsrmFileGroupImported, self), overwrite); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroupImported_put_OverwriteOnCommit(self: *const T, overwrite: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroupImported.VTable, self.vtable).put_OverwriteOnCommit(@ptrCast(*const IFsrmFileGroupImported, self), overwrite); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileGroupManager_Value = Guid.initString("426677d5-018c-485c-8a51-20b86d00bdc4"); pub const IID_IFsrmFileGroupManager = &IID_IFsrmFileGroupManager_Value; pub const IFsrmFileGroupManager = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, CreateFileGroup: fn( self: *const IFsrmFileGroupManager, fileGroup: ?*?*IFsrmFileGroup, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFileGroup: fn( self: *const IFsrmFileGroupManager, name: ?BSTR, fileGroup: ?*?*IFsrmFileGroup, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumFileGroups: fn( self: *const IFsrmFileGroupManager, options: FsrmEnumOptions, fileGroups: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ExportFileGroups: fn( self: *const IFsrmFileGroupManager, fileGroupNamesArray: ?*VARIANT, serializedFileGroups: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ImportFileGroups: fn( self: *const IFsrmFileGroupManager, serializedFileGroups: ?BSTR, fileGroupNamesArray: ?*VARIANT, fileGroups: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroupManager_CreateFileGroup(self: *const T, fileGroup: ?*?*IFsrmFileGroup) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroupManager.VTable, self.vtable).CreateFileGroup(@ptrCast(*const IFsrmFileGroupManager, self), fileGroup); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroupManager_GetFileGroup(self: *const T, name: ?BSTR, fileGroup: ?*?*IFsrmFileGroup) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroupManager.VTable, self.vtable).GetFileGroup(@ptrCast(*const IFsrmFileGroupManager, self), name, fileGroup); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroupManager_EnumFileGroups(self: *const T, options: FsrmEnumOptions, fileGroups: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroupManager.VTable, self.vtable).EnumFileGroups(@ptrCast(*const IFsrmFileGroupManager, self), options, fileGroups); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroupManager_ExportFileGroups(self: *const T, fileGroupNamesArray: ?*VARIANT, serializedFileGroups: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroupManager.VTable, self.vtable).ExportFileGroups(@ptrCast(*const IFsrmFileGroupManager, self), fileGroupNamesArray, serializedFileGroups); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileGroupManager_ImportFileGroups(self: *const T, serializedFileGroups: ?BSTR, fileGroupNamesArray: ?*VARIANT, fileGroups: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileGroupManager.VTable, self.vtable).ImportFileGroups(@ptrCast(*const IFsrmFileGroupManager, self), serializedFileGroups, fileGroupNamesArray, fileGroups); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileScreenBase_Value = Guid.initString("f3637e80-5b22-4a2b-a637-bbb642b41cfc"); pub const IID_IFsrmFileScreenBase = &IID_IFsrmFileScreenBase_Value; pub const IFsrmFileScreenBase = extern struct { pub const VTable = extern struct { base: IFsrmObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_BlockedFileGroups: fn( self: *const IFsrmFileScreenBase, blockList: ?*?*IFsrmMutableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_BlockedFileGroups: fn( self: *const IFsrmFileScreenBase, blockList: ?*IFsrmMutableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FileScreenFlags: fn( self: *const IFsrmFileScreenBase, fileScreenFlags: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FileScreenFlags: fn( self: *const IFsrmFileScreenBase, fileScreenFlags: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateAction: fn( self: *const IFsrmFileScreenBase, actionType: FsrmActionType, action: ?*?*IFsrmAction, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumActions: fn( self: *const IFsrmFileScreenBase, actions: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenBase_get_BlockedFileGroups(self: *const T, blockList: ?*?*IFsrmMutableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenBase.VTable, self.vtable).get_BlockedFileGroups(@ptrCast(*const IFsrmFileScreenBase, self), blockList); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenBase_put_BlockedFileGroups(self: *const T, blockList: ?*IFsrmMutableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenBase.VTable, self.vtable).put_BlockedFileGroups(@ptrCast(*const IFsrmFileScreenBase, self), blockList); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenBase_get_FileScreenFlags(self: *const T, fileScreenFlags: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenBase.VTable, self.vtable).get_FileScreenFlags(@ptrCast(*const IFsrmFileScreenBase, self), fileScreenFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenBase_put_FileScreenFlags(self: *const T, fileScreenFlags: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenBase.VTable, self.vtable).put_FileScreenFlags(@ptrCast(*const IFsrmFileScreenBase, self), fileScreenFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenBase_CreateAction(self: *const T, actionType: FsrmActionType, action: ?*?*IFsrmAction) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenBase.VTable, self.vtable).CreateAction(@ptrCast(*const IFsrmFileScreenBase, self), actionType, action); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenBase_EnumActions(self: *const T, actions: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenBase.VTable, self.vtable).EnumActions(@ptrCast(*const IFsrmFileScreenBase, self), actions); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileScreen_Value = Guid.initString("5f6325d3-ce88-4733-84c1-2d6aefc5ea07"); pub const IID_IFsrmFileScreen = &IID_IFsrmFileScreen_Value; pub const IFsrmFileScreen = extern struct { pub const VTable = extern struct { base: IFsrmFileScreenBase.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Path: fn( self: *const IFsrmFileScreen, path: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SourceTemplateName: fn( self: *const IFsrmFileScreen, fileScreenTemplateName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MatchesSourceTemplate: fn( self: *const IFsrmFileScreen, matches: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UserSid: fn( self: *const IFsrmFileScreen, userSid: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UserAccount: fn( self: *const IFsrmFileScreen, userAccount: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ApplyTemplate: fn( self: *const IFsrmFileScreen, fileScreenTemplateName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmFileScreenBase.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreen_get_Path(self: *const T, path: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreen.VTable, self.vtable).get_Path(@ptrCast(*const IFsrmFileScreen, self), path); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreen_get_SourceTemplateName(self: *const T, fileScreenTemplateName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreen.VTable, self.vtable).get_SourceTemplateName(@ptrCast(*const IFsrmFileScreen, self), fileScreenTemplateName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreen_get_MatchesSourceTemplate(self: *const T, matches: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreen.VTable, self.vtable).get_MatchesSourceTemplate(@ptrCast(*const IFsrmFileScreen, self), matches); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreen_get_UserSid(self: *const T, userSid: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreen.VTable, self.vtable).get_UserSid(@ptrCast(*const IFsrmFileScreen, self), userSid); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreen_get_UserAccount(self: *const T, userAccount: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreen.VTable, self.vtable).get_UserAccount(@ptrCast(*const IFsrmFileScreen, self), userAccount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreen_ApplyTemplate(self: *const T, fileScreenTemplateName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreen.VTable, self.vtable).ApplyTemplate(@ptrCast(*const IFsrmFileScreen, self), fileScreenTemplateName); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileScreenException_Value = Guid.initString("bee7ce02-df77-4515-9389-78f01c5afc1a"); pub const IID_IFsrmFileScreenException = &IID_IFsrmFileScreenException_Value; pub const IFsrmFileScreenException = extern struct { pub const VTable = extern struct { base: IFsrmObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Path: fn( self: *const IFsrmFileScreenException, path: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AllowedFileGroups: fn( self: *const IFsrmFileScreenException, allowList: ?*?*IFsrmMutableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_AllowedFileGroups: fn( self: *const IFsrmFileScreenException, allowList: ?*IFsrmMutableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenException_get_Path(self: *const T, path: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenException.VTable, self.vtable).get_Path(@ptrCast(*const IFsrmFileScreenException, self), path); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenException_get_AllowedFileGroups(self: *const T, allowList: ?*?*IFsrmMutableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenException.VTable, self.vtable).get_AllowedFileGroups(@ptrCast(*const IFsrmFileScreenException, self), allowList); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenException_put_AllowedFileGroups(self: *const T, allowList: ?*IFsrmMutableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenException.VTable, self.vtable).put_AllowedFileGroups(@ptrCast(*const IFsrmFileScreenException, self), allowList); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileScreenManager_Value = Guid.initString("ff4fa04e-5a94-4bda-a3a0-d5b4d3c52eba"); pub const IID_IFsrmFileScreenManager = &IID_IFsrmFileScreenManager_Value; pub const IFsrmFileScreenManager = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ActionVariables: fn( self: *const IFsrmFileScreenManager, variables: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ActionVariableDescriptions: fn( self: *const IFsrmFileScreenManager, descriptions: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateFileScreen: fn( self: *const IFsrmFileScreenManager, path: ?BSTR, fileScreen: ?*?*IFsrmFileScreen, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFileScreen: fn( self: *const IFsrmFileScreenManager, path: ?BSTR, fileScreen: ?*?*IFsrmFileScreen, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumFileScreens: fn( self: *const IFsrmFileScreenManager, path: ?BSTR, options: FsrmEnumOptions, fileScreens: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateFileScreenException: fn( self: *const IFsrmFileScreenManager, path: ?BSTR, fileScreenException: ?*?*IFsrmFileScreenException, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFileScreenException: fn( self: *const IFsrmFileScreenManager, path: ?BSTR, fileScreenException: ?*?*IFsrmFileScreenException, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumFileScreenExceptions: fn( self: *const IFsrmFileScreenManager, path: ?BSTR, options: FsrmEnumOptions, fileScreenExceptions: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateFileScreenCollection: fn( self: *const IFsrmFileScreenManager, collection: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenManager_get_ActionVariables(self: *const T, variables: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenManager.VTable, self.vtable).get_ActionVariables(@ptrCast(*const IFsrmFileScreenManager, self), variables); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenManager_get_ActionVariableDescriptions(self: *const T, descriptions: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenManager.VTable, self.vtable).get_ActionVariableDescriptions(@ptrCast(*const IFsrmFileScreenManager, self), descriptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenManager_CreateFileScreen(self: *const T, path: ?BSTR, fileScreen: ?*?*IFsrmFileScreen) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenManager.VTable, self.vtable).CreateFileScreen(@ptrCast(*const IFsrmFileScreenManager, self), path, fileScreen); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenManager_GetFileScreen(self: *const T, path: ?BSTR, fileScreen: ?*?*IFsrmFileScreen) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenManager.VTable, self.vtable).GetFileScreen(@ptrCast(*const IFsrmFileScreenManager, self), path, fileScreen); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenManager_EnumFileScreens(self: *const T, path: ?BSTR, options: FsrmEnumOptions, fileScreens: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenManager.VTable, self.vtable).EnumFileScreens(@ptrCast(*const IFsrmFileScreenManager, self), path, options, fileScreens); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenManager_CreateFileScreenException(self: *const T, path: ?BSTR, fileScreenException: ?*?*IFsrmFileScreenException) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenManager.VTable, self.vtable).CreateFileScreenException(@ptrCast(*const IFsrmFileScreenManager, self), path, fileScreenException); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenManager_GetFileScreenException(self: *const T, path: ?BSTR, fileScreenException: ?*?*IFsrmFileScreenException) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenManager.VTable, self.vtable).GetFileScreenException(@ptrCast(*const IFsrmFileScreenManager, self), path, fileScreenException); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenManager_EnumFileScreenExceptions(self: *const T, path: ?BSTR, options: FsrmEnumOptions, fileScreenExceptions: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenManager.VTable, self.vtable).EnumFileScreenExceptions(@ptrCast(*const IFsrmFileScreenManager, self), path, options, fileScreenExceptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenManager_CreateFileScreenCollection(self: *const T, collection: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenManager.VTable, self.vtable).CreateFileScreenCollection(@ptrCast(*const IFsrmFileScreenManager, self), collection); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileScreenTemplate_Value = Guid.initString("205bebf8-dd93-452a-95a6-32b566b35828"); pub const IID_IFsrmFileScreenTemplate = &IID_IFsrmFileScreenTemplate_Value; pub const IFsrmFileScreenTemplate = extern struct { pub const VTable = extern struct { base: IFsrmFileScreenBase.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmFileScreenTemplate, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const IFsrmFileScreenTemplate, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CopyTemplate: fn( self: *const IFsrmFileScreenTemplate, fileScreenTemplateName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CommitAndUpdateDerived: fn( self: *const IFsrmFileScreenTemplate, commitOptions: FsrmCommitOptions, applyOptions: FsrmTemplateApplyOptions, derivedObjectsResult: ?*?*IFsrmDerivedObjectsResult, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmFileScreenBase.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplate_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplate.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmFileScreenTemplate, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplate_put_Name(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplate.VTable, self.vtable).put_Name(@ptrCast(*const IFsrmFileScreenTemplate, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplate_CopyTemplate(self: *const T, fileScreenTemplateName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplate.VTable, self.vtable).CopyTemplate(@ptrCast(*const IFsrmFileScreenTemplate, self), fileScreenTemplateName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplate_CommitAndUpdateDerived(self: *const T, commitOptions: FsrmCommitOptions, applyOptions: FsrmTemplateApplyOptions, derivedObjectsResult: ?*?*IFsrmDerivedObjectsResult) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplate.VTable, self.vtable).CommitAndUpdateDerived(@ptrCast(*const IFsrmFileScreenTemplate, self), commitOptions, applyOptions, derivedObjectsResult); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileScreenTemplateImported_Value = Guid.initString("e1010359-3e5d-4ecd-9fe4-ef48622fdf30"); pub const IID_IFsrmFileScreenTemplateImported = &IID_IFsrmFileScreenTemplateImported_Value; pub const IFsrmFileScreenTemplateImported = extern struct { pub const VTable = extern struct { base: IFsrmFileScreenTemplate.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_OverwriteOnCommit: fn( self: *const IFsrmFileScreenTemplateImported, overwrite: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_OverwriteOnCommit: fn( self: *const IFsrmFileScreenTemplateImported, overwrite: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmFileScreenTemplate.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplateImported_get_OverwriteOnCommit(self: *const T, overwrite: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplateImported.VTable, self.vtable).get_OverwriteOnCommit(@ptrCast(*const IFsrmFileScreenTemplateImported, self), overwrite); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplateImported_put_OverwriteOnCommit(self: *const T, overwrite: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplateImported.VTable, self.vtable).put_OverwriteOnCommit(@ptrCast(*const IFsrmFileScreenTemplateImported, self), overwrite); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileScreenTemplateManager_Value = Guid.initString("cfe36cba-1949-4e74-a14f-f1d580ceaf13"); pub const IID_IFsrmFileScreenTemplateManager = &IID_IFsrmFileScreenTemplateManager_Value; pub const IFsrmFileScreenTemplateManager = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, CreateTemplate: fn( self: *const IFsrmFileScreenTemplateManager, fileScreenTemplate: ?*?*IFsrmFileScreenTemplate, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetTemplate: fn( self: *const IFsrmFileScreenTemplateManager, name: ?BSTR, fileScreenTemplate: ?*?*IFsrmFileScreenTemplate, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumTemplates: fn( self: *const IFsrmFileScreenTemplateManager, options: FsrmEnumOptions, fileScreenTemplates: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ExportTemplates: fn( self: *const IFsrmFileScreenTemplateManager, fileScreenTemplateNamesArray: ?*VARIANT, serializedFileScreenTemplates: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ImportTemplates: fn( self: *const IFsrmFileScreenTemplateManager, serializedFileScreenTemplates: ?BSTR, fileScreenTemplateNamesArray: ?*VARIANT, fileScreenTemplates: ?*?*IFsrmCommittableCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplateManager_CreateTemplate(self: *const T, fileScreenTemplate: ?*?*IFsrmFileScreenTemplate) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplateManager.VTable, self.vtable).CreateTemplate(@ptrCast(*const IFsrmFileScreenTemplateManager, self), fileScreenTemplate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplateManager_GetTemplate(self: *const T, name: ?BSTR, fileScreenTemplate: ?*?*IFsrmFileScreenTemplate) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplateManager.VTable, self.vtable).GetTemplate(@ptrCast(*const IFsrmFileScreenTemplateManager, self), name, fileScreenTemplate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplateManager_EnumTemplates(self: *const T, options: FsrmEnumOptions, fileScreenTemplates: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplateManager.VTable, self.vtable).EnumTemplates(@ptrCast(*const IFsrmFileScreenTemplateManager, self), options, fileScreenTemplates); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplateManager_ExportTemplates(self: *const T, fileScreenTemplateNamesArray: ?*VARIANT, serializedFileScreenTemplates: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplateManager.VTable, self.vtable).ExportTemplates(@ptrCast(*const IFsrmFileScreenTemplateManager, self), fileScreenTemplateNamesArray, serializedFileScreenTemplates); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileScreenTemplateManager_ImportTemplates(self: *const T, serializedFileScreenTemplates: ?BSTR, fileScreenTemplateNamesArray: ?*VARIANT, fileScreenTemplates: ?*?*IFsrmCommittableCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileScreenTemplateManager.VTable, self.vtable).ImportTemplates(@ptrCast(*const IFsrmFileScreenTemplateManager, self), serializedFileScreenTemplates, fileScreenTemplateNamesArray, fileScreenTemplates); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmReportManager_Value = Guid.initString("27b899fe-6ffa-4481-a184-d3daade8a02b"); pub const IID_IFsrmReportManager = &IID_IFsrmReportManager_Value; pub const IFsrmReportManager = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, EnumReportJobs: fn( self: *const IFsrmReportManager, options: FsrmEnumOptions, reportJobs: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateReportJob: fn( self: *const IFsrmReportManager, reportJob: ?*?*IFsrmReportJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetReportJob: fn( self: *const IFsrmReportManager, taskName: ?BSTR, reportJob: ?*?*IFsrmReportJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetOutputDirectory: fn( self: *const IFsrmReportManager, context: FsrmReportGenerationContext, path: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetOutputDirectory: fn( self: *const IFsrmReportManager, context: FsrmReportGenerationContext, path: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, IsFilterValidForReportType: fn( self: *const IFsrmReportManager, reportType: FsrmReportType, filter: FsrmReportFilter, valid: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetDefaultFilter: fn( self: *const IFsrmReportManager, reportType: FsrmReportType, filter: FsrmReportFilter, filterValue: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetDefaultFilter: fn( self: *const IFsrmReportManager, reportType: FsrmReportType, filter: FsrmReportFilter, filterValue: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetReportSizeLimit: fn( self: *const IFsrmReportManager, limit: FsrmReportLimit, limitValue: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetReportSizeLimit: fn( self: *const IFsrmReportManager, limit: FsrmReportLimit, limitValue: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_EnumReportJobs(self: *const T, options: FsrmEnumOptions, reportJobs: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).EnumReportJobs(@ptrCast(*const IFsrmReportManager, self), options, reportJobs); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_CreateReportJob(self: *const T, reportJob: ?*?*IFsrmReportJob) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).CreateReportJob(@ptrCast(*const IFsrmReportManager, self), reportJob); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_GetReportJob(self: *const T, taskName: ?BSTR, reportJob: ?*?*IFsrmReportJob) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).GetReportJob(@ptrCast(*const IFsrmReportManager, self), taskName, reportJob); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_GetOutputDirectory(self: *const T, context: FsrmReportGenerationContext, path: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).GetOutputDirectory(@ptrCast(*const IFsrmReportManager, self), context, path); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_SetOutputDirectory(self: *const T, context: FsrmReportGenerationContext, path: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).SetOutputDirectory(@ptrCast(*const IFsrmReportManager, self), context, path); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_IsFilterValidForReportType(self: *const T, reportType: FsrmReportType, filter: FsrmReportFilter, valid: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).IsFilterValidForReportType(@ptrCast(*const IFsrmReportManager, self), reportType, filter, valid); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_GetDefaultFilter(self: *const T, reportType: FsrmReportType, filter: FsrmReportFilter, filterValue: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).GetDefaultFilter(@ptrCast(*const IFsrmReportManager, self), reportType, filter, filterValue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_SetDefaultFilter(self: *const T, reportType: FsrmReportType, filter: FsrmReportFilter, filterValue: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).SetDefaultFilter(@ptrCast(*const IFsrmReportManager, self), reportType, filter, filterValue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_GetReportSizeLimit(self: *const T, limit: FsrmReportLimit, limitValue: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).GetReportSizeLimit(@ptrCast(*const IFsrmReportManager, self), limit, limitValue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportManager_SetReportSizeLimit(self: *const T, limit: FsrmReportLimit, limitValue: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportManager.VTable, self.vtable).SetReportSizeLimit(@ptrCast(*const IFsrmReportManager, self), limit, limitValue); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmReportJob_Value = Guid.initString("38e87280-715c-4c7d-a280-ea1651a19fef"); pub const IID_IFsrmReportJob = &IID_IFsrmReportJob_Value; pub const IFsrmReportJob = extern struct { pub const VTable = extern struct { base: IFsrmObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Task: fn( self: *const IFsrmReportJob, taskName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Task: fn( self: *const IFsrmReportJob, taskName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NamespaceRoots: fn( self: *const IFsrmReportJob, namespaceRoots: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_NamespaceRoots: fn( self: *const IFsrmReportJob, namespaceRoots: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Formats: fn( self: *const IFsrmReportJob, formats: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Formats: fn( self: *const IFsrmReportJob, formats: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailTo: fn( self: *const IFsrmReportJob, mailTo: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailTo: fn( self: *const IFsrmReportJob, mailTo: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RunningStatus: fn( self: *const IFsrmReportJob, runningStatus: ?*FsrmReportRunningStatus, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastRun: fn( self: *const IFsrmReportJob, lastRun: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastError: fn( self: *const IFsrmReportJob, lastError: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastGeneratedInDirectory: fn( self: *const IFsrmReportJob, path: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumReports: fn( self: *const IFsrmReportJob, reports: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateReport: fn( self: *const IFsrmReportJob, reportType: FsrmReportType, report: ?*?*IFsrmReport, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Run: fn( self: *const IFsrmReportJob, context: FsrmReportGenerationContext, ) callconv(@import("std").os.windows.WINAPI) HRESULT, WaitForCompletion: fn( self: *const IFsrmReportJob, waitSeconds: i32, completed: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Cancel: fn( self: *const IFsrmReportJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_get_Task(self: *const T, taskName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).get_Task(@ptrCast(*const IFsrmReportJob, self), taskName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_put_Task(self: *const T, taskName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).put_Task(@ptrCast(*const IFsrmReportJob, self), taskName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_get_NamespaceRoots(self: *const T, namespaceRoots: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).get_NamespaceRoots(@ptrCast(*const IFsrmReportJob, self), namespaceRoots); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_put_NamespaceRoots(self: *const T, namespaceRoots: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).put_NamespaceRoots(@ptrCast(*const IFsrmReportJob, self), namespaceRoots); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_get_Formats(self: *const T, formats: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).get_Formats(@ptrCast(*const IFsrmReportJob, self), formats); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_put_Formats(self: *const T, formats: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).put_Formats(@ptrCast(*const IFsrmReportJob, self), formats); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_get_MailTo(self: *const T, mailTo: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).get_MailTo(@ptrCast(*const IFsrmReportJob, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_put_MailTo(self: *const T, mailTo: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).put_MailTo(@ptrCast(*const IFsrmReportJob, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_get_RunningStatus(self: *const T, runningStatus: ?*FsrmReportRunningStatus) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).get_RunningStatus(@ptrCast(*const IFsrmReportJob, self), runningStatus); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_get_LastRun(self: *const T, lastRun: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).get_LastRun(@ptrCast(*const IFsrmReportJob, self), lastRun); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_get_LastError(self: *const T, lastError: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).get_LastError(@ptrCast(*const IFsrmReportJob, self), lastError); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_get_LastGeneratedInDirectory(self: *const T, path: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).get_LastGeneratedInDirectory(@ptrCast(*const IFsrmReportJob, self), path); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_EnumReports(self: *const T, reports: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).EnumReports(@ptrCast(*const IFsrmReportJob, self), reports); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_CreateReport(self: *const T, reportType: FsrmReportType, report: ?*?*IFsrmReport) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).CreateReport(@ptrCast(*const IFsrmReportJob, self), reportType, report); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_Run(self: *const T, context: FsrmReportGenerationContext) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).Run(@ptrCast(*const IFsrmReportJob, self), context); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_WaitForCompletion(self: *const T, waitSeconds: i32, completed: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).WaitForCompletion(@ptrCast(*const IFsrmReportJob, self), waitSeconds, completed); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportJob_Cancel(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportJob.VTable, self.vtable).Cancel(@ptrCast(*const IFsrmReportJob, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmReport_Value = Guid.initString("d8cc81d9-46b8-4fa4-bfa5-4aa9dec9b638"); pub const IID_IFsrmReport = &IID_IFsrmReport_Value; pub const IFsrmReport = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Type: fn( self: *const IFsrmReport, reportType: ?*FsrmReportType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmReport, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const IFsrmReport, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Description: fn( self: *const IFsrmReport, description: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Description: fn( self: *const IFsrmReport, description: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastGeneratedFileNamePrefix: fn( self: *const IFsrmReport, prefix: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFilter: fn( self: *const IFsrmReport, filter: FsrmReportFilter, filterValue: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetFilter: fn( self: *const IFsrmReport, filter: FsrmReportFilter, filterValue: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Delete: fn( self: *const IFsrmReport, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReport_get_Type(self: *const T, reportType: ?*FsrmReportType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReport.VTable, self.vtable).get_Type(@ptrCast(*const IFsrmReport, self), reportType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReport_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReport.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmReport, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReport_put_Name(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReport.VTable, self.vtable).put_Name(@ptrCast(*const IFsrmReport, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReport_get_Description(self: *const T, description: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReport.VTable, self.vtable).get_Description(@ptrCast(*const IFsrmReport, self), description); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReport_put_Description(self: *const T, description: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReport.VTable, self.vtable).put_Description(@ptrCast(*const IFsrmReport, self), description); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReport_get_LastGeneratedFileNamePrefix(self: *const T, prefix: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReport.VTable, self.vtable).get_LastGeneratedFileNamePrefix(@ptrCast(*const IFsrmReport, self), prefix); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReport_GetFilter(self: *const T, filter: FsrmReportFilter, filterValue: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReport.VTable, self.vtable).GetFilter(@ptrCast(*const IFsrmReport, self), filter, filterValue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReport_SetFilter(self: *const T, filter: FsrmReportFilter, filterValue: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReport.VTable, self.vtable).SetFilter(@ptrCast(*const IFsrmReport, self), filter, filterValue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReport_Delete(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReport.VTable, self.vtable).Delete(@ptrCast(*const IFsrmReport, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmReportScheduler_Value = Guid.initString("6879caf9-6617-4484-8719-71c3d8645f94"); pub const IID_IFsrmReportScheduler = &IID_IFsrmReportScheduler_Value; pub const IFsrmReportScheduler = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, VerifyNamespaces: fn( self: *const IFsrmReportScheduler, namespacesSafeArray: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateScheduleTask: fn( self: *const IFsrmReportScheduler, taskName: ?BSTR, namespacesSafeArray: ?*VARIANT, serializedTask: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ModifyScheduleTask: fn( self: *const IFsrmReportScheduler, taskName: ?BSTR, namespacesSafeArray: ?*VARIANT, serializedTask: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DeleteScheduleTask: fn( self: *const IFsrmReportScheduler, taskName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportScheduler_VerifyNamespaces(self: *const T, namespacesSafeArray: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportScheduler.VTable, self.vtable).VerifyNamespaces(@ptrCast(*const IFsrmReportScheduler, self), namespacesSafeArray); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportScheduler_CreateScheduleTask(self: *const T, taskName: ?BSTR, namespacesSafeArray: ?*VARIANT, serializedTask: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportScheduler.VTable, self.vtable).CreateScheduleTask(@ptrCast(*const IFsrmReportScheduler, self), taskName, namespacesSafeArray, serializedTask); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportScheduler_ModifyScheduleTask(self: *const T, taskName: ?BSTR, namespacesSafeArray: ?*VARIANT, serializedTask: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportScheduler.VTable, self.vtable).ModifyScheduleTask(@ptrCast(*const IFsrmReportScheduler, self), taskName, namespacesSafeArray, serializedTask); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmReportScheduler_DeleteScheduleTask(self: *const T, taskName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmReportScheduler.VTable, self.vtable).DeleteScheduleTask(@ptrCast(*const IFsrmReportScheduler, self), taskName); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileManagementJobManager_Value = Guid.initString("ee321ecb-d95e-48e9-907c-c7685a013235"); pub const IID_IFsrmFileManagementJobManager = &IID_IFsrmFileManagementJobManager_Value; pub const IFsrmFileManagementJobManager = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ActionVariables: fn( self: *const IFsrmFileManagementJobManager, variables: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ActionVariableDescriptions: fn( self: *const IFsrmFileManagementJobManager, descriptions: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumFileManagementJobs: fn( self: *const IFsrmFileManagementJobManager, options: FsrmEnumOptions, fileManagementJobs: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateFileManagementJob: fn( self: *const IFsrmFileManagementJobManager, fileManagementJob: ?*?*IFsrmFileManagementJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFileManagementJob: fn( self: *const IFsrmFileManagementJobManager, name: ?BSTR, fileManagementJob: ?*?*IFsrmFileManagementJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJobManager_get_ActionVariables(self: *const T, variables: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJobManager.VTable, self.vtable).get_ActionVariables(@ptrCast(*const IFsrmFileManagementJobManager, self), variables); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJobManager_get_ActionVariableDescriptions(self: *const T, descriptions: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJobManager.VTable, self.vtable).get_ActionVariableDescriptions(@ptrCast(*const IFsrmFileManagementJobManager, self), descriptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJobManager_EnumFileManagementJobs(self: *const T, options: FsrmEnumOptions, fileManagementJobs: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJobManager.VTable, self.vtable).EnumFileManagementJobs(@ptrCast(*const IFsrmFileManagementJobManager, self), options, fileManagementJobs); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJobManager_CreateFileManagementJob(self: *const T, fileManagementJob: ?*?*IFsrmFileManagementJob) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJobManager.VTable, self.vtable).CreateFileManagementJob(@ptrCast(*const IFsrmFileManagementJobManager, self), fileManagementJob); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJobManager_GetFileManagementJob(self: *const T, name: ?BSTR, fileManagementJob: ?*?*IFsrmFileManagementJob) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJobManager.VTable, self.vtable).GetFileManagementJob(@ptrCast(*const IFsrmFileManagementJobManager, self), name, fileManagementJob); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmFileManagementJob_Value = Guid.initString("0770687e-9f36-4d6f-8778-599d188461c9"); pub const IID_IFsrmFileManagementJob = &IID_IFsrmFileManagementJob_Value; pub const IFsrmFileManagementJob = extern struct { pub const VTable = extern struct { base: IFsrmObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmFileManagementJob, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const IFsrmFileManagementJob, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NamespaceRoots: fn( self: *const IFsrmFileManagementJob, namespaceRoots: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_NamespaceRoots: fn( self: *const IFsrmFileManagementJob, namespaceRoots: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Enabled: fn( self: *const IFsrmFileManagementJob, enabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Enabled: fn( self: *const IFsrmFileManagementJob, enabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_OperationType: fn( self: *const IFsrmFileManagementJob, operationType: ?*FsrmFileManagementType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_OperationType: fn( self: *const IFsrmFileManagementJob, operationType: FsrmFileManagementType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ExpirationDirectory: fn( self: *const IFsrmFileManagementJob, expirationDirectory: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ExpirationDirectory: fn( self: *const IFsrmFileManagementJob, expirationDirectory: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CustomAction: fn( self: *const IFsrmFileManagementJob, action: ?*?*IFsrmActionCommand, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Notifications: fn( self: *const IFsrmFileManagementJob, notifications: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Logging: fn( self: *const IFsrmFileManagementJob, loggingFlags: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Logging: fn( self: *const IFsrmFileManagementJob, loggingFlags: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ReportEnabled: fn( self: *const IFsrmFileManagementJob, reportEnabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ReportEnabled: fn( self: *const IFsrmFileManagementJob, reportEnabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Formats: fn( self: *const IFsrmFileManagementJob, formats: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Formats: fn( self: *const IFsrmFileManagementJob, formats: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_MailTo: fn( self: *const IFsrmFileManagementJob, mailTo: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_MailTo: fn( self: *const IFsrmFileManagementJob, mailTo: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DaysSinceFileCreated: fn( self: *const IFsrmFileManagementJob, daysSinceCreation: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DaysSinceFileCreated: fn( self: *const IFsrmFileManagementJob, daysSinceCreation: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DaysSinceFileLastAccessed: fn( self: *const IFsrmFileManagementJob, daysSinceAccess: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DaysSinceFileLastAccessed: fn( self: *const IFsrmFileManagementJob, daysSinceAccess: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DaysSinceFileLastModified: fn( self: *const IFsrmFileManagementJob, daysSinceModify: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DaysSinceFileLastModified: fn( self: *const IFsrmFileManagementJob, daysSinceModify: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PropertyConditions: fn( self: *const IFsrmFileManagementJob, propertyConditions: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FromDate: fn( self: *const IFsrmFileManagementJob, fromDate: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FromDate: fn( self: *const IFsrmFileManagementJob, fromDate: f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Task: fn( self: *const IFsrmFileManagementJob, taskName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Task: fn( self: *const IFsrmFileManagementJob, taskName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Parameters: fn( self: *const IFsrmFileManagementJob, parameters: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Parameters: fn( self: *const IFsrmFileManagementJob, parameters: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RunningStatus: fn( self: *const IFsrmFileManagementJob, runningStatus: ?*FsrmReportRunningStatus, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastError: fn( self: *const IFsrmFileManagementJob, lastError: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastReportPathWithoutExtension: fn( self: *const IFsrmFileManagementJob, path: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastRun: fn( self: *const IFsrmFileManagementJob, lastRun: ?*f64, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FileNamePattern: fn( self: *const IFsrmFileManagementJob, fileNamePattern: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_FileNamePattern: fn( self: *const IFsrmFileManagementJob, fileNamePattern: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Run: fn( self: *const IFsrmFileManagementJob, context: FsrmReportGenerationContext, ) callconv(@import("std").os.windows.WINAPI) HRESULT, WaitForCompletion: fn( self: *const IFsrmFileManagementJob, waitSeconds: i32, completed: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Cancel: fn( self: *const IFsrmFileManagementJob, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AddNotification: fn( self: *const IFsrmFileManagementJob, days: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DeleteNotification: fn( self: *const IFsrmFileManagementJob, days: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ModifyNotification: fn( self: *const IFsrmFileManagementJob, days: i32, newDays: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateNotificationAction: fn( self: *const IFsrmFileManagementJob, days: i32, actionType: FsrmActionType, action: ?*?*IFsrmAction, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumNotificationActions: fn( self: *const IFsrmFileManagementJob, days: i32, actions: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreatePropertyCondition: fn( self: *const IFsrmFileManagementJob, name: ?BSTR, propertyCondition: ?*?*IFsrmPropertyCondition, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateCustomAction: fn( self: *const IFsrmFileManagementJob, customAction: ?*?*IFsrmActionCommand, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmFileManagementJob, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_Name(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_Name(@ptrCast(*const IFsrmFileManagementJob, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_NamespaceRoots(self: *const T, namespaceRoots: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_NamespaceRoots(@ptrCast(*const IFsrmFileManagementJob, self), namespaceRoots); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_NamespaceRoots(self: *const T, namespaceRoots: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_NamespaceRoots(@ptrCast(*const IFsrmFileManagementJob, self), namespaceRoots); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_Enabled(self: *const T, enabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_Enabled(@ptrCast(*const IFsrmFileManagementJob, self), enabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_Enabled(self: *const T, enabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_Enabled(@ptrCast(*const IFsrmFileManagementJob, self), enabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_OperationType(self: *const T, operationType: ?*FsrmFileManagementType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_OperationType(@ptrCast(*const IFsrmFileManagementJob, self), operationType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_OperationType(self: *const T, operationType: FsrmFileManagementType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_OperationType(@ptrCast(*const IFsrmFileManagementJob, self), operationType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_ExpirationDirectory(self: *const T, expirationDirectory: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_ExpirationDirectory(@ptrCast(*const IFsrmFileManagementJob, self), expirationDirectory); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_ExpirationDirectory(self: *const T, expirationDirectory: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_ExpirationDirectory(@ptrCast(*const IFsrmFileManagementJob, self), expirationDirectory); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_CustomAction(self: *const T, action: ?*?*IFsrmActionCommand) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_CustomAction(@ptrCast(*const IFsrmFileManagementJob, self), action); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_Notifications(self: *const T, notifications: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_Notifications(@ptrCast(*const IFsrmFileManagementJob, self), notifications); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_Logging(self: *const T, loggingFlags: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_Logging(@ptrCast(*const IFsrmFileManagementJob, self), loggingFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_Logging(self: *const T, loggingFlags: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_Logging(@ptrCast(*const IFsrmFileManagementJob, self), loggingFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_ReportEnabled(self: *const T, reportEnabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_ReportEnabled(@ptrCast(*const IFsrmFileManagementJob, self), reportEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_ReportEnabled(self: *const T, reportEnabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_ReportEnabled(@ptrCast(*const IFsrmFileManagementJob, self), reportEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_Formats(self: *const T, formats: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_Formats(@ptrCast(*const IFsrmFileManagementJob, self), formats); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_Formats(self: *const T, formats: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_Formats(@ptrCast(*const IFsrmFileManagementJob, self), formats); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_MailTo(self: *const T, mailTo: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_MailTo(@ptrCast(*const IFsrmFileManagementJob, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_MailTo(self: *const T, mailTo: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_MailTo(@ptrCast(*const IFsrmFileManagementJob, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_DaysSinceFileCreated(self: *const T, daysSinceCreation: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_DaysSinceFileCreated(@ptrCast(*const IFsrmFileManagementJob, self), daysSinceCreation); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_DaysSinceFileCreated(self: *const T, daysSinceCreation: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_DaysSinceFileCreated(@ptrCast(*const IFsrmFileManagementJob, self), daysSinceCreation); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_DaysSinceFileLastAccessed(self: *const T, daysSinceAccess: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_DaysSinceFileLastAccessed(@ptrCast(*const IFsrmFileManagementJob, self), daysSinceAccess); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_DaysSinceFileLastAccessed(self: *const T, daysSinceAccess: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_DaysSinceFileLastAccessed(@ptrCast(*const IFsrmFileManagementJob, self), daysSinceAccess); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_DaysSinceFileLastModified(self: *const T, daysSinceModify: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_DaysSinceFileLastModified(@ptrCast(*const IFsrmFileManagementJob, self), daysSinceModify); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_DaysSinceFileLastModified(self: *const T, daysSinceModify: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_DaysSinceFileLastModified(@ptrCast(*const IFsrmFileManagementJob, self), daysSinceModify); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_PropertyConditions(self: *const T, propertyConditions: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_PropertyConditions(@ptrCast(*const IFsrmFileManagementJob, self), propertyConditions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_FromDate(self: *const T, fromDate: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_FromDate(@ptrCast(*const IFsrmFileManagementJob, self), fromDate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_FromDate(self: *const T, fromDate: f64) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_FromDate(@ptrCast(*const IFsrmFileManagementJob, self), fromDate); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_Task(self: *const T, taskName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_Task(@ptrCast(*const IFsrmFileManagementJob, self), taskName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_Task(self: *const T, taskName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_Task(@ptrCast(*const IFsrmFileManagementJob, self), taskName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_Parameters(self: *const T, parameters: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_Parameters(@ptrCast(*const IFsrmFileManagementJob, self), parameters); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_Parameters(self: *const T, parameters: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_Parameters(@ptrCast(*const IFsrmFileManagementJob, self), parameters); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_RunningStatus(self: *const T, runningStatus: ?*FsrmReportRunningStatus) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_RunningStatus(@ptrCast(*const IFsrmFileManagementJob, self), runningStatus); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_LastError(self: *const T, lastError: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_LastError(@ptrCast(*const IFsrmFileManagementJob, self), lastError); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_LastReportPathWithoutExtension(self: *const T, path: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_LastReportPathWithoutExtension(@ptrCast(*const IFsrmFileManagementJob, self), path); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_LastRun(self: *const T, lastRun: ?*f64) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_LastRun(@ptrCast(*const IFsrmFileManagementJob, self), lastRun); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_get_FileNamePattern(self: *const T, fileNamePattern: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).get_FileNamePattern(@ptrCast(*const IFsrmFileManagementJob, self), fileNamePattern); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_put_FileNamePattern(self: *const T, fileNamePattern: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).put_FileNamePattern(@ptrCast(*const IFsrmFileManagementJob, self), fileNamePattern); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_Run(self: *const T, context: FsrmReportGenerationContext) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).Run(@ptrCast(*const IFsrmFileManagementJob, self), context); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_WaitForCompletion(self: *const T, waitSeconds: i32, completed: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).WaitForCompletion(@ptrCast(*const IFsrmFileManagementJob, self), waitSeconds, completed); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_Cancel(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).Cancel(@ptrCast(*const IFsrmFileManagementJob, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_AddNotification(self: *const T, days: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).AddNotification(@ptrCast(*const IFsrmFileManagementJob, self), days); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_DeleteNotification(self: *const T, days: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).DeleteNotification(@ptrCast(*const IFsrmFileManagementJob, self), days); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_ModifyNotification(self: *const T, days: i32, newDays: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).ModifyNotification(@ptrCast(*const IFsrmFileManagementJob, self), days, newDays); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_CreateNotificationAction(self: *const T, days: i32, actionType: FsrmActionType, action: ?*?*IFsrmAction) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).CreateNotificationAction(@ptrCast(*const IFsrmFileManagementJob, self), days, actionType, action); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_EnumNotificationActions(self: *const T, days: i32, actions: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).EnumNotificationActions(@ptrCast(*const IFsrmFileManagementJob, self), days, actions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_CreatePropertyCondition(self: *const T, name: ?BSTR, propertyCondition: ?*?*IFsrmPropertyCondition) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).CreatePropertyCondition(@ptrCast(*const IFsrmFileManagementJob, self), name, propertyCondition); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileManagementJob_CreateCustomAction(self: *const T, customAction: ?*?*IFsrmActionCommand) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileManagementJob.VTable, self.vtable).CreateCustomAction(@ptrCast(*const IFsrmFileManagementJob, self), customAction); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmPropertyCondition_Value = Guid.initString("326af66f-2ac0-4f68-bf8c-4759f054fa29"); pub const IID_IFsrmPropertyCondition = &IID_IFsrmPropertyCondition_Value; pub const IFsrmPropertyCondition = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmPropertyCondition, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const IFsrmPropertyCondition, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Type: fn( self: *const IFsrmPropertyCondition, type: ?*FsrmPropertyConditionType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Type: fn( self: *const IFsrmPropertyCondition, type: FsrmPropertyConditionType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Value: fn( self: *const IFsrmPropertyCondition, value: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Value: fn( self: *const IFsrmPropertyCondition, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Delete: fn( self: *const IFsrmPropertyCondition, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyCondition_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyCondition.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmPropertyCondition, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyCondition_put_Name(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyCondition.VTable, self.vtable).put_Name(@ptrCast(*const IFsrmPropertyCondition, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyCondition_get_Type(self: *const T, type_: ?*FsrmPropertyConditionType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyCondition.VTable, self.vtable).get_Type(@ptrCast(*const IFsrmPropertyCondition, self), type_); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyCondition_put_Type(self: *const T, type_: FsrmPropertyConditionType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyCondition.VTable, self.vtable).put_Type(@ptrCast(*const IFsrmPropertyCondition, self), type_); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyCondition_get_Value(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyCondition.VTable, self.vtable).get_Value(@ptrCast(*const IFsrmPropertyCondition, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyCondition_put_Value(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyCondition.VTable, self.vtable).put_Value(@ptrCast(*const IFsrmPropertyCondition, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyCondition_Delete(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyCondition.VTable, self.vtable).Delete(@ptrCast(*const IFsrmPropertyCondition, self)); } };} pub usingnamespace MethodMixin(@This()); }; const IID_IFsrmFileCondition_Value = Guid.initString("70684ffc-691a-4a1a-b922-97752e138cc1"); pub const IID_IFsrmFileCondition = &IID_IFsrmFileCondition_Value; pub const IFsrmFileCondition = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Type: fn( self: *const IFsrmFileCondition, pVal: ?*FsrmFileConditionType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Delete: fn( self: *const IFsrmFileCondition, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileCondition_get_Type(self: *const T, pVal: ?*FsrmFileConditionType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileCondition.VTable, self.vtable).get_Type(@ptrCast(*const IFsrmFileCondition, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileCondition_Delete(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileCondition.VTable, self.vtable).Delete(@ptrCast(*const IFsrmFileCondition, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2012' const IID_IFsrmFileConditionProperty_Value = Guid.initString("81926775-b981-4479-988f-da171d627360"); pub const IID_IFsrmFileConditionProperty = &IID_IFsrmFileConditionProperty_Value; pub const IFsrmFileConditionProperty = extern struct { pub const VTable = extern struct { base: IFsrmFileCondition.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PropertyName: fn( self: *const IFsrmFileConditionProperty, pVal: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PropertyName: fn( self: *const IFsrmFileConditionProperty, newVal: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PropertyId: fn( self: *const IFsrmFileConditionProperty, pVal: ?*FsrmFileSystemPropertyId, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PropertyId: fn( self: *const IFsrmFileConditionProperty, newVal: FsrmFileSystemPropertyId, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Operator: fn( self: *const IFsrmFileConditionProperty, pVal: ?*FsrmPropertyConditionType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Operator: fn( self: *const IFsrmFileConditionProperty, newVal: FsrmPropertyConditionType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ValueType: fn( self: *const IFsrmFileConditionProperty, pVal: ?*FsrmPropertyValueType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ValueType: fn( self: *const IFsrmFileConditionProperty, newVal: FsrmPropertyValueType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Value: fn( self: *const IFsrmFileConditionProperty, pVal: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Value: fn( self: *const IFsrmFileConditionProperty, newVal: VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmFileCondition.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_get_PropertyName(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).get_PropertyName(@ptrCast(*const IFsrmFileConditionProperty, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_put_PropertyName(self: *const T, newVal: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).put_PropertyName(@ptrCast(*const IFsrmFileConditionProperty, self), newVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_get_PropertyId(self: *const T, pVal: ?*FsrmFileSystemPropertyId) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).get_PropertyId(@ptrCast(*const IFsrmFileConditionProperty, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_put_PropertyId(self: *const T, newVal: FsrmFileSystemPropertyId) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).put_PropertyId(@ptrCast(*const IFsrmFileConditionProperty, self), newVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_get_Operator(self: *const T, pVal: ?*FsrmPropertyConditionType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).get_Operator(@ptrCast(*const IFsrmFileConditionProperty, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_put_Operator(self: *const T, newVal: FsrmPropertyConditionType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).put_Operator(@ptrCast(*const IFsrmFileConditionProperty, self), newVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_get_ValueType(self: *const T, pVal: ?*FsrmPropertyValueType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).get_ValueType(@ptrCast(*const IFsrmFileConditionProperty, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_put_ValueType(self: *const T, newVal: FsrmPropertyValueType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).put_ValueType(@ptrCast(*const IFsrmFileConditionProperty, self), newVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_get_Value(self: *const T, pVal: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).get_Value(@ptrCast(*const IFsrmFileConditionProperty, self), pVal); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmFileConditionProperty_put_Value(self: *const T, newVal: VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmFileConditionProperty.VTable, self.vtable).put_Value(@ptrCast(*const IFsrmFileConditionProperty, self), newVal); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmPropertyDefinition_Value = Guid.initString("ede0150f-e9a3-419c-877c-01fe5d24c5d3"); pub const IID_IFsrmPropertyDefinition = &IID_IFsrmPropertyDefinition_Value; pub const IFsrmPropertyDefinition = extern struct { pub const VTable = extern struct { base: IFsrmObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmPropertyDefinition, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const IFsrmPropertyDefinition, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Type: fn( self: *const IFsrmPropertyDefinition, type: ?*FsrmPropertyDefinitionType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Type: fn( self: *const IFsrmPropertyDefinition, type: FsrmPropertyDefinitionType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PossibleValues: fn( self: *const IFsrmPropertyDefinition, possibleValues: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PossibleValues: fn( self: *const IFsrmPropertyDefinition, possibleValues: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ValueDescriptions: fn( self: *const IFsrmPropertyDefinition, valueDescriptions: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ValueDescriptions: fn( self: *const IFsrmPropertyDefinition, valueDescriptions: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Parameters: fn( self: *const IFsrmPropertyDefinition, parameters: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Parameters: fn( self: *const IFsrmPropertyDefinition, parameters: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmPropertyDefinition, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_put_Name(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).put_Name(@ptrCast(*const IFsrmPropertyDefinition, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_get_Type(self: *const T, type_: ?*FsrmPropertyDefinitionType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).get_Type(@ptrCast(*const IFsrmPropertyDefinition, self), type_); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_put_Type(self: *const T, type_: FsrmPropertyDefinitionType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).put_Type(@ptrCast(*const IFsrmPropertyDefinition, self), type_); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_get_PossibleValues(self: *const T, possibleValues: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).get_PossibleValues(@ptrCast(*const IFsrmPropertyDefinition, self), possibleValues); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_put_PossibleValues(self: *const T, possibleValues: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).put_PossibleValues(@ptrCast(*const IFsrmPropertyDefinition, self), possibleValues); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_get_ValueDescriptions(self: *const T, valueDescriptions: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).get_ValueDescriptions(@ptrCast(*const IFsrmPropertyDefinition, self), valueDescriptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_put_ValueDescriptions(self: *const T, valueDescriptions: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).put_ValueDescriptions(@ptrCast(*const IFsrmPropertyDefinition, self), valueDescriptions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_get_Parameters(self: *const T, parameters: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).get_Parameters(@ptrCast(*const IFsrmPropertyDefinition, self), parameters); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition_put_Parameters(self: *const T, parameters: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition.VTable, self.vtable).put_Parameters(@ptrCast(*const IFsrmPropertyDefinition, self), parameters); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2012' const IID_IFsrmPropertyDefinition2_Value = Guid.initString("47782152-d16c-4229-b4e1-0ddfe308b9f6"); pub const IID_IFsrmPropertyDefinition2 = &IID_IFsrmPropertyDefinition2_Value; pub const IFsrmPropertyDefinition2 = extern struct { pub const VTable = extern struct { base: IFsrmPropertyDefinition.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PropertyDefinitionFlags: fn( self: *const IFsrmPropertyDefinition2, propertyDefinitionFlags: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DisplayName: fn( self: *const IFsrmPropertyDefinition2, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_DisplayName: fn( self: *const IFsrmPropertyDefinition2, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_AppliesTo: fn( self: *const IFsrmPropertyDefinition2, appliesTo: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ValueDefinitions: fn( self: *const IFsrmPropertyDefinition2, valueDefinitions: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmPropertyDefinition.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition2_get_PropertyDefinitionFlags(self: *const T, propertyDefinitionFlags: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition2.VTable, self.vtable).get_PropertyDefinitionFlags(@ptrCast(*const IFsrmPropertyDefinition2, self), propertyDefinitionFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition2_get_DisplayName(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition2.VTable, self.vtable).get_DisplayName(@ptrCast(*const IFsrmPropertyDefinition2, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition2_put_DisplayName(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition2.VTable, self.vtable).put_DisplayName(@ptrCast(*const IFsrmPropertyDefinition2, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition2_get_AppliesTo(self: *const T, appliesTo: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition2.VTable, self.vtable).get_AppliesTo(@ptrCast(*const IFsrmPropertyDefinition2, self), appliesTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinition2_get_ValueDefinitions(self: *const T, valueDefinitions: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinition2.VTable, self.vtable).get_ValueDefinitions(@ptrCast(*const IFsrmPropertyDefinition2, self), valueDefinitions); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2012' const IID_IFsrmPropertyDefinitionValue_Value = Guid.initString("e946d148-bd67-4178-8e22-1c44925ed710"); pub const IID_IFsrmPropertyDefinitionValue = &IID_IFsrmPropertyDefinitionValue_Value; pub const IFsrmPropertyDefinitionValue = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmPropertyDefinitionValue, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_DisplayName: fn( self: *const IFsrmPropertyDefinitionValue, displayName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Description: fn( self: *const IFsrmPropertyDefinitionValue, description: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UniqueID: fn( self: *const IFsrmPropertyDefinitionValue, uniqueID: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinitionValue_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinitionValue.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmPropertyDefinitionValue, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinitionValue_get_DisplayName(self: *const T, displayName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinitionValue.VTable, self.vtable).get_DisplayName(@ptrCast(*const IFsrmPropertyDefinitionValue, self), displayName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinitionValue_get_Description(self: *const T, description: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinitionValue.VTable, self.vtable).get_Description(@ptrCast(*const IFsrmPropertyDefinitionValue, self), description); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyDefinitionValue_get_UniqueID(self: *const T, uniqueID: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyDefinitionValue.VTable, self.vtable).get_UniqueID(@ptrCast(*const IFsrmPropertyDefinitionValue, self), uniqueID); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmProperty_Value = Guid.initString("4a73fee4-4102-4fcc-9ffb-38614f9ee768"); pub const IID_IFsrmProperty = &IID_IFsrmProperty_Value; pub const IFsrmProperty = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmProperty, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Value: fn( self: *const IFsrmProperty, value: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Sources: fn( self: *const IFsrmProperty, sources: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PropertyFlags: fn( self: *const IFsrmProperty, flags: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmProperty_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmProperty.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmProperty, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmProperty_get_Value(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmProperty.VTable, self.vtable).get_Value(@ptrCast(*const IFsrmProperty, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmProperty_get_Sources(self: *const T, sources: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmProperty.VTable, self.vtable).get_Sources(@ptrCast(*const IFsrmProperty, self), sources); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmProperty_get_PropertyFlags(self: *const T, flags: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmProperty.VTable, self.vtable).get_PropertyFlags(@ptrCast(*const IFsrmProperty, self), flags); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmRule_Value = Guid.initString("cb0df960-16f5-4495-9079-3f9360d831df"); pub const IID_IFsrmRule = &IID_IFsrmRule_Value; pub const IFsrmRule = extern struct { pub const VTable = extern struct { base: IFsrmObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmRule, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const IFsrmRule, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RuleType: fn( self: *const IFsrmRule, ruleType: ?*FsrmRuleType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ModuleDefinitionName: fn( self: *const IFsrmRule, moduleDefinitionName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ModuleDefinitionName: fn( self: *const IFsrmRule, moduleDefinitionName: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NamespaceRoots: fn( self: *const IFsrmRule, namespaceRoots: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_NamespaceRoots: fn( self: *const IFsrmRule, namespaceRoots: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RuleFlags: fn( self: *const IFsrmRule, ruleFlags: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_RuleFlags: fn( self: *const IFsrmRule, ruleFlags: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Parameters: fn( self: *const IFsrmRule, parameters: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Parameters: fn( self: *const IFsrmRule, parameters: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastModified: fn( self: *const IFsrmRule, lastModified: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmRule, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_put_Name(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).put_Name(@ptrCast(*const IFsrmRule, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_get_RuleType(self: *const T, ruleType: ?*FsrmRuleType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).get_RuleType(@ptrCast(*const IFsrmRule, self), ruleType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_get_ModuleDefinitionName(self: *const T, moduleDefinitionName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).get_ModuleDefinitionName(@ptrCast(*const IFsrmRule, self), moduleDefinitionName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_put_ModuleDefinitionName(self: *const T, moduleDefinitionName: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).put_ModuleDefinitionName(@ptrCast(*const IFsrmRule, self), moduleDefinitionName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_get_NamespaceRoots(self: *const T, namespaceRoots: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).get_NamespaceRoots(@ptrCast(*const IFsrmRule, self), namespaceRoots); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_put_NamespaceRoots(self: *const T, namespaceRoots: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).put_NamespaceRoots(@ptrCast(*const IFsrmRule, self), namespaceRoots); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_get_RuleFlags(self: *const T, ruleFlags: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).get_RuleFlags(@ptrCast(*const IFsrmRule, self), ruleFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_put_RuleFlags(self: *const T, ruleFlags: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).put_RuleFlags(@ptrCast(*const IFsrmRule, self), ruleFlags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_get_Parameters(self: *const T, parameters: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).get_Parameters(@ptrCast(*const IFsrmRule, self), parameters); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_put_Parameters(self: *const T, parameters: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).put_Parameters(@ptrCast(*const IFsrmRule, self), parameters); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmRule_get_LastModified(self: *const T, lastModified: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmRule.VTable, self.vtable).get_LastModified(@ptrCast(*const IFsrmRule, self), lastModified); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmClassificationRule_Value = Guid.initString("afc052c2-5315-45ab-841b-c6db0e120148"); pub const IID_IFsrmClassificationRule = &IID_IFsrmClassificationRule_Value; pub const IFsrmClassificationRule = extern struct { pub const VTable = extern struct { base: IFsrmRule.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ExecutionOption: fn( self: *const IFsrmClassificationRule, executionOption: ?*FsrmExecutionOption, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ExecutionOption: fn( self: *const IFsrmClassificationRule, executionOption: FsrmExecutionOption, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PropertyAffected: fn( self: *const IFsrmClassificationRule, property: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PropertyAffected: fn( self: *const IFsrmClassificationRule, property: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Value: fn( self: *const IFsrmClassificationRule, value: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Value: fn( self: *const IFsrmClassificationRule, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmRule.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationRule_get_ExecutionOption(self: *const T, executionOption: ?*FsrmExecutionOption) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationRule.VTable, self.vtable).get_ExecutionOption(@ptrCast(*const IFsrmClassificationRule, self), executionOption); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationRule_put_ExecutionOption(self: *const T, executionOption: FsrmExecutionOption) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationRule.VTable, self.vtable).put_ExecutionOption(@ptrCast(*const IFsrmClassificationRule, self), executionOption); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationRule_get_PropertyAffected(self: *const T, property: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationRule.VTable, self.vtable).get_PropertyAffected(@ptrCast(*const IFsrmClassificationRule, self), property); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationRule_put_PropertyAffected(self: *const T, property: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationRule.VTable, self.vtable).put_PropertyAffected(@ptrCast(*const IFsrmClassificationRule, self), property); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationRule_get_Value(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationRule.VTable, self.vtable).get_Value(@ptrCast(*const IFsrmClassificationRule, self), value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationRule_put_Value(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationRule.VTable, self.vtable).put_Value(@ptrCast(*const IFsrmClassificationRule, self), value); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmPipelineModuleDefinition_Value = Guid.initString("515c1277-2c81-440e-8fcf-367921ed4f59"); pub const IID_IFsrmPipelineModuleDefinition = &IID_IFsrmPipelineModuleDefinition_Value; pub const IFsrmPipelineModuleDefinition = extern struct { pub const VTable = extern struct { base: IFsrmObject.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ModuleClsid: fn( self: *const IFsrmPipelineModuleDefinition, moduleClsid: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ModuleClsid: fn( self: *const IFsrmPipelineModuleDefinition, moduleClsid: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmPipelineModuleDefinition, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Name: fn( self: *const IFsrmPipelineModuleDefinition, name: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Company: fn( self: *const IFsrmPipelineModuleDefinition, company: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Company: fn( self: *const IFsrmPipelineModuleDefinition, company: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Version: fn( self: *const IFsrmPipelineModuleDefinition, version: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Version: fn( self: *const IFsrmPipelineModuleDefinition, version: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ModuleType: fn( self: *const IFsrmPipelineModuleDefinition, moduleType: ?*FsrmPipelineModuleType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Enabled: fn( self: *const IFsrmPipelineModuleDefinition, enabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Enabled: fn( self: *const IFsrmPipelineModuleDefinition, enabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NeedsFileContent: fn( self: *const IFsrmPipelineModuleDefinition, needsFileContent: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_NeedsFileContent: fn( self: *const IFsrmPipelineModuleDefinition, needsFileContent: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Account: fn( self: *const IFsrmPipelineModuleDefinition, retrievalAccount: ?*FsrmAccountType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Account: fn( self: *const IFsrmPipelineModuleDefinition, retrievalAccount: FsrmAccountType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SupportedExtensions: fn( self: *const IFsrmPipelineModuleDefinition, supportedExtensions: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_SupportedExtensions: fn( self: *const IFsrmPipelineModuleDefinition, supportedExtensions: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Parameters: fn( self: *const IFsrmPipelineModuleDefinition, parameters: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Parameters: fn( self: *const IFsrmPipelineModuleDefinition, parameters: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmObject.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_ModuleClsid(self: *const T, moduleClsid: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_ModuleClsid(@ptrCast(*const IFsrmPipelineModuleDefinition, self), moduleClsid); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_put_ModuleClsid(self: *const T, moduleClsid: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).put_ModuleClsid(@ptrCast(*const IFsrmPipelineModuleDefinition, self), moduleClsid); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmPipelineModuleDefinition, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_put_Name(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).put_Name(@ptrCast(*const IFsrmPipelineModuleDefinition, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_Company(self: *const T, company: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_Company(@ptrCast(*const IFsrmPipelineModuleDefinition, self), company); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_put_Company(self: *const T, company: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).put_Company(@ptrCast(*const IFsrmPipelineModuleDefinition, self), company); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_Version(self: *const T, version: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_Version(@ptrCast(*const IFsrmPipelineModuleDefinition, self), version); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_put_Version(self: *const T, version: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).put_Version(@ptrCast(*const IFsrmPipelineModuleDefinition, self), version); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_ModuleType(self: *const T, moduleType: ?*FsrmPipelineModuleType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_ModuleType(@ptrCast(*const IFsrmPipelineModuleDefinition, self), moduleType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_Enabled(self: *const T, enabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_Enabled(@ptrCast(*const IFsrmPipelineModuleDefinition, self), enabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_put_Enabled(self: *const T, enabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).put_Enabled(@ptrCast(*const IFsrmPipelineModuleDefinition, self), enabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_NeedsFileContent(self: *const T, needsFileContent: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_NeedsFileContent(@ptrCast(*const IFsrmPipelineModuleDefinition, self), needsFileContent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_put_NeedsFileContent(self: *const T, needsFileContent: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).put_NeedsFileContent(@ptrCast(*const IFsrmPipelineModuleDefinition, self), needsFileContent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_Account(self: *const T, retrievalAccount: ?*FsrmAccountType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_Account(@ptrCast(*const IFsrmPipelineModuleDefinition, self), retrievalAccount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_put_Account(self: *const T, retrievalAccount: FsrmAccountType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).put_Account(@ptrCast(*const IFsrmPipelineModuleDefinition, self), retrievalAccount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_SupportedExtensions(self: *const T, supportedExtensions: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_SupportedExtensions(@ptrCast(*const IFsrmPipelineModuleDefinition, self), supportedExtensions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_put_SupportedExtensions(self: *const T, supportedExtensions: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).put_SupportedExtensions(@ptrCast(*const IFsrmPipelineModuleDefinition, self), supportedExtensions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_get_Parameters(self: *const T, parameters: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).get_Parameters(@ptrCast(*const IFsrmPipelineModuleDefinition, self), parameters); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleDefinition_put_Parameters(self: *const T, parameters: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleDefinition.VTable, self.vtable).put_Parameters(@ptrCast(*const IFsrmPipelineModuleDefinition, self), parameters); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmClassifierModuleDefinition_Value = Guid.initString("bb36ea26-6318-4b8c-8592-f72dd602e7a5"); pub const IID_IFsrmClassifierModuleDefinition = &IID_IFsrmClassifierModuleDefinition_Value; pub const IFsrmClassifierModuleDefinition = extern struct { pub const VTable = extern struct { base: IFsrmPipelineModuleDefinition.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PropertiesAffected: fn( self: *const IFsrmClassifierModuleDefinition, propertiesAffected: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PropertiesAffected: fn( self: *const IFsrmClassifierModuleDefinition, propertiesAffected: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PropertiesUsed: fn( self: *const IFsrmClassifierModuleDefinition, propertiesUsed: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_PropertiesUsed: fn( self: *const IFsrmClassifierModuleDefinition, propertiesUsed: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_NeedsExplicitValue: fn( self: *const IFsrmClassifierModuleDefinition, needsExplicitValue: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_NeedsExplicitValue: fn( self: *const IFsrmClassifierModuleDefinition, needsExplicitValue: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmPipelineModuleDefinition.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleDefinition_get_PropertiesAffected(self: *const T, propertiesAffected: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleDefinition.VTable, self.vtable).get_PropertiesAffected(@ptrCast(*const IFsrmClassifierModuleDefinition, self), propertiesAffected); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleDefinition_put_PropertiesAffected(self: *const T, propertiesAffected: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleDefinition.VTable, self.vtable).put_PropertiesAffected(@ptrCast(*const IFsrmClassifierModuleDefinition, self), propertiesAffected); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleDefinition_get_PropertiesUsed(self: *const T, propertiesUsed: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleDefinition.VTable, self.vtable).get_PropertiesUsed(@ptrCast(*const IFsrmClassifierModuleDefinition, self), propertiesUsed); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleDefinition_put_PropertiesUsed(self: *const T, propertiesUsed: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleDefinition.VTable, self.vtable).put_PropertiesUsed(@ptrCast(*const IFsrmClassifierModuleDefinition, self), propertiesUsed); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleDefinition_get_NeedsExplicitValue(self: *const T, needsExplicitValue: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleDefinition.VTable, self.vtable).get_NeedsExplicitValue(@ptrCast(*const IFsrmClassifierModuleDefinition, self), needsExplicitValue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleDefinition_put_NeedsExplicitValue(self: *const T, needsExplicitValue: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleDefinition.VTable, self.vtable).put_NeedsExplicitValue(@ptrCast(*const IFsrmClassifierModuleDefinition, self), needsExplicitValue); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmStorageModuleDefinition_Value = Guid.initString("15a81350-497d-4aba-80e9-d4dbcc5521fe"); pub const IID_IFsrmStorageModuleDefinition = &IID_IFsrmStorageModuleDefinition_Value; pub const IFsrmStorageModuleDefinition = extern struct { pub const VTable = extern struct { base: IFsrmPipelineModuleDefinition.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Capabilities: fn( self: *const IFsrmStorageModuleDefinition, capabilities: ?*FsrmStorageModuleCaps, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Capabilities: fn( self: *const IFsrmStorageModuleDefinition, capabilities: FsrmStorageModuleCaps, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_StorageType: fn( self: *const IFsrmStorageModuleDefinition, storageType: ?*FsrmStorageModuleType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_StorageType: fn( self: *const IFsrmStorageModuleDefinition, storageType: FsrmStorageModuleType, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_UpdatesFileContent: fn( self: *const IFsrmStorageModuleDefinition, updatesFileContent: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_UpdatesFileContent: fn( self: *const IFsrmStorageModuleDefinition, updatesFileContent: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmPipelineModuleDefinition.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmStorageModuleDefinition_get_Capabilities(self: *const T, capabilities: ?*FsrmStorageModuleCaps) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmStorageModuleDefinition.VTable, self.vtable).get_Capabilities(@ptrCast(*const IFsrmStorageModuleDefinition, self), capabilities); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmStorageModuleDefinition_put_Capabilities(self: *const T, capabilities: FsrmStorageModuleCaps) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmStorageModuleDefinition.VTable, self.vtable).put_Capabilities(@ptrCast(*const IFsrmStorageModuleDefinition, self), capabilities); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmStorageModuleDefinition_get_StorageType(self: *const T, storageType: ?*FsrmStorageModuleType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmStorageModuleDefinition.VTable, self.vtable).get_StorageType(@ptrCast(*const IFsrmStorageModuleDefinition, self), storageType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmStorageModuleDefinition_put_StorageType(self: *const T, storageType: FsrmStorageModuleType) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmStorageModuleDefinition.VTable, self.vtable).put_StorageType(@ptrCast(*const IFsrmStorageModuleDefinition, self), storageType); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmStorageModuleDefinition_get_UpdatesFileContent(self: *const T, updatesFileContent: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmStorageModuleDefinition.VTable, self.vtable).get_UpdatesFileContent(@ptrCast(*const IFsrmStorageModuleDefinition, self), updatesFileContent); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmStorageModuleDefinition_put_UpdatesFileContent(self: *const T, updatesFileContent: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmStorageModuleDefinition.VTable, self.vtable).put_UpdatesFileContent(@ptrCast(*const IFsrmStorageModuleDefinition, self), updatesFileContent); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows8.0' const IID_IFsrmClassificationManager_Value = Guid.initString("d2dc89da-ee91-48a0-85d8-cc72a56f7d04"); pub const IID_IFsrmClassificationManager = &IID_IFsrmClassificationManager_Value; pub const IFsrmClassificationManager = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClassificationReportFormats: fn( self: *const IFsrmClassificationManager, formats: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ClassificationReportFormats: fn( self: *const IFsrmClassificationManager, formats: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Logging: fn( self: *const IFsrmClassificationManager, logging: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_Logging: fn( self: *const IFsrmClassificationManager, logging: i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClassificationReportMailTo: fn( self: *const IFsrmClassificationManager, mailTo: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ClassificationReportMailTo: fn( self: *const IFsrmClassificationManager, mailTo: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClassificationReportEnabled: fn( self: *const IFsrmClassificationManager, reportEnabled: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? put_ClassificationReportEnabled: fn( self: *const IFsrmClassificationManager, reportEnabled: i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClassificationLastReportPathWithoutExtension: fn( self: *const IFsrmClassificationManager, lastReportPath: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClassificationLastError: fn( self: *const IFsrmClassificationManager, lastError: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ClassificationRunningStatus: fn( self: *const IFsrmClassificationManager, runningStatus: ?*FsrmReportRunningStatus, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumPropertyDefinitions: fn( self: *const IFsrmClassificationManager, options: FsrmEnumOptions, propertyDefinitions: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreatePropertyDefinition: fn( self: *const IFsrmClassificationManager, propertyDefinition: ?*?*IFsrmPropertyDefinition, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyDefinition: fn( self: *const IFsrmClassificationManager, propertyName: ?BSTR, propertyDefinition: ?*?*IFsrmPropertyDefinition, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumRules: fn( self: *const IFsrmClassificationManager, ruleType: FsrmRuleType, options: FsrmEnumOptions, Rules: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateRule: fn( self: *const IFsrmClassificationManager, ruleType: FsrmRuleType, Rule: ?*?*IFsrmRule, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetRule: fn( self: *const IFsrmClassificationManager, ruleName: ?BSTR, ruleType: FsrmRuleType, Rule: ?*?*IFsrmRule, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumModuleDefinitions: fn( self: *const IFsrmClassificationManager, moduleType: FsrmPipelineModuleType, options: FsrmEnumOptions, moduleDefinitions: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CreateModuleDefinition: fn( self: *const IFsrmClassificationManager, moduleType: FsrmPipelineModuleType, moduleDefinition: ?*?*IFsrmPipelineModuleDefinition, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetModuleDefinition: fn( self: *const IFsrmClassificationManager, moduleName: ?BSTR, moduleType: FsrmPipelineModuleType, moduleDefinition: ?*?*IFsrmPipelineModuleDefinition, ) callconv(@import("std").os.windows.WINAPI) HRESULT, RunClassification: fn( self: *const IFsrmClassificationManager, context: FsrmReportGenerationContext, reserved: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, WaitForClassificationCompletion: fn( self: *const IFsrmClassificationManager, waitSeconds: i32, completed: ?*i16, ) callconv(@import("std").os.windows.WINAPI) HRESULT, CancelClassification: fn( self: *const IFsrmClassificationManager, ) callconv(@import("std").os.windows.WINAPI) HRESULT, EnumFileProperties: fn( self: *const IFsrmClassificationManager, filePath: ?BSTR, options: FsrmGetFilePropertyOptions, fileProperties: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFileProperty: fn( self: *const IFsrmClassificationManager, filePath: ?BSTR, propertyName: ?BSTR, options: FsrmGetFilePropertyOptions, property: ?*?*IFsrmProperty, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetFileProperty: fn( self: *const IFsrmClassificationManager, filePath: ?BSTR, propertyName: ?BSTR, propertyValue: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, ClearFileProperty: fn( self: *const IFsrmClassificationManager, filePath: ?BSTR, property: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_get_ClassificationReportFormats(self: *const T, formats: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).get_ClassificationReportFormats(@ptrCast(*const IFsrmClassificationManager, self), formats); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_put_ClassificationReportFormats(self: *const T, formats: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).put_ClassificationReportFormats(@ptrCast(*const IFsrmClassificationManager, self), formats); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_get_Logging(self: *const T, logging: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).get_Logging(@ptrCast(*const IFsrmClassificationManager, self), logging); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_put_Logging(self: *const T, logging: i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).put_Logging(@ptrCast(*const IFsrmClassificationManager, self), logging); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_get_ClassificationReportMailTo(self: *const T, mailTo: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).get_ClassificationReportMailTo(@ptrCast(*const IFsrmClassificationManager, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_put_ClassificationReportMailTo(self: *const T, mailTo: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).put_ClassificationReportMailTo(@ptrCast(*const IFsrmClassificationManager, self), mailTo); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_get_ClassificationReportEnabled(self: *const T, reportEnabled: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).get_ClassificationReportEnabled(@ptrCast(*const IFsrmClassificationManager, self), reportEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_put_ClassificationReportEnabled(self: *const T, reportEnabled: i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).put_ClassificationReportEnabled(@ptrCast(*const IFsrmClassificationManager, self), reportEnabled); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_get_ClassificationLastReportPathWithoutExtension(self: *const T, lastReportPath: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).get_ClassificationLastReportPathWithoutExtension(@ptrCast(*const IFsrmClassificationManager, self), lastReportPath); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_get_ClassificationLastError(self: *const T, lastError: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).get_ClassificationLastError(@ptrCast(*const IFsrmClassificationManager, self), lastError); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_get_ClassificationRunningStatus(self: *const T, runningStatus: ?*FsrmReportRunningStatus) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).get_ClassificationRunningStatus(@ptrCast(*const IFsrmClassificationManager, self), runningStatus); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_EnumPropertyDefinitions(self: *const T, options: FsrmEnumOptions, propertyDefinitions: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).EnumPropertyDefinitions(@ptrCast(*const IFsrmClassificationManager, self), options, propertyDefinitions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_CreatePropertyDefinition(self: *const T, propertyDefinition: ?*?*IFsrmPropertyDefinition) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).CreatePropertyDefinition(@ptrCast(*const IFsrmClassificationManager, self), propertyDefinition); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_GetPropertyDefinition(self: *const T, propertyName: ?BSTR, propertyDefinition: ?*?*IFsrmPropertyDefinition) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).GetPropertyDefinition(@ptrCast(*const IFsrmClassificationManager, self), propertyName, propertyDefinition); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_EnumRules(self: *const T, ruleType: FsrmRuleType, options: FsrmEnumOptions, Rules: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).EnumRules(@ptrCast(*const IFsrmClassificationManager, self), ruleType, options, Rules); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_CreateRule(self: *const T, ruleType: FsrmRuleType, Rule: ?*?*IFsrmRule) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).CreateRule(@ptrCast(*const IFsrmClassificationManager, self), ruleType, Rule); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_GetRule(self: *const T, ruleName: ?BSTR, ruleType: FsrmRuleType, Rule: ?*?*IFsrmRule) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).GetRule(@ptrCast(*const IFsrmClassificationManager, self), ruleName, ruleType, Rule); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_EnumModuleDefinitions(self: *const T, moduleType: FsrmPipelineModuleType, options: FsrmEnumOptions, moduleDefinitions: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).EnumModuleDefinitions(@ptrCast(*const IFsrmClassificationManager, self), moduleType, options, moduleDefinitions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_CreateModuleDefinition(self: *const T, moduleType: FsrmPipelineModuleType, moduleDefinition: ?*?*IFsrmPipelineModuleDefinition) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).CreateModuleDefinition(@ptrCast(*const IFsrmClassificationManager, self), moduleType, moduleDefinition); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_GetModuleDefinition(self: *const T, moduleName: ?BSTR, moduleType: FsrmPipelineModuleType, moduleDefinition: ?*?*IFsrmPipelineModuleDefinition) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).GetModuleDefinition(@ptrCast(*const IFsrmClassificationManager, self), moduleName, moduleType, moduleDefinition); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_RunClassification(self: *const T, context: FsrmReportGenerationContext, reserved: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).RunClassification(@ptrCast(*const IFsrmClassificationManager, self), context, reserved); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_WaitForClassificationCompletion(self: *const T, waitSeconds: i32, completed: ?*i16) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).WaitForClassificationCompletion(@ptrCast(*const IFsrmClassificationManager, self), waitSeconds, completed); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_CancelClassification(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).CancelClassification(@ptrCast(*const IFsrmClassificationManager, self)); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_EnumFileProperties(self: *const T, filePath: ?BSTR, options: FsrmGetFilePropertyOptions, fileProperties: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).EnumFileProperties(@ptrCast(*const IFsrmClassificationManager, self), filePath, options, fileProperties); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_GetFileProperty(self: *const T, filePath: ?BSTR, propertyName: ?BSTR, options: FsrmGetFilePropertyOptions, property: ?*?*IFsrmProperty) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).GetFileProperty(@ptrCast(*const IFsrmClassificationManager, self), filePath, propertyName, options, property); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_SetFileProperty(self: *const T, filePath: ?BSTR, propertyName: ?BSTR, propertyValue: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).SetFileProperty(@ptrCast(*const IFsrmClassificationManager, self), filePath, propertyName, propertyValue); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager_ClearFileProperty(self: *const T, filePath: ?BSTR, property: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager.VTable, self.vtable).ClearFileProperty(@ptrCast(*const IFsrmClassificationManager, self), filePath, property); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows8.0' const IID_IFsrmClassificationManager2_Value = Guid.initString("0004c1c9-127e-4765-ba07-6a3147bca112"); pub const IID_IFsrmClassificationManager2 = &IID_IFsrmClassificationManager2_Value; pub const IFsrmClassificationManager2 = extern struct { pub const VTable = extern struct { base: IFsrmClassificationManager.VTable, ClassifyFiles: fn( self: *const IFsrmClassificationManager2, filePaths: ?*SAFEARRAY, propertyNames: ?*SAFEARRAY, propertyValues: ?*SAFEARRAY, options: FsrmGetFilePropertyOptions, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmClassificationManager.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassificationManager2_ClassifyFiles(self: *const T, filePaths: ?*SAFEARRAY, propertyNames: ?*SAFEARRAY, propertyValues: ?*SAFEARRAY, options: FsrmGetFilePropertyOptions) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassificationManager2.VTable, self.vtable).ClassifyFiles(@ptrCast(*const IFsrmClassificationManager2, self), filePaths, propertyNames, propertyValues, options); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmPropertyBag_Value = Guid.initString("774589d1-d300-4f7a-9a24-f7b766800250"); pub const IID_IFsrmPropertyBag = &IID_IFsrmPropertyBag_Value; pub const IFsrmPropertyBag = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Name: fn( self: *const IFsrmPropertyBag, name: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RelativePath: fn( self: *const IFsrmPropertyBag, path: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_VolumeName: fn( self: *const IFsrmPropertyBag, volumeName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_RelativeNamespaceRoot: fn( self: *const IFsrmPropertyBag, relativeNamespaceRoot: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_VolumeIndex: fn( self: *const IFsrmPropertyBag, volumeId: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FileId: fn( self: *const IFsrmPropertyBag, fileId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ParentDirectoryId: fn( self: *const IFsrmPropertyBag, parentDirectoryId: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Size: fn( self: *const IFsrmPropertyBag, size: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_SizeAllocated: fn( self: *const IFsrmPropertyBag, sizeAllocated: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_CreationTime: fn( self: *const IFsrmPropertyBag, creationTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastAccessTime: fn( self: *const IFsrmPropertyBag, lastAccessTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastModificationTime: fn( self: *const IFsrmPropertyBag, lastModificationTime: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Attributes: fn( self: *const IFsrmPropertyBag, attributes: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_OwnerSid: fn( self: *const IFsrmPropertyBag, ownerSid: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_FilePropertyNames: fn( self: *const IFsrmPropertyBag, filePropertyNames: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_Messages: fn( self: *const IFsrmPropertyBag, messages: ?*?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_PropertyBagFlags: fn( self: *const IFsrmPropertyBag, flags: ?*u32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFileProperty: fn( self: *const IFsrmPropertyBag, name: ?BSTR, fileProperty: ?*?*IFsrmProperty, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SetFileProperty: fn( self: *const IFsrmPropertyBag, name: ?BSTR, value: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, AddMessage: fn( self: *const IFsrmPropertyBag, message: ?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetFileStreamInterface: fn( self: *const IFsrmPropertyBag, accessMode: FsrmFileStreamingMode, interfaceType: FsrmFileStreamingInterfaceType, pStreamInterface: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_Name(self: *const T, name: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_Name(@ptrCast(*const IFsrmPropertyBag, self), name); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_RelativePath(self: *const T, path: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_RelativePath(@ptrCast(*const IFsrmPropertyBag, self), path); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_VolumeName(self: *const T, volumeName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_VolumeName(@ptrCast(*const IFsrmPropertyBag, self), volumeName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_RelativeNamespaceRoot(self: *const T, relativeNamespaceRoot: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_RelativeNamespaceRoot(@ptrCast(*const IFsrmPropertyBag, self), relativeNamespaceRoot); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_VolumeIndex(self: *const T, volumeId: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_VolumeIndex(@ptrCast(*const IFsrmPropertyBag, self), volumeId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_FileId(self: *const T, fileId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_FileId(@ptrCast(*const IFsrmPropertyBag, self), fileId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_ParentDirectoryId(self: *const T, parentDirectoryId: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_ParentDirectoryId(@ptrCast(*const IFsrmPropertyBag, self), parentDirectoryId); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_Size(self: *const T, size: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_Size(@ptrCast(*const IFsrmPropertyBag, self), size); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_SizeAllocated(self: *const T, sizeAllocated: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_SizeAllocated(@ptrCast(*const IFsrmPropertyBag, self), sizeAllocated); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_CreationTime(self: *const T, creationTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_CreationTime(@ptrCast(*const IFsrmPropertyBag, self), creationTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_LastAccessTime(self: *const T, lastAccessTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_LastAccessTime(@ptrCast(*const IFsrmPropertyBag, self), lastAccessTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_LastModificationTime(self: *const T, lastModificationTime: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_LastModificationTime(@ptrCast(*const IFsrmPropertyBag, self), lastModificationTime); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_Attributes(self: *const T, attributes: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_Attributes(@ptrCast(*const IFsrmPropertyBag, self), attributes); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_OwnerSid(self: *const T, ownerSid: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_OwnerSid(@ptrCast(*const IFsrmPropertyBag, self), ownerSid); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_FilePropertyNames(self: *const T, filePropertyNames: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_FilePropertyNames(@ptrCast(*const IFsrmPropertyBag, self), filePropertyNames); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_Messages(self: *const T, messages: ?*?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_Messages(@ptrCast(*const IFsrmPropertyBag, self), messages); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_get_PropertyBagFlags(self: *const T, flags: ?*u32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).get_PropertyBagFlags(@ptrCast(*const IFsrmPropertyBag, self), flags); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_GetFileProperty(self: *const T, name: ?BSTR, fileProperty: ?*?*IFsrmProperty) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).GetFileProperty(@ptrCast(*const IFsrmPropertyBag, self), name, fileProperty); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_SetFileProperty(self: *const T, name: ?BSTR, value: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).SetFileProperty(@ptrCast(*const IFsrmPropertyBag, self), name, value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_AddMessage(self: *const T, message: ?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).AddMessage(@ptrCast(*const IFsrmPropertyBag, self), message); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag_GetFileStreamInterface(self: *const T, accessMode: FsrmFileStreamingMode, interfaceType: FsrmFileStreamingInterfaceType, pStreamInterface: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag.VTable, self.vtable).GetFileStreamInterface(@ptrCast(*const IFsrmPropertyBag, self), accessMode, interfaceType, pStreamInterface); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2012' const IID_IFsrmPropertyBag2_Value = Guid.initString("0e46bdbd-2402-4fed-9c30-9266e6eb2cc9"); pub const IID_IFsrmPropertyBag2 = &IID_IFsrmPropertyBag2_Value; pub const IFsrmPropertyBag2 = extern struct { pub const VTable = extern struct { base: IFsrmPropertyBag.VTable, GetFieldValue: fn( self: *const IFsrmPropertyBag2, field: FsrmPropertyBagField, value: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetUntrustedInFileProperties: fn( self: *const IFsrmPropertyBag2, props: ?*?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmPropertyBag.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag2_GetFieldValue(self: *const T, field: FsrmPropertyBagField, value: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag2.VTable, self.vtable).GetFieldValue(@ptrCast(*const IFsrmPropertyBag2, self), field, value); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPropertyBag2_GetUntrustedInFileProperties(self: *const T, props: ?*?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPropertyBag2.VTable, self.vtable).GetUntrustedInFileProperties(@ptrCast(*const IFsrmPropertyBag2, self), props); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmPipelineModuleImplementation_Value = Guid.initString("b7907906-2b02-4cb5-84a9-fdf54613d6cd"); pub const IID_IFsrmPipelineModuleImplementation = &IID_IFsrmPipelineModuleImplementation_Value; pub const IFsrmPipelineModuleImplementation = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, OnLoad: fn( self: *const IFsrmPipelineModuleImplementation, moduleDefinition: ?*IFsrmPipelineModuleDefinition, moduleConnector: ?*?*IFsrmPipelineModuleConnector, ) callconv(@import("std").os.windows.WINAPI) HRESULT, OnUnload: fn( self: *const IFsrmPipelineModuleImplementation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleImplementation_OnLoad(self: *const T, moduleDefinition: ?*IFsrmPipelineModuleDefinition, moduleConnector: ?*?*IFsrmPipelineModuleConnector) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleImplementation.VTable, self.vtable).OnLoad(@ptrCast(*const IFsrmPipelineModuleImplementation, self), moduleDefinition, moduleConnector); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleImplementation_OnUnload(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleImplementation.VTable, self.vtable).OnUnload(@ptrCast(*const IFsrmPipelineModuleImplementation, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmClassifierModuleImplementation_Value = Guid.initString("4c968fc6-6edb-4051-9c18-73b7291ae106"); pub const IID_IFsrmClassifierModuleImplementation = &IID_IFsrmClassifierModuleImplementation_Value; pub const IFsrmClassifierModuleImplementation = extern struct { pub const VTable = extern struct { base: IFsrmPipelineModuleImplementation.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_LastModified: fn( self: *const IFsrmClassifierModuleImplementation, lastModified: ?*VARIANT, ) callconv(@import("std").os.windows.WINAPI) HRESULT, UseRulesAndDefinitions: fn( self: *const IFsrmClassifierModuleImplementation, rules: ?*IFsrmCollection, propertyDefinitions: ?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, OnBeginFile: fn( self: *const IFsrmClassifierModuleImplementation, propertyBag: ?*IFsrmPropertyBag, arrayRuleIds: ?*SAFEARRAY, ) callconv(@import("std").os.windows.WINAPI) HRESULT, DoesPropertyValueApply: fn( self: *const IFsrmClassifierModuleImplementation, property: ?BSTR, value: ?BSTR, applyValue: ?*i16, idRule: Guid, idPropDef: Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT, GetPropertyValueToApply: fn( self: *const IFsrmClassifierModuleImplementation, property: ?BSTR, value: ?*?BSTR, idRule: Guid, idPropDef: Guid, ) callconv(@import("std").os.windows.WINAPI) HRESULT, OnEndFile: fn( self: *const IFsrmClassifierModuleImplementation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmPipelineModuleImplementation.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleImplementation_get_LastModified(self: *const T, lastModified: ?*VARIANT) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleImplementation.VTable, self.vtable).get_LastModified(@ptrCast(*const IFsrmClassifierModuleImplementation, self), lastModified); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleImplementation_UseRulesAndDefinitions(self: *const T, rules: ?*IFsrmCollection, propertyDefinitions: ?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleImplementation.VTable, self.vtable).UseRulesAndDefinitions(@ptrCast(*const IFsrmClassifierModuleImplementation, self), rules, propertyDefinitions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleImplementation_OnBeginFile(self: *const T, propertyBag: ?*IFsrmPropertyBag, arrayRuleIds: ?*SAFEARRAY) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleImplementation.VTable, self.vtable).OnBeginFile(@ptrCast(*const IFsrmClassifierModuleImplementation, self), propertyBag, arrayRuleIds); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleImplementation_DoesPropertyValueApply(self: *const T, property: ?BSTR, value: ?BSTR, applyValue: ?*i16, idRule: Guid, idPropDef: Guid) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleImplementation.VTable, self.vtable).DoesPropertyValueApply(@ptrCast(*const IFsrmClassifierModuleImplementation, self), property, value, applyValue, idRule, idPropDef); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleImplementation_GetPropertyValueToApply(self: *const T, property: ?BSTR, value: ?*?BSTR, idRule: Guid, idPropDef: Guid) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleImplementation.VTable, self.vtable).GetPropertyValueToApply(@ptrCast(*const IFsrmClassifierModuleImplementation, self), property, value, idRule, idPropDef); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmClassifierModuleImplementation_OnEndFile(self: *const T) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmClassifierModuleImplementation.VTable, self.vtable).OnEndFile(@ptrCast(*const IFsrmClassifierModuleImplementation, self)); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmStorageModuleImplementation_Value = Guid.initString("0af4a0da-895a-4e50-8712-a96724bcec64"); pub const IID_IFsrmStorageModuleImplementation = &IID_IFsrmStorageModuleImplementation_Value; pub const IFsrmStorageModuleImplementation = extern struct { pub const VTable = extern struct { base: IFsrmPipelineModuleImplementation.VTable, UseDefinitions: fn( self: *const IFsrmStorageModuleImplementation, propertyDefinitions: ?*IFsrmCollection, ) callconv(@import("std").os.windows.WINAPI) HRESULT, LoadProperties: fn( self: *const IFsrmStorageModuleImplementation, propertyBag: ?*IFsrmPropertyBag, ) callconv(@import("std").os.windows.WINAPI) HRESULT, SaveProperties: fn( self: *const IFsrmStorageModuleImplementation, propertyBag: ?*IFsrmPropertyBag, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IFsrmPipelineModuleImplementation.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmStorageModuleImplementation_UseDefinitions(self: *const T, propertyDefinitions: ?*IFsrmCollection) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmStorageModuleImplementation.VTable, self.vtable).UseDefinitions(@ptrCast(*const IFsrmStorageModuleImplementation, self), propertyDefinitions); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmStorageModuleImplementation_LoadProperties(self: *const T, propertyBag: ?*IFsrmPropertyBag) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmStorageModuleImplementation.VTable, self.vtable).LoadProperties(@ptrCast(*const IFsrmStorageModuleImplementation, self), propertyBag); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmStorageModuleImplementation_SaveProperties(self: *const T, propertyBag: ?*IFsrmPropertyBag) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmStorageModuleImplementation.VTable, self.vtable).SaveProperties(@ptrCast(*const IFsrmStorageModuleImplementation, self), propertyBag); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windowsServer2008' const IID_IFsrmPipelineModuleConnector_Value = Guid.initString("c16014f3-9aa1-46b3-b0a7-ab146eb205f2"); pub const IID_IFsrmPipelineModuleConnector = &IID_IFsrmPipelineModuleConnector_Value; pub const IFsrmPipelineModuleConnector = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ModuleImplementation: fn( self: *const IFsrmPipelineModuleConnector, pipelineModuleImplementation: ?*?*IFsrmPipelineModuleImplementation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_ModuleName: fn( self: *const IFsrmPipelineModuleConnector, userName: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HostingUserAccount: fn( self: *const IFsrmPipelineModuleConnector, userAccount: ?*?BSTR, ) callconv(@import("std").os.windows.WINAPI) HRESULT, // TODO: this function has a "SpecialName", should Zig do anything with this? get_HostingProcessPid: fn( self: *const IFsrmPipelineModuleConnector, pid: ?*i32, ) callconv(@import("std").os.windows.WINAPI) HRESULT, Bind: fn( self: *const IFsrmPipelineModuleConnector, moduleDefinition: ?*IFsrmPipelineModuleDefinition, moduleImplementation: ?*IFsrmPipelineModuleImplementation, ) callconv(@import("std").os.windows.WINAPI) HRESULT, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleConnector_get_ModuleImplementation(self: *const T, pipelineModuleImplementation: ?*?*IFsrmPipelineModuleImplementation) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleConnector.VTable, self.vtable).get_ModuleImplementation(@ptrCast(*const IFsrmPipelineModuleConnector, self), pipelineModuleImplementation); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleConnector_get_ModuleName(self: *const T, userName: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleConnector.VTable, self.vtable).get_ModuleName(@ptrCast(*const IFsrmPipelineModuleConnector, self), userName); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleConnector_get_HostingUserAccount(self: *const T, userAccount: ?*?BSTR) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleConnector.VTable, self.vtable).get_HostingUserAccount(@ptrCast(*const IFsrmPipelineModuleConnector, self), userAccount); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleConnector_get_HostingProcessPid(self: *const T, pid: ?*i32) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleConnector.VTable, self.vtable).get_HostingProcessPid(@ptrCast(*const IFsrmPipelineModuleConnector, self), pid); } // NOTE: method is namespaced with interface name to avoid conflicts for now pub fn IFsrmPipelineModuleConnector_Bind(self: *const T, moduleDefinition: ?*IFsrmPipelineModuleDefinition, moduleImplementation: ?*IFsrmPipelineModuleImplementation) callconv(.Inline) HRESULT { return @ptrCast(*const IFsrmPipelineModuleConnector.VTable, self.vtable).Bind(@ptrCast(*const IFsrmPipelineModuleConnector, self), moduleDefinition, moduleImplementation); } };} pub usingnamespace MethodMixin(@This()); }; // TODO: this type is limited to platform 'windows8.0' const IID_DIFsrmClassificationEvents_Value = Guid.initString("26942db0-dabf-41d8-bbdd-b129a9f70424"); pub const IID_DIFsrmClassificationEvents = &IID_DIFsrmClassificationEvents_Value; pub const DIFsrmClassificationEvents = extern struct { pub const VTable = extern struct { base: IDispatch.VTable, }; vtable: *const VTable, pub fn MethodMixin(comptime T: type) type { return struct { pub usingnamespace IDispatch.MethodMixin(T); };} pub usingnamespace MethodMixin(@This()); }; //-------------------------------------------------------------------------------- // Section: Functions (0) //-------------------------------------------------------------------------------- //-------------------------------------------------------------------------------- // Section: Unicode Aliases (0) //-------------------------------------------------------------------------------- const thismodule = @This(); pub usingnamespace switch (@import("../zig.zig").unicode_mode) { .ansi => struct { }, .wide => struct { }, .unspecified => if (@import("builtin").is_test) struct { } else struct { }, }; //-------------------------------------------------------------------------------- // Section: Imports (7) //-------------------------------------------------------------------------------- const Guid = @import("../zig.zig").Guid; const BSTR = @import("../foundation.zig").BSTR; const HRESULT = @import("../foundation.zig").HRESULT; const IDispatch = @import("../system/com.zig").IDispatch; const IUnknown = @import("../system/com.zig").IUnknown; const SAFEARRAY = @import("../system/com.zig").SAFEARRAY; const VARIANT = @import("../system/com.zig").VARIANT; test { @setEvalBranchQuota( @import("std").meta.declarations(@This()).len * 3 ); // reference all the pub declarations if (!@import("builtin").is_test) return; inline for (@import("std").meta.declarations(@This())) |decl| { if (decl.is_pub) { _ = decl; } } }
win32/storage/file_server_resource_manager.zig
const csv = @import("csv.zig"); const std = @import("std"); const io = std.io; const warn = std.debug.warn; const testing = std.testing; const WriterTest = struct { input: []const []const u8, output: []const u8, use_crlf: bool, comma: u8, fn init( input: []const []const u8, output: []const u8, use_crlf: bool, comma: u8, ) WriterTest { return WriterTest{ .input = input, .output = output, .use_crlf = use_crlf, .comma = comma, }; } }; const writer_test_list = [_]WriterTest{ WriterTest.init([_][]const u8{"abc"}, "abc\n", false, 0), WriterTest.init([_][]const u8{"abc"}, "abc\r\n", true, 0), WriterTest.init([_][]const u8{"\"abc\""}, "\"\"\"abc\"\"\"\n", false, 0), WriterTest.init([_][]const u8{"a\"b"}, "\"a\"\"b\"\n", false, 0), WriterTest.init([_][]const u8{"\"a\"b\""}, "\"\"\"a\"\"b\"\"\"\n", false, 0), WriterTest.init([_][]const u8{" abc"}, "\" abc\"\n", false, 0), WriterTest.init([_][]const u8{"abc,def"}, "\"abc,def\"\n", false, 0), WriterTest.init([_][]const u8{ "abc", "def" }, "abc,def\n", false, 0), WriterTest.init([_][]const u8{"abc\ndef"}, "\"abc\ndef\"\n", false, 0), WriterTest.init([_][]const u8{"abc\ndef"}, "\"abc\r\ndef\"\r\n", true, 0), WriterTest.init([_][]const u8{"abc\rdef"}, "\"abcdef\"\r\n", true, 0), WriterTest.init([_][]const u8{"abc\rdef"}, "\"abc\rdef\"\n", false, 0), WriterTest.init([_][]const u8{""}, "\n", false, 0), WriterTest.init([_][]const u8{ "", "" }, ",\n", false, 0), WriterTest.init([_][]const u8{ "", "", "" }, ",,\n", false, 0), WriterTest.init([_][]const u8{ "", "", "a" }, ",,a\n", false, 0), WriterTest.init([_][]const u8{ "", "a", "" }, ",a,\n", false, 0), WriterTest.init([_][]const u8{ "", "a", "a" }, ",a,a\n", false, 0), WriterTest.init([_][]const u8{ "a", "", "" }, "a,,\n", false, 0), WriterTest.init([_][]const u8{ "a", "", "a" }, "a,,a\n", false, 0), WriterTest.init([_][]const u8{ "a", "a", "" }, "a,a,\n", false, 0), WriterTest.init([_][]const u8{ "a", "a", "a" }, "a,a,a\n", false, 0), WriterTest.init([_][]const u8{"\\."}, "\"\\.\"\n", false, 0), WriterTest.init([_][]const u8{ "x09\x41\xb4\x1c", "aktau" }, "x09\x41\xb4\x1c,aktau\n", false, 0), WriterTest.init([_][]const u8{ ",x09\x41\xb4\x1c", "aktau" }, "\",x09\x41\xb4\x1c\",aktau\n", false, 0), WriterTest.init([_][]const u8{ "a", "a", "" }, "a|a|\n", false, '|'), WriterTest.init([_][]const u8{ ",", ",", "" }, ",|,|\n", false, '|'), }; test "csv.Writer" { var buf = &try std.Buffer.init(std.debug.global_allocator, ""); defer buf.deinit(); var buffer_stream = io.BufferOutStream.init(buf); var w = &csv.Writer.init(&buffer_stream.stream); for (writer_test_list) |ts, id| { w.use_crlf = false; if (ts.use_crlf) { w.use_crlf = true; } if (ts.comma != 0) { w.comma = ts.comma; } try buf.resize(0); try w.write(ts.input); try w.flush(); testing.expect(buf.eql(ts.output)); } }
src/encoding/csv/csv_test.zig
const std = @import("std"); const syntax = @import("syntax.zig"); const mem = std.mem; const io = std.io; const math = std.math; const fs = std.fs; const os = std.os; pub const Color = enum { Reset, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, Gray, BrightRed, BrightGreen, BrightYellow, BrightBlue, BrightMagenta, BrightCyan, BrightWhite, pub fn getColor(self: Color) []const u8 { return switch (self) { .Reset => "\x1b[0m", .Black => "\x1b[30m", .Red => "\x1b[31m", .Green => "\x1b[32m", .Yellow => "\x1b[33m", .Blue => "\x1b[34m", .Magenta => "\x1b[35m", .Cyan => "\x1b[36m", .White => "\x1b[37m", .Gray => "\x1b[90m", .BrightRed => "\x1b[91m", .BrightGreen => "\x1b[92m", .BrightYellow => "\x1b[93m", .BrightBlue => "\x1b[94m", .BrightMagenta => "\x1b[95m", .BrightCyan => "\x1b[96m", .BrightWhite => "\x1b[97m", }; } }; pub const Blo = struct { const Self = Blo; const max_file_size = 1024 * 1024 * 10; pub const Config = struct { highlight: bool, ascii_chars: bool, info: bool, colors: bool, show_end: bool, line_number: bool, }; allocator: mem.Allocator, out: fs.File, writer: fs.File.Writer, config: Config, pub fn init(allocator: mem.Allocator, out: fs.File, config: Config) Self { var modif_config = config; if (!out.supportsAnsiEscapeCodes()) { modif_config.ascii_chars = true; modif_config.colors = false; } return .{ .allocator = allocator, .out = out, .writer = out.writer(), .config = modif_config }; } pub fn write(self: Self, data: []const u8) !void { try self.writer.writeAll(data); } pub fn writeNTime(self: Self, data: []const u8) !void { try self.writer.writeByteNTimes(data); } fn writeSliceNTime(self: Self, slice: []const u8, n: usize) !void { var i = n; while (i > 0) : (i -= 1) { try self.writer.writeAll(slice); } } fn print(self: Self, comptime format: []const u8, args: anytype) !void { try self.writer.print(format, args); } // count number length fn digitLen(n: usize) usize { if (n < 10) return 1; return 1 + digitLen(n / 10); } // Format to human readable size like 10B, 10KB, etc fn fmtSize(self: Self, bytes: usize) ![]const u8 { const suffix = &[_][]const u8{ "B", "KB", "MB" }; var size = bytes; var i: usize = 0; while (size >= 1024) { size /= 1024; i += 1; } return std.fmt.allocPrint(self.allocator, "{d} {s}", .{ size, suffix[i] }) catch "Unkown"; } fn fillSlice(slice: []u8, value: []const u8) void { var i: usize = 0; while (i < slice.len) : (i += value.len) { mem.copy(u8, slice[i .. i + value.len], value); } } fn setColor(self: Self, value: []const u8, color: Color, out: ?Color) ![]const u8 { if (self.config.colors) { var res = std.ArrayList(u8).init(self.allocator); defer res.deinit(); try res.appendSlice(Color.getColor(color)); try res.appendSlice(value); if (out) |out_color| { try res.appendSlice(Color.getColor(out_color)); } else { try res.appendSlice(Color.getColor(.Reset)); } return res.toOwnedSlice(); } else return value; } pub fn printFile(self: Self, path: []const u8) !void { // reading file const file = try fs.cwd().openFile(path, .{}); const data = try file.readToEndAlloc(self.allocator, max_file_size); // writing file information if (self.config.info) { // file stat const stat = try file.stat(); // file size const size = try self.fmtSize(@intCast(usize, stat.size)); // file info const stat_len = 2; // path - size - owner const total_stat_len = path.len + size.len; const space = if (self.config.line_number) " " ** 5 else ""; // printing if (self.config.ascii_chars) { const width_len = (total_stat_len + (stat_len * 3) + 5); const width = try self.allocator.alloc(u8, width_len); defer self.allocator.free(width); for (width) |*char| char.* = '-'; try self.print( \\{s}{s}{s} \\{s}-- {s} -- {s} -- \\{s}{s}{s} \\ , .{ space, Color.getColor(.Gray), width, space, self.setColor(path, .Yellow, .Gray), self.setColor(size, .Magenta, .Gray), space, width, Color.getColor(.Reset) }); } else { const side_margin = 2; const brick = "─"; var path_width = try self.allocator.alloc(u8, (path.len + side_margin) * brick.len); var size_width = try self.allocator.alloc(u8, (size.len + side_margin) * brick.len); fillSlice(path_width, brick); fillSlice(size_width, brick); defer { self.allocator.free(path_width); self.allocator.free(size_width); } const left_bottom_corner = if (self.config.line_number) "├" else "└"; try self.print( \\{s}{s}┌{s}┬{s}┐ \\{s}│ {s} │ {s} │ \\{s}{s}{s}┴{s}┘{s} \\ , .{ space, Color.getColor(.Gray), path_width, size_width, space, self.setColor(path, .Yellow, .Gray), self.setColor(size, .Magenta, .Gray), space, left_bottom_corner, path_width, size_width, Color.getColor(.Reset), }); } } // check for line numbers if (self.config.line_number) { var line_num: usize = 1; if (self.config.highlight) { var syntax_iterator = syntax.SyntaxIterator.init(.json, null, data); const line_split_char = if (self.config.ascii_chars) "|" else "│"; var i: usize = 0; while (syntax_iterator.next()) |token| : (i += 1) { const lnl = digitLen(line_num); // line number length if (i == 0) { try self.writer.writeByteNTimes(' ', 4 - lnl); try self.writer.print("{s}{d}{s} {s} ", .{ Color.getColor(.Cyan), line_num, Color.getColor(.Reset), self.setColor(line_split_char, .Gray, null) }); try self.writer.writeAll(token.color.getColor()); try self.writer.writeAll(data[token.start..token.end]); } else if (data[token.start..token.end][0] == '\n') { line_num += 1; try self.writer.writeByte('\n'); try self.writer.writeByteNTimes(' ', 4 - lnl); try self.writer.print("{s}{d}{s} {s} ", .{ Color.getColor(.Cyan), line_num, Color.getColor(.Reset), self.setColor(line_split_char, .Gray, null) }); } else { try self.writer.writeAll(token.color.getColor()); try self.writer.writeAll(data[token.start..token.end]); } } } else { var lines = mem.split(u8, data, "\n"); const line_split_char = if (self.config.ascii_chars) "|" else "│"; while (lines.next()) |line| : (line_num += 1) { const lnl = digitLen(line_num); // line number length try self.writer.writeByteNTimes(' ', 4 - lnl); try self.writer.print("{s}{d}{s} {s} ", .{ Color.getColor(.Cyan), line_num, Color.getColor(.Reset), self.setColor(line_split_char, .Gray, null) }); try self.writer.writeAll(line); if (lines.index != null) try self.writer.writeByte('\n'); } } } else { if (self.config.highlight) { var syntax_iterator = syntax.SyntaxIterator.init(.json, null, data); while (syntax_iterator.next()) |token| { try self.writer.writeAll(token.color.getColor()); try self.writer.writeAll(data[token.start..token.end]); } } else { try self.writer.writeAll(data); } } // show file end with <end> if (self.config.show_end) { try self.writer.writeAll("<end>"); } } };
src/blo.zig
const std = @import("std"); pub const PreloadedInfo = struct { width: u16, height: u16, bytes_per_line: u16, }; pub fn preload(reader: anytype) !PreloadedInfo { var header: [70]u8 = undefined; _ = try reader.readNoEof(&header); try reader.skipBytes(58, .{}); const manufacturer = header[0]; const version = header[1]; if (manufacturer != 0x0a or version != 5) { return error.PcxLoadFailed; } const encoding = header[2]; const bits_per_pixel = header[3]; const xmin = @as(u16, header[4]) | (@as(u16, header[5]) << 8); const ymin = @as(u16, header[6]) | (@as(u16, header[7]) << 8); const xmax = @as(u16, header[8]) | (@as(u16, header[9]) << 8); const ymax = @as(u16, header[10]) | (@as(u16, header[11]) << 8); // const hres = @as(u16, header[12]) | (@as(u16, header[13]) << 8); // const vres = @as(u16, header[14]) | (@as(u16, header[15]) << 8); // const reserved = header[64]; const color_planes = header[65]; const bytes_per_line = @as(u16, header[66]) | (@as(u16, header[67]) << 8); // const palette_type = @as(u16, header[68]) | (@as(u16, header[69]) << 8); if (encoding != 1 or bits_per_pixel != 8 or xmin > xmax or ymin > ymax or color_planes != 1) { return error.PcxLoadFailed; } return PreloadedInfo{ .width = xmax - xmin + 1, .height = ymax - ymin + 1, .bytes_per_line = bytes_per_line, }; } pub fn loadIndexed( reader: anytype, preloaded: PreloadedInfo, out_buffer: []u8, out_palette: ?[]u8, ) !void { try loadIndexedWithStride(reader, preloaded, out_buffer, 1, out_palette); } // this function is mostly useful as a helper to loadRGB and loadRGBA, which // use it in order to avoid having to allocate two buffers (one for indexed // and one for true color). pub fn loadIndexedWithStride( reader: anytype, preloaded: PreloadedInfo, out_buffer: []u8, out_buffer_stride: usize, out_palette: ?[]u8, ) !void { var input_buffer: [128]u8 = undefined; var input: []u8 = input_buffer[0..0]; if (out_buffer_stride < 1) { return error.PcxLoadFailed; } if (out_palette) |pal| { if (pal.len < 768) { return error.PcxLoadFailed; } } const width: usize = preloaded.width; const height: usize = preloaded.height; const datasize = width * height * out_buffer_stride; if (out_buffer.len < datasize) { return error.PcxLoadFailed; } // load image data (1 byte per pixel) var in: usize = 0; var out: usize = 0; var runlen: u8 = undefined; var y: u16 = 0; while (y < height) : (y += 1) { var x: u16 = 0; while (x < preloaded.bytes_per_line) { var databyte = blk: { if (in >= input.len) { const n = try reader.read(&input_buffer); if (n == 0) { return error.EndOfStream; } input = input_buffer[0..n]; in = 0; } defer in += 1; break :blk input[in]; }; if ((databyte & 0xc0) == 0xc0) { runlen = databyte & 0x3f; databyte = blk: { if (in >= input.len) { const n = try reader.read(&input_buffer); if (n == 0) { return error.EndOfStream; } input = input_buffer[0..n]; in = 0; } defer in += 1; break :blk input[in]; }; } else { runlen = 1; } while (runlen > 0) { runlen -= 1; if (x < width) { if (out >= datasize) { return error.PcxLoadFailed; } out_buffer[out] = databyte; out += out_buffer_stride; } x += 1; } } } if (out != datasize) { return error.PcxLoadFailed; } // load palette... this occupies the last 768 bytes of the file. as there // is no seeking, use a buffering scheme to recover the palette once we // actually hit the end of the file. // note: palette is supposed to be preceded by a 0x0C marker byte, but // i've dealt with images that didn't have it so i won't assume it's // there var page_bufs: [2][768]u8 = undefined; var pages: [2][]u8 = undefined; var which_page: u8 = 0; while (true) { var n: usize = 0; if (in < input.len) { // some left over buffered data from the image data loading (this // will only happen on the first iteration) n = input.len - in; std.mem.copy(u8, page_bufs[which_page][0..n], input[in..]); in = input.len; } n += try reader.read(page_bufs[which_page][n..]); pages[which_page] = page_bufs[which_page][0..n]; if (n < 768) { // reached EOF if (n == 0) { which_page ^= 1; } break; } which_page ^= 1; } if (pages[0].len + pages[1].len < 768) { return error.PcxLoadFailed; } // the palette will either be completely contained in the current page; // or else its first part will be in the opposite page, and the rest in // the current page const cur_page = pages[which_page]; const opp_page = pages[which_page ^ 1]; const cur_len = cur_page.len; const opp_len = 768 - cur_len; if (out_palette) |pal| { std.mem.copy(u8, pal[0..opp_len], opp_page[cur_len..768]); std.mem.copy(u8, pal[opp_len..768], cur_page); } } pub fn loadRGB( reader: anytype, preloaded: PreloadedInfo, out_buffer: []u8, ) !void { const num_pixels = @as(usize, preloaded.width) * @as(usize, preloaded.height); if (out_buffer.len < num_pixels * 3) { return error.PcxLoadFailed; } var palette: [768]u8 = undefined; try loadIndexedWithStride(reader, preloaded, out_buffer, 3, &palette); var i: usize = 0; while (i < num_pixels) : (i += 1) { const index: usize = out_buffer[i * 3 + 0]; out_buffer[i * 3 + 0] = palette[index * 3 + 0]; out_buffer[i * 3 + 1] = palette[index * 3 + 1]; out_buffer[i * 3 + 2] = palette[index * 3 + 2]; } } pub fn loadRGBA( reader: anytype, preloaded: PreloadedInfo, transparent_index: ?u8, out_buffer: []u8, ) !void { const num_pixels = @as(usize, preloaded.width) * @as(usize, preloaded.height); if (out_buffer.len < num_pixels * 4) { return error.PcxLoadFailed; } var palette: [768]u8 = undefined; try loadIndexedWithStride(reader, preloaded, out_buffer, 4, &palette); var i: usize = 0; while (i < num_pixels) : (i += 1) { const index: usize = out_buffer[i * 4 + 0]; out_buffer[i * 4 + 0] = palette[index * 3 + 0]; out_buffer[i * 4 + 1] = palette[index * 3 + 1]; out_buffer[i * 4 + 2] = palette[index * 3 + 2]; out_buffer[i * 4 + 3] = if ((transparent_index orelse ~index) == index) 0 else 255; } } pub fn saveIndexed( writer: anytype, width: usize, height: usize, pixels: []const u8, palette: []const u8, ) !void { if (width < 1 or width > 65535 or height < 1 or height > 65535 or pixels.len < width * height or palette.len != 768) { return error.PcxWriteFailed; } const xmax = @intCast(u16, width - 1); const ymax = @intCast(u16, height - 1); const bytes_per_line = @intCast(u16, width); const palette_type: u16 = 1; var header: [128]u8 = undefined; header[0] = 0x0a; // manufacturer header[1] = 5; // version header[2] = 1; // encoding header[3] = 8; // bits per pixel header[4] = 0; header[5] = 0; // xmin header[6] = 0; header[7] = 0; // ymin header[8] = @intCast(u8, xmax & 0xff); header[9] = @intCast(u8, xmax >> 8); header[10] = @intCast(u8, ymax & 0xff); header[11] = @intCast(u8, ymax >> 8); header[12] = 0; header[13] = 0; // hres header[14] = 0; header[15] = 0; // vres std.mem.set(u8, header[16..64], 0); header[64] = 0; // reserved header[65] = 1; // color planes header[66] = @intCast(u8, bytes_per_line & 0xff); header[67] = @intCast(u8, bytes_per_line >> 8); header[68] = @intCast(u8, palette_type & 0xff); header[69] = @intCast(u8, palette_type >> 8); std.mem.set(u8, header[70..128], 0); try writer.writeAll(&header); var y: usize = 0; while (y < height) : (y += 1) { const row = pixels[y * width .. (y + 1) * width]; var x: usize = 0; while (x < width) { const index = row[x]; // look ahead to see how many subsequent pixels on the same // row have the same value var max = x + 63; // run cannot be longer than 63 pixels if (max > width) { max = width; } const old_x = x; while (x < max and row[x] == index) { x += 1; } // encode run const runlen = @intCast(u8, x - old_x); if (runlen > 1 or (index & 0xc0) == 0xc0) { try writer.writeByte(runlen | 0xc0); } try writer.writeByte(index); } } try writer.writeByte(0x0c); try writer.writeAll(palette); }
pcx.zig
const std = @import("std"); const c = @import("c.zig"); const utility = @import("utility.zig"); const Query = struct { fn Select(comptime M: type, comptime DbHandle: type) type { const MInfo = @typeInfo(M); comptime var model_type: type = M; comptime var is_array = false; if (MInfo == .Pointer and MInfo.Pointer.size == .Slice) { model_type = MInfo.Pointer.child; is_array = true; } if (@typeInfo(model_type) != .Struct) { @compileError("M must be a struct"); } if (!@hasDecl(model_type, "Table")) { @compileError("M must have Table declaration"); } if (!@hasDecl(model_type, "Allocator")) { @compileError("M must have Allocator declaration for Select queries"); } comptime var result_type: type = if (is_array) []model_type else model_type; return struct { const Self = @This(); pub const Model = model_type; pub const Result = result_type; const PossibleError = OrmWhere.Error || error{ None, ModelMustBeStruct, TestError }; allocator: *std.mem.Allocator, db_handle: *DbHandle, orm_where: OrmWhere, err: PossibleError, pub fn init(allocator: *std.mem.Allocator, db: *DbHandle) Self { return Self{ .allocator = allocator, .db_handle = db, .orm_where = OrmWhere.init(), .err = PossibleError.None, }; } pub fn deinit(self: Self) void { self.orm_where.deinit(); } pub fn where(self: *Self, args: var) *Self { if (self.err != PossibleError.None) { // don't bother doing extra work if there's already an error return self; } self.orm_where.parseArguments(self.allocator, args) catch |err| { self.err = PossibleError.TestError; }; return self; } pub fn send(self: *Self) !?Result { // clean itself up so the user doesn't have to create a tmp variable just to clean it up defer self.deinit(); if (self.err != Self.PossibleError.None) { return self.err; } var query_result = try self.db_handle.sendSelectQuery(Self, self); defer query_result.deinit(); const send_type = if (is_array) std.ArrayList(Model) else Result; var result: send_type = undefined; if (is_array) { result = send_type.init(self.allocator); } var rows = query_result.numberOfRows(); var columns = query_result.numberOfColumns(); if (rows == 0) { return null; } var x: usize = 0; while (x < rows) : (x += 1) { var y: usize = 0; var tmp: Model = undefined; inner: while (y < columns) : (y += 1) { var opt_column_name = query_result.columnName(y); if (opt_column_name) |column_name| { var field_value = query_result.getValue(x, y); const ModelInfo = @typeInfo(Model); inline for (ModelInfo.Struct.fields) |field| { if (std.mem.eql(u8, field.name, column_name)) { const field_type = @TypeOf(@field(tmp, field.name)); const Info = @typeInfo(field_type); if ((Info == .Pointer and Info.Pointer.size == .Slice and Info.Pointer.child == u8) or (Info == .Array and Info.Array.child == u8)) { @field(tmp, field.name).len = 0; } } } if (field_value) |value| { inline for (ModelInfo.Struct.fields) |field| { if (std.mem.eql(u8, field.name, column_name)) { var column_type = query_result.getType(y); const field_type = @TypeOf(@field(tmp, field.name)); const Info = @typeInfo(field_type); const new_value: field_type = try column_type.castValue(field_type, value); if ((Info == .Pointer and Info.Pointer.size == .Slice and Info.Pointer.child == u8) or (Info == .Array and Info.Array.child == u8)) { var heap_value = try Model.Allocator.alloc(u8, new_value.len); std.mem.copy(u8, heap_value[0..], new_value[0..]); @field(tmp, field.name) = heap_value; } else { @field(tmp, field.name) = new_value; } // Uncommenting this will crash the compiler // continue :inner; } } } else { // if no value on this row or column then we're obviously out of columns and no point in continuing (if we would have without the break) break; } } else { // if no value on this row or column then we're obviously out of columns and no point in continuing (if we would have without the break) break; } } if (is_array) { try result.append(tmp); } else { result = tmp; } } if (is_array) { return result.toOwnedSlice(); } return result; } }; } fn Insert(comptime M: type, comptime DbHandle: type) type { if (@typeInfo(M) != .Struct) { @compileError("M must be a struct"); } if (!@hasDecl(M, "Table")) { @compileError("M must have Table declaration"); } return struct { const Self = @This(); pub const Model = M; pub const PossibleError = error{None}; db_handle: *DbHandle, value: M, pub fn init(db_handle: *DbHandle, value: M) Self { return Self{ .db_handle = db_handle, .value = value, }; } pub fn send(self: *Self) !void { var query_result = try self.db_handle.sendInsertQuery(Self, self); defer query_result.deinit(); } }; } fn Delete(comptime M: type, comptime DbHandle: type) type { if (@typeInfo(M) != .Struct) { @compileError("M must be a struct"); } if (!@hasDecl(M, "Table")) { @compileError("M must have Table declaration"); } return struct { const Self = @This(); pub const Model = M; pub const PossibleError = error{None}; db_handle: *DbHandle, value: M, pub fn init(db_handle: *DbHandle, value: M) Self { return Self{ .db_handle = db_handle, .value = value, }; } pub fn send(self: *Self) !void { var query_result = try self.db_handle.sendDeleteQuery(Self, self); defer query_result.deinit(); } }; } fn DeleteAll(comptime M: type, comptime DbHandle: type) type { if (@typeInfo(M) != .Struct) { @compileError("M must be a struct"); } if (!@hasDecl(M, "Table")) { @compileError("M must have Table declaration"); } return struct { const Self = @This(); pub const Model = M; pub const PossibleError = error{None}; db_handle: *DbHandle, pub fn init(db_handle: *DbHandle) Self { return Self{ .db_handle = db_handle, }; } pub fn send(self: *Self) !void { var query_result = try self.db_handle.sendDeleteAllQuery(Self); defer query_result.deinit(); } }; } }; pub fn Database(comptime D: type) type { return struct { const Self = @This(); pub const Driver = D; driver: Driver, allocator: *std.mem.Allocator, pub fn init(allocator: *std.mem.Allocator) Self { return Self{ .driver = Driver.init(allocator), .allocator = allocator, }; } pub fn deinit(self: Self) void {} /// Used to clean-up the result model given by a Select query pub fn deinitModel(self: Self, model: var) void { const ModelType = @TypeOf(model); const ModelInfo = @typeInfo(ModelType); if (ModelInfo == .Pointer and ModelInfo.Pointer.size == .Slice) { if (@typeInfo(ModelInfo.Pointer.child) != .Struct) { @compileError("Unknown Model type"); } for (model) |m| { const MInfo = @typeInfo(@TypeOf(m)); inline for (MInfo.Struct.fields) |field| { // only string types are allocated const Info = @typeInfo(field.field_type); if ((Info == .Pointer and Info.Pointer.size == .Slice and Info.Pointer.child == u8) or (Info == .Array and Info.Array.child == u8)) { if (@field(m, field.name).len > 0) { ModelInfo.Pointer.child.Allocator.free(@field(m, field.name)); } } } } self.allocator.free(model); return; } else if (ModelInfo != .Struct) { @compileError("Unknown Model type"); return; } inline for (ModelInfo.Struct.fields) |field| { // only string types are allocated const Info = @typeInfo(field.field_type); if ((Info == .Pointer and Info.Pointer.size == .Slice and Info.Pointer.child == u8) or (Info == .Array and Info.Array.child == u8)) { if (@field(model, field.name).len > 0) { ModelType.Allocator.free(@field(model, field.name)); } } } } pub fn connect(self: *Self, conn_str: []const u8) !void { try self.driver.connect(conn_str); } pub fn select(self: *Self, comptime T: type) Query.Select(T, Self) { return Query.Select(T, Self).init(self.allocator, self); } pub fn insert(self: *Self, comptime T: type, value: T) Query.Insert(T, Self) { return Query.Insert(T, Self).init(self, value); } pub fn delete(self: *Self, comptime T: type, value: T) Query.Delete(T, Self) { return Query.Delete(T, Self).init(self, value); } pub fn deleteAll(self: *Self, comptime T: type) Query.DeleteAll(T, Self) { return Query.DeleteAll(T, Self).init(self); } fn sendSelectQuery(self: Self, comptime SelectType: type, query: *SelectType) !Driver.Result { var sql = try self.driver.selectQueryToSql(SelectType, query); defer self.driver.free(sql); var db_result = try self.driver.exec(sql); return db_result; } fn sendInsertQuery(self: Self, comptime InsertQuery: type, query: *InsertQuery) !Driver.Result { var sql = try self.driver.insertQueryToSql(InsertQuery, query); defer self.driver.free(sql); var db_result = try self.driver.exec(sql); return db_result; } fn sendDeleteQuery(self: Self, comptime DeleteQuery: type, query: *DeleteQuery) !Driver.Result { var sql = try self.driver.deleteQueryToSql(DeleteQuery, query); defer self.driver.free(sql); var db_result = try self.driver.exec(sql); return db_result; } fn sendDeleteAllQuery(self: Self, comptime DeleteAllQuery: type) !Driver.Result { var sql = try self.driver.deleteAllQueryToSql(DeleteAllQuery); defer self.driver.free(sql); var db_result = try self.driver.exec(sql); return db_result; } }; } pub const PqDriver = struct { const Self = @This(); pub const Error = error{ ConnectionFailure, QueryFailure, NotConnected }; // These values come from running `select oid, typname from pg_type;` pub const ColumnType = enum(usize) { Unknown = 0, Bool = 16, Char = 18, Int8 = 20, Int2 = 21, Int4 = 23, Text = 25, Float4 = 700, Float8 = 701, Varchar = 1043, Date = 1082, Time = 1083, Timestamp = 1114, pub fn castValue(column_type: ColumnType, comptime T: type, str: []const u8) !T { const Info = @typeInfo(T); switch (column_type) { .Int8, .Int4, .Int2 => { if (Info == .Int or Info == .ComptimeInt) { return utility.strToNum(T, str) catch return error.TypesNotCompatible; } return error.TypesNotCompatible; }, .Float4, .Float8 => { // TODO need a function similar to strToNum but can understand the decimal point return error.NotImplemented; }, .Bool => { if (T == bool and str.len > 0) { return str[0] == 't'; } else { return error.TypesNotCompatible; } }, .Char, .Text, .Varchar => { // FIXME Zig compiler says this cannot be done at compile time // if (utility.isStringType(T)) { // return str; // } // Workaround if ((Info == .Pointer and Info.Pointer.size == .Slice and Info.Pointer.child == u8) or (Info == .Array and Info.Array.child == u8)) { return str; } else if (Info == .Optional) { const ChildInfo = @typeInfo(Info.Optional.child); if (ChildInfo == .Pointer and ChildInfo.Pointer.Size == .Slice and ChildInfo.Pointer.child == u8) { return str; } if (ChildInfo == .Array and ChildInfo.child == u8) { return str; } } return error.TypesNotCompatible; }, .Date => { return error.NotImplemented; }, .Time => { return error.NotImplemented; }, .Timestamp => { return error.NotImplemented; }, else => { return error.TypesNotCompatible; }, } unreachable; } }; pub const Result = struct { res: *c.PGresult, pub fn numberOfRows(self: Result) usize { return @intCast(usize, c.PQntuples(self.res)); } pub fn numberOfColumns(self: Result) usize { return @intCast(usize, c.PQnfields(self.res)); } pub fn columnName(self: Result, column_number: usize) ?[]const u8 { var name = @as(?[*:0]const u8, c.PQfname(self.res, @intCast(c_int, column_number))); if (name) |str| { return str[0..std.mem.len(str)]; } return null; } pub fn getValue(self: Result, row_number: usize, column_number: usize) ?[]const u8 { var value = @as(?[*:0]const u8, c.PQgetvalue(self.res, @intCast(c_int, row_number), @intCast(c_int, column_number))); if (value) |str| { return str[0..std.mem.len(str)]; } return null; } pub fn getType(self: Result, column_number: usize) PqDriver.ColumnType { var oid = @intCast(usize, c.PQftype(self.res, @intCast(c_int, column_number))); return std.meta.intToEnum(PqDriver.ColumnType, oid) catch return PqDriver.ColumnType.Unknown; } pub fn deinit(self: Result) void { c.PQclear(self.res); } }; allocator: *std.mem.Allocator, connected: bool, _conn: *c.PGconn, pub fn init(allocator: *std.mem.Allocator) Self { return Self{ .allocator = allocator, .connected = false, ._conn = undefined, }; } pub fn free(self: Self, val: var) void { self.allocator.free(val); } pub fn connect(self: *Self, url: []const u8) !void { var conn_info = try std.cstr.addNullByte(self.allocator, url); defer self.allocator.free(conn_info); if (c.PQconnectdb(conn_info)) |conn| { self._conn = conn; } if (@enumToInt(c.PQstatus(self._conn)) != c.CONNECTION_OK) { return Self.Error.ConnectionFailure; } self.connected = true; } pub fn finish(self: *Self) void { c.PQfinish(self._conn); } pub fn exec(self: Self, query: []const u8) !Result { if (!self.connected) { return Error.NotConnected; } var cstr_query = try std.cstr.addNullByte(self.allocator, query); defer self.allocator.free(cstr_query); var res = c.PQexec(self._conn, cstr_query); var response_code = @enumToInt(c.PQresultStatus(res)); if (response_code != c.PGRES_TUPLES_OK and response_code != c.PGRES_COMMAND_OK and response_code != c.PGRES_NONFATAL_ERROR) { var msg = @as([*:0]const u8, c.PQresultErrorMessage(res)); std.debug.warn("{}\n", .{msg}); c.PQclear(res); return Self.Error.QueryFailure; } if (res) |result| { return Result{ .res = result }; } else { return Self.Error.QueryFailure; } } pub fn selectQueryToSql(self: Self, comptime QueryType: type, query: *QueryType) ![]const u8 { var string_builder = std.ArrayList(u8).init(self.allocator); defer string_builder.deinit(); var out = string_builder.outStream(); try out.writeAll("select "); const ModelInfo = @typeInfo(QueryType.Model); inline for (ModelInfo.Struct.fields) |field, i| { try out.writeAll(field.name); if (i + 1 < ModelInfo.Struct.fields.len) { try out.writeAll(","); } } try out.print(" from {}", .{QueryType.Model.Table}); if (query.orm_where.arguments) |arguments| { try out.writeAll(" where "); var it = arguments.iterator(); var i: usize = 0; while (it.next()) |arg| : (i += 1) { switch (arg.value) { .String => |str| { try out.print("{}='{}'", .{ arg.key, str }); }, .Other => |other| { try out.print("{}={}", .{ arg.key, other }); }, } if (i + 1 < arguments.size) { try out.writeAll(" and "); } } } try out.writeAll(";"); return string_builder.toOwnedSlice(); } pub fn insertQueryToSql(self: Self, comptime QueryType: type, query: *QueryType) ![]const u8 { var string_builder = std.ArrayList(u8).init(self.allocator); defer string_builder.deinit(); var out = string_builder.outStream(); try out.print("insert into {} (", .{QueryType.Model.Table}); const ModelInfo = @typeInfo(QueryType.Model); inline for (ModelInfo.Struct.fields) |field, i| { try out.writeAll(field.name); if (i + 1 < ModelInfo.Struct.fields.len) { try out.writeAll(","); } } try out.writeAll(") values("); inline for (ModelInfo.Struct.fields) |field, i| { var field_value = @field(query.value, field.name); if (utility.isString(field_value)) |str| { try out.print("'{}'", .{str}); } else { try out.print("{}", .{field_value}); } if (i + 1 < ModelInfo.Struct.fields.len) { try out.writeAll(","); } } try out.writeAll(");"); return string_builder.toOwnedSlice(); } pub fn deleteQueryToSql(self: Self, comptime QueryType: type, query: *QueryType) ![]const u8 { var string_builder = std.ArrayList(u8).init(self.allocator); defer string_builder.deinit(); var out = string_builder.outStream(); try out.print("delete from {} ", .{QueryType.Model.Table}); const ModelInfo = @typeInfo(QueryType.Model); if (ModelInfo.Struct.fields.len > 0) { try out.writeAll("where "); inline for (ModelInfo.Struct.fields) |field, i| { var field_value = @field(query.value, field.name); try out.print("{}=", .{field.name}); if (utility.isString(field_value)) |str| { try out.print("'{}'", .{str}); } else { try out.print("{}", .{field_value}); } if (i + 1 < ModelInfo.Struct.fields.len) { try out.writeAll(" and "); } } } try out.writeAll(";"); return string_builder.toOwnedSlice(); } pub fn deleteAllQueryToSql(self: Self, comptime QueryType: type) ![]const u8 { var string_builder = std.ArrayList(u8).init(self.allocator); defer string_builder.deinit(); var out = string_builder.outStream(); try out.print("delete from {};", .{QueryType.Model.Table}); return string_builder.toOwnedSlice(); } }; test "" { const Foo = struct { bar: var, }; const foo = Foo{ .bar = 5 }; std.meta.refAllDecls(Foo); std.meta.refAllDecls(PqDriver); } test "pq" { var pq = PqDriver.init(std.testing.allocator); try pq.connect("postgres://testuser:testpassword@localhost:5432/testdb"); defer pq.finish(); _ = try pq.exec("delete from test_table"); _ = try pq.exec("insert into test_table (test_value) values('zig');"); var res = try pq.exec("select * from test_table"); var column_name = res.columnName(1).?; std.testing.expect(std.mem.eql(u8, column_name, "test_value")); } fn sanitize(value: []const u8, out: var) !void { // FIXME implement sanitize try out.writeAll(value); } const OrmWhere = struct { const Self = @This(); const Error = error{ArgsMustBeStruct}; const Argument = union(enum) { String: []const u8, Other: []const u8, }; arguments: ?std.hash_map.StringHashMap(Argument), container: ?std.ArrayList(u8), pub fn init() Self { return Self{ .arguments = null, .container = null, }; } pub fn deinit(self: Self) void { if (self.arguments) |args| { args.deinit(); } if (self.container) |container| { container.deinit(); } } pub fn parseArguments(self: *Self, allocator: *std.mem.Allocator, args: var) !void { self.arguments = std.hash_map.StringHashMap(Argument).init(allocator); self.container = std.ArrayList(u8).init(allocator); const ArgsInfo = @typeInfo(@TypeOf(args)); if (ArgsInfo != .Struct) { return Self.Error.ArgsMustBeStruct; } inline for (ArgsInfo.Struct.fields) |field| { var value = @field(args, field.name); const field_type = @typeInfo(@TypeOf(value)); if (utility.isString(value)) |str| { if (self.container) |*container| { var start = container.items.len; if (start > 0) { start -= 1; } try sanitize(str, container.outStream()); if (self.arguments) |*arguments| { _ = try arguments.put(field.name, Argument{ .String = container.items[start..] }); } } } else { if (self.container) |*container| { var start: usize = container.items.len; if (start > 0) { start -= 1; } try std.fmt.formatType(value, "", std.fmt.FormatOptions{}, container.outStream(), std.fmt.default_max_depth); if (self.arguments) |*arguments| { _ = try arguments.put(field.name, Argument{ .Other = container.items[start..] }); } } } } } }; test "orm" { const UserModel = struct { // required declaration used by the orm pub const Table = "test_table"; pub const Allocator = std.testing.allocator; test_value: []const u8, test_num: u32, test_bool: bool, }; const PqDatabase = Database(PqDriver); var db = PqDatabase.init(std.testing.allocator); try db.connect("postgres://testuser:testpassword@localhost:5432/testdb"); try db.deleteAll(UserModel).send(); var new_user = UserModel{ .test_value = "foo", .test_num = 42, .test_bool = true }; try db.insert(UserModel, new_user).send(); try db.insert(UserModel, new_user).send(); try db.insert(UserModel, new_user).send(); if (try db.select(UserModel).where(.{ .test_value = "foo" }).send()) |model| { defer db.deinitModel(model); std.testing.expect(std.mem.eql(u8, model.test_value, "foo")); std.testing.expect(model.test_num == 42); std.testing.expect(model.test_bool); } if (try db.select([]UserModel).send()) |models| { defer db.deinitModel(models); std.testing.expect(models.len == 3); for (models) |model| { std.testing.expect(std.mem.eql(u8, model.test_value, "foo")); std.testing.expect(model.test_num == 42); std.testing.expect(model.test_bool); } } if (try db.select(UserModel).where(.{ .test_value = "none" }).send()) |undefined_model| { defer db.deinitModel(undefined_model); } try db.delete(UserModel, new_user).send(); try db.deleteAll(UserModel).send(); }
src/database.zig
const std = @import("std"); const DynamicArray = @import("./dynamic_array.zig").DynamicArray; const Value = @import("./value.zig").Value; const Allocator = std.mem.Allocator; const expect = std.testing.expect; pub const OpCode = enum(u8) { const Self = @This(); op_ret, op_constant, op_nil, op_true, op_false, op_negate, op_not, op_equal, op_greater, op_less, op_add, op_sub, op_mul, op_div, op_print, op_pop, op_define_gloabl, op_get_global, op_set_global, pub fn toU8(self: Self) u8 { return @enumToInt(self); } pub fn num_operands(self: Self) usize { return switch (self) { .op_constant => 1, .op_define_gloabl => 1, .op_get_global => 1, .op_set_global => 1, else => 0, }; } }; pub const Chunk = struct { const Self = @This(); const BytesArray = DynamicArray(u8); const ValuesArray = DynamicArray(Value); const LinesArray = DynamicArray(usize); code: BytesArray, constants: ValuesArray, lines: LinesArray, pub fn init(allocator: *Allocator) Chunk { return Self{ .code = BytesArray.init(allocator), .constants = ValuesArray.init(allocator), .lines = LinesArray.init(allocator), }; } pub fn write(self: *Self, byte: u8, line: usize) void { self.code.appendItem(byte); self.lines.appendItem(line); } pub fn deinit(self: *Chunk) void { self.code.deinit(); self.constants.deinit(); self.lines.deinit(); } pub fn addConstant(self: *Self, value: Value) u16 { self.constants.appendItem(value); return @intCast(u16, self.constants.count - 1); } }; test "create a Chunk" { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer { const leaked = gpa.deinit(); if (leaked) expect(false) catch @panic("The list is leaking"); } var chunk = Chunk.init(&gpa.allocator); defer chunk.deinit(); chunk.write(OpCode.op_ret.toU8(), 1); try expect(chunk.code.items[0] == OpCode.op_ret.toU8()); chunk.write(OpCode.op_ret.toU8(), 1); chunk.write(OpCode.op_ret.toU8(), 1); chunk.write(OpCode.op_ret.toU8(), 1); chunk.write(OpCode.op_ret.toU8(), 1); chunk.write(OpCode.op_ret.toU8(), 1); try expect(chunk.code.items[4] == OpCode.op_ret.toU8()); chunk.deinit(); }
src/chunks.zig
const std = @import("std"); const zp = @import("zplay"); const SimpleRenderer = zp.graphics.@"3d".SimpleRenderer; const Mesh = zp.graphics.@"3d".Mesh; const Camera = zp.graphics.@"3d".Camera; const Material = zp.graphics.@"3d".Material; const Texture2D = zp.graphics.texture.Texture2D; const dig = zp.deps.dig; const alg = zp.deps.alg; const Vec3 = alg.Vec3; const Vec4 = alg.Vec4; var simple_renderer: SimpleRenderer = undefined; var wireframe_mode = true; var perspective_mode = true; var use_texture = false; var quad: Mesh = undefined; var cube1: Mesh = undefined; var cube2: Mesh = undefined; var sphere: Mesh = undefined; var cylinder: Mesh = undefined; var prim: Mesh = undefined; var cone: Mesh = undefined; var default_material: Material = undefined; var picture_material: Material = undefined; var camera = Camera.fromPositionAndTarget( Vec3.new(0, 0, 6), Vec3.zero(), null, ); fn init(ctx: *zp.Context) anyerror!void { std.log.info("game init", .{}); // init imgui try dig.init(ctx.window); // simple renderer simple_renderer = SimpleRenderer.init(); // generate meshes quad = try Mesh.genQuad(std.testing.allocator, 1, 1); cube1 = try Mesh.genCube(std.testing.allocator, 0.5, 0.5, 0.5); cube2 = try Mesh.genCube(std.testing.allocator, 0.5, 0.7, 2); sphere = try Mesh.genSphere(std.testing.allocator, 0.7, 36, 18); cylinder = try Mesh.genCylinder(std.testing.allocator, 1, 0.5, 0.5, 2, 36); prim = try Mesh.genCylinder(std.testing.allocator, 1, 0.3, 0.3, 1, 3); cone = try Mesh.genCylinder(std.testing.allocator, 1, 0.5, 0, 1, 36); // create picture_material default_material = Material.init(.{ .single_texture = Texture2D.fromPixelData( std.testing.allocator, &.{ 0, 255, 0, 255 }, 1, 1, .{}, ) catch unreachable, }); picture_material = Material.init(.{ .single_texture = Texture2D.fromFilePath( std.testing.allocator, "assets/wall.jpg", false, .{}, ) catch unreachable, }); var unit = default_material.allocTextureUnit(0); _ = picture_material.allocTextureUnit(unit); // enable depth test ctx.graphics.toggleCapability(.depth_test, true); } fn loop(ctx: *zp.Context) void { const S = struct { var frame: f32 = 0; var axis = Vec4.new(1, 1, 1, 0); var last_tick: ?f32 = null; }; S.frame += 1; while (ctx.pollEvent()) |e| { _ = dig.processEvent(e); switch (e) { .window_event => |we| { switch (we.data) { .resized => |size| { ctx.graphics.setViewport(0, 0, size.width, size.height); }, else => {}, } }, .keyboard_event => |key| { if (key.trigger_type == .up) { switch (key.scan_code) { .escape => ctx.kill(), .f1 => ctx.toggleFullscreeen(null), else => {}, } } }, .quit_event => ctx.kill(), else => {}, } } var width: u32 = undefined; var height: u32 = undefined; ctx.getWindowSize(&width, &height); // start drawing ctx.graphics.clear(true, true, false, [_]f32{ 0.2, 0.3, 0.3, 1.0 }); var projection: alg.Mat4 = undefined; if (perspective_mode) { projection = alg.Mat4.perspective( camera.zoom, @intToFloat(f32, width) / @intToFloat(f32, height), 0.1, 100, ); } else { projection = alg.Mat4.orthographic( -3, 3, -3, 3, 0, 100, ); } S.axis = alg.Mat4.fromRotation(1, Vec3.new(-1, 1, -1)).multByVec4(S.axis); const model = alg.Mat4.fromRotation( S.frame, Vec3.new(S.axis.x, S.axis.y, S.axis.z), ); var renderer = simple_renderer.renderer(); renderer.begin(); { renderer.renderMesh( quad, model.translate(Vec3.new(-2.0, 1.2, 0)), projection, camera, if (use_texture) picture_material else default_material, null, ) catch unreachable; renderer.renderMesh( cube1, model.translate(Vec3.new(-0.5, 1.2, 0)), projection, camera, if (use_texture) picture_material else default_material, null, ) catch unreachable; renderer.renderMesh( cube2, model.translate(Vec3.new(1.0, 1.2, 0)), projection, camera, if (use_texture) picture_material else default_material, null, ) catch unreachable; renderer.renderMesh( sphere, model.translate(Vec3.new(-2.2, -1.2, 0)), projection, camera, if (use_texture) picture_material else default_material, null, ) catch unreachable; renderer.renderMesh( cylinder, model.translate(Vec3.new(-0.4, -1.2, 0)), projection, camera, if (use_texture) picture_material else default_material, null, ) catch unreachable; renderer.renderMesh( prim, model.translate(Vec3.new(1.1, -1.2, 0)), projection, camera, if (use_texture) picture_material else default_material, null, ) catch unreachable; renderer.renderMesh( cone, model.translate(Vec3.new(2.3, -1.2, 0)), projection, camera, if (use_texture) picture_material else default_material, null, ) catch unreachable; } renderer.end(); // settings dig.beginFrame(); { dig.setNextWindowPos( .{ .x = @intToFloat(f32, width) - 10, .y = 50 }, .{ .cond = dig.c.ImGuiCond_Once, .pivot = .{ .x = 1, .y = 0 }, }, ); if (dig.begin( "settings", null, dig.c.ImGuiWindowFlags_NoResize | dig.c.ImGuiWindowFlags_AlwaysAutoResize, )) { _ = dig.checkbox("wireframe", &wireframe_mode); _ = dig.checkbox("perspective", &perspective_mode); _ = dig.checkbox("texture", &use_texture); ctx.graphics.setPolygonMode( if (wireframe_mode) .line else .fill, ); } dig.end(); } dig.endFrame(); } fn quit(ctx: *zp.Context) void { _ = ctx; std.log.info("game quit", .{}); } pub fn main() anyerror!void { try zp.run(.{ .initFn = init, .loopFn = loop, .quitFn = quit, .enable_highres_depth = false, }); }
examples/mesh_generation.zig
const std = @import("std"); const request = @import("request.zig"); const builtin = @import("builtin"); const testing = std.testing; pub const Update = struct { update_id: i64, chat_id: i64, text: []const u8, }; pub const Telezig = struct { allocator: std.mem.Allocator, token: [46]u8, pub fn init(allocator: std.mem.Allocator, token: []const u8) !Telezig { if (token.len != 46) return error.BadToken; var result = Telezig{.allocator = allocator, .token = undefined}; std.mem.copy(u8, result.token[0..], token); return result; } // pub fn deinit(self: *Telezig) void { // //For future deiniting // } pub fn getUpdates(self: Telezig) !Update { const host = "api.telegram.org"; const path = "/bot{s}" ++ "/getUpdates?offset=-1"; var buffer = [_]u8{undefined} ** (host.len + path.len + self.token.len); const formatted_path = try std.fmt.bufPrint(&buffer, path, .{self.token}); var response = try request.makeGetRequestAlloc(self.allocator, host, formatted_path); var parser = std.json.Parser.init(self.allocator, false); defer parser.deinit(); var tree = try parser.parse(response); defer tree.deinit(); var result = tree.root.Object.get("result").?.Array; if (result.items.len < 1) return error.NoUpdateMessages; var lastIndex = result.items.len - 1; var update_id = result.items[0].Object.get("update_id").?.Integer; var message = result.items[lastIndex].Object.get("message").?; var text = message.Object.get("text").?.String; defer self.allocator.free(text); var chat = message.Object.get("chat").?; var chat_id = chat.Object.get("id").?; return Update{ .update_id = update_id, .chat_id = chat_id.Integer, .text = try self.allocator.dupe(u8, text), }; } pub fn sendMessage(self: Telezig, update: Update) !void { const host = "api.telegram.org"; const path = "/bot{s}" ++ "/sendMessage"; var buffer = [_]u8{undefined} ** (host.len + path.len + self.token.len); const formatted_path = try std.fmt.bufPrint(&buffer, path, .{self.token}); const echo_complete = try std.fmt.allocPrint(self.allocator, "{{ \"chat_id\": {d}, \"text\": \"{s}\" }}", .{ update.chat_id, update.text }); defer self.allocator.free(echo_complete); var response = try request.makePostRequestAlloc(self.allocator, host, formatted_path, echo_complete, "Content-Type: application/json"); defer self.allocator.free(response); } }; // not related to library, for testing usage only fn getToken(token_path: []const u8, buffer: []u8) !void { const file = try std.fs.cwd().openFile(token_path, .{ .mode = .read_only }); defer file.close(); _ = try file.reader().read(buffer); } // requires token.txt file in working directory // checks for message 10 times with 1 second interval // replies to new messages with same text test "Echobot test" { // windows-only initialization if (builtin.os.tag == std.Target.Os.Tag.windows) _ = try std.os.windows.WSAStartup(2, 0); var allocator = std.testing.allocator; var token: [46]u8 = undefined; try getToken("token.txt", token[0..]); var bot = try Telezig.init(allocator, token[0..]); var update_id: i64 = std.math.minInt(i64); var i: usize = 0; while (i < 10) : (i += 1) { var update = try bot.getUpdates(); defer bot.allocator.free(update.text); var new_update_id = update.update_id; if (update_id == new_update_id) continue; update_id = new_update_id; try bot.sendMessage(update); std.time.sleep(1 * std.time.ns_per_s); } // windows-only cleanup if (builtin.os.tag == std.Target.Os.Tag.windows) try std.os.windows.WSACleanup(); }
src/main.zig
const builtin = @import("builtin"); const std = @import("std"); const json = std.json; const mem = std.mem; pub fn main() anyerror!void { var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); defer arena.deinit(); const allocator = &arena.allocator; const args = try std.process.argsAlloc(allocator); var parser: json.Parser = undefined; var dump = Dump.init(allocator); for (args[1..]) |arg| { parser = json.Parser.init(allocator, false); const json_text = try std.io.readFileAlloc(allocator, arg); const tree = try parser.parse(json_text); try dump.mergeJson(tree.root); } const stdout = try std.io.getStdOut(); try dump.render(&stdout.outStream().stream); } const Dump = struct { zig_id: ?[]const u8 = null, zig_version: ?[]const u8 = null, root_name: ?[]const u8 = null, targets: std.ArrayList([]const u8), files_list: std.ArrayList([]const u8), files_map: std.StringHashMap(usize), fn init(allocator: *mem.Allocator) Dump { return Dump{ .targets = std.ArrayList([]const u8).init(allocator), .files_list = std.ArrayList([]const u8).init(allocator), .files_map = std.StringHashMap(usize).init(allocator), }; } fn mergeJson(self: *Dump, root: json.Value) !void { const params = &root.Object.get("params").?.value.Object; const zig_id = params.get("zigId").?.value.String; const zig_version = params.get("zigVersion").?.value.String; const root_name = params.get("rootName").?.value.String; try mergeSameStrings(&self.zig_id, zig_id); try mergeSameStrings(&self.zig_version, zig_version); try mergeSameStrings(&self.root_name, root_name); const target = params.get("target").?.value.String; try self.targets.append(target); // Merge files const other_files = root.Object.get("files").?.value.Array.toSliceConst(); var other_file_to_mine = std.AutoHashMap(usize, usize).init(self.a()); for (other_files) |other_file, i| { const gop = try self.files_map.getOrPut(other_file.String); if (gop.found_existing) { try other_file_to_mine.putNoClobber(i, gop.kv.value); } else { gop.kv.value = self.files_list.len; try self.files_list.append(other_file.String); } } const other_ast_nodes = root.Object.get("astNodes").?.value.Array.toSliceConst(); var other_ast_node_to_mine = std.AutoHashMap(usize, usize).init(self.a()); } fn render(self: *Dump, stream: var) !void { var jw = json.WriteStream(@typeOf(stream).Child, 10).init(stream); try jw.beginObject(); try jw.objectField("typeKinds"); try jw.beginArray(); inline for (@typeInfo(builtin.TypeId).Enum.fields) |field| { try jw.arrayElem(); try jw.emitString(field.name); } try jw.endArray(); try jw.objectField("files"); try jw.beginArray(); for (self.files_list.toSliceConst()) |file| { try jw.arrayElem(); try jw.emitString(file); } try jw.endArray(); try jw.endObject(); } fn a(self: Dump) *mem.Allocator { return self.targets.allocator; } fn mergeSameStrings(opt_dest: *?[]const u8, src: []const u8) !void { if (opt_dest.*) |dest| { if (!mem.eql(u8, dest, src)) return error.MismatchedDumps; } else { opt_dest.* = src; } } };
tools/merge_anal_dumps.zig
const std = @import("std"); const root = @import("root"); const liu = @import("./lib.zig"); const builtin = @import("builtin"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; pub const Obj = enum(u32) { // These are kept up to date with src/wasm.ts jsundefined, jsnull, log, info, warn, err, success, U8Array, F32Array, _, }; const ext = struct { extern fn makeString(message: [*]const u8, length: usize) Obj; extern fn makeView(o: Obj, message: ?*const anyopaque, length: usize) Obj; extern fn makeArray() Obj; extern fn makeObj() Obj; extern fn arrayPush(arr: Obj, obj: Obj) void; extern fn objSet(obj: Obj, key: Obj, value: Obj) void; extern fn watermark() Obj; extern fn setWatermark(objIndex: Obj) void; extern fn objMapStringEncode(idx: Obj) usize; extern fn objMapLen(idx: Obj) usize; extern fn readObjMapBytes(idx: Obj, begin: [*]u8) void; extern fn postMessage(tagIdx: Obj, id: Obj) void; extern fn exit(objIndex: Obj) noreturn; }; pub const watermark = ext.watermark; pub const setWatermark = ext.setWatermark; pub const out = struct { pub const array = ext.makeArray; pub const obj = ext.makeObj; pub const arrayPush = ext.arrayPush; pub const objSet = ext.objSet; pub fn slice(data: anytype) Obj { const ptr: ?*const anyopaque = ptr: { switch (@typeInfo(@TypeOf(data))) { .Array => {}, .Pointer => |info| switch (info.size) { .One => switch (@typeInfo(info.child)) { .Array => break :ptr data, else => {}, }, .Many, .C => {}, .Slice => break :ptr data.ptr, }, else => {}, } @compileError("Need to pass a slice or array"); }; const len = data.len; const T = std.meta.Elem(@TypeOf(data)); return switch (T) { u8 => ext.makeView(.U8Array, ptr, len), f32 => ext.makeView(.F32Array, ptr, len), else => unreachable, }; } pub fn string(a: []const u8) Obj { return ext.makeString(a.ptr, a.len); } pub fn fmt(comptime format: []const u8, args: anytype) Obj { var _temp = liu.Temp.init(); const temp = _temp.allocator(); defer _temp.deinit(); const allocResult = std.fmt.allocPrint(temp, format, args); const data = allocResult catch @panic("failed to print"); return ext.makeString(data.ptr, data.len); } pub fn post(level: Obj, comptime format: []const u8, args: anytype) void { if (builtin.target.cpu.arch != .wasm32) { std.log.info(format, args); return; } const object = fmt(format, args); ext.postMessage(level, object); ext.setWatermark(object); } }; pub const in = struct { pub fn bytes(obj: Obj, alloc: Allocator) ![]u8 { if (builtin.target.cpu.arch != .wasm32) return &.{}; const len = ext.objMapLen(obj); const data = try alloc.alloc(u8, len); ext.readObjMapBytes(obj, data.ptr); return data; } pub fn string(obj: Obj, alloc: Allocator) ![]u8 { if (builtin.target.cpu.arch != .wasm32) return &.{}; const len = ext.objMapStringEncode(obj); const data = try alloc.alloc(u8, len); ext.readObjMapBytes(obj, data.ptr); return data; } }; pub fn exit(msg: []const u8) noreturn { const obj = ext.makeString(msg.ptr, msg.len); return ext.exit(obj); } const CommandBuffer = liu.RingBuffer(root.WasmCommand, 64); var initialized: bool = false; var cmd_bump: liu.Bump = undefined; var commands: CommandBuffer = undefined; const CmdAlloc = cmd_bump.allocator(); pub fn initIfNecessary() void { if (builtin.target.cpu.arch != .wasm32) { return; } if (!initialized) { cmd_bump = liu.Bump.init(4096, liu.Pages); commands = CommandBuffer.init(); initialized = true; } } pub const strip_debug_info = true; pub const have_error_return_tracing = false; pub fn log( comptime message_level: std.log.Level, comptime scope: @Type(.EnumLiteral), comptime fmt: []const u8, args: anytype, ) void { if (builtin.target.cpu.arch != .wasm32) { std.log.defaultLog(message_level, scope, fmt, args); return; } _ = scope; if (@enumToInt(message_level) > @enumToInt(std.log.level)) { return; } const level_obj: Obj = switch (message_level) { .debug => .info, .info => .info, .warn => .warn, .err => .err, }; out.post(level_obj, fmt ++ "\n", args); } pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn { @setCold(true); if (builtin.target.cpu.arch != .wasm32) { std.builtin.default_panic(msg, error_return_trace); } _ = error_return_trace; exit(msg); }
src/liu/wasm.zig
const std = @import("std"); const upaya = @import("upaya_cli.zig"); const Texture = @import("texture.zig").Texture; const Point = @import("math/point.zig").Point; /// Image is a CPU side array of color data with some helper methods that can be used to prep data /// before creating a Texture pub const Image = struct { w: usize = 0, h: usize = 0, pixels: []u32, pub fn init(width: usize, height: usize) Image { return .{ .w = width, .h = height, .pixels = upaya.mem.allocator.alloc(u32, width * height) catch unreachable }; } pub fn initFromFile(file: []const u8) Image { const image_contents = upaya.fs.read(upaya.mem.tmp_allocator, file) catch unreachable; var w: c_int = undefined; var h: c_int = undefined; var channels: c_int = undefined; const load_res = upaya.stb.stbi_load_from_memory(image_contents.ptr, @intCast(c_int, image_contents.len), &w, &h, &channels, 4); if (load_res == null) unreachable; defer upaya.stb.stbi_image_free(load_res); var img = init(@intCast(usize, w), @intCast(usize, h)); var pixels = std.mem.bytesAsSlice(u32, load_res[0..@intCast(usize, w * h * channels)]); for (pixels) |p, i| { img.pixels[i] = p; } return img; } pub fn initFromData(data: [*c]const u8, len: u64) Image { var w: c_int = undefined; var h: c_int = undefined; var channels: c_int = undefined; const load_res = upaya.stb.stbi_load_from_memory(data, @intCast(c_int, len), &w, &h, &channels, 4); if (load_res == null) { std.debug.print("null image!\n", .{}); unreachable; } defer upaya.stb.stbi_image_free(load_res); var img = init(@intCast(usize, w), @intCast(usize, h)); var pixels = std.mem.bytesAsSlice(u32, load_res[0..@intCast(usize, w * h * channels)]); for (pixels) |p, i| { img.pixels[i] = p; } return img; } pub fn deinit(self: Image) void { upaya.mem.allocator.free(self.pixels); } pub fn fillRect(self: *Image, rect: upaya.math.Rect, color: upaya.math.Color) void { const x = @intCast(usize, rect.x); var y = @intCast(usize, rect.y); const w = @intCast(usize, rect.width); var h = @intCast(usize, rect.height); var data = self.pixels[x + y * self.w ..]; while (h > 0) : (h -= 1) { var i: usize = 0; while (i < w) : (i += 1) { data[i] = color.value; } y += 1; data = self.pixels[x + y * self.w ..]; } } pub fn blit(self: *Image, src: Image, x: usize, y: usize) void { var yy = y; var h = src.h; var data = self.pixels[x + yy * self.w ..]; var src_y: usize = 0; while (h > 0) : (h -= 1) { data = self.pixels[x + yy * self.w ..]; const src_row = src.pixels[src_y * src.w .. (src_y * src.w) + src.w]; std.mem.copy(u32, data, src_row); // next row and move our slice to it as well src_y += 1; yy += 1; } } pub fn blitWithoutTransparent(self: *Image, src: Image, pos_x: i32, pos_y: i32) void { var x: usize = 0; var y: usize = 0; var src_x: usize = 0; var src_y: usize = 0; var src_w: usize = src.w; var src_h: usize = src.h; if (pos_x + @intCast(i32, src.w) < 0) return; if (pos_x > self.w) return; if (pos_y + @intCast(i32,src.h) < 0) return; if (pos_y > self.h) return; if (pos_x < 0) { x = 0; src_x = @intCast(usize, std.math.absInt(pos_x) catch unreachable); src_w = @intCast(usize, @intCast(i32, src_w) + pos_x); }else { x = @intCast(usize, pos_x); if (x + src_w > self.w) src_w = self.w - x; } if (pos_y < 0) { y = 0; src_h = @intCast(usize, @intCast(i32, src_h) + pos_y); src_y = @intCast(usize, std.math.absInt(pos_y) catch unreachable); }else { y = @intCast(usize, pos_y); if (y + src_h > self.h) src_h = self.h - y; } var h: usize = 0; while (h < src_h) : (h += 1) { const data = self.pixels[x + y * self.w ..]; const src_row = src.pixels[src_x + src_y * src.w .. src_x + (src_y * src.w) + src_w]; var xx: usize = 0; while (xx < src_w) : (xx += 1) { if (src_row[xx] != 0x00000000) data[xx] = src_row[xx]; } // next row and move our slice to it as well src_y += 1; y += 1; } } pub fn asTexture(self: Image, filter: Texture.Filter) Texture { return Texture.initWithColorData(self.pixels, @intCast(i32, self.w), @intCast(i32, self.h), filter, .clamp); } pub fn save(self: Image, file: []const u8) void { var c_file = std.cstr.addNullByte(upaya.mem.tmp_allocator, file) catch unreachable; var bytes = std.mem.sliceAsBytes(self.pixels); _ = upaya.stb.stbi_write_png(c_file.ptr, @intCast(c_int, self.w), @intCast(c_int, self.h), 4, bytes.ptr, @intCast(c_int, self.w * 4)); } /// returns true if the image was loaded successfully pub fn getTextureSize(file: []const u8, w: *c_int, h: *c_int) bool { const image_contents = upaya.fs.read(upaya.mem.tmp_allocator, file) catch unreachable; var comp: c_int = undefined; if (upaya.stb.stbi_info_from_memory(image_contents.ptr, @intCast(c_int, image_contents.len), w, h, &comp) == 1) { return true; } return false; } pub fn cropToPoints(self: *Image, tl: Point, br: Point) Point { var top = @intCast(usize, tl.y); var bottom = @intCast(usize, br.y); var left = @intCast(usize, tl.x); var right = @intCast(usize, br.x); var v_crop_image = Image.init(self.w, bottom - top); std.mem.copy(u32, v_crop_image.pixels, self.pixels[top * self.w .. bottom * self.w]); var crop_image = Image.init(right - left, bottom - top); var h: usize = crop_image.h; while (h > 0) : (h -= 1) { const row = v_crop_image.pixels[h * v_crop_image.w - v_crop_image.w .. h * v_crop_image.w]; const src = row[left..right]; const dst = crop_image.pixels[h * crop_image.w - crop_image.w .. h * crop_image.w]; std.mem.copy(u32, dst, src); } self.h = crop_image.h; self.w = crop_image.w; std.mem.copy(u32, self.pixels, crop_image.pixels); v_crop_image.deinit(); crop_image.deinit(); return .{ .x = @intCast(i32, left), .y = @intCast(i32, top) }; } pub fn crop(self: *Image) Point { var top: usize = 0; var bottom = self.h - 1; var left: usize = 0; var right = self.w - 1; top: { while (top < bottom) : (top += 1) { var row = self.pixels[top * self.w .. top * self.w + self.w]; if (containsColor(row)) { top -= 1; break :top; } } } bottom: { while (bottom > top) : (bottom -= 1) { var row = self.pixels[bottom * self.w - self.w .. bottom * self.w]; if (containsColor(row)) { break :bottom; } } } var v_crop_image = Image.init(self.w, bottom - top); std.mem.copy(u32, v_crop_image.pixels, self.pixels[top * self.w .. bottom * self.w]); left: { while (left < right) : (left += 1) { var y: usize = bottom; while (y > top) : (y -= 1) { if (self.pixels[left + y * self.w] & 0xFF000000 != 0) { left -= 1; break :left; } } } } right: { while (right > left) : (right -= 1) { var y: usize = bottom; while (y > top) : (y -= 1) { if (self.pixels[right + y * self.w] & 0xFF000000 != 0) { right += 1; break :right; } } } } var crop_image = Image.init(right - left, bottom - top); var h: usize = crop_image.h; while (h > 0) : (h -= 1) { const row = v_crop_image.pixels[h * v_crop_image.w - v_crop_image.w .. h * v_crop_image.w]; const src = row[left..right]; const dst = crop_image.pixels[h * crop_image.w - crop_image.w .. h * crop_image.w]; std.mem.copy(u32, dst, src); } self.h = crop_image.h; self.w = crop_image.w; std.mem.copy(u32, self.pixels, crop_image.pixels); v_crop_image.deinit(); crop_image.deinit(); return .{ .x = @intCast(i32, left), .y = @intCast(i32, top) }; } fn containsColor(pixels: []u32) bool { for (pixels) |p| { if (p & 0xFF000000 != 0) { return true; } } return false; } };
src/image.zig
const PixelFormat = @import("pixel_format.zig").PixelFormat; const color = @import("color.zig"); const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const Grayscale1 = color.Grayscale1; const Grayscale2 = color.Grayscale2; const Grayscale4 = color.Grayscale4; const Grayscale8 = color.Grayscale8; const Grayscale8Alpha = color.Grayscale8Alpha; const Grayscale16 = color.Grayscale16; const Grayscale16Alpha = color.Grayscale16Alpha; const Rgb24 = color.Rgb24; const Rgba32 = color.Rgba32; const Rgb565 = color.Rgb565; const Rgb555 = color.Rgb555; const Bgr24 = color.Bgr24; const Bgra32 = color.Bgra32; const Rgb48 = color.Rgb48; const Rgba64 = color.Rgba64; const Colorf32 = color.Colorf32; pub fn IndexedStorage(comptime T: type) type { return struct { palette: []Rgba32, indices: []T, pub const palette_size = 1 << @bitSizeOf(T); const Self = @This(); pub fn init(allocator: Allocator, pixel_count: usize) !Self { return Self{ .indices = try allocator.alloc(T, pixel_count), .palette = try allocator.alloc(Rgba32, palette_size), }; } pub fn deinit(self: Self, allocator: Allocator) void { allocator.free(self.palette); allocator.free(self.indices); } }; } pub const IndexedStorage1 = IndexedStorage(u1); pub const IndexedStorage2 = IndexedStorage(u2); pub const IndexedStorage4 = IndexedStorage(u4); pub const IndexedStorage8 = IndexedStorage(u8); pub const IndexedStorage16 = IndexedStorage(u16); pub const PixelStorage = union(PixelFormat) { index1: IndexedStorage1, index2: IndexedStorage2, index4: IndexedStorage4, index8: IndexedStorage8, index16: IndexedStorage16, grayscale1: []Grayscale1, grayscale2: []Grayscale2, grayscale4: []Grayscale4, grayscale8: []Grayscale8, grayscale8Alpha: []Grayscale8Alpha, grayscale16: []Grayscale16, grayscale16Alpha: []Grayscale16Alpha, rgb24: []Rgb24, rgba32: []Rgba32, rgb565: []Rgb565, rgb555: []Rgb555, bgr24: []Bgr24, bgra32: []Bgra32, rgb48: []Rgb48, rgba64: []Rgba64, float32: []Colorf32, const Self = @This(); pub fn init(allocator: Allocator, format: PixelFormat, pixel_count: usize) !Self { return switch (format) { .index1 => { return Self{ .index1 = try IndexedStorage(u1).init(allocator, pixel_count), }; }, .index2 => { return Self{ .index2 = try IndexedStorage(u2).init(allocator, pixel_count), }; }, .index4 => { return Self{ .index4 = try IndexedStorage(u4).init(allocator, pixel_count), }; }, .index8 => { return Self{ .index8 = try IndexedStorage(u8).init(allocator, pixel_count), }; }, .index16 => { return Self{ .index16 = try IndexedStorage(u16).init(allocator, pixel_count), }; }, .grayscale1 => { return Self{ .grayscale1 = try allocator.alloc(Grayscale1, pixel_count), }; }, .grayscale2 => { return Self{ .grayscale2 = try allocator.alloc(Grayscale2, pixel_count), }; }, .grayscale4 => { return Self{ .grayscale4 = try allocator.alloc(Grayscale4, pixel_count), }; }, .grayscale8 => { return Self{ .grayscale8 = try allocator.alloc(Grayscale8, pixel_count), }; }, .grayscale8Alpha => { return Self{ .grayscale8Alpha = try allocator.alloc(Grayscale8Alpha, pixel_count), }; }, .grayscale16 => { return Self{ .grayscale16 = try allocator.alloc(Grayscale16, pixel_count), }; }, .grayscale16Alpha => { return Self{ .grayscale16Alpha = try allocator.alloc(Grayscale16Alpha, pixel_count), }; }, .rgb24 => { return Self{ .rgb24 = try allocator.alloc(Rgb24, pixel_count), }; }, .rgba32 => { return Self{ .rgba32 = try allocator.alloc(Rgba32, pixel_count), }; }, .rgb565 => { return Self{ .rgb565 = try allocator.alloc(Rgb565, pixel_count), }; }, .rgb555 => { return Self{ .rgb555 = try allocator.alloc(Rgb555, pixel_count), }; }, .bgr24 => { return Self{ .bgr24 = try allocator.alloc(Bgr24, pixel_count), }; }, .bgra32 => { return Self{ .bgra32 = try allocator.alloc(Bgra32, pixel_count), }; }, .rgb48 => { return Self{ .rgb48 = try allocator.alloc(Rgb48, pixel_count), }; }, .rgba64 => { return Self{ .rgba64 = try allocator.alloc(Rgba64, pixel_count), }; }, .float32 => { return Self{ .float32 = try allocator.alloc(Colorf32, pixel_count), }; }, }; } pub fn deinit(self: Self, allocator: Allocator) void { switch (self) { .index1 => |data| data.deinit(allocator), .index2 => |data| data.deinit(allocator), .index4 => |data| data.deinit(allocator), .index8 => |data| data.deinit(allocator), .index16 => |data| data.deinit(allocator), .grayscale1 => |data| allocator.free(data), .grayscale2 => |data| allocator.free(data), .grayscale4 => |data| allocator.free(data), .grayscale8 => |data| allocator.free(data), .grayscale8Alpha => |data| allocator.free(data), .grayscale16 => |data| allocator.free(data), .grayscale16Alpha => |data| allocator.free(data), .rgb24 => |data| allocator.free(data), .rgba32 => |data| allocator.free(data), .rgb565 => |data| allocator.free(data), .rgb555 => |data| allocator.free(data), .bgr24 => |data| allocator.free(data), .bgra32 => |data| allocator.free(data), .rgb48 => |data| allocator.free(data), .rgba64 => |data| allocator.free(data), .float32 => |data| allocator.free(data), } } pub fn len(self: Self) usize { return switch (self) { .index1 => |data| data.indices.len, .index2 => |data| data.indices.len, .index4 => |data| data.indices.len, .index8 => |data| data.indices.len, .index16 => |data| data.indices.len, .grayscale1 => |data| data.len, .grayscale2 => |data| data.len, .grayscale4 => |data| data.len, .grayscale8 => |data| data.len, .grayscale8Alpha => |data| data.len, .grayscale16 => |data| data.len, .grayscale16Alpha => |data| data.len, .rgb24 => |data| data.len, .rgba32 => |data| data.len, .rgb565 => |data| data.len, .rgb555 => |data| data.len, .bgr24 => |data| data.len, .bgra32 => |data| data.len, .rgb48 => |data| data.len, .rgba64 => |data| data.len, .float32 => |data| data.len, }; } pub fn isIndexed(self: Self) bool { return switch (self) { .index1 => true, .index2 => true, .index4 => true, .index8 => true, .index16 => true, else => false, }; } pub fn getPallete(self: Self) ?[]Rgba32 { return switch (self) { .index1 => |data| data.palette, .index2 => |data| data.palette, .index4 => |data| data.palette, .index8 => |data| data.palette, .index16 => |data| data.palette, else => null, }; } pub fn pixelsAsBytes(self: Self) []u8 { return switch (self) { .index1 => |data| mem.sliceAsBytes(data.indices), .index2 => |data| mem.sliceAsBytes(data.indices), .index4 => |data| mem.sliceAsBytes(data.indices), .index8 => |data| mem.sliceAsBytes(data.indices), .index16 => |data| mem.sliceAsBytes(data.indices), .grayscale1 => |data| mem.sliceAsBytes(data), .grayscale2 => |data| mem.sliceAsBytes(data), .grayscale4 => |data| mem.sliceAsBytes(data), .grayscale8 => |data| mem.sliceAsBytes(data), .grayscale8Alpha => |data| mem.sliceAsBytes(data), .grayscale16 => |data| mem.sliceAsBytes(data), .grayscale16Alpha => |data| mem.sliceAsBytes(data), .rgb24 => |data| mem.sliceAsBytes(data), .rgba32 => |data| mem.sliceAsBytes(data), .rgb565 => |data| mem.sliceAsBytes(data), .rgb555 => |data| mem.sliceAsBytes(data), .bgr24 => |data| mem.sliceAsBytes(data), .bgra32 => |data| mem.sliceAsBytes(data), .rgb48 => |data| mem.sliceAsBytes(data), .rgba64 => |data| mem.sliceAsBytes(data), .float32 => |data| mem.sliceAsBytes(data), }; } }; pub const PixelStorageIterator = struct { pixels: *const PixelStorage = undefined, current_index: usize = 0, end: usize = 0, const Self = @This(); pub fn init(pixels: *const PixelStorage) Self { return Self{ .pixels = pixels, .end = pixels.len(), }; } pub fn initNull() Self { return Self{}; } pub fn next(self: *Self) ?Colorf32 { if (self.current_index >= self.end) { return null; } const result: ?Colorf32 = switch (self.pixels.*) { .index1 => |data| data.palette[data.indices[self.current_index]].toColorf32(), .index2 => |data| data.palette[data.indices[self.current_index]].toColorf32(), .index4 => |data| data.palette[data.indices[self.current_index]].toColorf32(), .index8 => |data| data.palette[data.indices[self.current_index]].toColorf32(), .index16 => |data| data.palette[data.indices[self.current_index]].toColorf32(), .grayscale1 => |data| data[self.current_index].toColorf32(), .grayscale2 => |data| data[self.current_index].toColorf32(), .grayscale4 => |data| data[self.current_index].toColorf32(), .grayscale8 => |data| data[self.current_index].toColorf32(), .grayscale8Alpha => |data| data[self.current_index].toColorf32(), .grayscale16 => |data| data[self.current_index].toColorf32(), .grayscale16Alpha => |data| data[self.current_index].toColorf32(), .rgb24 => |data| data[self.current_index].toColorf32(), .rgba32 => |data| data[self.current_index].toColorf32(), .rgb565 => |data| data[self.current_index].toColorf32(), .rgb555 => |data| data[self.current_index].toColorf32(), .bgr24 => |data| data[self.current_index].toColorf32(), .bgra32 => |data| data[self.current_index].toColorf32(), .rgb48 => |data| data[self.current_index].toColorf32(), .rgba64 => |data| data[self.current_index].toColorf32(), .float32 => |data| data[self.current_index], }; self.current_index += 1; return result; } }; // ********************* TESTS ********************* test "Indexed Pixel Storage" { var storage = try PixelStorage.init(std.testing.allocator, .index8, 64); defer storage.deinit(std.testing.allocator); try std.testing.expectEqual(@as(usize, 64), storage.len()); try std.testing.expect(storage.isIndexed()); std.mem.set(u8, storage.index8.indices, 0); storage.index8.palette[0] = Rgba32.fromValue(0); storage.index8.palette[1] = Rgba32.fromValue(0xffffffff); storage.index8.indices[0] = 1; var iterator = PixelStorageIterator.init(&storage); var cnt: u32 = 0; var expected = Colorf32.fromU32Rgba(0xffffffff); while (iterator.next()) |item| { try std.testing.expectEqual(expected, item); expected = Colorf32.fromU32Rgba(0); cnt += 1; } try std.testing.expectEqual(@as(u32, 64), cnt); } test "RGBA Pixel Storage" { var storage = try PixelStorage.init(std.testing.allocator, .rgba32, 64); defer storage.deinit(std.testing.allocator); try std.testing.expectEqual(@as(usize, 64), storage.len()); try std.testing.expect(!storage.isIndexed()); std.mem.set(Rgba32, storage.rgba32, Rgba32.fromValue(0)); var iterator = PixelStorageIterator.init(&storage); storage.rgba32.ptr[0] = Rgba32.fromValue(0xffffffff); var cnt: u32 = 0; var expected = Colorf32.fromU32Rgba(0xffffffff); while (iterator.next()) |item| { try std.testing.expectEqual(expected, item); expected = Colorf32.fromU32Rgba(0); cnt += 1; } try std.testing.expectEqual(@as(u32, 64), cnt); }
src/pixel_storage.zig
const Emulator = @import("emulator.zig").Emulator; const std = @import("std"); const sdl = @cImport({ @cInclude("SDL.h"); }); const key_mapping = [_] struct { sdl_key: u32, chip8_key: u8 } { .{.sdl_key = sdl.SDLK_1, .chip8_key = 0x1}, .{.sdl_key = sdl.SDLK_2, .chip8_key = 0x2}, .{.sdl_key = sdl.SDLK_3, .chip8_key = 0x3}, .{.sdl_key = sdl.SDLK_4, .chip8_key = 0xC}, .{.sdl_key = sdl.SDLK_q, .chip8_key = 0x4}, .{.sdl_key = sdl.SDLK_w, .chip8_key = 0x5}, .{.sdl_key = sdl.SDLK_e, .chip8_key = 0x6}, .{.sdl_key = sdl.SDLK_r, .chip8_key = 0xD}, .{.sdl_key = sdl.SDLK_a, .chip8_key = 0x7}, .{.sdl_key = sdl.SDLK_s, .chip8_key = 0x8}, .{.sdl_key = sdl.SDLK_d, .chip8_key = 0x9}, .{.sdl_key = sdl.SDLK_f, .chip8_key = 0xE}, .{.sdl_key = sdl.SDLK_z, .chip8_key = 0xA}, .{.sdl_key = sdl.SDLK_x, .chip8_key = 0x0}, .{.sdl_key = sdl.SDLK_c, .chip8_key = 0xB}, .{.sdl_key = sdl.SDLK_v, .chip8_key = 0xF}, }; pub fn main() anyerror!void { const allocator = std.heap.c_allocator; var emulator = Emulator.initialize(); try emulator.load_program("tetris.ch8", allocator); if (sdl.SDL_Init(sdl.SDL_INIT_EVERYTHING) != 0) { std.debug.print("SD_Init Error: {}\n", .{sdl.SDL_GetError()}); return; } defer sdl.SDL_Quit(); var window = sdl.SDL_CreateWindow("CHIP-8 Emulator", sdl.SDL_WINDOWPOS_CENTERED, sdl.SDL_WINDOWPOS_CENTERED, 1280, 720, sdl.SDL_WINDOW_SHOWN); if (window == null) { std.debug.print("SDL_CreateWidnow Error: {}\n", .{sdl.SDL_GetError()}); return; } defer sdl.SDL_DestroyWindow(window); var renderer = sdl.SDL_CreateRenderer(window, -1, sdl.SDL_RENDERER_ACCELERATED | sdl.SDL_RENDERER_PRESENTVSYNC); if(renderer == null) { std.debug.print("SDL_CreateRenderer Error: {}\n", .{sdl.SDL_GetError()}); return; } defer sdl.SDL_DestroyRenderer(renderer); var texture = sdl.SDL_CreateTexture(renderer, sdl.SDL_PIXELFORMAT_RGBA8888, sdl.SDL_TEXTUREACCESS_STREAMING, 64, 32); defer sdl.SDL_DestroyTexture(texture); const CYCLE_TIME_NS = 16 * 1000; var timer = try std.time.Timer.start(); main_loop: while (true) { timer.reset(); var event: sdl.SDL_Event = undefined; while(sdl.SDL_PollEvent(&event) != 0) { switch(event.type) { sdl.SDL_QUIT => break :main_loop, sdl.SDL_KEYDOWN, sdl.SDL_KEYUP => { const keycode = event.key.keysym.sym; for (key_mapping) |map| { if (map.sdl_key == keycode) { emulator.keys[map.chip8_key] = event.type == sdl.SDL_KEYDOWN; break; } } }, else => {} } } emulator.emulate_cycle(); if (emulator.draw_flag) { var pixels = [_]u32{0x000000FF} ** (64 * 32); for (emulator.gfx) | value, i| { if (value != 0) { pixels[i] = 0xFFFFFFFF; } } _ = sdl.SDL_UpdateTexture(texture, null, &pixels, @sizeOf(u32) * 64); emulator.draw_flag = false; } _ = sdl.SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); _ = sdl.SDL_RenderClear(renderer); _ = sdl.SDL_RenderCopy(renderer, texture, null, null); sdl.SDL_RenderPresent(renderer); const time_took = timer.read(); if (time_took < CYCLE_TIME_NS) { std.time.sleep(CYCLE_TIME_NS - time_took); } } }
src/main.zig
const std = @import("std"); const match = @import("path/filepath/match"); const FileInfo = @import("path/file_info").FileInfo; const mem = std.mem; const path = std.fs.path; const File = std.fs.File; const io = std.io; const warn = std.debug.warn; pub const Rule = struct { patterns: std.ArrayList(Pattern), // keep this copy so we can have access to the rules slices during the // lifetime of this Rule instance. buf: std.Buffer, const Pattern = struct { raw: []const u8, rule: []const u8, match: ?fn ([]const u8, []const u8, FileInfo) bool, must_dir: bool, negate: bool, fn init(raw: []const u8) Pattern { return Pattern{ .raw = raw, .rule = "", .match = simpleMatch, .must_dir = false, .negate = false, }; } }; fn simpleMatch(rule: []const u8, path_name: []const u8, fi: FileInfo) bool { const ok = match.match(rule, path_name) catch |err| { return false; }; return ok; } fn matchRoot(rule: []const u8, path_name: []const u8, fi: FileInfo) bool { const x = if (rule.len > 0 and rule[0] == '/') rule[1..] else rule; const ok = match.match(x, path_name) catch |err| { return false; }; return ok; } fn matchStructure(rule: []const u8, path_name: []const u8, fi: FileInfo) bool { return simpleMatch(rule, path_name, fi); } fn matchFallback(rule: []const u8, path_name: []const u8, fi: FileInfo) bool { const base = path.basename(path_name); const ok = match.match(rule, base) catch |err| { return false; }; return ok; } pub fn init(a: *mem.Allocator) !Rule { return Rule{ .patterns = std.ArrayList(Pattern).init(a), .buf = try std.Buffer.init(a, ""), }; } pub fn deinit(self: *Rule) void { self.patterns.deinit(); self.buf.deinit(); } fn parseRule(self: *Rule, rule_pattern: []const u8) !void { var rule = mem.trim(u8, rule_pattern, " "); if (rule.len == 0) { return; } if (rule[0] == '#') { return; } if (mem.indexOf(u8, rule, "**") != null) { return error.DoubleStarNotSupported; } _ = try match.match(rule, "abs"); var pattern = Pattern.init(rule); if (rule[0] == '!') { pattern.negate = true; pattern.rule = rule[1..]; } if (mem.endsWith(u8, pattern.rule, "/")) { pattern.must_dir = true; pattern.rule = mem.trimRight(u8, pattern.rule, "/"); } if (pattern.rule.len > 0 and pattern.rule[0] == '/') { pattern.match = matchRoot; } else if (mem.indexOf(u8, pattern.rule, "/") != null) { pattern.match = matchStructure; } else { pattern.match = matchFallback; } pattern.rule = rule; try self.patterns.append(pattern); } fn ignore(self: *Rule, path_name: []const u8, fi: FileInfo) bool { if (path_name.len == 0) { return false; } if (mem.eql(u8, path_name, ".") or mem.eql(u8, path_name, "./")) { return false; } for (self.patterns.toSlice()) |pattern| { if (pattern.match) |match_fn| { if (pattern.negate) { if (pattern.must_dir and !fi.is_dir) { return true; } if (!match_fn(pattern.rule, path_name, fi)) { return true; } continue; } if (pattern.must_dir and !fi.is_dir) { continue; } if (match_fn(pattern.rule, path_name, fi)) { return true; } } else { return false; } } return false; } }; pub fn parseStream(a: *mem.Allocator, stream: var) !Rule { var r = try Rule.init(a); var size: usize = 0; while (true) { size = r.buf.len(); const line = io.readLineFrom(stream, &r.buf) catch |err| { if (err == error.EndOfStream) { const end = r.buf.len(); if (end > size) { // last line in the stream try Rule.parseRule(&r, r.buf.toSlice()[size..]); } break; } return err; }; try Rule.parseRule(&r, line); } return r; } pub fn parseString(a: *mem.Allocator, src: []const u8) !Rule { var string_stream = io.SliceInStream.init(src); return parseStream(a, &string_stream.stream); }
src/ignore/ignore.zig
const builtin = @import("builtin"); const std = @import("std"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; const dlist = @import("dlist.zig"); const ListNode = dlist.ListNode; const params = @import("params.zig"); //===========================================================================// // The Superblock struct is kept packed so that we can rely on the alignments // of positions within its `blocks` array. This in turn obligates us to // declare SuperblockHeader packed as well. pub fn SuperblockHeader(comptime Heap: type) type { return packed struct { /// This field always stores params.superblock_magic_number. magic_number: u32, /// The block size for this superblock. block_size: u32, /// The number of blocks in this superblock. num_blocks: u32, /// The number of blocks in this superblock that aren't currently /// allocated. num_free_blocks: u32, /// The head of the freelist. first_free_block: ?[*]u8, /// Intrusive doubly-linked list node. list_node: ListNode, /// The heap that this superblock belongs to. heap: *Heap, }; } pub fn Superblock(comptime Heap: type) type { return packed struct { header: SuperblockHeader(Heap), blocks: [params.superblock_size - @sizeOf(SuperblockHeader(Heap))]u8, pub fn init(block_size: u32, heap: *Heap, child_allocator: *Allocator) !*Superblock(Heap) { assert(block_size >= params.min_block_size); assert(block_size <= params.max_block_size); // Allocate a new superblock from the child allocator: var superblocks = try child_allocator.alignedAlloc( Superblock(Heap), params.superblock_size, 1); var superblock = &superblocks[0]; assert(@ptrToInt(superblock) % params.superblock_size == 0); // Initialize bookkeeping header values: superblock.header.magic_number = params.superblock_magic_number; superblock.header.block_size = block_size; superblock.header.num_blocks = @divFloor(@intCast(u32, superblock.blocks.len), block_size); superblock.header.num_free_blocks = superblock.header.num_blocks; superblock.header.heap = heap; superblock.header.list_node.init(); // Initialize block free list: var next: ?[*]u8 = null; var offset: usize = superblock.blocks.len; while (offset >= block_size) { offset -= block_size; const ptr: [*]u8 = superblock.blocks[offset..].ptr; @ptrCast(*?[*]u8, @alignCast(params.min_block_size, ptr)).* = next; next = ptr; } superblock.header.first_free_block = next; return superblock; } pub fn deinit(self: *this, child_allocator: *Allocator) void { self.header.list_node.remove(); child_allocator.destroy(self); } /// Returns true if this superblock is totally full. pub fn isFull(self: *const this) bool { return self.header.num_free_blocks == 0; } /// Returns the index of the emptyness bucket that this superblock /// should be in -- 0 for totally full, `totally_empty_bucket_index` /// for totally empty, or somewhere in between. pub fn emptynessBucketIndex(self: *const this) usize { if (self.header.num_free_blocks == 0) { return 0; // totally full } return 1 + @divFloor(params.emptyness_denominator * self.header.num_free_blocks, self.header.num_blocks); } /// Removes this superblock from its current list and places it at the /// head of the new list. If `list` is already the superblock's /// current list, then the superblock is moved to the head of that /// list. pub fn transferTo(self: *this, list: *SuperblockList(Heap)) void { self.header.list_node.remove(); list.insert(self); } /// Allocates a slice of memory of the given size (which must be no /// more than this superblock's block size) from this superblock, or /// returns `OutOfMemory` if this superblock is totally full. pub fn alloc(self: *this, size: usize) Allocator.Error![]u8 { assert(size <= self.header.block_size); if (self.header.first_free_block) |ptr| { assert(self.header.num_free_blocks > 0); self.header.num_free_blocks -= 1; self.header.first_free_block = @ptrCast(*?[*]u8, @alignCast(params.min_block_size, ptr)).*; var new_mem = ptr[0..size]; // In debug mode, memset the allocated portion of the block to // 0xaa, and the unallocated portion of the block to 0xdd. if (builtin.mode == builtin.Mode.Debug) { std.mem.set(u8, new_mem, params.allocated_byte_memset); const start = @ptrToInt(new_mem.ptr) + new_mem.len; const len = self.header.block_size - new_mem.len; std.mem.set(u8, @intToPtr([*]u8, start)[0..len], params.deallocated_byte_memset); } return new_mem; } else { assert(self.header.num_free_blocks == 0); return Allocator.Error.OutOfMemory; } } /// Frees a slice of memory from this superblock. pub fn free(self: *this, old_mem: []u8) void { // Check that `old_mem` belongs to this superblock. assert(@ptrToInt(old_mem.ptr) & params.superblock_ptr_mask == @ptrToInt(self)); // Sanity-check size and alignment of `old_mem`. assert(old_mem.len <= self.header.block_size); assert(@ptrToInt(old_mem.ptr) % self.header.block_size == 0); // Sanity-check that this superblock isn't totally empty (or else // how could we be freeing from it?). assert(self.header.num_free_blocks < self.header.num_blocks); // TODO: In debug builds, walk freelist to check for double-free. // Free the block by adding it to the freelist. @ptrCast(*?[*]u8, @alignCast(params.min_block_size, old_mem.ptr)).* = self.header.first_free_block; self.header.first_free_block = old_mem.ptr; self.header.num_free_blocks += 1; // In debug mode, memset the rest of the free block to 0xdd. if (builtin.mode == builtin.Mode.Debug) { const ptr_size = @sizeOf(*?[*]u8); const start = @ptrToInt(old_mem.ptr) + ptr_size; const len = self.header.block_size - ptr_size; std.mem.set(u8, @intToPtr([*]u8, start)[0..len], params.deallocated_byte_memset); } } }; } pub fn SuperblockList(comptime Heap: type) type { return struct { node: ListNode, /// Initializes this list to empty. pub fn init(self: *this) void { self.node.init(); } /// Frees all superblocks in this list. fn deinit(self: *this, child_allocator: *Allocator) void { while (!self.isEmpty()) { const header = @fieldParentPtr(SuperblockHeader(Heap), "list_node", self.node.next); const superblock = @fieldParentPtr(Superblock(Heap), "header", header); superblock.deinit(child_allocator); } } /// Returns true if the list is empty. fn isEmpty(self: *const this) bool { return self.node.isEmpty(); } /// Returns the superblock at the head of the list, or null if the list /// is empty. fn head(self: *const this) ?*Superblock(Heap) { if (self.isEmpty()) { return null; } else { const header = @fieldParentPtr(SuperblockHeader(Heap), "list_node", self.node.next); assert(header.magic_number == params.superblock_magic_number); return @fieldParentPtr(Superblock(Heap), "header", header); } } fn insert(self: *this, superblock: *Superblock(Heap)) void { superblock.header.list_node.insertAfter(&self.node); } }; } //===========================================================================// test "Superblock struct size is correct" { comptime assert(@sizeOf(Superblock(@OpaqueType())) == params.superblock_size); } //===========================================================================//
src/ziegfried/sblock.zig
const std = @import("std"); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const game = @import("game.zig"); const @"u32_2" = game.u32_2; const @"u16_2" = game.u16_2; const event = @import("event.zig"); const test_seed: u64 = 0xC0FFEE42DEADBEEF; test "Critical path" { const extent = u32_2{ 5, 5 }; const mine_count: u32 = 2; const uncover_pos_0 = u16_2{ 2, 2 }; const uncover_pos_1 = u16_2{ 0, 1 }; const allocator: std.mem.Allocator = std.heap.page_allocator; var game_state = try game.create_game_state(allocator, extent, mine_count, test_seed); defer game.destroy_game_state(allocator, &game_state); game.uncover(&game_state, uncover_pos_0); try expectEqual(game_state.is_ended, false); try expectEqual(game.cell_at(&game_state, uncover_pos_0).is_covered, false); game.uncover(&game_state, uncover_pos_1); try expectEqual(game_state.is_ended, true); try expectEqual(game.cell_at(&game_state, uncover_pos_1).is_covered, false); } test "Toggle flag" { const extent = u32_2{ 5, 5 }; const mine_count: u32 = 2; const uncover_pos_0 = u16_2{ 2, 2 }; const uncover_pos_1 = u16_2{ 0, 1 }; const allocator: std.mem.Allocator = std.heap.page_allocator; var game_state = try game.create_game_state(allocator, extent, mine_count, test_seed); defer game.destroy_game_state(allocator, &game_state); game.uncover(&game_state, uncover_pos_0); try expectEqual(game.cell_at(&game_state, uncover_pos_0).is_covered, false); game.toggle_flag(&game_state, uncover_pos_1); game.uncover(&game_state, uncover_pos_1); try expectEqual(game.cell_at(&game_state, uncover_pos_1).is_covered, true); game.toggle_flag(&game_state, uncover_pos_1); game.uncover(&game_state, uncover_pos_1); try expectEqual(game.cell_at(&game_state, uncover_pos_1).is_covered, false); } test "Big uncover" { const extent = u32_2{ 100, 100 }; const mine_count: u32 = 1; const start_pos = u16_2{ 25, 25 }; const allocator: std.mem.Allocator = std.heap.page_allocator; var game_state = try game.create_game_state(allocator, extent, mine_count, test_seed); defer game.destroy_game_state(allocator, &game_state); game.uncover(&game_state, start_pos); try expect(game_state.event_history[0] == event.GameEventTag.discover_many); } test "Number uncover" { const extent = u32_2{ 5, 5 }; const mine_count: u32 = 3; const allocator: std.mem.Allocator = std.heap.page_allocator; var game_state = try game.create_game_state(allocator, extent, mine_count, test_seed); defer game.destroy_game_state(allocator, &game_state); game.uncover(&game_state, .{ 0, 0 }); game.toggle_flag(&game_state, .{ 0, 2 }); game.uncover(&game_state, .{ 1, 1 }); try expectEqual(game.cell_at(&game_state, .{ 2, 1 }).is_covered, false); try expectEqual(game.cell_at(&game_state, .{ 3, 1 }).is_covered, false); try expect(game_state.event_history[0] == event.GameEventTag.discover_many); try expect(game_state.event_history[1] == event.GameEventTag.discover_number); try expectEqual(game_state.is_ended, false); }
src/minesweeper/test.zig
const unicode = @import("./src/index.zig"); const utf8 = unicode.utf8; const warn = @import("std").debug.warn; test "ExampleRuneLen" { warn("\n{}\n", try utf8.runeLen('a')); warn("{}\n", try utf8.runeLen(0x754c)); // chinese character 0x754c 界 // Test 1/1 ExampleRuneLen... // 1 // 3 // OK } test "Example_is" { const mixed = "\t5Ὂg̀9! ℃ᾭG"; var iter = utf8.Iterator.init(mixed); var a = []u8{0} ** 5; warn("\n"); while (true) { const next = try iter.next(); if (next == null) { break; } const size = try utf8.encodeRune(a[0..], next.?.value); warn("For {}:\n", a[0..size]); if (unicode.isControl(next.?.value)) { warn("\t is control rune\n"); } if (unicode.isDigit(next.?.value)) { warn("\t is digit rune\n"); } if (unicode.isGraphic(next.?.value)) { warn("\t is graphic rune\n"); } if (unicode.isLetter(next.?.value)) { warn("\t is letter rune\n"); } if (unicode.isLower(next.?.value)) { warn("\t is lower case rune\n"); } if (unicode.isMark(next.?.value)) { warn("\t is mark rune\n"); } if (unicode.isNumber(next.?.value)) { warn("\t is number rune\n"); } if (unicode.isPrint(next.?.value)) { warn("\t is printable rune\n"); } if (unicode.isPunct(next.?.value)) { warn("\t is punct rune\n"); } if (unicode.isSpace(next.?.value)) { warn("\t is space rune\n"); } if (unicode.isSymbol(next.?.value)) { warn("\t is symbol rune\n"); } if (unicode.isTitle(next.?.value)) { warn("\t is title rune\n"); } if (unicode.isUpper(next.?.value)) { warn("\t is upper case rune\n"); } } // Test 2/2 Example_is... // For : // is control rune // is space rune // For 5: // is digit rune // is graphic rune // is number rune // is printable rune // For Ὂ: // is graphic rune // is letter rune // is printable rune // is upper case rune // For g: // is graphic rune // is letter rune // is lower case rune // is printable rune // For ̀: // is graphic rune // is mark rune // is printable rune // For 9: // is digit rune // is graphic rune // is number rune // is printable rune // For !: // is graphic rune // is printable rune // is punct rune // For : // is graphic rune // is printable rune // is space rune // For ℃: // is graphic rune // is printable rune // is symbol rune // For ᾭ: // is graphic rune // is letter rune // is printable rune // is title rune // For G: // is graphic rune // is letter rune // is printable rune // is upper case rune // OK }
examples.zig
const std = @import("std"); const os = std.os; const wayland = @import("wayland"); const wl = wayland.client.wl; const xdg = wayland.client.xdg; const wlr = wayland.client.zwlr; const Surface = @import("Surface.zig"); pub const Context = struct { running: bool, shm: ?*wl.Shm, compositor: ?*wl.Compositor, subcompositor: ?*wl.Subcompositor, layer_shell: ?*wlr.LayerShellV1, screencopy: ?*wlr.ScreencopyManagerV1, surfaces: std.ArrayList(Surface), active_surface: ?*Surface, }; pub fn main() !void { const display = try wl.Display.connect(null); const registry = try display.getRegistry(); var context = Context{ .running = true, .shm = null, .compositor = null, .layer_shell = null, .subcompositor = null, .screencopy = null, .surfaces = std.ArrayList(Surface).init(std.heap.c_allocator), .active_surface = null, }; registry.setListener(*Context, registryListener, &context); _ = try display.roundtrip(); for (context.surfaces.items) |*surface| { try surface.setup(); } _ = try display.roundtrip(); while (context.running) { _ = try display.dispatch(); } } fn registryListener(registry: *wl.Registry, event: wl.Registry.Event, context: *Context) void { switch (event) { .global => |global| { if (std.cstr.cmp(global.interface, wl.Compositor.getInterface().name) == 0) { context.compositor = registry.bind(global.name, wl.Compositor, 4) catch return; } else if (std.cstr.cmp(global.interface, wl.Subcompositor.getInterface().name) == 0) { context.subcompositor = registry.bind(global.name, wl.Subcompositor, 1) catch return; } else if (std.cstr.cmp(global.interface, wl.Shm.getInterface().name) == 0) { context.shm = registry.bind(global.name, wl.Shm, 1) catch return; } else if (std.cstr.cmp(global.interface, wlr.LayerShellV1.getInterface().name) == 0) { context.layer_shell = registry.bind(global.name, wlr.LayerShellV1, 2) catch return; } else if (std.cstr.cmp(global.interface, wlr.ScreencopyManagerV1.getInterface().name) == 0) { context.screencopy = registry.bind(global.name, wlr.ScreencopyManagerV1, 1) catch return; } else if (std.cstr.cmp(global.interface, wl.Output.getInterface().name) == 0) { const output = registry.bind(global.name, wl.Output, 3) catch return; context.surfaces.append(Surface.init(context, output)) catch return; } else if (std.cstr.cmp(global.interface, wl.Seat.getInterface().name) == 0) { const seat = registry.bind(global.name, wl.Seat, 1) catch return; seat.setListener(*Context, seatListener, context); } }, // TODO Check for removed output / seat .global_remove => {}, } } fn seatListener(seat: *wl.Seat, event: wl.Seat.Event, context: *Context) void { switch (event) { .capabilities => |data| { const pointer = seat.getPointer() catch return; pointer.setListener(*Context, pointerListener, context); }, .name => {}, } } fn pointerListener(pointer: *wl.Pointer, event: wl.Pointer.Event, context: *Context) void { switch (event) { .enter => |data| { pointer.setCursor(data.serial, null, 0, 0); for (context.surfaces.items) |*surface| { if (surface.surface == data.surface) { surface.handlePointerMotion(data.surface_x.toInt(), data.surface_y.toInt()); context.active_surface = surface; } } }, .leave => { if (context.active_surface) |surface| { surface.handlePointerLeft(); } context.active_surface = null; }, .motion => |data| { if (context.active_surface) |surface| { surface.handlePointerMotion(data.surface_x.toInt(), data.surface_y.toInt()); } }, .button => { context.running = false; if (context.active_surface) |surface| { std.debug.print("0x{X:0>2}{X:0>2}{X:0>2}\n", .{ surface.color.r, surface.color.g, surface.color.b }); } }, .axis => {}, .frame => {}, .axis_source => {}, .axis_stop => {}, .axis_discrete => {}, } }
src/main.zig
const imgui = @import("../../c.zig"); pub const c = @import("c.zig"); pub const ImNodesContext = c.ImNodesContext; pub const ImNodesEditorContext = c.ImNodesEditorContext; pub fn setImGuiContext(ctx: *imgui.ImGuiContext) void { return c.imnodes_SetImGuiContext(ctx); } pub fn createContext() ?*c.ImNodesContext { return c.imnodes_CreateContext(); } pub fn destroyContext(ctx: *c.ImNodesContext) void { return c.imnodes_DestroyContext(ctx); } pub fn getCurrentContext() ?*c.ImNodesContext { return c.imnodes_GetCurrentContext(); } pub fn setCurrentContext(ctx: *c.ImNodesContext) void { return c.imnodes_SetCurrentContext(ctx); } pub fn editorContextCreate() ?*c.ImNodesEditorContext { return c.imnodes_EditorContextCreate(); } pub fn editorContextFree(noname1: *c.ImNodesEditorContext) void { return c.imnodes_EditorContextFree(noname1); } pub fn editorContextSet(noname1: *c.ImNodesEditorContext) void { return c.imnodes_EditorContextSet(noname1); } pub fn editorContextGetPanning(pOut: [*c]imgui.ImVec2) void { return c.imnodes_EditorContextGetPanning(pOut); } pub fn editorContextResetPanning(pos: imgui.ImVec2) void { return c.imnodes_EditorContextResetPanning(pos); } pub fn editorContextMoveToNode(node_id: c_int) void { return c.imnodes_EditorContextMoveToNode(node_id); } pub fn getIO() [*c]c.ImNodesIO { return c.imnodes_GetIO(); } pub fn getStyle() [*c]c.ImNodesStyle { return c.imnodes_GetStyle(); } pub fn styleColorsDark() void { return c.imnodes_StyleColorsDark(); } pub fn styleColorsClassic() void { return c.imnodes_StyleColorsClassic(); } pub fn styleColorsLight() void { return c.imnodes_StyleColorsLight(); } pub fn beginNodeEditor() void { return c.imnodes_BeginNodeEditor(); } pub fn endNodeEditor() void { return c.imnodes_EndNodeEditor(); } pub fn miniMap(minimap_size_fraction: f32, location: c.ImNodesMiniMapLocation, node_hovering_callback: c.ImNodesMiniMapNodeHoveringCallback, node_hovering_callback_data: *anyopaque) void { return c.imnodes_MiniMap(minimap_size_fraction, location, node_hovering_callback, node_hovering_callback_data); } pub fn pushColorStyle(item: c.ImNodesCol, color: c_uint) void { return c.imnodes_PushColorStyle(item, color); } pub fn popColorStyle() void { return c.imnodes_PopColorStyle(); } pub fn pushStyleVar(style_item: c.ImNodesStyleVar, value: f32) void { return c.imnodes_PushStyleVar(style_item, value); } pub fn popStyleVar() void { return c.imnodes_PopStyleVar(); } pub fn beginNode(id: c_int) void { return c.imnodes_BeginNode(id); } pub fn endNode() void { return c.imnodes_EndNode(); } pub fn getNodeDimensions(pOut: [*c]imgui.ImVec2, id: c_int) void { return c.imnodes_GetNodeDimensions(pOut, id); } pub fn beginNodeTitleBar() void { return c.imnodes_BeginNodeTitleBar(); } pub fn endNodeTitleBar() void { return c.imnodes_EndNodeTitleBar(); } pub fn beginInputAttribute(id: c_int, shape: c.ImNodesPinShape) void { return c.imnodes_BeginInputAttribute(id, shape); } pub fn endInputAttribute() void { return c.imnodes_EndInputAttribute(); } pub fn beginOutputAttribute(id: c_int, shape: c.ImNodesPinShape) void { return c.imnodes_BeginOutputAttribute(id, shape); } pub fn endOutputAttribute() void { return c.imnodes_EndOutputAttribute(); } pub fn beginStaticAttribute(id: c_int) void { return c.imnodes_BeginStaticAttribute(id); } pub fn endStaticAttribute() void { return c.imnodes_EndStaticAttribute(); } pub fn pushAttributeFlag(flag: c.ImNodesAttributeFlags) void { return c.imnodes_PushAttributeFlag(flag); } pub fn popAttributeFlag() void { return c.imnodes_PopAttributeFlag(); } pub fn link(id: c_int, start_attribute_id: c_int, end_attribute_id: c_int) void { return c.imnodes_Link(id, start_attribute_id, end_attribute_id); } pub fn setNodeDraggable(node_id: c_int, draggable: bool) void { return c.imnodes_SetNodeDraggable(node_id, draggable); } pub fn setNodeScreenSpacePos(node_id: c_int, screen_space_pos: imgui.ImVec2) void { return c.imnodes_SetNodeScreenSpacePos(node_id, screen_space_pos); } pub fn setNodeEditorSpacePos(node_id: c_int, editor_space_pos: imgui.ImVec2) void { return c.imnodes_SetNodeEditorSpacePos(node_id, editor_space_pos); } pub fn setNodeGridSpacePos(node_id: c_int, grid_pos: imgui.ImVec2) void { return c.imnodes_SetNodeGridSpacePos(node_id, grid_pos); } pub fn getNodeScreenSpacePos(pOut: [*c]imgui.ImVec2, node_id: c_int) void { return c.imnodes_GetNodeScreenSpacePos(pOut, node_id); } pub fn getNodeEditorSpacePos(pOut: [*c]imgui.ImVec2, node_id: c_int) void { return c.imnodes_GetNodeEditorSpacePos(pOut, node_id); } pub fn getNodeGridSpacePos(pOut: [*c]imgui.ImVec2, node_id: c_int) void { return c.imnodes_GetNodeGridSpacePos(pOut, node_id); } pub fn isEditorHovered() bool { return c.imnodes_IsEditorHovered(); } pub fn isNodeHovered(node_id: [*c]c_int) bool { return c.imnodes_IsNodeHovered(node_id); } pub fn isLinkHovered(link_id: [*c]c_int) bool { return c.imnodes_IsLinkHovered(link_id); } pub fn isPinHovered(attribute_id: [*c]c_int) bool { return c.imnodes_IsPinHovered(attribute_id); } pub fn numSelectedNodes() c_int { return c.imnodes_NumSelectedNodes(); } pub fn numSelectedLinks() c_int { return c.imnodes_NumSelectedLinks(); } pub fn getSelectedNodes(node_ids: [*c]c_int) void { return c.imnodes_GetSelectedNodes(node_ids); } pub fn getSelectedLinks(link_ids: [*c]c_int) void { return c.imnodes_GetSelectedLinks(link_ids); } pub fn clearNodeSelection_Nil() void { return c.imnodes_ClearNodeSelection_Nil(); } pub fn clearLinkSelection_Nil() void { return c.imnodes_ClearLinkSelection_Nil(); } pub fn selectNode(node_id: c_int) void { return c.imnodes_SelectNode(node_id); } pub fn clearNodeSelection_Int(node_id: c_int) void { return c.imnodes_ClearNodeSelection_Int(node_id); } pub fn isNodeSelected(node_id: c_int) bool { return c.imnodes_IsNodeSelected(node_id); } pub fn selectLink(link_id: c_int) void { return c.imnodes_SelectLink(link_id); } pub fn clearLinkSelection_Int(link_id: c_int) void { return c.imnodes_ClearLinkSelection_Int(link_id); } pub fn isLinkSelected(link_id: c_int) bool { return c.imnodes_IsLinkSelected(link_id); } pub fn isAttributeActive() bool { return c.imnodes_IsAttributeActive(); } pub fn isAnyAttributeActive(attribute_id: [*c]c_int) bool { return c.imnodes_IsAnyAttributeActive(attribute_id); } pub fn isLinkStarted(started_at_attribute_id: [*c]c_int) bool { return c.imnodes_IsLinkStarted(started_at_attribute_id); } pub fn isLinkDropped(started_at_attribute_id: [*c]c_int, including_detached_links: bool) bool { return c.imnodes_IsLinkDropped(started_at_attribute_id, including_detached_links); } pub fn isLinkCreated_BoolPtr(started_at_attribute_id: [*c]c_int, ended_at_attribute_id: [*c]c_int, created_from_snap: [*c]bool) bool { return c.imnodes_IsLinkCreated_BoolPtr(started_at_attribute_id, ended_at_attribute_id, created_from_snap); } pub fn isLinkCreated_IntPtr(started_at_node_id: [*c]c_int, started_at_attribute_id: [*c]c_int, ended_at_node_id: [*c]c_int, ended_at_attribute_id: [*c]c_int, created_from_snap: [*c]bool) bool { return c.imnodes_IsLinkCreated_IntPtr(started_at_node_id, started_at_attribute_id, ended_at_node_id, ended_at_attribute_id, created_from_snap); } pub fn isLinkDestroyed(link_id: *c_int) bool { return c.imnodes_IsLinkDestroyed(link_id); } pub fn saveCurrentEditorStateToIniString(data_size: *usize) [*c]const u8 { return c.imnodes_SaveCurrentEditorStateToIniString(data_size); } pub fn saveEditorStateToIniString(editor: *const c.ImNodesEditorContext, data_size: *usize) [*c]const u8 { return c.imnodes_SaveEditorStateToIniString(editor, data_size); } pub fn loadCurrentEditorStateFromIniString(data: []u8) void { return c.imnodes_LoadCurrentEditorStateFromIniString(data.ptr, data.len); } pub fn loadEditorStateFromIniString(editor: *c.ImNodesEditorContext, data: []const u8) void { return c.imnodes_LoadEditorStateFromIniString(editor, data.ptr, data.len); } pub fn saveCurrentEditorStateToIniFile(file_name: [:0]const u8) void { return c.imnodes_SaveCurrentEditorStateToIniFile(file_name); } pub fn saveEditorStateToIniFile(editor: *const c.ImNodesEditorContext, file_name: [:0]const u8) void { return c.imnodes_SaveEditorStateToIniFile(editor, file_name); } pub fn loadCurrentEditorStateFromIniFile(file_name: [:0]const u8) void { return c.imnodes_LoadCurrentEditorStateFromIniFile(file_name); } pub fn loadEditorStateFromIniFile(editor: *c.ImNodesEditorContext, file_name: [:0]const u8) void { return c.imnodes_LoadEditorStateFromIniFile(editor, file_name); }
src/deps/imgui/ext/imnodes/imnodes.zig
const std = @import("std"); const builtin = @import("builtin"); const warn = std.debug.print; const Allocator = std.mem.Allocator; const thread = @import("../thread.zig"); const config = @import("../config.zig"); const c = @cImport({ @cInclude("stdio.h"); @cInclude("ui.h"); }); const GUIError = error{ Init, Setup }; var columnbox: *c.uiBox = undefined; pub const Column = struct { columnbox: [*c]c.uiControl, // config_window: [*c]c.GtkWidget, main: *config.ColumnInfo, }; var myActor: *thread.Actor = undefined; pub fn libname() []const u8 { return "libui"; } pub fn init(alloca: *Allocator, set: *config.Settings) !void { var tf = usize(1); if (tf != 1) return GUIError.Init; } pub fn gui_setup(actor: *thread.Actor) !void { myActor = actor; var uiInitOptions = c.uiInitOptions{ .Size = 0 }; var err = c.uiInit(&uiInitOptions); if (err == 0) { build(); } else { warn("libui init failed {}\n", err); return GUIError.Init; } } fn build() void { var window = c.uiNewWindow("Zootdeck", 320, 240, 0); c.uiWindowSetMargined(window, 1); const f: ?fn (*c.uiWindow, *anyopaque) callconv(.C) c_int = onClosing; c.uiWindowOnClosing(window, f, null); var hbox = c.uiNewHorizontalBox(); c.uiWindowSetChild(window, @ptrCast(*c.uiControl, @alignCast(8, hbox))); //columnbox = @ptrCast(*c.uiControl, @alignCast(8, hbox)); if (hbox) |hb| { columnbox = hb; } var controls_vbox = c.uiNewVerticalBox(); c.uiBoxAppend(hbox, @ptrCast(*c.uiControl, @alignCast(8, controls_vbox)), 0); var addButton = c.uiNewButton("+"); c.uiBoxAppend(controls_vbox, @ptrCast(*c.uiControl, @alignCast(8, addButton)), 0); c.uiControlShow(@ptrCast(*c.uiControl, @alignCast(8, window))); } pub fn mainloop() void { c.uiMain(); } pub fn gui_end() void {} export fn onClosing(w: *c.uiWindow, data: *anyopaque) c_int { warn("ui quitting\n"); c.uiQuit(); return 1; } pub fn schedule(funcMaybe: ?fn (*anyopaque) callconv(.C) c_int, param: *anyopaque) void { if (funcMaybe) |func| { warn("schedule FUNC {}\n", func); _ = func(@ptrCast(*anyopaque, &"w")); } } pub fn show_main_schedule(in: *anyopaque) callconv(.C) c_int { return 0; } pub fn add_column_schedule(in: *anyopaque) callconv(.C) c_int { warn("libui add column\n"); var column_vbox = c.uiNewVerticalBox(); // crashes here var url_label = c.uiNewLabel("site.xyz"); c.uiBoxAppend(column_vbox, @ptrCast(*c.uiControl, @alignCast(8, url_label)), 0); c.uiBoxAppend(columnbox, @ptrCast(*c.uiControl, @alignCast(8, column_vbox)), 0); return 0; } pub fn column_remove_schedule(in: *anyopaque) callconv(.C) c_int { return 0; } pub fn column_config_oauth_url_schedule(in: *anyopaque) callconv(.C) c_int { return 0; } pub fn update_column_config_oauth_finalize_schedule(in: *anyopaque) callconv(.C) c_int { return 0; } pub fn update_column_ui_schedule(in: *anyopaque) callconv(.C) c_int { return 0; } pub fn update_column_netstatus_schedule(in: *anyopaque) callconv(.C) c_int { return 0; } pub fn update_column_toots_schedule(in: *anyopaque) callconv(.C) c_int { return 0; }
src/gui/libui.zig
const std = @import("std"); const use_test_input = false; const filename = if (use_test_input) "day-9_test-input" else "day-9_real-input"; const line_length = if (use_test_input) 10 else 100; const line_count = if (use_test_input) 5 else 100; pub fn main() !void { std.debug.print("--- Day 9 ---\n", .{}); var file = try std.fs.cwd().openFile(filename, .{}); defer file.close(); var buffer: [1024 * 1024]u8 = undefined; var map: [line_length * line_count]u4 = undefined; { var line_i: usize = 0; while (line_i < line_count):(line_i += 1) { const line = try file.reader().readUntilDelimiter(buffer[0..], '\n'); for (line) |char, char_i| { const map_i = line_i * line_length + char_i; map[map_i] = parseInt(char); } } } var buffer_allocator = std.heap.FixedBufferAllocator.init(buffer[0..]); var low_points = std.ArrayList(usize).init(buffer_allocator.allocator()); { var y: usize = 0; while (y < line_count):(y += 1) { var x: usize = 0; while (x < line_length):(x += 1) { if (x > 0) { if (map[getIndex(x - 1, y)] <= map[getIndex(x, y)]) continue; } if (x < line_length - 1) { if (map[getIndex(x + 1, y)] <= map[getIndex(x, y)]) continue; } if (y > 0) { if (map[getIndex(x, y - 1)] <= map[getIndex(x, y)]) continue; } if (y < line_count - 1) { if (map[getIndex(x, y + 1)] <= map[getIndex(x, y)]) continue; } try low_points.append(getIndex(x, y)); } } } var basin_sizes = [_]u32 {0} ** 3; { for (low_points.items) |low_point_index| { var size: u32 = 1; var visited = std.ArrayList(usize).init(buffer_allocator.allocator()); var frontier = std.ArrayList(usize).init(buffer_allocator.allocator()); const low_point_coords = getCoords(low_point_index); if (low_point_coords.x > 0) { try frontier.append(low_point_index - 1); } if (low_point_coords.x < line_length - 1) { try frontier.append(low_point_index + 1); } if (low_point_coords.y > 0) { try frontier.append(low_point_index - line_length); } if (low_point_coords.y < line_count - 1) { try frontier.append(low_point_index + line_length); } while (frontier.items.len != 0) { const index = frontier.pop(); if (index == low_point_index) continue; if (map[index] == 9) continue; if (contains(visited.items, index)) continue; try visited.append(index); size += 1; const coords = getCoords(index); if (coords.x > 0) { try frontier.append(index - 1); } if (coords.x < line_length - 1) { try frontier.append(index + 1); } if (coords.y > 0) { try frontier.append(index - line_length); } if (coords.y < line_count - 1) { try frontier.append(index + line_length); } } var smallest_basin_index: usize = 0; var smallest_basin_size: u32 = 9999; for (basin_sizes) |b_size, i| { if (b_size < smallest_basin_size) { smallest_basin_index = i; smallest_basin_size = b_size; } } if (smallest_basin_size < size) { basin_sizes[smallest_basin_index] = size; } } } var basin_product: u32 = 1; std.debug.print("largest basins are ", .{}); for (basin_sizes) |b_size| { std.debug.print("{} ", .{ b_size }); basin_product *= b_size; } std.debug.print("\n", .{}); std.debug.print("the product is {}\n", .{ basin_product }); } fn contains(haystack: []usize, needle: usize) bool { for (haystack) |item| { if (item == needle) return true; } return false; } fn getCoords(index: usize) struct { x: usize, y: usize } { return .{ .x = index % line_length, .y = index / line_length, }; } fn getIndex(x: usize, y: usize) usize { return y * line_length + x; } fn parseInt(char: u8) u4 { return @intCast(u4, char - '0'); }
day-9.zig
const std = @import("std"); const builtin = @import("builtin"); const log = std.log; const mem = std.mem; pub usingnamespace std.c; pub usingnamespace mach_task; const mach_task = if (builtin.target.isDarwin()) struct { pub const MachError = error{ /// Not enough permissions held to perform the requested kernel /// call. PermissionDenied, /// Kernel returned an unhandled and unexpected error code. /// This is a catch-all for any yet unobserved kernel response /// to some Mach message. Unexpected, }; pub const MachTask = struct { port: std.c.mach_port_name_t, pub fn isValid(self: MachTask) bool { return self.port != 0; } pub fn getCurrProtection(task: MachTask, address: u64, len: usize) MachError!std.c.vm_prot_t { var base_addr = address; var base_len: std.c.mach_vm_size_t = if (len == 1) 2 else len; var objname: std.c.mach_port_t = undefined; var info: std.c.vm_region_submap_info_64 = undefined; var count: std.c.mach_msg_type_number_t = std.c.VM_REGION_SUBMAP_SHORT_INFO_COUNT_64; switch (std.c.getKernError(std.c.mach_vm_region( task.port, &base_addr, &base_len, std.c.VM_REGION_BASIC_INFO_64, @ptrCast(std.c.vm_region_info_t, &info), &count, &objname, ))) { .SUCCESS => return info.protection, .FAILURE => return error.PermissionDenied, else => |err| { log.err("mach_vm_region kernel call failed with error code: {s}", .{@tagName(err)}); return error.Unexpected; }, } } pub fn setMaxProtection(task: MachTask, address: u64, len: usize, prot: std.c.vm_prot_t) MachError!void { return task.setProtectionImpl(address, len, true, prot); } pub fn setCurrProtection(task: MachTask, address: u64, len: usize, prot: std.c.vm_prot_t) MachError!void { return task.setProtectionImpl(address, len, false, prot); } fn setProtectionImpl(task: MachTask, address: u64, len: usize, set_max: bool, prot: std.c.vm_prot_t) MachError!void { switch (std.c.getKernError(std.c.mach_vm_protect(task.port, address, len, @boolToInt(set_max), prot))) { .SUCCESS => return, .FAILURE => return error.PermissionDenied, else => |err| { log.err("mach_vm_protect kernel call failed with error code: {s}", .{@tagName(err)}); return error.Unexpected; }, } } /// Will write to VM even if current protection attributes specifically prohibit /// us from doing so, by temporarily setting protection level to a level with VM_PROT_COPY /// variant, and resetting after a successful or unsuccessful write. pub fn writeMemProtected(task: MachTask, address: u64, buf: []const u8, arch: std.Target.Cpu.Arch) MachError!usize { const curr_prot = try task.getCurrProtection(address, buf.len); try task.setCurrProtection( address, buf.len, std.c.PROT.READ | std.c.PROT.WRITE | std.c.PROT.COPY, ); defer { task.setCurrProtection(address, buf.len, curr_prot) catch {}; } return task.writeMem(address, buf, arch); } pub fn writeMem(task: MachTask, address: u64, buf: []const u8, arch: std.Target.Cpu.Arch) MachError!usize { const count = buf.len; var total_written: usize = 0; var curr_addr = address; const page_size = try getPageSize(task); // TODO we probably can assume value here var out_buf = buf[0..]; while (total_written < count) { const curr_size = maxBytesLeftInPage(page_size, curr_addr, count - total_written); switch (std.c.getKernError(std.c.mach_vm_write( task.port, curr_addr, @ptrToInt(out_buf.ptr), @intCast(std.c.mach_msg_type_number_t, curr_size), ))) { .SUCCESS => {}, .FAILURE => return error.PermissionDenied, else => |err| { log.err("mach_vm_write kernel call failed with error code: {s}", .{@tagName(err)}); return error.Unexpected; }, } switch (arch) { .aarch64 => { var mattr_value: std.c.vm_machine_attribute_val_t = std.c.MATTR_VAL_CACHE_FLUSH; switch (std.c.getKernError(std.c.vm_machine_attribute( task.port, curr_addr, curr_size, std.c.MATTR_CACHE, &mattr_value, ))) { .SUCCESS => {}, .FAILURE => return error.PermissionDenied, else => |err| { log.err("vm_machine_attribute kernel call failed with error code: {s}", .{@tagName(err)}); return error.Unexpected; }, } }, .x86_64 => {}, else => unreachable, } out_buf = out_buf[curr_size..]; total_written += curr_size; curr_addr += curr_size; } return total_written; } pub fn readMem(task: MachTask, address: u64, buf: []u8) MachError!usize { const count = buf.len; var total_read: usize = 0; var curr_addr = address; const page_size = try getPageSize(task); // TODO we probably can assume value here var out_buf = buf[0..]; while (total_read < count) { const curr_size = maxBytesLeftInPage(page_size, curr_addr, count - total_read); var curr_bytes_read: std.c.mach_msg_type_number_t = 0; var vm_memory: std.c.vm_offset_t = undefined; switch (std.c.getKernError(std.c.mach_vm_read(task.port, curr_addr, curr_size, &vm_memory, &curr_bytes_read))) { .SUCCESS => {}, .FAILURE => return error.PermissionDenied, else => |err| { log.err("mach_vm_read kernel call failed with error code: {s}", .{@tagName(err)}); return error.Unexpected; }, } @memcpy(out_buf[0..].ptr, @intToPtr([*]const u8, vm_memory), curr_bytes_read); _ = std.c.vm_deallocate(std.c.mach_task_self(), vm_memory, curr_bytes_read); out_buf = out_buf[curr_bytes_read..]; curr_addr += curr_bytes_read; total_read += curr_bytes_read; } return total_read; } fn maxBytesLeftInPage(page_size: usize, address: u64, count: usize) usize { var left = count; if (page_size > 0) { const page_offset = address % page_size; const bytes_left_in_page = page_size - page_offset; if (count > bytes_left_in_page) { left = bytes_left_in_page; } } return left; } fn getPageSize(task: MachTask) MachError!usize { if (task.isValid()) { var info_count = std.c.TASK_VM_INFO_COUNT; var vm_info: std.c.task_vm_info_data_t = undefined; switch (std.c.getKernError(std.c.task_info( task.port, std.c.TASK_VM_INFO, @ptrCast(std.c.task_info_t, &vm_info), &info_count, ))) { .SUCCESS => return @intCast(usize, vm_info.page_size), else => {}, } } var page_size: std.c.vm_size_t = undefined; switch (std.c.getKernError(std.c._host_page_size(std.c.mach_host_self(), &page_size))) { .SUCCESS => return page_size, else => |err| { log.err("_host_page_size kernel call failed with error code: {s}", .{@tagName(err)}); return error.Unexpected; }, } } }; pub fn machTaskForPid(pid: std.os.pid_t) MachError!MachTask { var port: std.c.mach_port_name_t = undefined; switch (std.c.getKernError(std.c.task_for_pid(std.c.mach_task_self(), pid, &port))) { .SUCCESS => {}, .FAILURE => return error.PermissionDenied, else => |err| { log.err("task_for_pid kernel call failed with error code: {s}", .{@tagName(err)}); return error.Unexpected; }, } return MachTask{ .port = port }; } } else struct {};
lib/std/os/darwin.zig
const std = @import("std"); const Token = @import("Token.zig"); pub const Type = union(enum) { boolean: bool, builtin: Token.Tag, float: f64, func_return: *Node, global: Token.Tag, ident: []const u8, int: i32, list: []Node, map: []Entry, loop_break, loop_continue, nil, raw_str: []const u8, stmt_end, string: []const Segment, uint: u32, assign: Assign, call: Call, conditional: Conditional, define: Assign, event: Event, func: Function, infix: Infix, loop: Loop, prefix: Prefix, range: Range, rec_range: RecRange, redir: Redir, subscript: Subscript, }; offset: u16, ty: Type, const Node = @This(); pub fn new(ty: Type, offset: u16) Node { return .{ .offset = offset, .ty = ty }; } const Call = struct { args: []Node, callee: *Node, pub fn format(call: Call, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { _ = try writer.print("{}(", .{call.callee.*}); for (call.args) |a, i| { if (i != 0) try writer.writeByte(','); _ = try writer.print("{}", .{a}); } try writer.writeByte(')'); } }; const Conditional = struct { condition: *Node, then_branch: []Node, else_branch: []Node, pub fn format(conditional: Conditional, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { _ = try writer.print("if ({}) {{", .{conditional.condition.*}); for (conditional.then_branch) |n| _ = try writer.print("{} ", .{n}); try writer.writeAll("} else {"); for (conditional.else_branch) |n| _ = try writer.print("{} ", .{n}); try writer.writeByte('}'); } }; pub const Combo = enum { none, add, sub, mul, div, mod, pub fn format(combo: Combo, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { switch (combo) { .none => try writer.writeByte('='), .add => try writer.writeAll("+="), .sub => try writer.writeAll("-="), .mul => try writer.writeAll("*="), .div => try writer.writeAll("/="), .mod => try writer.writeAll("%="), } } }; const Assign = struct { combo: Combo = .none, lvalue: *Node, rvalue: *Node, pub fn format(assign: Assign, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { _ = try writer.print("{} {} {}", .{ assign.lvalue.*, assign.combo, assign.rvalue.* }); } }; pub const Entry = struct { key: Node, value: Node, }; const EventType = enum { init, file, rec, exit, pub fn format(event: EventType, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { switch (event) { .init => try writer.writeAll("onInit"), .file => try writer.writeAll("onFile"), .rec => try writer.writeAll("onRec"), .exit => try writer.writeAll("onExit"), } } }; const Event = struct { nodes: []Node, ty: EventType, pub fn format(event: Event, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { _ = try writer.print("{} {{", .{event.ty}); for (event.nodes) |n| _ = try writer.print("{} ", .{n}); try writer.writeByte('}'); } }; const Function = struct { name: []const u8 = "", params: [][]const u8, body: []Node, pub fn format(func: Function, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { if (func.name.len != 0) try writer.writeAll(func.name); try writer.writeByte('{'); for (func.params) |param, i| { if (i != 0) try writer.writeByte(','); try writer.writeAll(param); } try writer.writeAll(" => "); for (func.body) |n| _ = try writer.print("{} ", .{n}); try writer.writeByte('}'); } }; const Infix = struct { left: *Node, op: Token.Tag, right: *Node, pub fn format(infix: Infix, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { _ = try writer.print("{} {s} {}", .{ infix.left.*, @tagName(infix.op), infix.right.* }); } }; const Loop = struct { condition: *Node, body: []Node, is_do: bool, pub fn format(loop: Loop, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { if (loop.is_do) { try writer.writeAll("do {"); for (loop.body) |n| _ = try writer.print("{} ", .{n}); _ = try writer.print("}} while ({})", .{loop.condition.*}); } else { _ = try writer.print("while ({}) {{", .{loop.condition.*}); for (loop.body) |n| _ = try writer.print("{} ", .{n}); try writer.writeByte('}'); } } }; const Prefix = struct { op: Token.Tag, operand: *Node, pub fn format(prefix: Prefix, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { _ = try writer.print("{s}{}", .{ @tagName(prefix.op), prefix.operand.* }); } }; const Range = struct { inclusive: bool, from: *Node, to: *Node, pub fn format(range: Range, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { const op = if (range.inclusive) "..=" else "..<"; _ = try writer.print("{}{s}{}", .{ range.from.*, op, range.to.* }); } }; const RecRange = struct { from: ?*Node, to: ?*Node, action: []Node, id: u8, exclusive: bool, pub fn format(recrange: RecRange, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { _ = try writer.print("RecRange{}", .{recrange.id}); } }; const Redir = struct { expr: *Node, file: *Node, clobber: bool, pub fn format(redir: Redir, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { const op = if (redir.clobber) "!>" else "+>"; _ = try writer.print("{} {s} {}", .{ redir.expr.*, op, redir.file.* }); } }; pub const Ipol = struct { spec: ?[]const u8, nodes: []Node, offset: u16, pub fn format(ipol: Ipol, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { try writer.writeByte('{'); if (ipol.spec) |spec| _ = try writer.print("#{s}#", .{spec}); for (ipol.nodes) |n| _ = try writer.print("{} ", .{n}); try writer.writeByte('}'); } }; pub const Segment = union(enum) { ipol: Ipol, plain: []const u8, pub fn format(segment: Segment, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { switch (segment) { .ipol => |i| _ = try writer.print("{}", .{i}), .plain => |s| try writer.writeAll(s), } } }; const Subscript = struct { container: *Node, index: *Node, pub fn format(subscript: Subscript, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { _ = try writer.print("{}[{}]", .{ subscript.container.*, subscript.index.* }); } }; pub fn format(node: Node, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { switch (node.ty) { .boolean => |b| _ = try writer.print("{}", .{b}), .builtin => |b| try writer.writeAll(@tagName(b)), .float => |f| _ = try writer.print("{d}", .{f}), .func_return => |r| _ = try writer.print("return {}", .{r.*}), .global => |g| try writer.writeAll(@tagName(g)), .ident => |i| try writer.writeAll(i), .int => |i| _ = try writer.print("{}", .{i}), .list => |l| try printList(l, writer), .map => |m| try printMap(m, writer), .loop_break => try writer.writeAll("break"), .loop_continue => try writer.writeAll("continue"), .nil => try writer.writeAll("nil"), .stmt_end => try writer.writeByte(';'), .raw_str => |s| try writer.writeAll(s), .string => |s| try printString(s, writer), .uint => |u| _ = try writer.print("{}", .{u}), .assign => |a| _ = try writer.print("{}", .{a}), .call => |c| _ = try writer.print("{}", .{c}), .conditional => |c| _ = try writer.print("{}", .{c}), .define => |d| _ = try writer.print("{}", .{d}), .event => |e| _ = try writer.print("{}", .{e}), .func => |f| _ = try writer.print("{}", .{f}), .infix => |i| _ = try writer.print("{}", .{i}), .loop => |l| _ = try writer.print("{}", .{l}), .prefix => |p| _ = try writer.print("{}", .{p}), .range => |r| _ = try writer.print("{}", .{r}), .rec_range => |r| _ = try writer.print("{}", .{r}), .redir => |r| _ = try writer.print("{}", .{r}), .subscript => |s| _ = try writer.print("{}", .{s}), } } fn printList(l: []Node, writer: anytype) !void { try writer.writeByte('['); for (l) |n, i| { if (i != 0) try writer.writeByte(','); _ = try writer.print("{}", .{n}); } try writer.writeByte(']'); } fn printMap(m: []Entry, writer: anytype) !void { try writer.writeByte('['); for (m) |e, i| { if (i != 0) try writer.writeByte(','); _ = try writer.print("{}:{}", .{ e.key, e.value }); } try writer.writeByte(']'); } fn printString(s: []const Segment, writer: anytype) !void { try writer.writeByte('"'); for (s) |seg| _ = try writer.print("{}", .{seg}); try writer.writeByte('"'); }
src/Node.zig
usingnamespace @import("../bits/linux.zig"); pub fn syscall_pipe(fd: *[2]i32) usize { return asm volatile ( \\ mov %[arg], %%g3 \\ t 0x6d \\ bcc,pt %%xcc, 1f \\ nop \\ # Return the error code \\ ba 2f \\ neg %%o0 \\1: \\ st %%o0, [%%g3+0] \\ st %%o1, [%%g3+4] \\ clr %%o0 \\2: : [ret] "={o0}" (-> usize), : [number] "{g1}" (@enumToInt(SYS.pipe)), [arg] "r" (fd), : "memory", "g3" ); } pub fn syscall_fork() usize { // Linux/sparc64 fork() returns two values in %o0 and %o1: // - On the parent's side, %o0 is the child's PID and %o1 is 0. // - On the child's side, %o0 is the parent's PID and %o1 is 1. // We need to clear the child's %o0 so that the return values // conform to the libc convention. return asm volatile ( \\ t 0x6d \\ bcc,pt %%xcc, 1f \\ nop \\ ba 2f \\ neg %%o0 \\ 1: \\ # Clear the child's %%o0 \\ dec %%o1 \\ and %%o1, %%o0, %%o0 \\ 2: : [ret] "={o0}" (-> usize), : [number] "{g1}" (@enumToInt(SYS.fork)), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } pub fn syscall0(number: SYS) usize { return asm volatile ( \\ t 0x6d \\ bcc,pt %%xcc, 1f \\ nop \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), : [number] "{g1}" (@enumToInt(number)), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } pub fn syscall1(number: SYS, arg1: usize) usize { return asm volatile ( \\ t 0x6d \\ bcc,pt %%xcc, 1f \\ nop \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), : [number] "{g1}" (@enumToInt(number)), [arg1] "{o0}" (arg1), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize { return asm volatile ( \\ t 0x6d \\ bcc,pt %%xcc, 1f \\ nop \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), : [number] "{g1}" (@enumToInt(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize { return asm volatile ( \\ t 0x6d \\ bcc,pt %%xcc, 1f \\ nop \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), : [number] "{g1}" (@enumToInt(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), [arg3] "{o2}" (arg3), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize { return asm volatile ( \\ t 0x6d \\ bcc,pt %%xcc, 1f \\ nop \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), : [number] "{g1}" (@enumToInt(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), [arg3] "{o2}" (arg3), [arg4] "{o3}" (arg4), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize { return asm volatile ( \\ t 0x6d \\ bcc,pt %%xcc, 1f \\ nop \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), : [number] "{g1}" (@enumToInt(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), [arg3] "{o2}" (arg3), [arg4] "{o3}" (arg4), [arg5] "{o4}" (arg5), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } pub fn syscall6( number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize, arg6: usize, ) usize { return asm volatile ( \\ t 0x6d \\ bcc,pt %%xcc, 1f \\ nop \\ neg %%o0 \\ 1: : [ret] "={o0}" (-> usize), : [number] "{g1}" (@enumToInt(number)), [arg1] "{o0}" (arg1), [arg2] "{o1}" (arg2), [arg3] "{o2}" (arg3), [arg4] "{o3}" (arg4), [arg5] "{o4}" (arg5), [arg6] "{o5}" (arg6), : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" ); } /// This matches the libc clone function. pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize; pub const restore = restore_rt; // Need to use C ABI here instead of naked // to prevent an infinite loop when calling rt_sigreturn. pub fn restore_rt() callconv(.C) void { return asm volatile ("t 0x6d" : : [number] "{g1}" (@enumToInt(SYS.rt_sigreturn)), : "memory", "xcc", "o0", "o1", "o2", "o3", "o4", "o5", "o7" ); }
lib/std/os/linux/sparc64.zig
const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const bog = @import("bog.zig"); const Node = bog.Node; const Type = bog.Type; /// Id's of all the bytecode instructions pub const Op = enum(u8) { move_double = 0x10, copy_double = 0x11, discard_single = 0x12, /// res = CAPTURE(arg) load_capture_double = 0x13, /// CAPTURE(res, lhs) = rhs store_capture_triple = 0x14, load_this_single = 0x15, const_primitive = 0x20, /// A = INT(arg1) const_int = 0x21, /// A = NUM(arg1, arg2) const_num = 0x22, const_string_off = 0x23, import_off = 0x24, div_floor_triple = 0x30, div_triple = 0x31, mul_triple = 0x32, pow_triple = 0x33, mod_triple = 0x34, add_triple = 0x35, sub_triple = 0x36, l_shift_triple = 0x37, r_shift_triple = 0x38, bit_and_triple = 0x39, bit_or_triple = 0x3A, bit_xor_triple = 0x3B, bit_not_double = 0x3C, equal_triple = 0x40, not_equal_triple = 0x41, less_than_triple = 0x42, less_than_equal_triple = 0x43, greater_than_triple = 0x44, greater_than_equal_triple = 0x45, in_triple = 0x46, is_type_id = 0x47, as_type_id = 0x48, bool_and_triple = 0x4A, bool_or_triple = 0x4B, bool_not_double = 0x4C, negate_double = 0x4D, /// IF (B==error) RET B ELSE A = B try_double = 0x4E, unwrap_error_double = 0x50, unwrap_tagged = 0x51, /// res = lhs[rhs] get_triple = 0x52, /// res[lhs] = rhs set_triple = 0x53, build_error_double = 0xB0, build_tuple_off = 0xB1, build_list_off = 0xB2, build_map_off = 0xB3, build_func = 0xB4, build_tagged = 0xB5, build_range = 0xB6, /// ip = arg1 jump = 0xA0, /// if (A) ip = arg1 jump_true = 0xA1, /// if (not A) ip = arg1 jump_false = 0xA2, /// if (not A is error) ip = arg1 jump_not_error = 0xA3, /// if (A is none) ip = arg1 jump_none = 0xA4, iter_init_double = 0xA5, /// This is fused with a jump_none as an optimization iter_next_double = 0xA6, // if (A is error) ip = arg1 jump_error = 0xA7, call = 0x90, /// RETURN(arg) return_single = 0x91, /// RETURN(()) return_none = 0x92, // unstable instructions /// TODO better debug info line_info, append_double, _, }; /// All integers are little endian pub const Instruction = packed union { bare: u32, bare_signed: i32, op: packed struct { op: Op, __pad1: u8 = 0, __pad2: u8 = 0, __pad3: u8 = 0, }, single: packed struct { op: Op, arg: RegRef, __pad: u16 = 0, }, double: packed struct { op: Op, res: RegRef, arg: RegRef, __pad: u8 = 0, }, triple: packed struct { op: Op, res: RegRef, lhs: RegRef, rhs: RegRef, }, type_id: packed struct { op: Op, res: RegRef, arg: RegRef, type_id: Type, }, off: packed struct { op: Op, res: RegRef, off: u16, pub inline fn isArg(self: @This()) bool { return self.off == 0xFFFF; } }, tagged: packed struct { op: Op = .build_tagged, res: RegRef, arg: RegRef, kind: packed enum(u8) { none = 0, some = 1, _, }, }, primitive: packed struct { op: Op = .const_primitive, res: u8, kind: packed enum(u8) { none = 0, True = 1, False = 2, _, }, __pad: u8 = 0, }, int: packed struct { op: Op = .const_int, res: RegRef, /// if true arg is given as two instructions long: bool, arg: i15, }, func: packed struct { op: Op = .build_func, res: RegRef, arg_count: u8, capture_count: u8, // followed by an offset }, jump: packed struct { op: Op, arg: RegRef, __pad: u16 = 0, // followed by an offset }, call: packed struct { /// A = B(C, C + 1, ... C + N) op: Op = .call, res: RegRef, func: RegRef, first: RegRef, // followed by a bare instruction with arg count // TODO max 32 args, reduce waste of space }, range: packed struct { op: Op = .build_range, res: RegRef, start: RegRef, end: RegRef, }, range_cont: packed struct { step: RegRef, start_kind: RangeKind, end_kind: RangeKind, step_kind: RangeKind, }, pub const RangeKind = packed enum(u8) { reg, value, default, _, }; comptime { std.debug.assert(@sizeOf(Instruction) == @sizeOf(u32)); } }; pub const RegRef = u8; /// A self contained Bog module with its code and strings. pub const Module = struct { name: []const u8, code: []const Instruction, strings: []const u8, entry: u32, // debug_info, pub fn deinit(module: *Module, alloc: *std.mem.Allocator) void { alloc.free(module.name); alloc.free(module.code); alloc.free(module.strings); alloc.destroy(module); } /// The magic number for a Bog bytecode file. pub const magic = "\x7fbog"; /// Current bytecode version. pub const bytecode_version = 6; pub const last_compatible = 5; /// The header of a Bog bytecode file. /// All integer values are little-endian. pub const Header = packed struct { /// A magic number, must be `\x7fbog`. magic: [4]u8, /// Version of this header. version: u32, /// Offset to the string table. strings: u32, /// Offset to the bytecode. code: u32, /// Offset to the module entry point. entry: u32, }; pub const ReadError = error{ /// Source did not start with a correct magic number. InvalidMagic, /// Header was malformed. InvalidHeader, /// This version of Bog cannot execute this bytecode. UnsupportedVersion, /// Code sections length is not a multiple of 4. MalformedCode, }; /// Reads a module from memory. pub fn read(src: []const u8) ReadError!Module { if (!mem.startsWith(u8, src, magic)) return error.InvalidMagic; if (src.len < @sizeOf(Header)) return error.InvalidHeader; const header = if (@import("builtin").endian == .Little) @ptrCast(*const Header, src.ptr).* else Header{ .magic = src[0..4].*, .version = mem.readIntLittle(u32, src[4..8]), .strings = mem.readIntLittle(u32, src[8..12]), .code = mem.readIntLittle(u32, src[12..16]), .entry = mem.readIntLittle(u32, src[16..20]), }; if (header.version < last_compatible) return error.UnsupportedVersion; // strings must come before code if (header.strings > header.code) return error.InvalidHeader; if (src.len < header.code) return error.InvalidHeader; const code = src[header.code..]; if (code.len % @sizeOf(Instruction) != 0) return error.InvalidHeader; return Module{ .name = "", .strings = src[header.strings..header.code], .code = mem.bytesAsSlice(Instruction, code), // entry is offset to to the beginning of code .entry = header.entry - header.code, }; } /// Serializes the module to a writer. pub fn write(module: Module, writer: anytype) @TypeOf(writer).Error!void { try writer.writeAll(magic); try writer.writeIntLittle(u32, bytecode_version); // strings come immediately after header const strings_offset = @intCast(u32, @sizeOf(Header)); try writer.writeIntLittle(u32, strings_offset); // code comes immediately after strings const code_offset = strings_offset + @intCast(u32, module.strings.len); try writer.writeIntLittle(u32, code_offset); // entry is offset to the beginning of the code const entry_offset = code_offset + module.entry; try writer.writeIntLittle(u32, entry_offset); // write strings try writer.writeAll(module.strings); // write code try writer.writeAll(mem.sliceAsBytes(module.code)); } /// Pretty prints debug info about the module. pub fn dump(module: Module, allocator: *Allocator, writer: anytype) (@TypeOf(writer).Error || Allocator.Error)!void { var arena_allocator = std.heap.ArenaAllocator.init(allocator); defer arena_allocator.deinit(); const arena = &arena_allocator.allocator; var jumps = try module.mapJumpTargets(arena); var ip: usize = 0; while (ip < module.code.len) { if (ip == module.entry) { try writer.writeAll("\nentry:"); } if (jumps.get(ip)) |label| { try writer.print("\n{s}:", .{label}); } const inst = module.code[ip]; ip += 1; if (inst.op.op != .line_info) { try writer.print("\n {: <5} {s: <20} ", .{ ip, @tagName(inst.op.op) }); } switch (inst.op.op) { .const_primitive => { try writer.print("{} <- ({s})\n", .{ inst.primitive.res, @tagName(inst.primitive.kind) }); }, .const_int => { const val = if (inst.int.long) blk: { ip += 2; break :blk module.code[ip - 2].bare_signed; } else inst.int.arg; try writer.print("{} <- ({})\n", .{ inst.int.res, val }); }, .const_num => { try writer.print("{} <- ({d})\n", .{ inst.single.arg, @ptrCast(*align(@alignOf(Instruction)) const f64, &module.code[ip]).* }); ip += 2; }, .const_string_off, .import_off => { const offset = if (inst.off.isArg()) blk: { ip += 1; break :blk module.code[ip - 1].bare; } else inst.off.off; const len = @ptrCast(*align(1) const u32, module.strings[offset..].ptr).*; const slice = module.strings[offset + @sizeOf(u32) ..][0..len]; try writer.print("{} <- \"{s}\"\n", .{ inst.off.res, slice }); }, .build_tagged => { const offset = module.code[ip].bare; ip += 1; const len = @ptrCast(*align(1) const u32, module.strings[offset..].ptr).*; const slice = module.strings[offset + @sizeOf(u32) ..][0..len]; if (inst.tagged.kind == .none) try writer.print("{} <- @{s}\n", .{ inst.off.res, slice }) else try writer.print("{} <- @{s}({})\n", .{ inst.off.res, slice, inst.tagged.arg }); }, .jump, .jump_false, .jump_true, .jump_none, .jump_error, .jump_not_error => { const jump_target = if (inst.jump.op == .jump) @intCast(usize, @intCast(isize, ip) + module.code[ip].bare_signed) else ip + module.code[ip].bare; ip += 1; const label = jumps.get(jump_target) orelse unreachable; if (inst.jump.op == .jump) try writer.print("to {s}\n", .{label}) else try writer.print("to {s}, cond {}\n", .{ label, inst.jump.arg }); }, .build_func => { const offset = module.code[ip].bare; ip += 1; const label = jumps.get(offset) orelse unreachable; try writer.print("{} <- {s}({})[{}]\n", .{ inst.func.res, label, inst.func.arg_count, inst.func.capture_count }); }, .div_floor_triple, .div_triple, .mul_triple, .pow_triple, .mod_triple, .add_triple, .sub_triple, .l_shift_triple, .r_shift_triple, .bit_and_triple, .bit_or_triple, .bit_xor_triple, .equal_triple, .not_equal_triple, .less_than_triple, .less_than_equal_triple, .greater_than_triple, .greater_than_equal_triple, .in_triple, .bool_and_triple, .bool_or_triple, => { try writer.print("{} <- {} {s} {}\n", .{ inst.triple.res, inst.triple.lhs, opToStr(inst.triple.op), inst.triple.rhs }); }, .get_triple => { try writer.print("{} <- {}[{}]\n", .{ inst.triple.res, inst.triple.lhs, inst.triple.rhs }); }, .set_triple => { try writer.print("{}[{}] <- {}\n", .{ inst.triple.res, inst.triple.lhs, inst.triple.rhs }); }, .iter_next_double => { const jump_target = ip + module.code[ip].bare; ip += 1; const label = jumps.get(jump_target) orelse unreachable; try writer.print("{} <- {}, jump_none to {s}\n", .{ inst.double.res, inst.double.arg, label }); }, .build_error_double, .unwrap_error_double, .iter_init_double, .move_double, .copy_double, .append_double => { try writer.print("{} <- {}\n", .{ inst.double.res, inst.double.arg }); }, .unwrap_tagged => { const offset = module.code[ip].bare; ip += 1; const len = @ptrCast(*align(1) const u32, module.strings[offset..].ptr).*; const slice = module.strings[offset + @sizeOf(u32) ..][0..len]; try writer.print("{} <- @{s}({})\n", .{ inst.double.res, slice, inst.double.arg }); }, .bool_not_double, .bit_not_double, .negate_double, .try_double => { try writer.print("{} <- {s} {}\n", .{ inst.double.res, opToStr(inst.double.op), inst.double.arg }); }, .store_capture_triple => { try writer.print("{}[{}] <- {}\n", .{ inst.triple.res, inst.triple.rhs, inst.triple.lhs }); }, .load_capture_double => { try writer.print("{} <- [{}]\n", .{ inst.double.res, inst.double.arg }); }, .build_tuple_off, .build_list_off, .build_map_off => { const size = if (inst.off.isArg()) blk: { ip += 1; break :blk module.code[ip - 1].bare; } else inst.off.off; try writer.print("{} <- size:{}\n", .{ inst.off.res, size }); }, .build_range => { const cont = module.code[ip].range_cont; ip += 1; try writer.print("{} <- {}:{}:{} #{s}:{s}:{s}\n", .{ inst.range.res, inst.range.start, inst.range.end, cont.step, @tagName(cont.start_kind), @tagName(cont.end_kind), @tagName(cont.step_kind), }); }, .call => { var first = inst.call.first; const last = module.code[ip].bare + first; try writer.print("{} <- {}(", .{ inst.call.res, inst.call.func }); var comma = false; while (first < last) : (first += 1) { if (comma) { try writer.writeAll(", "); } else comma = true; try writer.print("{}", .{first}); } try writer.writeAll(")\n"); ip += 1; }, .line_info => ip += 1, .is_type_id, .as_type_id => { try writer.print("{} <- {} {s} {s}\n", .{ inst.type_id.res, inst.type_id.arg, opToStr(inst.op.op), @tagName(inst.type_id.type_id) }); }, .discard_single, .return_single, .load_this_single => { try writer.print("{}\n", .{inst.single.arg}); }, .return_none => try writer.writeByte('\n'), _ => unreachable, } } } const JumpMap = std.AutoHashMap(usize, []const u8); fn mapJumpTargets(module: Module, arena: *Allocator) Allocator.Error!JumpMap { var map = JumpMap.init(arena); var ip: usize = 0; var mangle: u32 = 0; while (ip < module.code.len) { const inst = module.code[ip]; ip += 1; switch (inst.op.op) { .jump, .jump_false, .jump_true, .jump_none, .jump_error, .jump_not_error, .iter_next_double => { const jump_target = if (inst.jump.op == .jump) @intCast(usize, @intCast(isize, ip) + module.code[ip].bare_signed) else ip + module.code[ip].bare; ip += 1; if (map.get(jump_target)) |_| continue; _ = try map.put(jump_target, try std.fmt.allocPrint(arena, "{s}_{}", .{ @tagName(inst.op.op), mangle })); mangle += 1; }, .build_func => { _ = try map.put(module.code[ip].bare, try std.fmt.allocPrint(arena, "function_{}", .{mangle})); mangle += 1; }, .const_int => if (inst.int.long) { ip += 2; }, .const_num => ip += 2, .import_off, .const_string_off, .build_tuple_off, .build_list_off, .build_map_off, => if (inst.off.isArg()) { ip += 1; }, .build_range, .build_tagged, .line_info, .call => ip += 1, else => {}, } } return map; } fn opToStr(op: Op) []const u8 { return switch (op) { .div_floor_triple => "//", .div_triple => "/", .mul_triple => "*", .pow_triple => "**", .mod_triple => "%", .add_triple => "+", .sub_triple, .negate_double => "-", .l_shift_triple => "<<", .r_shift_triple => ">>", .bit_and_triple => "&", .bit_or_triple => "|", .bit_xor_triple => "^", .equal_triple => "==", .not_equal_triple => "!=", .less_than_triple => "<", .less_than_equal_triple => "<=", .greater_than_triple => ">", .greater_than_equal_triple => ">=", .in_triple => "in", .bool_and_triple => "and", .bool_or_triple => "or", .bool_not_double => "not", .bit_not_double => "~", .try_double => "try", .is_type_id => "is", .as_type_id => "as", else => unreachable, }; } };
src/bytecode.zig
const std = @import("../std.zig"); const assert = std.debug.assert; const math = std.math; const mem = std.mem; const Allocator = @This(); pub const Error = error{OutOfMemory}; /// Attempt to allocate at least `len` bytes aligned to `ptr_align`. /// /// If `len_align` is `0`, then the length returned MUST be exactly `len` bytes, /// otherwise, the length must be aligned to `len_align`. /// /// `len` must be greater than or equal to `len_align` and must be aligned by `len_align`. /// /// `ret_addr` is optionally provided as the first return address of the allocation call stack. /// If the value is `0` it means no return address has been provided. allocFn: fn (self: *Allocator, len: usize, ptr_align: u29, len_align: u29, ret_addr: usize) Error![]u8, /// Attempt to expand or shrink memory in place. `buf.len` must equal the most recent /// length returned by `allocFn` or `resizeFn`. `buf_align` must equal the same value /// that was passed as the `ptr_align` parameter to the original `allocFn` call. /// /// Passing a `new_len` of 0 frees and invalidates the buffer such that it can no /// longer be passed to `resizeFn`. /// /// error.OutOfMemory can only be returned if `new_len` is greater than `buf.len`. /// If `buf` cannot be expanded to accomodate `new_len`, then the allocation MUST be /// unmodified and error.OutOfMemory MUST be returned. /// /// If `len_align` is `0`, then the length returned MUST be exactly `len` bytes, /// otherwise, the length must be aligned to `len_align`. Note that `len_align` does *not* /// provide a way to modify the alignment of a pointer. Rather it provides an API for /// accepting more bytes of memory from the allocator than requested. /// /// `new_len` must be greater than or equal to `len_align` and must be aligned by `len_align`. /// /// `ret_addr` is optionally provided as the first return address of the allocation call stack. /// If the value is `0` it means no return address has been provided. resizeFn: fn (self: *Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Error!usize, /// Set to resizeFn if in-place resize is not supported. pub fn noResize( self: *Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize, ) Error!usize { if (new_len > buf.len) return error.OutOfMemory; return new_len; } /// Realloc is used to modify the size or alignment of an existing allocation, /// as well as to provide the allocator with an opportunity to move an allocation /// to a better location. /// When the size/alignment is greater than the previous allocation, this function /// returns `error.OutOfMemory` when the requested new allocation could not be granted. /// When the size/alignment is less than or equal to the previous allocation, /// this function returns `error.OutOfMemory` when the allocator decides the client /// would be better off keeping the extra alignment/size. Clients will call /// `resizeFn` when they require the allocator to track a new alignment/size, /// and so this function should only return success when the allocator considers /// the reallocation desirable from the allocator's perspective. /// As an example, `std.ArrayList` tracks a "capacity", and therefore can handle /// reallocation failure, even when `new_n` <= `old_mem.len`. A `FixedBufferAllocator` /// would always return `error.OutOfMemory` for `reallocFn` when the size/alignment /// is less than or equal to the old allocation, because it cannot reclaim the memory, /// and thus the `std.ArrayList` would be better off retaining its capacity. /// When `reallocFn` returns, /// `return_value[0..min(old_mem.len, new_byte_count)]` must be the same /// as `old_mem` was when `reallocFn` is called. The bytes of /// `return_value[old_mem.len..]` have undefined values. /// The returned slice must have its pointer aligned at least to `new_alignment` bytes. fn reallocBytes( self: *Allocator, /// Guaranteed to be the same as what was returned from most recent call to /// `allocFn` or `resizeFn`. /// If `old_mem.len == 0` then this is a new allocation and `new_byte_count` /// is guaranteed to be >= 1. old_mem: []u8, /// If `old_mem.len == 0` then this is `undefined`, otherwise: /// Guaranteed to be the same as what was passed to `allocFn`. /// Guaranteed to be >= 1. /// Guaranteed to be a power of 2. old_alignment: u29, /// If `new_byte_count` is 0 then this is a free and it is guaranteed that /// `old_mem.len != 0`. new_byte_count: usize, /// Guaranteed to be >= 1. /// Guaranteed to be a power of 2. /// Returned slice's pointer must have this alignment. new_alignment: u29, /// 0 indicates the length of the slice returned MUST match `new_byte_count` exactly /// non-zero means the length of the returned slice must be aligned by `len_align` /// `new_len` must be aligned by `len_align` len_align: u29, return_address: usize, ) Error![]u8 { if (old_mem.len == 0) { const new_mem = try self.allocFn(self, new_byte_count, new_alignment, len_align, return_address); // TODO: https://github.com/ziglang/zig/issues/4298 @memset(new_mem.ptr, undefined, new_byte_count); return new_mem; } if (mem.isAligned(@ptrToInt(old_mem.ptr), new_alignment)) { if (new_byte_count <= old_mem.len) { const shrunk_len = self.shrinkBytes(old_mem, old_alignment, new_byte_count, len_align, return_address); return old_mem.ptr[0..shrunk_len]; } if (self.resizeFn(self, old_mem, old_alignment, new_byte_count, len_align, return_address)) |resized_len| { assert(resized_len >= new_byte_count); // TODO: https://github.com/ziglang/zig/issues/4298 @memset(old_mem.ptr + new_byte_count, undefined, resized_len - new_byte_count); return old_mem.ptr[0..resized_len]; } else |_| {} } if (new_byte_count <= old_mem.len and new_alignment <= old_alignment) { return error.OutOfMemory; } return self.moveBytes(old_mem, old_alignment, new_byte_count, new_alignment, len_align, return_address); } /// Move the given memory to a new location in the given allocator to accomodate a new /// size and alignment. fn moveBytes( self: *Allocator, old_mem: []u8, old_align: u29, new_len: usize, new_alignment: u29, len_align: u29, return_address: usize, ) Error![]u8 { assert(old_mem.len > 0); assert(new_len > 0); const new_mem = try self.allocFn(self, new_len, new_alignment, len_align, return_address); @memcpy(new_mem.ptr, old_mem.ptr, math.min(new_len, old_mem.len)); // TODO DISABLED TO AVOID BUGS IN TRANSLATE C // TODO see also https://github.com/ziglang/zig/issues/4298 // use './zig build test-translate-c' to reproduce, some of the symbols in the // generated C code will be a sequence of 0xaa (the undefined value), meaning // it is printing data that has been freed //@memset(old_mem.ptr, undefined, old_mem.len); _ = self.shrinkBytes(old_mem, old_align, 0, 0, return_address); return new_mem; } /// Returns a pointer to undefined memory. /// Call `destroy` with the result to free the memory. pub fn create(self: *Allocator, comptime T: type) Error!*T { if (@sizeOf(T) == 0) return @as(*T, undefined); const slice = try self.allocAdvancedWithRetAddr(T, null, 1, .exact, @returnAddress()); return &slice[0]; } /// `ptr` should be the return value of `create`, or otherwise /// have the same address and alignment property. pub fn destroy(self: *Allocator, ptr: anytype) void { const info = @typeInfo(@TypeOf(ptr)).Pointer; const T = info.child; if (@sizeOf(T) == 0) return; const non_const_ptr = @intToPtr([*]u8, @ptrToInt(ptr)); _ = self.shrinkBytes(non_const_ptr[0..@sizeOf(T)], info.alignment, 0, 0, @returnAddress()); } /// Allocates an array of `n` items of type `T` and sets all the /// items to `undefined`. Depending on the Allocator /// implementation, it may be required to call `free` once the /// memory is no longer needed, to avoid a resource leak. If the /// `Allocator` implementation is unknown, then correct code will /// call `free` when done. /// /// For allocating a single item, see `create`. pub fn alloc(self: *Allocator, comptime T: type, n: usize) Error![]T { return self.allocAdvancedWithRetAddr(T, null, n, .exact, @returnAddress()); } pub fn allocWithOptions( self: *Allocator, comptime Elem: type, n: usize, /// null means naturally aligned comptime optional_alignment: ?u29, comptime optional_sentinel: ?Elem, ) Error!AllocWithOptionsPayload(Elem, optional_alignment, optional_sentinel) { return self.allocWithOptionsRetAddr(Elem, n, optional_alignment, optional_sentinel, @returnAddress()); } pub fn allocWithOptionsRetAddr( self: *Allocator, comptime Elem: type, n: usize, /// null means naturally aligned comptime optional_alignment: ?u29, comptime optional_sentinel: ?Elem, return_address: usize, ) Error!AllocWithOptionsPayload(Elem, optional_alignment, optional_sentinel) { if (optional_sentinel) |sentinel| { const ptr = try self.allocAdvancedWithRetAddr(Elem, optional_alignment, n + 1, .exact, return_address); ptr[n] = sentinel; return ptr[0..n :sentinel]; } else { return self.allocAdvancedWithRetAddr(Elem, optional_alignment, n, .exact, return_address); } } fn AllocWithOptionsPayload(comptime Elem: type, comptime alignment: ?u29, comptime sentinel: ?Elem) type { if (sentinel) |s| { return [:s]align(alignment orelse @alignOf(Elem)) Elem; } else { return []align(alignment orelse @alignOf(Elem)) Elem; } } /// Allocates an array of `n + 1` items of type `T` and sets the first `n` /// items to `undefined` and the last item to `sentinel`. Depending on the /// Allocator implementation, it may be required to call `free` once the /// memory is no longer needed, to avoid a resource leak. If the /// `Allocator` implementation is unknown, then correct code will /// call `free` when done. /// /// For allocating a single item, see `create`. /// /// Deprecated; use `allocWithOptions`. pub fn allocSentinel( self: *Allocator, comptime Elem: type, n: usize, comptime sentinel: Elem, ) Error![:sentinel]Elem { return self.allocWithOptionsRetAddr(Elem, n, null, sentinel, @returnAddress()); } /// Deprecated: use `allocAdvanced` pub fn alignedAlloc( self: *Allocator, comptime T: type, /// null means naturally aligned comptime alignment: ?u29, n: usize, ) Error![]align(alignment orelse @alignOf(T)) T { return self.allocAdvancedWithRetAddr(T, alignment, n, .exact, @returnAddress()); } pub fn allocAdvanced( self: *Allocator, comptime T: type, /// null means naturally aligned comptime alignment: ?u29, n: usize, exact: Exact, ) Error![]align(alignment orelse @alignOf(T)) T { return self.allocAdvancedWithRetAddr(T, alignment, n, exact, @returnAddress()); } pub const Exact = enum { exact, at_least }; pub fn allocAdvancedWithRetAddr( self: *Allocator, comptime T: type, /// null means naturally aligned comptime alignment: ?u29, n: usize, exact: Exact, return_address: usize, ) Error![]align(alignment orelse @alignOf(T)) T { const a = if (alignment) |a| blk: { if (a == @alignOf(T)) return allocAdvancedWithRetAddr(self, T, null, n, exact, return_address); break :blk a; } else @alignOf(T); if (n == 0) { return @as([*]align(a) T, undefined)[0..0]; } const byte_count = math.mul(usize, @sizeOf(T), n) catch return Error.OutOfMemory; // TODO The `if (alignment == null)` blocks are workarounds for zig not being able to // access certain type information about T without creating a circular dependency in async // functions that heap-allocate their own frame with @Frame(func). const size_of_T = if (alignment == null) @intCast(u29, @divExact(byte_count, n)) else @sizeOf(T); const len_align: u29 = switch (exact) { .exact => 0, .at_least => size_of_T, }; const byte_slice = try self.allocFn(self, byte_count, a, len_align, return_address); switch (exact) { .exact => assert(byte_slice.len == byte_count), .at_least => assert(byte_slice.len >= byte_count), } // TODO: https://github.com/ziglang/zig/issues/4298 @memset(byte_slice.ptr, undefined, byte_slice.len); if (alignment == null) { // This if block is a workaround (see comment above) return @intToPtr([*]T, @ptrToInt(byte_slice.ptr))[0..@divExact(byte_slice.len, @sizeOf(T))]; } else { return mem.bytesAsSlice(T, @alignCast(a, byte_slice)); } } /// Increases or decreases the size of an allocation. It is guaranteed to not move the pointer. pub fn resize(self: *Allocator, old_mem: anytype, new_n: usize) Error!@TypeOf(old_mem) { const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; const T = Slice.child; if (new_n == 0) { self.free(old_mem); return &[0]T{}; } const old_byte_slice = mem.sliceAsBytes(old_mem); const new_byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory; const rc = try self.resizeFn(self, old_byte_slice, Slice.alignment, new_byte_count, 0, @returnAddress()); assert(rc == new_byte_count); const new_byte_slice = old_mem.ptr[0..new_byte_count]; return mem.bytesAsSlice(T, new_byte_slice); } /// This function requests a new byte size for an existing allocation, /// which can be larger, smaller, or the same size as the old memory /// allocation. /// This function is preferred over `shrink`, because it can fail, even /// when shrinking. This gives the allocator a chance to perform a /// cheap shrink operation if possible, or otherwise return OutOfMemory, /// indicating that the caller should keep their capacity, for example /// in `std.ArrayList.shrink`. /// If you need guaranteed success, call `shrink`. /// If `new_n` is 0, this is the same as `free` and it always succeeds. pub fn realloc(self: *Allocator, old_mem: anytype, new_n: usize) t: { const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; break :t Error![]align(Slice.alignment) Slice.child; } { const old_alignment = @typeInfo(@TypeOf(old_mem)).Pointer.alignment; return self.reallocAdvancedWithRetAddr(old_mem, old_alignment, new_n, .exact, @returnAddress()); } pub fn reallocAtLeast(self: *Allocator, old_mem: anytype, new_n: usize) t: { const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; break :t Error![]align(Slice.alignment) Slice.child; } { const old_alignment = @typeInfo(@TypeOf(old_mem)).Pointer.alignment; return self.reallocAdvancedWithRetAddr(old_mem, old_alignment, new_n, .at_least, @returnAddress()); } /// This is the same as `realloc`, except caller may additionally request /// a new alignment, which can be larger, smaller, or the same as the old /// allocation. pub fn reallocAdvanced( self: *Allocator, old_mem: anytype, comptime new_alignment: u29, new_n: usize, exact: Exact, ) Error![]align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child { return self.reallocAdvancedWithRetAddr(old_mem, new_alignment, new_n, exact, @returnAddress()); } pub fn reallocAdvancedWithRetAddr( self: *Allocator, old_mem: anytype, comptime new_alignment: u29, new_n: usize, exact: Exact, return_address: usize, ) Error![]align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child { const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; const T = Slice.child; if (old_mem.len == 0) { return self.allocAdvancedWithRetAddr(T, new_alignment, new_n, exact, return_address); } if (new_n == 0) { self.free(old_mem); return @as([*]align(new_alignment) T, undefined)[0..0]; } const old_byte_slice = mem.sliceAsBytes(old_mem); const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory; // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure const len_align: u29 = switch (exact) { .exact => 0, .at_least => @sizeOf(T), }; const new_byte_slice = try self.reallocBytes(old_byte_slice, Slice.alignment, byte_count, new_alignment, len_align, return_address); return mem.bytesAsSlice(T, @alignCast(new_alignment, new_byte_slice)); } /// Prefer calling realloc to shrink if you can tolerate failure, such as /// in an ArrayList data structure with a storage capacity. /// Shrink always succeeds, and `new_n` must be <= `old_mem.len`. /// Returned slice has same alignment as old_mem. /// Shrinking to 0 is the same as calling `free`. pub fn shrink(self: *Allocator, old_mem: anytype, new_n: usize) t: { const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; break :t []align(Slice.alignment) Slice.child; } { const old_alignment = @typeInfo(@TypeOf(old_mem)).Pointer.alignment; return self.alignedShrinkWithRetAddr(old_mem, old_alignment, new_n, @returnAddress()); } /// This is the same as `shrink`, except caller may additionally request /// a new alignment, which must be smaller or the same as the old /// allocation. pub fn alignedShrink( self: *Allocator, old_mem: anytype, comptime new_alignment: u29, new_n: usize, ) []align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child { return self.alignedShrinkWithRetAddr(old_mem, new_alignment, new_n, @returnAddress()); } /// This is the same as `alignedShrink`, except caller may additionally pass /// the return address of the first stack frame, which may be relevant for /// allocators which collect stack traces. pub fn alignedShrinkWithRetAddr( self: *Allocator, old_mem: anytype, comptime new_alignment: u29, new_n: usize, return_address: usize, ) []align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child { const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; const T = Slice.child; if (new_n == old_mem.len) return old_mem; assert(new_n < old_mem.len); assert(new_alignment <= Slice.alignment); // Here we skip the overflow checking on the multiplication because // new_n <= old_mem.len and the multiplication didn't overflow for that operation. const byte_count = @sizeOf(T) * new_n; const old_byte_slice = mem.sliceAsBytes(old_mem); // TODO: https://github.com/ziglang/zig/issues/4298 @memset(old_byte_slice.ptr + byte_count, undefined, old_byte_slice.len - byte_count); _ = self.shrinkBytes(old_byte_slice, Slice.alignment, byte_count, 0, return_address); return old_mem[0..new_n]; } /// Free an array allocated with `alloc`. To free a single item, /// see `destroy`. pub fn free(self: *Allocator, memory: anytype) void { const Slice = @typeInfo(@TypeOf(memory)).Pointer; const bytes = mem.sliceAsBytes(memory); const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0; if (bytes_len == 0) return; const non_const_ptr = @intToPtr([*]u8, @ptrToInt(bytes.ptr)); // TODO: https://github.com/ziglang/zig/issues/4298 @memset(non_const_ptr, undefined, bytes_len); _ = self.shrinkBytes(non_const_ptr[0..bytes_len], Slice.alignment, 0, 0, @returnAddress()); } /// Copies `m` to newly allocated memory. Caller owns the memory. pub fn dupe(allocator: *Allocator, comptime T: type, m: []const T) ![]T { const new_buf = try allocator.alloc(T, m.len); mem.copy(T, new_buf, m); return new_buf; } /// Copies `m` to newly allocated memory, with a null-terminated element. Caller owns the memory. pub fn dupeZ(allocator: *Allocator, comptime T: type, m: []const T) ![:0]T { const new_buf = try allocator.alloc(T, m.len + 1); mem.copy(T, new_buf, m); new_buf[m.len] = 0; return new_buf[0..m.len :0]; } /// Call `resizeFn`, but caller guarantees that `new_len` <= `buf.len` meaning /// error.OutOfMemory should be impossible. /// This function allows a runtime `buf_align` value. Callers should generally prefer /// to call `shrink` directly. pub fn shrinkBytes( self: *Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, return_address: usize, ) usize { assert(new_len <= buf.len); return self.resizeFn(self, buf, buf_align, new_len, len_align, return_address) catch unreachable; }
lib/std/mem/Allocator.zig
const zang = @import("zang"); const common = @import("common.zig"); const c = @import("common/c.zig"); const Instrument = @import("modules.zig").HardSquareInstrument; pub const AUDIO_FORMAT: zang.AudioFormat = .signed16_lsb; pub const AUDIO_SAMPLE_RATE = 48000; pub const AUDIO_BUFFER_SIZE = 1024; pub const DESCRIPTION = \\example_arpeggiator \\ \\Play an instrument with the keyboard. You can hold \\down multiple notes. The arpeggiator will cycle \\through them lowest to highest. ; const a4 = 440.0; const Arpeggiator = struct { pub const num_outputs = 2; pub const num_temps = Instrument.num_temps; pub const Params = struct { sample_rate: f32, note_held: [common.key_bindings.len]bool, }; iq: zang.Notes(Instrument.Params).ImpulseQueue, idgen: zang.IdGenerator, instrument: Instrument, trigger: zang.Trigger(Instrument.Params), next_frame: usize, last_note: ?usize, fn init() Arpeggiator { return .{ .iq = zang.Notes(Instrument.Params).ImpulseQueue.init(), .idgen = zang.IdGenerator.init(), .instrument = Instrument.init(), .trigger = zang.Trigger(Instrument.Params).init(), .next_frame = 0, .last_note = null, }; } fn paint( self: *Arpeggiator, span: zang.Span, outputs: [num_outputs][]f32, temps: [num_temps][]f32, params: Params, ) void { const note_duration = @floatToInt(usize, 0.03 * params.sample_rate); // TODO - if only one key is held, try to reuse the previous impulse id // to prevent the envelope from retriggering on the same note. // then replace Gate with Envelope. // or maybe not... this is the only example that uses Gate, don't want // to lose the coverage // also, if possible, when all keys are released, call reset on the // arpeggiator, so that whenever you start pressing keys, it starts // immediately while (self.next_frame < outputs[0].len) { const next_note_index = blk: { const start = if (self.last_note) |last_note| last_note + 1 else 0; var i: usize = 0; while (i < common.key_bindings.len) : (i += 1) { const index = (start + i) % common.key_bindings.len; if (params.note_held[index]) { break :blk index; } } break :blk null; }; if (next_note_index) |index| { const freq = a4 * common.key_bindings[index].rel_freq; self.iq.push(self.next_frame, self.idgen.nextId(), .{ .sample_rate = params.sample_rate, .freq = freq, .note_on = true, }); self.last_note = index; } else if (self.last_note) |last_note| { const freq = a4 * common.key_bindings[last_note].rel_freq; self.iq.push(self.next_frame, self.idgen.nextId(), .{ .sample_rate = params.sample_rate, .freq = freq, .note_on = false, }); } self.next_frame += note_duration; } self.next_frame -= outputs[0].len; var ctr = self.trigger.counter(span, self.iq.consume()); while (self.trigger.next(&ctr)) |result| { self.instrument.paint( result.span, .{outputs[0]}, temps, result.note_id_changed, result.params, ); zang.addScalarInto(result.span, outputs[1], result.params.freq); } } }; pub const MainModule = struct { pub const num_outputs = 2; pub const num_temps = Arpeggiator.num_temps; pub const output_audio = common.AudioOut{ .mono = 0 }; pub const output_visualize = 0; pub const output_sync_oscilloscope = 1; current_params: Arpeggiator.Params, iq: zang.Notes(Arpeggiator.Params).ImpulseQueue, idgen: zang.IdGenerator, arpeggiator: Arpeggiator, trigger: zang.Trigger(Arpeggiator.Params), pub fn init() MainModule { return .{ .current_params = .{ .sample_rate = AUDIO_SAMPLE_RATE, .note_held = [1]bool{false} ** common.key_bindings.len, }, .iq = zang.Notes(Arpeggiator.Params).ImpulseQueue.init(), .idgen = zang.IdGenerator.init(), .arpeggiator = Arpeggiator.init(), .trigger = zang.Trigger(Arpeggiator.Params).init(), }; } pub fn paint( self: *MainModule, span: zang.Span, outputs: [num_outputs][]f32, temps: [num_temps][]f32, ) void { var ctr = self.trigger.counter(span, self.iq.consume()); while (self.trigger.next(&ctr)) |result| { self.arpeggiator.paint(result.span, outputs, temps, result.params); } } pub fn keyEvent(self: *MainModule, key: i32, down: bool, impulse_frame: usize) bool { for (common.key_bindings) |kb, i| { if (kb.key == key) { self.current_params.note_held[i] = down; self.iq.push(impulse_frame, self.idgen.nextId(), self.current_params); } } return true; } };
examples/example_arpeggiator.zig
usingnamespace @import("core.zig"); const vk = @import("vulkan"); usingnamespace @import("vulkan/device.zig"); usingnamespace @import("vulkan/buffer.zig"); usingnamespace @import("vulkan/image.zig"); const ImageTransferQueue = std.ArrayList(struct { image: Image, staging_buffer: Buffer, }); const BufferTransferQueue = std.ArrayList(struct { buffer: Buffer, buffer_offset: u32, staging_buffer: Buffer, }); pub const TransferQueue = struct { const Self = @This(); allocator: *Allocator, device: Device, buffer_transfers: BufferTransferQueue, previous_buffer_transfers: ?BufferTransferQueue, image_transfers: ImageTransferQueue, previous_image_transfers: ?ImageTransferQueue, pub fn init( allocator: *Allocator, device: Device, ) Self { return Self{ .allocator = allocator, .device = device, .image_transfers = ImageTransferQueue.init(allocator), .previous_image_transfers = null, .buffer_transfers = BufferTransferQueue.init(allocator), .previous_buffer_transfers = null, }; } pub fn deinit(self: *Self) void { deleteTransferList(BufferTransferQueue, self.buffer_transfers); if (self.previous_buffer_transfers) |buffer_transfer| { deleteTransferList(BufferTransferQueue, buffer_transfer); } deleteTransferList(ImageTransferQueue, self.image_transfers); if (self.previous_image_transfers) |image_transfers| { deleteTransferList(ImageTransferQueue, image_transfers); } } pub fn copyToBuffer(self: *Self, buffer: Buffer, comptime Type: type, data: []const Type) void { var staging_buffer_size = @intCast(u32, @sizeOf(Type) * data.len); var staging_buffer = Buffer.init(self.device, staging_buffer_size, .{ .transfer_src_bit = true }, .{ .host_visible_bit = true, .host_coherent_bit = true }) catch { std.debug.panic("Failed to create staging buffer", .{}); }; staging_buffer.fill(Type, data) catch { std.debug.panic("Failed to fill staging buffer", .{}); }; self.buffer_transfers.append(.{ .buffer = buffer, .buffer_offset = 0, .staging_buffer = staging_buffer, }) catch { std.debug.panic("Failed to append buffer transfer queue", .{}); }; } pub fn copyToImage(self: *Self, image: Image, comptime Type: type, data: []const Type) void { var staging_buffer_size = @intCast(u32, @sizeOf(Type) * data.len); var staging_buffer = Buffer.init(self.device, staging_buffer_size, .{ .transfer_src_bit = true }, .{ .host_visible_bit = true, .host_coherent_bit = true }) catch { std.debug.panic("Failed to create staging buffer", .{}); }; staging_buffer.fill(Type, data) catch { std.debug.panic("Failed to fill staging buffer", .{}); }; self.image_transfers.append(.{ .image = image, .staging_buffer = staging_buffer, }) catch { std.debug.panic("Failed to append image transfer queue", .{}); }; } pub fn commitTransfers(self: *Self, command_buffer: vk.CommandBuffer) void { for (self.buffer_transfers.items) |buffer_transfer| { var region = [_]vk.BufferCopy{.{ .src_offset = 0, .dst_offset = buffer_transfer.buffer_offset, .size = @intCast(vk.DeviceSize, buffer_transfer.staging_buffer.size), }}; self.device.dispatch.cmdCopyBuffer( command_buffer, buffer_transfer.staging_buffer.handle, buffer_transfer.buffer.handle, 1, &region, ); } self.previous_buffer_transfers = self.buffer_transfers; self.buffer_transfers = BufferTransferQueue.init(self.allocator); for (self.image_transfers.items) |image_transfer| { transitionImageLayout( self.device, command_buffer, image_transfer.image.handle, .@"undefined", .transfer_dst_optimal, .{}, .{ .transfer_write_bit = true }, .{ .top_of_pipe_bit = true }, .{ .transfer_bit = true }, ); var image_extent: vk.Extent3D = .{ .width = image_transfer.image.size.width, .height = image_transfer.image.size.height, .depth = 1, }; var region = [_]vk.BufferImageCopy{.{ .buffer_offset = 0, .buffer_row_length = 0, .buffer_image_height = 0, .image_subresource = .{ .aspect_mask = .{ .color_bit = true }, .mip_level = 0, .base_array_layer = 0, .layer_count = 1, }, .image_offset = .{ .x = 0, .y = 0, .z = 0 }, .image_extent = image_extent, }}; self.device.dispatch.cmdCopyBufferToImage( command_buffer, image_transfer.staging_buffer.handle, image_transfer.image.handle, .transfer_dst_optimal, 1, &region, ); transitionImageLayout( self.device, command_buffer, image_transfer.image.handle, .transfer_dst_optimal, .shader_read_only_optimal, .{ .transfer_write_bit = true }, .{ .shader_read_bit = true }, .{ .transfer_bit = true }, .{ .fragment_shader_bit = true }, ); } self.previous_image_transfers = self.image_transfers; self.image_transfers = ImageTransferQueue.init(self.allocator); } pub fn clearResources(self: *Self) void { if (self.previous_buffer_transfers) |buffer_transfers| { deleteTransferList(BufferTransferQueue, buffer_transfers); self.previous_buffer_transfers = null; } if (self.previous_image_transfers) |image_transfers| { deleteTransferList(ImageTransferQueue, image_transfers); self.previous_image_transfers = null; } } }; fn transitionImageLayout( device: Device, command_buffer: vk.CommandBuffer, image: vk.Image, old_layout: vk.ImageLayout, new_layout: vk.ImageLayout, src_access_mask: vk.AccessFlags, dst_access_mask: vk.AccessFlags, src_stage_mask: vk.PipelineStageFlags, dst_stage_mask: vk.PipelineStageFlags, ) void { var image_barrier = [_]vk.ImageMemoryBarrier{.{ .src_access_mask = src_access_mask, .dst_access_mask = dst_access_mask, .old_layout = old_layout, .new_layout = new_layout, .src_queue_family_index = vk.QUEUE_FAMILY_IGNORED, .dst_queue_family_index = vk.QUEUE_FAMILY_IGNORED, .image = image, .subresource_range = .{ .aspect_mask = .{ .color_bit = true }, .base_mip_level = 0, .level_count = 1, .base_array_layer = 0, .layer_count = 1, }, }}; device.dispatch.cmdPipelineBarrier( command_buffer, src_stage_mask, dst_stage_mask, .{}, 0, undefined, 0, undefined, 1, &image_barrier, ); } fn deleteTransferList(comptime Type: type, array_list: Type) void { for (array_list.items) |item| { item.staging_buffer.deinit(); } array_list.deinit(); }
src/transfer_queue.zig
const std = @import("std"); const ecs = @import("ecs"); const Registry = @import("ecs").Registry; const BasicGroup = @import("ecs").BasicGroup; const OwningGroup = @import("ecs").OwningGroup; const Velocity = struct { x: f32 = 0, y: f32 = 0 }; const Position = struct { x: f32 = 0, y: f32 = 0 }; const Empty = struct {}; const Sprite = struct { x: f32 = 0 }; const Transform = struct { x: f32 = 0 }; const Renderable = struct { x: f32 = 0 }; const Rotation = struct { x: f32 = 0 }; fn printStore(store: anytype, name: []const u8) void { std.debug.print("--- {} ---\n", .{name}); for (store.set.dense.items) |e, i| { std.debug.print("e[{}] s[{}]{}", .{ e, store.set.page(store.set.dense.items[i]), store.set.sparse.items[store.set.page(store.set.dense.items[i])] }); std.debug.print(" ({d:.2}) ", .{store.instances.items[i]}); } std.debug.print("\n", .{}); } test "sort BasicGroup by Entity" { var reg = Registry.init(std.testing.allocator); defer reg.deinit(); var group = reg.group(.{}, .{ Sprite, Renderable }, .{}); var i: usize = 0; while (i < 5) : (i += 1) { var e = reg.create(); reg.add(e, Sprite{ .x = @intToFloat(f32, i) }); reg.add(e, Renderable{ .x = @intToFloat(f32, i) }); } const SortContext = struct { group: BasicGroup, fn sort(this: *@This(), a: ecs.Entity, b: ecs.Entity) bool { const real_a = this.group.getConst(Sprite, a); const real_b = this.group.getConst(Sprite, b); return real_a.x > real_b.x; } }; var context = SortContext{ .group = group }; group.sort(ecs.Entity, &context, SortContext.sort); var val: f32 = 0; var iter = group.iterator(); while (iter.next()) |entity| { try std.testing.expectEqual(val, group.getConst(Sprite, entity).x); val += 1; } } test "sort BasicGroup by Component" { var reg = Registry.init(std.testing.allocator); defer reg.deinit(); var group = reg.group(.{}, .{ Sprite, Renderable }, .{}); var i: usize = 0; while (i < 5) : (i += 1) { var e = reg.create(); reg.add(e, Sprite{ .x = @intToFloat(f32, i) }); reg.add(e, Renderable{ .x = @intToFloat(f32, i) }); } const SortContext = struct { fn sort(_: void, a: Sprite, b: Sprite) bool { return a.x > b.x; } }; group.sort(Sprite, {}, SortContext.sort); var val: f32 = 0; var iter = group.iterator(); while (iter.next()) |entity| { try std.testing.expectEqual(val, group.getConst(Sprite, entity).x); val += 1; } } test "sort OwningGroup by Entity" { var reg = Registry.init(std.testing.allocator); defer reg.deinit(); var group = reg.group(.{ Sprite, Renderable }, .{}, .{}); var i: usize = 0; while (i < 5) : (i += 1) { var e = reg.create(); reg.add(e, Sprite{ .x = @intToFloat(f32, i) }); reg.add(e, Renderable{ .x = @intToFloat(f32, i) }); } const SortContext = struct { group: OwningGroup, fn sort(this: @This(), a: ecs.Entity, b: ecs.Entity) bool { const sprite_a = this.group.getConst(Sprite, a); const sprite_b = this.group.getConst(Sprite, b); return sprite_a.x > sprite_b.x; } }; const context = SortContext{ .group = group }; group.sort(ecs.Entity, context, SortContext.sort); var val: f32 = 0; var iter = group.iterator(struct { s: *Sprite, r: *Renderable }); while (iter.next()) |entity| { try std.testing.expectEqual(val, entity.s.*.x); val += 1; } } test "sort OwningGroup by Component" { var reg = Registry.init(std.testing.allocator); defer reg.deinit(); var group = reg.group(.{ Sprite, Renderable }, .{}, .{}); var i: usize = 0; while (i < 5) : (i += 1) { var e = reg.create(); reg.add(e, Sprite{ .x = @intToFloat(f32, i) }); reg.add(e, Renderable{ .x = @intToFloat(f32, i) }); } const SortContext = struct { fn sort(_: void, a: Sprite, b: Sprite) bool { return a.x > b.x; } }; group.sort(Sprite, {}, SortContext.sort); var val: f32 = 0; var iter = group.iterator(struct { s: *Sprite, r: *Renderable }); while (iter.next()) |entity| { try std.testing.expectEqual(val, entity.s.*.x); val += 1; } } test "sort OwningGroup by Component ensure unsorted non-matches" { var reg = Registry.init(std.testing.allocator); defer reg.deinit(); var group = reg.group(.{ Sprite, Renderable }, .{}, .{}); var i: usize = 0; while (i < 5) : (i += 1) { var e = reg.create(); reg.add(e, Sprite{ .x = @intToFloat(f32, i) }); reg.add(e, Renderable{ .x = @intToFloat(f32, i) }); var e2 = reg.create(); reg.add(e2, Sprite{ .x = @intToFloat(f32, i + 1 * 50) }); } try std.testing.expectEqual(group.len(), 5); try std.testing.expectEqual(reg.len(Sprite), 10); const SortContext = struct { fn sort(_: void, a: Sprite, b: Sprite) bool { // sprites with x > 50 shouldnt match in the group std.testing.expect(a.x < 50 and b.x < 50) catch unreachable; return a.x > b.x; } }; group.sort(Sprite, {}, SortContext.sort); // all the var view = reg.view(.{Sprite}, .{}); var count: usize = 0; var iter = view.iterator(); while (iter.next()) |sprite| { count += 1; // all sprite.x > 50 should be at the end and we iterate backwards if (count < 6) { try std.testing.expect(sprite.x >= 50); } } } test "nested OwningGroups add/remove components" { var reg = Registry.init(std.testing.allocator); defer reg.deinit(); var group1 = reg.group(.{Sprite}, .{Renderable}, .{}); var group2 = reg.group(.{ Sprite, Transform }, .{Renderable}, .{}); var group3 = reg.group(.{ Sprite, Transform }, .{ Renderable, Rotation }, .{}); try std.testing.expect(!reg.sortable(Sprite)); try std.testing.expect(!reg.sortable(Transform)); try std.testing.expect(reg.sortable(Renderable)); var e1 = reg.create(); reg.addTypes(e1, .{ Sprite, Renderable, Rotation }); try std.testing.expectEqual(group1.len(), 1); try std.testing.expectEqual(group2.len(), 0); try std.testing.expectEqual(group3.len(), 0); reg.add(e1, Transform{}); try std.testing.expectEqual(group3.len(), 1); reg.remove(Sprite, e1); try std.testing.expectEqual(group1.len(), 0); try std.testing.expectEqual(group2.len(), 0); try std.testing.expectEqual(group3.len(), 0); } test "nested OwningGroups entity order" { var reg = Registry.init(std.testing.allocator); defer reg.deinit(); var group1 = reg.group(.{Sprite}, .{Renderable}, .{}); var group2 = reg.group(.{ Sprite, Transform }, .{Renderable}, .{}); var i: usize = 0; while (i < 5) : (i += 1) { var e = reg.create(); reg.add(e, Sprite{ .x = @intToFloat(f32, i) }); reg.add(e, Renderable{ .x = @intToFloat(f32, i) }); } try std.testing.expectEqual(group1.len(), 5); try std.testing.expectEqual(group2.len(), 0); _ = reg.assure(Sprite); _ = reg.assure(Transform); // printStore(sprite_store, "Sprite"); reg.add(1, Transform{ .x = 1 }); // printStore(sprite_store, "Sprite"); // printStore(transform_store, "Transform"); // std.debug.print("group2.current: {}\n", .{group2.group_data.current}); }
tests/groups_test.zig
const builtin = @import("builtin"); const std = @import("std"); pub const MESSIBLE = @import("./fomu/messible.zig").MESSIBLE; pub const REBOOT = @import("./fomu/reboot.zig").REBOOT; pub const RGB = @import("./fomu/rgb.zig").RGB; pub const TIMER0 = @import("./fomu/timer0.zig").TIMER0; pub const TOUCH = @import("./fomu/touch.zig").TOUCH; pub const SYSTEM_CLOCK_FREQUENCY = 12000000; pub const start = @import("./fomu/start.zig"); // This forces start.zig file to be imported comptime { _ = start; } /// Panic function that sets LED to red and flashing + prints the panic message over messible pub fn panic(message: []const u8, stack_trace: ?*builtin.StackTrace) noreturn { @setCold(true); // Put LED into non-raw flashing mode RGB.CTRL.* = .{ .EXE = true, .CURREN = true, .RGBLEDEN = true, .RRAW = false, .GRAW = false, .BRAW = false, }; // Set colour to red RGB.setColour(255, 0, 0); // Enable the LED driver, and set 250 Hz mode. RGB.setControlRegister(.{ .enable = true, .fr = .@"250", .quick_stop = false, .outskew = false, .output_polarity = .active_high, .pwm_mode = .linear, .BRMSBEXT = 0, }); messibleOutstream.print("PANIC: {}\r\n", .{message}) catch void; while (true) { // TODO: Use @breakpoint() once https://reviews.llvm.org/D69390 is available asm volatile ("ebreak"); } } const OutStream = std.io.OutStream(error{}); pub const messibleOutstream = &OutStream{ .writeFn = struct { pub fn messibleWrite(self: *const OutStream, bytes: []const u8) error{}!void { var left: []const u8 = bytes; while (left.len > 0) { const bytes_written = MESSIBLE.write(left); left = left[bytes_written..]; } } }.messibleWrite, }; const InStream = std.io.InStream(error{}); pub const messibleInstream = &InStream{ .writeFn = struct { pub fn messibleRead(self: *const InStream, buffer: []u8) error{}!usize { while (true) { const bytes_read = MESSIBLE.read(buffer); if (bytes_read != 0) return bytes_read; } } }.messibleRead, };
riscv-zig-blink/src/fomu.zig
const std = @import("std"); const print = std.debug.print; const verbose = true; pub fn Testcase( comptime func: @TypeOf(std.math.exp), comptime name: []const u8, comptime float_type: type, ) type { if (@typeInfo(float_type) != .Float) @compileError("Expected float type"); return struct { const F: type = float_type; input: F, exp_output: F, const bits = std.meta.bitCount(F); const U: type = std.meta.Int(.unsigned, bits); pub fn run(tc: @This()) !void { const hex_bits_fmt_size = comptime std.fmt.comptimePrint("{d}", .{bits / 4}); const hex_float_fmt_size = switch (bits) { 16 => "10", 32 => "16", 64 => "24", 128 => "40", else => unreachable, }; const input_bits = @bitCast(U, tc.input); if (verbose) { print( " IN: 0x{X:0>" ++ hex_bits_fmt_size ++ "} " ++ "{[1]x:<" ++ hex_float_fmt_size ++ "} {[1]e}\n", .{ input_bits, tc.input }, ); } const output = func(tc.input); const output_bits = @bitCast(U, output); if (verbose) { print( "OUT: 0x{X:0>" ++ hex_bits_fmt_size ++ "} " ++ "{[1]x:<" ++ hex_float_fmt_size ++ "} {[1]e}\n", .{ output_bits, output }, ); } const exp_output_bits = @bitCast(U, tc.exp_output); // Compare bits rather than values so that NaN compares correctly. if (output_bits != exp_output_bits) { if (verbose) { print( "EXP: 0x{X:0>" ++ hex_bits_fmt_size ++ "} " ++ "{[1]x:<" ++ hex_float_fmt_size ++ "} {[1]e}\n", .{ exp_output_bits, tc.exp_output }, ); } print( "FAILURE: expected {s}({x})->{x}, got {x} ({d}-bit)\n", .{ name, tc.input, tc.exp_output, output, bits }, ); return error.TestExpectedEqual; } } }; } pub fn runTests(tests: anytype) !void { var failures: usize = 0; print("\n", .{}); for (tests) |tc| { tc.run() catch { failures += 1; }; print("\n", .{}); } if (failures > 0) return error.Failure; }
tests/util.zig
const builtin = @import("builtin"); const clz = @import("count0bits.zig"); const testing = @import("std").testing; fn test__clzsi2(a: u32, expected: i32) !void { // stage1 and stage2 diverge on function pointer semantics switch (builtin.zig_backend) { .stage1 => { // Use of `var` here is working around a stage1 bug. var nakedClzsi2 = clz.__clzsi2; var actualClzsi2 = @ptrCast(fn (a: i32) callconv(.C) i32, nakedClzsi2); var x = @bitCast(i32, a); var result = actualClzsi2(x); try testing.expectEqual(expected, result); }, else => { const nakedClzsi2 = clz.__clzsi2; const actualClzsi2 = @ptrCast(*const fn (a: i32) callconv(.C) i32, &nakedClzsi2); const x = @bitCast(i32, a); const result = actualClzsi2(x); try testing.expectEqual(expected, result); }, } } test "clzsi2" { try test__clzsi2(0x00800000, 8); try test__clzsi2(0x01000000, 7); try test__clzsi2(0x02000000, 6); try test__clzsi2(0x03000000, 6); try test__clzsi2(0x04000000, 5); try test__clzsi2(0x05000000, 5); try test__clzsi2(0x06000000, 5); try test__clzsi2(0x07000000, 5); try test__clzsi2(0x08000000, 4); try test__clzsi2(0x09000000, 4); try test__clzsi2(0x0A000000, 4); try test__clzsi2(0x0B000000, 4); try test__clzsi2(0x0C000000, 4); try test__clzsi2(0x0D000000, 4); try test__clzsi2(0x0E000000, 4); try test__clzsi2(0x0F000000, 4); try test__clzsi2(0x10000000, 3); try test__clzsi2(0x11000000, 3); try test__clzsi2(0x12000000, 3); try test__clzsi2(0x13000000, 3); try test__clzsi2(0x14000000, 3); try test__clzsi2(0x15000000, 3); try test__clzsi2(0x16000000, 3); try test__clzsi2(0x17000000, 3); try test__clzsi2(0x18000000, 3); try test__clzsi2(0x19000000, 3); try test__clzsi2(0x1A000000, 3); try test__clzsi2(0x1B000000, 3); try test__clzsi2(0x1C000000, 3); try test__clzsi2(0x1D000000, 3); try test__clzsi2(0x1E000000, 3); try test__clzsi2(0x1F000000, 3); try test__clzsi2(0x20000000, 2); try test__clzsi2(0x21000000, 2); try test__clzsi2(0x22000000, 2); try test__clzsi2(0x23000000, 2); try test__clzsi2(0x24000000, 2); try test__clzsi2(0x25000000, 2); try test__clzsi2(0x26000000, 2); try test__clzsi2(0x27000000, 2); try test__clzsi2(0x28000000, 2); try test__clzsi2(0x29000000, 2); try test__clzsi2(0x2A000000, 2); try test__clzsi2(0x2B000000, 2); try test__clzsi2(0x2C000000, 2); try test__clzsi2(0x2D000000, 2); try test__clzsi2(0x2E000000, 2); try test__clzsi2(0x2F000000, 2); try test__clzsi2(0x30000000, 2); try test__clzsi2(0x31000000, 2); try test__clzsi2(0x32000000, 2); try test__clzsi2(0x33000000, 2); try test__clzsi2(0x34000000, 2); try test__clzsi2(0x35000000, 2); try test__clzsi2(0x36000000, 2); try test__clzsi2(0x37000000, 2); try test__clzsi2(0x38000000, 2); try test__clzsi2(0x39000000, 2); try test__clzsi2(0x3A000000, 2); try test__clzsi2(0x3B000000, 2); try test__clzsi2(0x3C000000, 2); try test__clzsi2(0x3D000000, 2); try test__clzsi2(0x3E000000, 2); try test__clzsi2(0x3F000000, 2); try test__clzsi2(0x40000000, 1); try test__clzsi2(0x41000000, 1); try test__clzsi2(0x42000000, 1); try test__clzsi2(0x43000000, 1); try test__clzsi2(0x44000000, 1); try test__clzsi2(0x45000000, 1); try test__clzsi2(0x46000000, 1); try test__clzsi2(0x47000000, 1); try test__clzsi2(0x48000000, 1); try test__clzsi2(0x49000000, 1); try test__clzsi2(0x4A000000, 1); try test__clzsi2(0x4B000000, 1); try test__clzsi2(0x4C000000, 1); try test__clzsi2(0x4D000000, 1); try test__clzsi2(0x4E000000, 1); try test__clzsi2(0x4F000000, 1); try test__clzsi2(0x50000000, 1); try test__clzsi2(0x51000000, 1); try test__clzsi2(0x52000000, 1); try test__clzsi2(0x53000000, 1); try test__clzsi2(0x54000000, 1); try test__clzsi2(0x55000000, 1); try test__clzsi2(0x56000000, 1); try test__clzsi2(0x57000000, 1); try test__clzsi2(0x58000000, 1); try test__clzsi2(0x59000000, 1); try test__clzsi2(0x5A000000, 1); try test__clzsi2(0x5B000000, 1); try test__clzsi2(0x5C000000, 1); try test__clzsi2(0x5D000000, 1); try test__clzsi2(0x5E000000, 1); try test__clzsi2(0x5F000000, 1); try test__clzsi2(0x60000000, 1); try test__clzsi2(0x61000000, 1); try test__clzsi2(0x62000000, 1); try test__clzsi2(0x63000000, 1); try test__clzsi2(0x64000000, 1); try test__clzsi2(0x65000000, 1); try test__clzsi2(0x66000000, 1); try test__clzsi2(0x67000000, 1); try test__clzsi2(0x68000000, 1); try test__clzsi2(0x69000000, 1); try test__clzsi2(0x6A000000, 1); try test__clzsi2(0x6B000000, 1); try test__clzsi2(0x6C000000, 1); try test__clzsi2(0x6D000000, 1); try test__clzsi2(0x6E000000, 1); try test__clzsi2(0x6F000000, 1); try test__clzsi2(0x70000000, 1); try test__clzsi2(0x71000000, 1); try test__clzsi2(0x72000000, 1); try test__clzsi2(0x73000000, 1); try test__clzsi2(0x74000000, 1); try test__clzsi2(0x75000000, 1); try test__clzsi2(0x76000000, 1); try test__clzsi2(0x77000000, 1); try test__clzsi2(0x78000000, 1); try test__clzsi2(0x79000000, 1); try test__clzsi2(0x7A000000, 1); try test__clzsi2(0x7B000000, 1); try test__clzsi2(0x7C000000, 1); try test__clzsi2(0x7D000000, 1); try test__clzsi2(0x7E000000, 1); try test__clzsi2(0x7F000000, 1); try test__clzsi2(0x80000000, 0); try test__clzsi2(0x81000000, 0); try test__clzsi2(0x82000000, 0); try test__clzsi2(0x83000000, 0); try test__clzsi2(0x84000000, 0); try test__clzsi2(0x85000000, 0); try test__clzsi2(0x86000000, 0); try test__clzsi2(0x87000000, 0); try test__clzsi2(0x88000000, 0); try test__clzsi2(0x89000000, 0); try test__clzsi2(0x8A000000, 0); try test__clzsi2(0x8B000000, 0); try test__clzsi2(0x8C000000, 0); try test__clzsi2(0x8D000000, 0); try test__clzsi2(0x8E000000, 0); try test__clzsi2(0x8F000000, 0); try test__clzsi2(0x90000000, 0); try test__clzsi2(0x91000000, 0); try test__clzsi2(0x92000000, 0); try test__clzsi2(0x93000000, 0); try test__clzsi2(0x94000000, 0); try test__clzsi2(0x95000000, 0); try test__clzsi2(0x96000000, 0); try test__clzsi2(0x97000000, 0); try test__clzsi2(0x98000000, 0); try test__clzsi2(0x99000000, 0); try test__clzsi2(0x9A000000, 0); try test__clzsi2(0x9B000000, 0); try test__clzsi2(0x9C000000, 0); try test__clzsi2(0x9D000000, 0); try test__clzsi2(0x9E000000, 0); try test__clzsi2(0x9F000000, 0); try test__clzsi2(0xA0000000, 0); try test__clzsi2(0xA1000000, 0); try test__clzsi2(0xA2000000, 0); try test__clzsi2(0xA3000000, 0); try test__clzsi2(0xA4000000, 0); try test__clzsi2(0xA5000000, 0); try test__clzsi2(0xA6000000, 0); try test__clzsi2(0xA7000000, 0); try test__clzsi2(0xA8000000, 0); try test__clzsi2(0xA9000000, 0); try test__clzsi2(0xAA000000, 0); try test__clzsi2(0xAB000000, 0); try test__clzsi2(0xAC000000, 0); try test__clzsi2(0xAD000000, 0); try test__clzsi2(0xAE000000, 0); try test__clzsi2(0xAF000000, 0); try test__clzsi2(0xB0000000, 0); try test__clzsi2(0xB1000000, 0); try test__clzsi2(0xB2000000, 0); try test__clzsi2(0xB3000000, 0); try test__clzsi2(0xB4000000, 0); try test__clzsi2(0xB5000000, 0); try test__clzsi2(0xB6000000, 0); try test__clzsi2(0xB7000000, 0); try test__clzsi2(0xB8000000, 0); try test__clzsi2(0xB9000000, 0); try test__clzsi2(0xBA000000, 0); try test__clzsi2(0xBB000000, 0); try test__clzsi2(0xBC000000, 0); try test__clzsi2(0xBD000000, 0); try test__clzsi2(0xBE000000, 0); try test__clzsi2(0xBF000000, 0); try test__clzsi2(0xC0000000, 0); try test__clzsi2(0xC1000000, 0); try test__clzsi2(0xC2000000, 0); try test__clzsi2(0xC3000000, 0); try test__clzsi2(0xC4000000, 0); try test__clzsi2(0xC5000000, 0); try test__clzsi2(0xC6000000, 0); try test__clzsi2(0xC7000000, 0); try test__clzsi2(0xC8000000, 0); try test__clzsi2(0xC9000000, 0); try test__clzsi2(0xCA000000, 0); try test__clzsi2(0xCB000000, 0); try test__clzsi2(0xCC000000, 0); try test__clzsi2(0xCD000000, 0); try test__clzsi2(0xCE000000, 0); try test__clzsi2(0xCF000000, 0); try test__clzsi2(0xD0000000, 0); try test__clzsi2(0xD1000000, 0); try test__clzsi2(0xD2000000, 0); try test__clzsi2(0xD3000000, 0); try test__clzsi2(0xD4000000, 0); try test__clzsi2(0xD5000000, 0); try test__clzsi2(0xD6000000, 0); try test__clzsi2(0xD7000000, 0); try test__clzsi2(0xD8000000, 0); try test__clzsi2(0xD9000000, 0); try test__clzsi2(0xDA000000, 0); try test__clzsi2(0xDB000000, 0); try test__clzsi2(0xDC000000, 0); try test__clzsi2(0xDD000000, 0); try test__clzsi2(0xDE000000, 0); try test__clzsi2(0xDF000000, 0); try test__clzsi2(0xE0000000, 0); try test__clzsi2(0xE1000000, 0); try test__clzsi2(0xE2000000, 0); try test__clzsi2(0xE3000000, 0); try test__clzsi2(0xE4000000, 0); try test__clzsi2(0xE5000000, 0); try test__clzsi2(0xE6000000, 0); try test__clzsi2(0xE7000000, 0); try test__clzsi2(0xE8000000, 0); try test__clzsi2(0xE9000000, 0); try test__clzsi2(0xEA000000, 0); try test__clzsi2(0xEB000000, 0); try test__clzsi2(0xEC000000, 0); try test__clzsi2(0xED000000, 0); try test__clzsi2(0xEE000000, 0); try test__clzsi2(0xEF000000, 0); try test__clzsi2(0xF0000000, 0); try test__clzsi2(0xF1000000, 0); try test__clzsi2(0xF2000000, 0); try test__clzsi2(0xF3000000, 0); try test__clzsi2(0xF4000000, 0); try test__clzsi2(0xF5000000, 0); try test__clzsi2(0xF6000000, 0); try test__clzsi2(0xF7000000, 0); try test__clzsi2(0xF8000000, 0); try test__clzsi2(0xF9000000, 0); try test__clzsi2(0xFA000000, 0); try test__clzsi2(0xFB000000, 0); try test__clzsi2(0xFC000000, 0); try test__clzsi2(0xFD000000, 0); try test__clzsi2(0xFE000000, 0); try test__clzsi2(0xFF000000, 0); // arm and thumb1 assume input a != 0 //try test__clzsi2(0x00000000, 32); try test__clzsi2(0x00000001, 31); try test__clzsi2(0x00000002, 30); try test__clzsi2(0x00000004, 29); try test__clzsi2(0x00000008, 28); try test__clzsi2(0x00000010, 27); try test__clzsi2(0x00000020, 26); try test__clzsi2(0x00000040, 25); try test__clzsi2(0x00000080, 24); try test__clzsi2(0x00000100, 23); try test__clzsi2(0x00000200, 22); try test__clzsi2(0x00000400, 21); try test__clzsi2(0x00000800, 20); try test__clzsi2(0x00001000, 19); try test__clzsi2(0x00002000, 18); try test__clzsi2(0x00004000, 17); try test__clzsi2(0x00008000, 16); try test__clzsi2(0x00010000, 15); try test__clzsi2(0x00020000, 14); try test__clzsi2(0x00040000, 13); try test__clzsi2(0x00080000, 12); try test__clzsi2(0x00100000, 11); try test__clzsi2(0x00200000, 10); try test__clzsi2(0x00400000, 9); }
lib/compiler_rt/clzsi2_test.zig
const std = @import("std"); const expect = std.testing.expect; /// Anchor for non-ELF kernels pub const Anchor = packed struct { anchor: [15]u8 = "STIVALE2 ANCHOR", bits: u8, phys_load_addr: u64, phys_bss_start: u64, phys_bss_end: u64, phys_stivale2hdr: u64, }; /// A tag containing a unique identifier, which must belong to a type which is a u64, non-exhaustive enum. pub fn TagGeneric(comptime Id: type) type { if (@typeInfo(Id) != .Enum) @compileError("Tag identifier must be an enum"); if (@typeInfo(Id).Enum.tag_type != u64) @compileError("Tag identifier enum tag type isn't u64"); if (@typeInfo(Id).Enum.is_exhaustive) @compileError("Tag identifier must be a non-exhaustive enum"); return packed struct { const Self = @This(); /// The unique identifier of the tag identifier: Id, /// The next tag in the linked list next: ?*const Self = null, }; } test "TagGeneric" { const Identifier = enum(u64) { hello = 0x0, world = 0x1, _, }; const Tag = TagGeneric(Identifier); try expect(@bitSizeOf(Tag) == 128); } /// The Header contains information passed from the kernel to the bootloader. /// The kernel must have a section `.stivale2hdr` either containing a header, or an anchor pointing to one. pub const Header = packed struct { /// The address to be jumped to as the entry point of the kernel. If 0, the ELF entry point will be used. entry_point: ?fn (*const Struct) callconv(.C) noreturn = null, /// The stack address which will be in ESP/RSP when the kernel is loaded. /// The stack must be at least 256 bytes, and must have a 16 byte aligned address. stack: ?*u8, flags: Flags, /// Pointer to the first tag of the linked list of header tags. tags: ?*const Tag, pub const Flags = packed struct { /// Reserved and unused reserved: u1 = 0, /// If set, all pointers are to be offset to the higher half. higher_half: u1 = 0, /// If set, enables protected memory ranges. pmr: u1 = 0, /// If set, enables fully virtual kernel mapping for PMRs. fully_virtual_mapping: u1 = 0, /// Do NOT fail to boot if low memory area could not be allocated. THIS SHOULD ALWAYS BE SET AS THIS /// FUNCTIONALITY IS DEPRECATED. boot_if_lma_fail: u1 = 1, /// Undefined and must be set to 0. zeros: u59 = 0, }; pub const Tag = TagGeneric(Identifier); /// Unique identifiers for each header tag pub const Identifier = enum(u64) { any_video = 0xc75c9fa92a44c4db, framebuffer = 0x3ecc1bc43d0f7971, framebuffer_mtrr = 0x4c7bb07731282e00, terminal = 0xa85d499b1823be72, smp = 0x1ab015085f3273df, five_level_paging = 0x932f477032007e8f, slide_hddm = 0xdc29269c2af53d1d, unmap_null = 0x92919432b16fe7e7, _, }; /// This tag tells the bootloader that the kernel has no requirement for a framebuffer to be initialised. /// Using neither this tag nor `FramebufferTag` means "force CGA text mode", and the bootloader will /// refuse to boot the kernel if that cannot be fulfilled. pub const AnyVideoTag = packed struct { tag: Tag = .{ .identifier = .any_video }, preference: Preference, pub const Preference = enum(u64) { linear = 0, no_linear = 1, }; }; /// This tag tells the bootloader framebuffer preferences. If used without `AnyVideo`, the bootloader /// will refuse to boot the kernel if a framebuffer cannot be initialised. Using neither means force CGA /// text mode, and the bootloader will refuse to boot the kernel if that cannot be fulfilled. pub const FramebufferTag = packed struct { tag: Tag = .{ .identifier = .framebuffer }, width: u16 = 0, height: u16 = 0, bpp: u16 = 0, unused: u16 = 0, }; /// **WARNING:** This tag is deprecated. Use is discouraged and may not be supported on newer bootloaders! /// This tag tells the bootloader to set up MTRR write-combining for the framebuffer. pub const FramebufferMtrrTag = packed struct { tag: Tag = .{ .identifier = .framebuffer_mtrr }, }; /// This tag tells the bootloader to set up a terminal for the kernel. The terminal may run in framebuffer /// or text mode. pub const TerminalTag = packed struct { tag: Tag = .{ .identifier = .terminal }, flags: @This().Flags = .{}, /// Address of the terminal callback function callback: ?fn (CallbackType, u64, u64, u64) callconv(.C) void = null, pub const Flags = packed struct { /// Set if a callback function is provided callback: u1 = 0, /// Undefined and must be set to 0. zeros: u63 = 0, }; /// These are the possible types which the terminal callback function may have to deal with. pub const CallbackType = enum(u64) { dec = 10, bell = 20, private_id = 30, status_report = 40, pos_report = 50, kbd_leds = 60, mode = 70, linux = 80, }; }; /// This tag enables support for booting up application processors. pub const SmpTag = packed struct { tag: Tag = .{ .identifier = .smp }, flags: @This().Flags = .{}, pub const Flags = packed struct { /// Use xAPIC xapic: u1 = 0, /// Use x2APIC if possible x2apic: u1 = 0, /// Undefined and must be set to 0. zeros: u62 = 0, }; }; /// This tag enables support for 5-level paging, if available. pub const FiveLevelPagingTag = packed struct { tag: Tag = .{ .identifier = .five_level_paging }, }; /// This tag tells the bootloader to add a random slide to the base address of the higher half direct map (HHDM) pub const SlideHhdmTag = packed struct { tag: Tag = .{ .identifier = .slide_hhdm }, flags: @This().Flags = .{}, /// Desired alignment for base address of the HHDM. Must be non-0 and aligned to 2MiB. alignment: u64, pub const Flags = packed struct { /// Undefined and must be set to 0. zeros: u64 = 0, }; }; /// This tag tells the bootloader to unmap the first page of the virtual address space. pub const UnmapNullTag = packed struct { tag: Tag = .{ .identifier = .unmap_null }, }; comptime { std.testing.refAllDecls(@This()); } }; test "Header Size" { try expect(@bitSizeOf(Header) == 256); } test "Header Tag Sizes" { try expect(@bitSizeOf(Header.AnyVideoTag) == 192); try expect(@bitSizeOf(Header.FramebufferTag) == 192); try expect(@bitSizeOf(Header.FramebufferMtrrTag) == 128); try expect(@bitSizeOf(Header.TerminalTag) == 256); try expect(@bitSizeOf(Header.SmpTag) == 192); try expect(@bitSizeOf(Header.FiveLevelPagingTag) == 128); try expect(@bitSizeOf(Header.SlideHhdmTag) == 256); try expect(@bitSizeOf(Header.UnmapNullTag) == 128); } /// The Struct contains information passed from the bootloader to the kernel. /// A pointer to this is passed to the kernel as an argument to the entry point. pub const Struct = packed struct { /// Null terminated ASCII string bootloader_brand: [64]u8, /// Null terminated ASCII string bootloader_version: [64]u8, /// Pointer to the first tag of the linked list of tags. tags: ?*const Tag = null, pub const Tag = TagGeneric(Identifier); /// Unique identifiers for each struct tag pub const Identifier = enum(u64) { pmrs = 0x5df266a64047b6bd, cmdline = 0xe5e76a1b4597a781, memmap = 0x2187f79e8612de07, framebuffer = 0x506461d2950408fa, framebuffer_mtrr = 0x6bc1a78ebe871172, textmode = 0x38d74c23e0dca893, edid = 0x968609d7af96b845, terminal = 0xc2b3f4c3233b0974, modules = 0x4b6fe466aade04ce, rsdp = 0x9e1786930a375e78, smbios = 0x274bd246c62bf7d1, epoch = 0x566a7bed888e1407, firmware = 0x359d837855e3858c, efi_system_table = 0x4bc5ec15845b558e, kernel_file = 0xe599d90c2975584a, kernel_file_v2 = 0x37c13018a02c6ea2, boot_volume = 0x9b4358364c19ee62, kernel_slide = 0xee80847d01506c57, smp = 0x34d1d96339647025, pxe_server_info = 0x29d1e96239247032, mmio32_uart = 0xb813f9b8dbc78797, dtb = 0xabb29bd49a2833fa, hhdm = 0xb0ed257db18cb58f, _, }; /// This struct contains all detected tags, returned by `Struct.parse()` pub const Parsed = struct { bootloader_brand: []const u8, bootloader_version: []const u8, first: ?*const Tag = null, pmrs: ?*const PmrsTag = null, cmdline: ?*const CmdlineTag = null, memmap: ?*const MemmapTag = null, framebuffer: ?*const FramebufferTag = null, framebuffer_mtrr: ?*const FramebufferMtrrTag = null, textmode: ?*const TextModeTag = null, edid: ?*const EdidTag = null, terminal: ?*const TerminalTag = null, modules: ?*const ModulesTag = null, rsdp: ?*const RsdpTag = null, smbios: ?*const SmbiosTag = null, epoch: ?*const EpochTag = null, firmware: ?*const FirmwareTag = null, efi_system_table: ?*const EfiSystemTableTag = null, kernel_file: ?*const KernelFileTag = null, kernel_file_v2: ?*const KernelFileV2Tag = null, boot_volume: ?*const BootVolumeTag = null, kernel_slide: ?*const KernelSlideTag = null, smp: ?*const SmpTag = null, pxe_server_info: ?*const PxeServerInfoTag = null, mmio32_uart: ?*const Mmio32UartTag = null, dtb: ?*const DtbTag = null, hhdm: ?*const HhdmTag = null, }; /// Returns `Struct.Parsed`, filled with all detected tags pub fn parse(self: *const Struct) Parsed { var parsed = Parsed{ .bootloader_brand = std.mem.sliceTo(&self.bootloader_brand, 0), .bootloader_version = std.mem.sliceTo(&self.bootloader_version, 0), .first = self.tags, }; var tag_opt = self.tags; while (tag_opt) |tag| : (tag_opt = tag.next) { switch (tag.identifier) { .pmrs => parsed.pmrs = @ptrCast(*const PmrsTag, tag), .cmdline => parsed.cmdline = @ptrCast(*const CmdlineTag, tag), .memmap => parsed.memmap = @ptrCast(*const MemmapTag, tag), .framebuffer => parsed.framebuffer = @ptrCast(*const FramebufferTag, tag), .framebuffer_mtrr => parsed.framebuffer_mtrr = @ptrCast(*const FramebufferMtrrTag, tag), .textmode => parsed.textmode = @ptrCast(*const TextModeTag, tag), .edid => parsed.edid = @ptrCast(*const EdidTag, tag), .terminal => parsed.terminal = @ptrCast(*const TerminalTag, tag), .modules => parsed.modules = @ptrCast(*const ModulesTag, tag), .rsdp => parsed.rsdp = @ptrCast(*const RsdpTag, tag), .smbios => parsed.smbios = @ptrCast(*const SmbiosTag, tag), .epoch => parsed.epoch = @ptrCast(*const EpochTag, tag), .firmware => parsed.firmware = @ptrCast(*const FirmwareTag, tag), .efi_system_table => parsed.efi_system_table = @ptrCast(*const EfiSystemTableTag, tag), .kernel_file => parsed.kernel_file = @ptrCast(*const KernelFileTag, tag), .kernel_file_v2 => parsed.kernel_file_v2 = @ptrCast(*const KernelFileV2Tag, tag), .boot_volume => parsed.boot_volume = @ptrCast(*const BootVolumeTag, tag), .kernel_slide => parsed.kernel_slide = @ptrCast(*const KernelSlideTag, tag), .smp => parsed.smp = @ptrCast(*const SmpTag, tag), .pxe_server_info => parsed.pxe_server_info = @ptrCast(*const PxeServerInfoTag, tag), .mmio32_uart => parsed.mmio32_uart = @ptrCast(*const Mmio32UartTag, tag), .dtb => parsed.dtb = @ptrCast(*const DtbTag, tag), .hhdm => parsed.hhdm = @ptrCast(*const HhdmTag, tag), _ => {}, // Ignore unknown tags } } return parsed; } /// This tag tells the kernel that the PMR flag in the header was recognised and that the kernel has been /// successfully mapped by its ELF segments. It also provides the array of ranges and their corresponding /// permissions. pub const PmrsTag = packed struct { tag: Tag = .{ .identifier = .pmrs }, /// Number of entries in array entries: u64, /// Returns array of Pmr structs pub fn getPmrs(self: *const PmrsTag) []const Pmr { return @intToPtr([*]const Pmr, @ptrToInt(&self.entries) + 8)[0..self.entries]; } }; pub const Pmr = packed struct { base: u64, length: u64, permissions: Permissions, pub const Permissions = packed struct { executable: u1, writable: u1, readable: u1, unused: u61, }; }; /// This tag provides the kernel with the command line string. pub const CmdlineTag = packed struct { tag: Tag = .{ .identifier = .cmdline }, /// Null-terminated array cmdline: [*:0]const u8, pub fn asSlice(self: *const CmdlineTag) []const u8 { return std.mem.sliceTo(self.cmdline, 0); } }; /// This tag provides the kernel with the memory map. pub const MemmapTag = packed struct { tag: Tag = .{ .identifier = .memmap }, /// Number of entries in array entries: u64, /// Returns array of `MemmapEntry` structs pub fn getMemmap(self: *const MemmapTag) []const MemmapEntry { return @intToPtr([*]const MemmapEntry, @ptrToInt(&self.entries) + 8)[0..self.entries]; } }; pub const MemmapEntry = packed struct { /// Physical address of the base of the memory section base: u64, /// Length of the memory section length: u64, type: Type, unused: u32, pub const Type = enum(u32) { usable = 1, reserved = 2, acpi_reclaimable = 3, acpi_nvs = 4, bad_memory = 5, bootloader_reclaimable = 0x1000, kernel_and_modules = 0x1001, framebuffer = 0x1002, }; }; /// This tag provides the kernel with details of the currently set-up framebuffer, if any pub const FramebufferTag = packed struct { tag: Tag = .{ .identifier = .framebuffer }, /// The address of the framebuffer address: u64, /// Width and height of the framebuffer in pixels width: u16, height: u16, /// Pitch in bytes pitch: u16, /// Bits per pixel bpp: u16, memory_model: MemoryModel, red_mask_size: u8, red_mask_shift: u8, green_mask_size: u8, green_mask_shift: u8, blue_mask_size: u8, blue_mask_shift: u8, unused: u8, pub const MemoryModel = enum(u8) { rgb = 1, _, }; }; /// **WARNING:** This tag is deprecated. Use is discouraged and may not be supported on newer bootloaders! /// This tag signals to the kernel that MTRR write-combining for the framebuffer was enabled. pub const FramebufferMtrrTag = packed struct { tag: Tag = .{ .identifier = .framebuffer_mtrr }, }; /// This tag provides the kernel with details of the currently set up CGA text mode, if any. pub const TextModeTag = packed struct { tag: Tag = .{ .identifier = .textmode }, /// The address of the text mode buffer address: u64, unused: u16, rows: u16, columns: u16, bytes_per_char: u16, }; /// This tag provides the kernel with EDID information. pub const EdidTag = packed struct { tag: Tag = .{ .identifier = .edid }, /// The number of bytes in the array edid_size: u64, /// Returns edid information pub fn getEdidInformation(self: *const EdidTag) []const u8 { return @intToPtr([*]u8, @ptrToInt(&self.edid_size) + 8)[0..self.edid_size]; } }; /// This tag provides the kernel with the entry point of the `stivale2_term_write()` function, if it was /// requested, and supported by the bootloader. pub const TerminalTag = packed struct { tag: Tag = .{ .identifier = .terminal }, flags: Flags, cols: u16, rows: u16, /// Pointer to the entry point of the `stivale2_term_write()` function. term_write: fn (ptr: [*]const u8, length: u64) callconv(.C) void, /// If `Flags.max_length` is set, this field specifies the maximum allowed string length to be passed /// to `term_write()`. If this is 0, then there is limit. max_length: u64, pub const Flags = packed struct { /// If set, cols and rows are provided cols_and_rows: u1, /// If not set, assume a max_length of 1024 max_length: u1, /// If the callback was requested and supported by the bootloader, this is set callback: u1, /// If set, context control is available context_control: u1, unused: u28, }; pub const Writer = struct { context: TerminalTag, pub const Error = error{}; // No errors can be returned, but this is necessary anyway to be a valid writer... pub fn write(self: Writer, bytes: []const u8) !usize { self.context.write(bytes); return bytes.len; } pub fn writeAll(self: Writer, bytes: []const u8) !void { _ = try self.write(bytes); } pub fn print(self: Writer, comptime format: []const u8, args: anytype) !void { return std.fmt.format(self, format, args); } pub fn writeByte(self: Writer, byte: u8) !void { _ = try self.write(&[_]u8{byte}); } pub fn writeByteNTimes(self: Writer, byte: u8, n: usize) !void { var bytes: [256]u8 = undefined; std.mem.set(u8, bytes[0..], byte); var remaining: usize = n; while (remaining > 0) { const to_write = std.math.min(remaining, bytes.len); try self.writeAll(bytes[0..to_write]); remaining -= to_write; } } }; pub fn writer(self: TerminalTag) Writer { return Writer{ .context = self }; } pub fn write(self: TerminalTag, bytes: []const u8) void { self.term_write(bytes.ptr, bytes.len); } pub fn print(self: TerminalTag, comptime format: []const u8, args: anytype) void { self.writer().print(format, args) catch unreachable; } }; /// This tag provides the kernel with a list of modules loaded alongside the kernel. pub const ModulesTag = packed struct { tag: Tag = .{ .identifier = .modules }, /// Number of modules in the array module_count: u64, /// Returns array of `Module` structs pub fn getModules(self: *const ModulesTag) []const Module { return @intToPtr([*]const Module, @ptrToInt(&self.module_count) + 8)[0..self.module_count]; } }; pub const Module = packed struct { /// Address where the module is loaded begin: u64, /// End address of the module end: u64, /// ASCII null-terminated string passed to the module string: [128]u8, pub fn getString(self: *const Module) []const u8 { return std.mem.sliceTo(&self.string, 0); } }; /// This tag provides the kernel with the location of the ACPI RSDP structure pub const RsdpTag = packed struct { tag: Tag = .{ .identifier = .rsdp }, /// Address of the ACPI RSDP structure rsdp: u64, }; /// This tag provides the kernel with the location of SMBIOS entry points in memory pub const SmbiosTag = packed struct { tag: Tag = .{ .identifier = .smbios }, /// Flags are for future use and currently all unused flags: Flags, /// 32-bit SMBIOS entry point address, 0 if unavailable smbios_entry_32: u64, /// 64-bit SMBIOS entry point address, 0 if unavailable smbios_entry_64: u64, pub const Flags = packed struct { unused: u64, }; }; /// This tag provides the kernel with the current UNIX epoch pub const EpochTag = packed struct { tag: Tag = .{ .identifier = .epoch }, /// UNIX epoch at boot, read from RTC epoch: u64, }; /// This tag provides the kernel with info about the firmware pub const FirmwareTag = packed struct { tag: Tag = .{ .identifier = .firmware }, flags: Flags, pub const Flags = packed struct { /// If set, BIOS, if unset, UEFI bios: u1, unused: u63, }; }; /// This tag provides the kernel with a pointer to the EFI system table if available pub const EfiSystemTableTag = packed struct { tag: Tag = .{ .identifier = .efi_system_table }, /// Address of the EFI system table system_table: u64, }; /// This tag provides the kernel with a pointer to a copy of the executable file of the kernel pub const KernelFileTag = packed struct { tag: Tag = .{ .identifier = .kernel_file }, /// Address of the kernel file kernel_file: [*]const u8, }; /// This tag provides the kernel with a pointer to a copy of the executable file of the kernel, along with /// the size of the file pub const KernelFileV2Tag = packed struct { tag: Tag = .{ .identifier = .kernel_file_v2 }, /// Address of the kernel file kernel_file: [*]const u8, /// Size of the kernel file kernel_size: u64, /// Returns a slice over the kernel file pub fn asSlice(self: KernelFileV2Tag) []const u8 { return self.kernel_file[0..self.kernel_size]; } }; /// This tag provides the GUID and partition GUID of the volume from which the kernel was loaded, if available pub const BootVolumeTag = packed struct { tag: Tag = .{ .identifier = .boot_volume }, flags: Flags, /// GUID -- valid when flags.guid_valid is set guid: Guid, /// Partition GUID -- valid when flags.part_guid_valid is set part_guid: Guid, pub const Flags = packed struct { /// Set if GUID is valid guid_valid: u1, /// Set if partition GUID is valid part_guid_valid: u1, unused: u62, }; pub const Guid = packed struct { a: u32, b: u16, c: u16, d: [8]u8, }; }; /// This tag provides the kernel with the slide that the bootloader has applied to the kernel's address pub const KernelSlideTag = packed struct { tag: Tag = .{ .identifier = .kernel_slide }, kernel_slide: u64, }; /// This tag provides the kernel with info about a multiprocessor environment pub const SmpTag = packed struct { tag: Tag = .{ .identifier = .smp }, flags: Flags, /// LAPIC ID of the BSP bsp_lapic_id: u32, unused: u32, /// Total number of logical CPUs (incl BSP) cpu_count: u64, /// Returns array of `SmpInfo` structs pub fn getSmpInfo(self: *const SmpTag) []const SmpInfo { return @intToPtr([*]const SmpInfo, @ptrToInt(&self.cpu_count) + 8)[0..self.cpu_count]; } pub const Flags = packed struct { /// Set if x2APIC was requested, supported, and sucessfully enabled x2apic: u1, unused: u63, }; }; pub const SmpInfo = packed struct { /// ACPI processor UID as specified by MADT processor_id: u32, /// LAPIC ID as specified by MADT lapic_id: u32, /// The stack that will be loaded in ESP/RSP once the goto_address field is loaded. This **MUST** point /// to a valid stack of at least 256 bytes in size, and 16-byte aligned. `target_stack` is unused for /// the struct describing the BSP. target_stack: u64, /// This field is polled by the started APs until the kernel on another CPU performs a write to this field. /// When that happens, bootloader code will load up ESP/RSP with the stack value specified in /// `target_stack`. It will then proceed to load a pointer to this structure in either RDI for 64-bit, or /// onto the stack for 32-bit. Then, `goto_address` is called, and execution is handed off. goto_address: u64, /// This field is here for the kernel to use for whatever it wants. Writes here should be performed before /// writing to `goto_address`. extra_argument: u64, }; /// This tag provides the kernel with the server ip that it was booted from, if the kernel has been booted /// via PXE pub const PxeServerInfoTag = packed struct { tag: Tag = .{ .identifier = .pxe_server_info }, /// Server IP in network byte order server_ip: u32, }; /// This tag provides the kernel with the address of a memory mapped UART port pub const Mmio32UartTag = packed struct { tag: Tag = .{ .identifier = .mmio32_uart }, /// The address of the UART port addr: u64, }; /// This tag describes a device tree blob pub const DtbTag = packed struct { tag: Tag = .{ .identifier = .dtb }, /// The address of the DTB addr: u64, /// The size of the DTB size: u64, }; /// This tag reports the start address of the higher half direct map (HHDM) pub const HhdmTag = packed struct { tag: Tag = .{ .identifier = .hhdm }, /// Beginning of the HHDM (virtual address) addr: u64, }; comptime { std.testing.refAllDecls(@This()); } }; test "Struct Size" { try expect(@bitSizeOf(Struct) == 64 * 8 * 2 + 64); } test "Struct Tag Sizes" { try expect(@bitSizeOf(Struct.PmrsTag) == 192); try expect(@bitSizeOf(Struct.CmdlineTag) == 192); try expect(@bitSizeOf(Struct.MemmapTag) == 192); try expect(@bitSizeOf(Struct.FramebufferTag) == 320); try expect(@bitSizeOf(Struct.FramebufferMtrrTag) == 128); try expect(@bitSizeOf(Struct.TextModeTag) == 256); try expect(@bitSizeOf(Struct.EdidTag) == 192); try expect(@bitSizeOf(Struct.TerminalTag) == 320); try expect(@bitSizeOf(Struct.ModulesTag) == 192); try expect(@bitSizeOf(Struct.RsdpTag) == 192); try expect(@bitSizeOf(Struct.SmbiosTag) == 320); try expect(@bitSizeOf(Struct.EpochTag) == 192); try expect(@bitSizeOf(Struct.FirmwareTag) == 192); try expect(@bitSizeOf(Struct.EfiSystemTableTag) == 192); try expect(@bitSizeOf(Struct.KernelFileTag) == 192); try expect(@bitSizeOf(Struct.KernelFileV2Tag) == 256); try expect(@bitSizeOf(Struct.BootVolumeTag) == 448); try expect(@bitSizeOf(Struct.KernelSlideTag) == 192); try expect(@bitSizeOf(Struct.SmpTag) == 320); try expect(@bitSizeOf(Struct.PxeServerInfoTag) == 160); try expect(@bitSizeOf(Struct.Mmio32UartTag) == 192); try expect(@bitSizeOf(Struct.DtbTag) == 256); try expect(@bitSizeOf(Struct.HhdmTag) == 192); } test "Struct Other Sizes" { try expect(@bitSizeOf(Struct.Pmr) == 192); try expect(@bitSizeOf(Struct.MemmapEntry) == 192); try expect(@bitSizeOf(Struct.Module) == 1152); try expect(@bitSizeOf(Struct.SmpInfo) == 256); } test "KernelFileV2Tag asSlice" { const string: []const u8 = "Hello world!"; const kernel_file_v2_tag = Struct.KernelFileV2Tag{ .kernel_file = string.ptr, .kernel_size = string.len, }; try expect(std.mem.eql(u8, string, kernel_file_v2_tag.asSlice())); } // We use this only as a helper for our test fn padString(comptime string: anytype, comptime len: usize) [len]u8 { comptime { if (string.len >= len) unreachable; const paddingLen = len - string.len; const padding = [1]u8{0} ** paddingLen; return string ++ padding; } } test "Parse Struct" { var info = Struct{ .bootloader_brand = padString("Foo...".*, 64), .bootloader_version = padString("Bar!".*, 64), }; var epochtag = Struct.EpochTag{ .epoch = 0x6969696969696969 }; info.tags = &epochtag.tag; const parsed = info.parse(); try expect(parsed.epoch.?.*.epoch == 0x6969696969696969); try expect(std.mem.eql(u8, parsed.bootloader_brand, "Foo...")); try expect(std.mem.eql(u8, parsed.bootloader_version, "Bar!")); } /// This function takes your kernel entry point as an argument. It parses the `Struct` for you, and provides `Struct.Parsed` as an argument to the /// entry point. You may export it as `_start` using `@export`. pub fn entryPoint(comptime entrypoint: fn (Struct.Parsed) noreturn) fn (*const Struct) callconv(.C) noreturn { return struct { pub fn entryPoint(info: *const Struct) callconv(.C) noreturn { const parsed = info.parse(); entrypoint(parsed); } }.entryPoint; } test "entryPoint" { const kmain = struct { pub fn kmain(_: Struct.Parsed) noreturn { while (true) {} } }.kmain; _ = entryPoint(kmain); } comptime { std.testing.refAllDecls(@This()); }
src/stivale2.zig
const std = @import("std"); const Arena = std.heap.ArenaAllocator; const expectEqual = std.testing.expectEqual; const expectEqualStrings = std.testing.expectEqualStrings; const yeti = @import("yeti"); const initCodebase = yeti.initCodebase; const tokenize = yeti.tokenize; const parse = yeti.parse; const analyzeSemantics = yeti.analyzeSemantics; const codegen = yeti.codegen; const printWasm = yeti.printWasm; const components = yeti.components; const literalOf = yeti.query.literalOf; const typeOf = yeti.query.typeOf; const MockFileSystem = yeti.FileSystem; test "tokenize while" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); const module = try codebase.createEntity(.{}); const code = "while"; var tokens = try tokenize(module, code); { const token = tokens.next().?; try expectEqual(token.get(components.TokenKind), .while_); try expectEqual(token.get(components.Span), .{ .begin = .{ .column = 0, .row = 0 }, .end = .{ .column = 5, .row = 0 }, }); } try expectEqual(tokens.next(), null); } test "parse while" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); const module = try codebase.createEntity(.{}); const code = \\start() i32 { \\ i = 0 \\ while(i < 10) { \\ i = i + 1 \\ } \\ i \\} ; var tokens = try tokenize(module, code); try parse(module, &tokens); const top_level = module.get(components.TopLevel); const start = top_level.findString("start"); const overloads = start.get(components.Overloads).slice(); try expectEqual(overloads.len, 1); const body = overloads[0].get(components.Body).slice(); try expectEqual(body.len, 3); const define = body[0]; try expectEqual(define.get(components.AstKind), .define); try expectEqualStrings(literalOf(define.get(components.Name).entity), "i"); try expectEqualStrings(literalOf(define.get(components.Value).entity), "0"); const while_ = body[1]; try expectEqual(while_.get(components.AstKind), .while_); const conditional = while_.get(components.Conditional).entity; try expectEqual(conditional.get(components.AstKind), .binary_op); try expectEqual(conditional.get(components.BinaryOp), .less_than); const while_body = while_.get(components.Body).slice(); try expectEqual(while_body.len, 1); const assign = while_body[0]; try expectEqual(assign.get(components.AstKind), .define); try expectEqualStrings(literalOf(assign.get(components.Name).entity), "i"); const value = assign.get(components.Value).entity; try expectEqual(value.get(components.AstKind), .binary_op); try expectEqual(value.get(components.BinaryOp), .add); const i = body[2]; try expectEqual(i.get(components.AstKind), .symbol); try expectEqualStrings(literalOf(i), "i"); } test "analyze semantics of while loop" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); const builtins = codebase.get(components.Builtins); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i32 { \\ i = 0 \\ while(i < 10) { \\ i = i + 1 \\ } \\ i \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); const top_level = module.get(components.TopLevel); const start = top_level.findString("start").get(components.Overloads).slice()[0]; try expectEqualStrings(literalOf(start.get(components.Module).entity), "foo"); try expectEqualStrings(literalOf(start.get(components.Name).entity), "start"); try expectEqual(start.get(components.Parameters).len(), 0); try expectEqual(start.get(components.ReturnType).entity, builtins.I32); const body = start.get(components.Body).slice(); try expectEqual(body.len, 3); const i = blk: { const define = body[0]; try expectEqual(define.get(components.AstKind), .define); try expectEqual(typeOf(define), builtins.Void); try expectEqualStrings(literalOf(define.get(components.Value).entity), "0"); const local = define.get(components.Local).entity; try expectEqual(local.get(components.AstKind), .local); try expectEqualStrings(literalOf(local.get(components.Name).entity), "i"); try expectEqual(typeOf(local), builtins.I32); break :blk local; }; const while_ = body[1]; try expectEqual(while_.get(components.AstKind), .while_); try expectEqual(typeOf(while_), builtins.Void); const conditional = while_.get(components.Conditional).entity; try expectEqual(conditional.get(components.AstKind), .intrinsic); try expectEqual(typeOf(conditional), builtins.I32); const while_body = while_.get(components.Body).slice(); try expectEqual(while_body.len, 1); const assign = while_body[0]; try expectEqual(assign.get(components.AstKind), .assign); try expectEqual(typeOf(assign), builtins.Void); try expectEqual(assign.get(components.Local).entity, i); const value = assign.get(components.Value).entity; try expectEqual(value.get(components.AstKind), .intrinsic); try expectEqual(body[2], i); } test "codegen while loop" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i32 { \\ i = 0 \\ while(i < 10) { \\ i = i + 1 \\ } \\ i \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); try codegen(module); const top_level = module.get(components.TopLevel); const start = top_level.findString("start").get(components.Overloads).slice()[0]; const start_instructions = start.get(components.WasmInstructions).slice(); try expectEqual(start_instructions.len, 17); { const i32_const = start_instructions[0]; try expectEqual(i32_const.get(components.WasmInstructionKind), .i32_const); try expectEqualStrings(literalOf(i32_const.get(components.Constant).entity), "0"); const local_set = start_instructions[1]; try expectEqual(local_set.get(components.WasmInstructionKind), .local_set); const local = local_set.get(components.Local).entity; try expectEqualStrings(literalOf(local.get(components.Name).entity), "i"); } { const block = start_instructions[2]; try expectEqual(block.get(components.WasmInstructionKind), .block); try expectEqual(block.get(components.Label).value, 0); const loop = start_instructions[3]; try expectEqual(loop.get(components.WasmInstructionKind), .loop); try expectEqual(loop.get(components.Label).value, 1); const local_get = start_instructions[4]; try expectEqual(local_get.get(components.WasmInstructionKind), .local_get); const local = local_get.get(components.Local).entity; try expectEqualStrings(literalOf(local.get(components.Name).entity), "i"); const i32_const = start_instructions[5]; try expectEqual(i32_const.get(components.WasmInstructionKind), .i32_const); try expectEqualStrings(literalOf(i32_const.get(components.Constant).entity), "10"); try expectEqual(start_instructions[6].get(components.WasmInstructionKind), .i32_lt); try expectEqual(start_instructions[7].get(components.WasmInstructionKind), .i32_eqz); const br_if = start_instructions[8]; try expectEqual(br_if.get(components.WasmInstructionKind), .br_if); try expectEqual(br_if.get(components.Label).value, 0); } { const local_get = start_instructions[9]; try expectEqual(local_get.get(components.WasmInstructionKind), .local_get); const local = local_get.get(components.Local).entity; try expectEqualStrings(literalOf(local.get(components.Name).entity), "i"); const i32_const = start_instructions[10]; try expectEqual(i32_const.get(components.WasmInstructionKind), .i32_const); try expectEqualStrings(literalOf(i32_const.get(components.Constant).entity), "1"); try expectEqual(start_instructions[11].get(components.WasmInstructionKind), .i32_add); const local_set = start_instructions[12]; try expectEqual(local_set.get(components.WasmInstructionKind), .local_set); try expectEqual(local_set.get(components.Local).entity, local); const br = start_instructions[13]; try expectEqual(br.get(components.WasmInstructionKind), .br); try expectEqual(br.get(components.Label).value, 1); try expectEqual(start_instructions[14].get(components.WasmInstructionKind), .end); try expectEqual(start_instructions[15].get(components.WasmInstructionKind), .end); } const local_get = start_instructions[16]; try expectEqual(local_get.get(components.WasmInstructionKind), .local_get); const local = local_get.get(components.Local).entity; try expectEqualStrings(literalOf(local.get(components.Name).entity), "i"); } test "codegen while loop proper type inference" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i64 { \\ i = 0 \\ while(i < 10) { \\ i = i + 1 \\ } \\ i \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); try codegen(module); const top_level = module.get(components.TopLevel); const start = top_level.findString("start").get(components.Overloads).slice()[0]; const start_instructions = start.get(components.WasmInstructions).slice(); try expectEqual(start_instructions.len, 17); { const i64_const = start_instructions[0]; try expectEqual(i64_const.get(components.WasmInstructionKind), .i64_const); try expectEqualStrings(literalOf(i64_const.get(components.Constant).entity), "0"); const local_set = start_instructions[1]; try expectEqual(local_set.get(components.WasmInstructionKind), .local_set); const local = local_set.get(components.Local).entity; try expectEqualStrings(literalOf(local.get(components.Name).entity), "i"); } { const block = start_instructions[2]; try expectEqual(block.get(components.WasmInstructionKind), .block); try expectEqual(block.get(components.Label).value, 0); const loop = start_instructions[3]; try expectEqual(loop.get(components.WasmInstructionKind), .loop); try expectEqual(loop.get(components.Label).value, 1); const local_get = start_instructions[4]; try expectEqual(local_get.get(components.WasmInstructionKind), .local_get); const local = local_get.get(components.Local).entity; try expectEqualStrings(literalOf(local.get(components.Name).entity), "i"); const i64_const = start_instructions[5]; try expectEqual(i64_const.get(components.WasmInstructionKind), .i64_const); try expectEqualStrings(literalOf(i64_const.get(components.Constant).entity), "10"); try expectEqual(start_instructions[6].get(components.WasmInstructionKind), .i64_lt); try expectEqual(start_instructions[7].get(components.WasmInstructionKind), .i32_eqz); const br_if = start_instructions[8]; try expectEqual(br_if.get(components.WasmInstructionKind), .br_if); try expectEqual(br_if.get(components.Label).value, 0); } { const local_get = start_instructions[9]; try expectEqual(local_get.get(components.WasmInstructionKind), .local_get); const local = local_get.get(components.Local).entity; try expectEqualStrings(literalOf(local.get(components.Name).entity), "i"); const i64_const = start_instructions[10]; try expectEqual(i64_const.get(components.WasmInstructionKind), .i64_const); try expectEqualStrings(literalOf(i64_const.get(components.Constant).entity), "1"); try expectEqual(start_instructions[11].get(components.WasmInstructionKind), .i64_add); const local_set = start_instructions[12]; try expectEqual(local_set.get(components.WasmInstructionKind), .local_set); try expectEqual(local_set.get(components.Local).entity, local); const br = start_instructions[13]; try expectEqual(br.get(components.WasmInstructionKind), .br); try expectEqual(br.get(components.Label).value, 1); try expectEqual(start_instructions[14].get(components.WasmInstructionKind), .end); try expectEqual(start_instructions[15].get(components.WasmInstructionKind), .end); } const local_get = start_instructions[16]; try expectEqual(local_get.get(components.WasmInstructionKind), .local_get); const local = local_get.get(components.Local).entity; try expectEqualStrings(literalOf(local.get(components.Name).entity), "i"); } test "print wasm while loop" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i32 { \\ i = 0 \\ while(i < 10) { \\ i = i + 1 \\ } \\ i \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); try codegen(module); const wasm = try printWasm(module); try expectEqualStrings(wasm, \\(module \\ \\ (func $foo/start (result i32) \\ (local $i i32) \\ (i32.const 0) \\ (local.set $i) \\ block $.label.0 \\ loop $.label.1 \\ (local.get $i) \\ (i32.const 10) \\ i32.lt_s \\ i32.eqz \\ br_if $.label.0 \\ (local.get $i) \\ (i32.const 1) \\ i32.add \\ (local.set $i) \\ br $.label.1 \\ end $.label.1 \\ end $.label.0 \\ (local.get $i)) \\ \\ (export "_start" (func $foo/start))) ); } test "print wasm properly infer type for while loop" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i64 { \\ sum = 0 \\ i = 0 \\ while(i < 10) { \\ sum += 1 \\ i += 1 \\ } \\ sum \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); try codegen(module); const wasm = try printWasm(module); try expectEqualStrings(wasm, \\(module \\ \\ (func $foo/start (result i64) \\ (local $sum i64) \\ (local $i i32) \\ (i64.const 0) \\ (local.set $sum) \\ (i32.const 0) \\ (local.set $i) \\ block $.label.0 \\ loop $.label.1 \\ (local.get $i) \\ (i32.const 10) \\ i32.lt_s \\ i32.eqz \\ br_if $.label.0 \\ (local.get $sum) \\ (i64.const 1) \\ i64.add \\ (local.set $sum) \\ (local.get $i) \\ (i32.const 1) \\ i32.add \\ (local.set $i) \\ br $.label.1 \\ end $.label.1 \\ end $.label.0 \\ (local.get $sum)) \\ \\ (export "_start" (func $foo/start))) ); }
src/tests/test_while.zig
usingnamespace @import("root").preamble; const atomic_queue = lib.containers.atomic_queue; const guard_size = os.platform.thread.stack_guard_size; const map_size = os.platform.thread.task_stack_size; const total_size = guard_size + map_size; const nonbacked = os.memory.vmm.nonbacked(); /// Separate execution unit pub const Task = struct { /// General task registers that are preserved on every interrupt registers: os.platform.InterruptFrame = undefined, /// Core ID task is allocated to allocated_core_id: usize = undefined, /// Platform-specific data related to the task (e.g. TSS on x86_64) platform_data: os.platform.thread.TaskData = undefined, /// Hook for the task queue queue_hook: atomic_queue.Node = undefined, /// Virtual memory space task runs in paging_context: *os.platform.paging.PagingContext = undefined, /// Top of the stack used by the task stack: usize = undefined, /// The process context that the task currently is executing within process: ?*os.kernel.process.Process = null, /// The name assigned on task creation name: []const u8, /// The name set by the task itself, if any secondary_name: ?[]const u8 = null, /// Allocate stack for the task. Used in scheduler makeTask routine pub fn allocStack(self: *@This()) !void { // Allocate non-backing virtual memory const slice = (try nonbacked.allocFn(nonbacked, total_size, 1, 1, 0)); errdefer _ = nonbacked.resizeFn( nonbacked, slice, 1, 0, 1, 0, ) catch @panic("task alloc stack"); // Map pages const virt = @ptrToInt(slice.ptr); try os.memory.paging.map(.{ .virt = virt + guard_size, .size = map_size, .perm = os.memory.paging.rw(), .memtype = .MemoryWriteBack, }); self.stack = virt + total_size; } /// Free stack used by the task. Used in User Request Monitor on task termination pub fn freeStack(self: *@This()) void { const virt = self.stack - total_size; // Unmap stack pages os.memory.paging.unmap(.{ .virt = virt + guard_size, .size = map_size, .reclaim_pages = true, }); // Free nonbacked memory _ = nonbacked.resizeFn( nonbacked, @intToPtr([*]u8, virt)[0..total_size], 1, 0, 1, 0, ) catch @panic("task free stack"); } pub fn enqueue(self: *@This()) void { os.platform.smp.cpus[self.allocated_core_id].executable_tasks.enqueue(self); } };
subprojects/flork/src/thread/task.zig
const gllparser = @import("../gllparser/gllparser.zig"); const Error = gllparser.Error; const Parser = gllparser.Parser; const ParserContext = gllparser.Context; const Result = gllparser.Result; const NodeName = gllparser.NodeName; const ResultStream = gllparser.ResultStream; const Literal = @import("../parser/literal.zig").Literal; const LiteralValue = @import("../parser/literal.zig").Value; const MapTo = @import("mapto.zig").MapTo; const std = @import("std"); const testing = std.testing; const mem = std.mem; pub fn Context(comptime Payload: type, comptime V: type) type { return []const *Parser(Payload, V); } /// Represents a sequence of parsed values. /// /// In the case of a non-ambiguous grammar, a `Sequence` combinator will yield: /// /// ``` /// stream(value1, value2) /// ``` /// /// In the case of an ambiguous grammar, it would yield a stream with only the first parse path. /// Use SequenceAmbiguous if ambiguou parse paths are desirable. pub fn Value(comptime V: type) type { return struct { results: *ResultStream(Result(V)), pub fn deinit(self: *const @This(), allocator: mem.Allocator) void { self.results.deinit(); allocator.destroy(self.results); } }; } pub const Ownership = enum { borrowed, owned, copy, }; /// Matches the `input` parsers sequentially. The parsers must produce the same data type (use /// MapTo, if needed.) If ambiguous parse paths are desirable, use SequenceAmbiguous. /// /// The `input` parsers must remain alive for as long as the `Sequence` parser will be used. pub fn Sequence(comptime Payload: type, comptime V: type) type { return struct { parser: Parser(Payload, Value(V)) = Parser(Payload, Value(V)).init(parse, nodeName, deinit, countReferencesTo), input: Context(Payload, V), ownership: Ownership, const Self = @This(); pub fn init(allocator: mem.Allocator, input: Context(Payload, V), ownership: Ownership) !*Parser(Payload, Value(V)) { var self = Self{ .input = input, .ownership = ownership }; if (ownership == .copy) { const Elem = std.meta.Elem(@TypeOf(input)); var copy = try allocator.alloc(Elem, input.len); std.mem.copy(Elem, copy, input); self.input = copy; self.ownership = .owned; } return try self.parser.heapAlloc(allocator, self); } pub fn initStack(input: Context(Payload, V), ownership: Ownership) Self { if (ownership == Ownership.copy) unreachable; return Self{ .input = input }; } pub fn deinit(parser: *Parser(Payload, Value(V)), allocator: mem.Allocator, freed: ?*std.AutoHashMap(usize, void)) void { const self = @fieldParentPtr(Self, "parser", parser); for (self.input) |child_parser| { child_parser.deinit(allocator, freed); } if (self.ownership == .owned) allocator.free(self.input); } pub fn countReferencesTo(parser: *const Parser(Payload, Value(V)), other: usize, freed: *std.AutoHashMap(usize, void)) usize { const self = @fieldParentPtr(Self, "parser", parser); if (@ptrToInt(parser) == other) return 1; var count: usize = 0; for (self.input) |in_parser| { count += in_parser.countReferencesTo(other, freed); } return count; } pub fn nodeName(parser: *const Parser(Payload, Value(V)), node_name_cache: *std.AutoHashMap(usize, NodeName)) Error!u64 { const self = @fieldParentPtr(Self, "parser", parser); var v = std.hash_map.hashString("Sequence"); for (self.input) |in_parser| { v +%= try in_parser.nodeName(node_name_cache); } return v; } pub fn parse(parser: *const Parser(Payload, Value(V)), in_ctx: *const ParserContext(Payload, Value(V))) callconv(.Async) Error!void { const self = @fieldParentPtr(Self, "parser", parser); var ctx = in_ctx.with(self.input); defer ctx.results.close(); // Invoke each child parser to produce each of our results. Each time we ask a child // parser to parse, it can produce a set of results (its result stream) which are // varying parse paths / interpretations, we take the first successful one. // Return early if we're not trying to parse anything (stream close signals to the // consumer there were no matches). if (self.input.len == 0) { return; } var buffer = try ctx.allocator.create(ResultStream(Result(V))); errdefer ctx.allocator.destroy(buffer); errdefer buffer.deinit(); buffer.* = try ResultStream(Result(V)).init(ctx.allocator, ctx.key); var offset: usize = ctx.offset; for (self.input) |child_parser| { const child_node_name = try child_parser.nodeName(&in_ctx.memoizer.node_name_cache); var child_ctx = try in_ctx.initChild(V, child_node_name, offset); defer child_ctx.deinitChild(); if (!child_ctx.existing_results) try child_parser.parse(&child_ctx); var num_local_values: usize = 0; var sub = child_ctx.subscribe(); while (sub.next()) |next| { switch (next.result) { .err => { buffer.close(); buffer.deinit(); ctx.allocator.destroy(buffer); try ctx.results.add(Result(Value(V)).initError(next.offset, next.result.err)); return; }, else => { // TODO(slimsag): need path committal functionality if (num_local_values == 0) { // TODO(slimsag): if no consumption, could get stuck forever! offset = next.offset; try buffer.add(next.toUnowned()); } num_local_values += 1; }, } } } buffer.close(); try ctx.results.add(Result(Value(V)).init(offset, .{ .results = buffer })); } }; } test "sequence" { nosuspend { const allocator = testing.allocator; const Payload = void; const ctx = try ParserContext(Payload, Value(LiteralValue)).init(allocator, "abc123abc456_123abc", {}); defer ctx.deinit(); var seq = try Sequence(Payload, LiteralValue).init(allocator, &.{ (try Literal(Payload).init(allocator, "abc")).ref(), (try Literal(Payload).init(allocator, "123ab")).ref(), (try Literal(Payload).init(allocator, "c45")).ref(), (try Literal(Payload).init(allocator, "6")).ref(), }, .borrowed); defer seq.deinit(allocator, null); try seq.parse(&ctx); var sub = ctx.subscribe(); var sequence = sub.next().?.result.value; try testing.expect(sub.next() == null); // stream closed var sequenceSub = sequence.results.subscribe(ctx.key, ctx.path, Result(LiteralValue).initError(ctx.offset, "matches only the empty language")); try testing.expectEqual(@as(usize, 3), sequenceSub.next().?.offset); try testing.expectEqual(@as(usize, 8), sequenceSub.next().?.offset); try testing.expectEqual(@as(usize, 11), sequenceSub.next().?.offset); try testing.expectEqual(@as(usize, 12), sequenceSub.next().?.offset); try testing.expect(sequenceSub.next() == null); // stream closed } }
src/combn/combinator/sequence.zig
const std = @import("std"); const sdl = @import("sdl"); const builtin = @import("builtin"); const stdx = @import("stdx"); const ptrCastTo = stdx.mem.ptrCastTo; const c = @cImport({ @cDefine("GL_GLEXT_PROTOTYPES", ""); // Includes glGenVertexArrays @cInclude("GL/gl.h"); }); const IsWasm = builtin.target.isWasm(); /// WebGL2 bindings. /// https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext /// https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext extern "graphics" fn jsGlCreateTexture() u32; extern "graphics" fn jsGlEnable(cap: u32) void; extern "graphics" fn jsGlDisable(cap: u32) void; extern "graphics" fn jsGlBindTexture(target: u32, texture: u32) void; extern "graphics" fn jsGlClearColor(r: f32, g: f32, b: f32, a: f32) void; extern "graphics" fn jsGlGetParameterInt(tag: u32) i32; extern "graphics" fn jsGlGetFrameBufferBinding() u32; extern "graphics" fn jsGlCreateFramebuffer() u32; extern "graphics" fn jsGlBindFramebuffer(target: u32, framebuffer: u32) void; extern "graphics" fn jsGlBindRenderbuffer(target: u32, renderbuffer: u32) void; extern "graphics" fn jsGlRenderbufferStorageMultisample(target: u32, samples: i32, internalformat: u32, width: i32, height: i32) void; extern "graphics" fn jsGlBindVertexArray(array: u32) void; extern "graphics" fn jsGlBindBuffer(target: u32, buffer: u32) void; extern "graphics" fn jsGlEnableVertexAttribArray(index: u32) void; extern "graphics" fn jsGlCreateShader(@"type": u32) u32; extern "graphics" fn jsGlShaderSource(shader: u32, src_ptr: *const u8, src_len: usize) void; extern "graphics" fn jsGlCompileShader(shader: u32) void; extern "graphics" fn jsGlGetShaderParameterInt(shader: u32, pname: u32) i32; extern "graphics" fn jsGlGetShaderInfoLog(shader: u32, buf_size: u32, log_ptr: *u8) u32; extern "graphics" fn jsGlDeleteShader(shader: u32) void; extern "graphics" fn jsGlCreateProgram() u32; extern "graphics" fn jsGlAttachShader(program: u32, shader: u32) void; extern "graphics" fn jsGlDetachShader(program: u32, shader: u32) void; extern "graphics" fn jsGlLinkProgram(program: u32) void; extern "graphics" fn jsGlGetProgramParameterInt(program: u32, pname: u32) i32; extern "graphics" fn jsGlGetProgramInfoLog(program: u32, buf_size: u32, log_ptr: *u8) u32; extern "graphics" fn jsGlDeleteProgram(program: u32) void; extern "graphics" fn jsGlCreateVertexArray() u32; extern "graphics" fn jsGlTexParameteri(target: u32, pname: u32, param: i32) void; extern "graphics" fn jsGlTexImage2D(target: u32, level: i32, internal_format: i32, width: i32, height: i32, border: i32, format: u32, @"type": u32, pixels: ?*const u8) void; extern "graphics" fn jsGlTexSubImage2D(target: u32, level: i32, xoffset: i32, yoffset: i32, width: i32, height: i32, format: u32, @"type": u32, pixels: ?*const u8) void; extern "graphics" fn jsGlCreateBuffer() u32; extern "graphics" fn jsGlVertexAttribPointer(index: u32, size: i32, @"type": u32, normalized: u8, stride: i32, pointer: ?*const anyopaque) void; extern "graphics" fn jsGlActiveTexture(texture: u32) void; extern "graphics" fn jsGlDeleteTexture(texture: u32) void; extern "graphics" fn jsGlUseProgram(program: u32) void; extern "graphics" fn jsGlUniformMatrix4fv(location: i32, transpose: u8, value_ptr: *const f32) void; extern "graphics" fn jsGlUniform1i(location: i32, val: i32) void; extern "graphics" fn jsGlBufferData(target: u32, data_ptr: ?*const u8, data_size: u32, usage: u32) void; extern "graphics" fn jsGlDrawElements(mode: u32, num_indices: u32, index_type: u32, index_offset: u32) void; extern "graphics" fn jsGlCreateRenderbuffer() u32; extern "graphics" fn jsGlFramebufferRenderbuffer(target: u32, attachment: u32, renderbuffertarget: u32, renderbuffer: u32) void; extern "graphics" fn jsGlFramebufferTexture2D(target: u32, attachment: u32, textarget: u32, texture: u32, level: i32) void; extern "graphics" fn jsGlViewport(x: i32, y: i32, width: i32, height: i32) void; extern "graphics" fn jsGlClear(mask: u32) void; extern "graphics" fn jsGlBlendFunc(sfactor: u32, dfactor: u32) void; extern "graphics" fn jsGlBlitFramebuffer(srcX0: i32, srcY0: i32, srcX1: i32, srcY1: i32, dstX0: i32, dstY0: i32, dstX1: i32, dstY1: i32, mask: u32, filter: u32) void; extern "graphics" fn jsGlBlendEquation(mode: u32) void; extern "graphics" fn jsGlScissor(x: i32, y: i32, width: i32, height: i32) void; extern "graphics" fn jsGlGetUniformLocation(program: u32, name_ptr: *const u8, name_len: u32) u32; extern "graphics" fn jsGlCheckFramebufferStatus(target: u32) u32; extern "graphics" fn jsGlDeleteVertexArray(vao: u32) void; extern "graphics" fn jsGlDeleteBuffer(buffer: u32) void; const IsWindows = builtin.os.tag == .windows; pub usingnamespace c; pub inline fn clear(mask: c.GLbitfield) void { if (IsWasm) { jsGlClear(mask); } else { c.glClear(mask); } } pub inline fn getUniformLocation(program: c.GLuint, name: [:0]const u8) c.GLint { if (IsWasm) { const len = std.mem.indexOfSentinel(u8, 0, name); return @intCast(i32, jsGlGetUniformLocation(program, &name[0], len)); } else if (IsWindows) { return winGetUniformLocation(program, name); } else { return c.glGetUniformLocation(program, name); } } pub inline fn genTextures(n: c.GLsizei, textures: [*c]c.GLuint) void { if (IsWasm) { if (n == 1) { textures[0] = jsGlCreateTexture(); } else { stdx.unsupported(); } } else { c.glGenTextures(n, textures); } } pub inline fn deleteTextures(n: c.GLsizei, textures: [*c]const c.GLuint) void { if (IsWasm) { if (n == 1) { jsGlDeleteTexture(textures[0]); } else { stdx.unsupported(); } } else { c.glDeleteTextures(n, textures); } } pub inline fn texParameteri(target: c.GLenum, pname: c.GLenum, param: c.GLint) void { if (IsWasm) { // webgl2 supported targets: // GL_TEXTURE_2D // GL_TEXTURE_CUBE_MAP // GL_TEXTURE_3D // GL_TEXTURE_2D_ARRAY jsGlTexParameteri(target, pname, param); } else { c.glTexParameteri(target, pname, param); } } pub inline fn enable(cap: c.GLenum) void { if (IsWasm) { // webgl2 supports: // GL_BLEND // GL_DEPTH_TEST // GL_DITHER // GL_POLYGON_OFFSET_FILL // GL_SAMPLE_ALPHA_TO_COVERAGE // GL_SAMPLE_COVERAGE // GL_SCISSOR_TEST // GL_STENCIL_TEST jsGlEnable(cap); } else { c.glEnable(cap); } } pub inline fn disable(cap: c.GLenum) void { if (IsWasm) { jsGlDisable(cap); } else { c.glDisable(cap); } } pub inline fn bindTexture(target: c.GLenum, texture: c.GLuint) void { if (IsWasm) { // webgl2 supports: // GL_TEXTURE_2D // GL_TEXTURE_CUBE_MAP // GL_TEXTURE_3D // GL_TEXTURE_2D_ARRAY jsGlBindTexture(target, texture); } else { c.glBindTexture(target, texture); } } pub inline fn clearColor(red: c.GLclampf, green: c.GLclampf, blue: c.GLclampf, alpha: c.GLclampf) void { if (IsWasm) { jsGlClearColor(red, green, blue, alpha); } else { c.glClearColor(red, green, blue, alpha); } } pub inline fn getIntegerv(pname: c.GLenum, params: [*c]c.GLint) void { if (IsWasm) { switch (pname) { c.GL_MAJOR_VERSION => { params[0] = 3; }, c.GL_MINOR_VERSION => { params[0] = 0; }, c.GL_FRAMEBUFFER_BINDING => { params[0] = @intCast(i32, jsGlGetFrameBufferBinding()); }, else => { params[0] = jsGlGetParameterInt(pname); }, } } else { c.glGetIntegerv(pname, params); } } pub inline fn renderbufferStorageMultisample(target: c.GLenum, samples: c.GLsizei, internalformat: c.GLenum, width: c.GLsizei, height: c.GLsizei) void { if (IsWasm) { // webgl2 supported targets: // GL_RENDERBUFFER jsGlRenderbufferStorageMultisample(target, samples, internalformat, width, height); } else { c.glRenderbufferStorageMultisample(target, samples, internalformat, width, height); } } pub fn getMaxTotalTextures() usize { var res: c_int = 0; getIntegerv(c.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &res); return @intCast(usize, res); } pub fn getMaxFragmentTextures() usize { var res: c_int = 0; getIntegerv(c.GL_MAX_TEXTURE_IMAGE_UNITS, &res); return @intCast(usize, res); } pub fn getMaxSamples() usize { var res: c_int = 0; getIntegerv(c.GL_MAX_SAMPLES, &res); return @intCast(usize, res); } pub fn getNumSampleBuffers() usize { var res: c_int = 0; getIntegerv(c.GL_SAMPLE_BUFFERS, &res); return @intCast(usize, res); } pub fn getNumSamples() usize { var res: c_int = 0; getIntegerv(c.GL_SAMPLES, &res); return @intCast(usize, res); } pub fn getDrawFrameBufferBinding() usize { var res: c_int = 0; getIntegerv(c.GL_FRAMEBUFFER_BINDING, &res); return @intCast(usize, res); } pub fn checkFramebufferStatus(target: c.GLenum) c.GLenum { if (IsWasm) { return jsGlCheckFramebufferStatus(target); } else if (IsWindows) { return winCheckFramebufferStatus(target); } else { return c.glCheckFramebufferStatus(target); } } pub inline fn drawElements(mode: c.GLenum, num_indices: usize, index_type: c.GLenum, index_offset: usize) void { if (IsWasm) { jsGlDrawElements(mode, num_indices, index_type, index_offset); } else { c.glDrawElements(mode, @intCast(c_int, num_indices), index_type, @intToPtr(?*const c.GLvoid, index_offset)); } } pub inline fn useProgram(program: c.GLuint) void { if (IsWasm) { jsGlUseProgram(program); } else if (IsWindows) { winUseProgram(program); } else { c.glUseProgram(program); } } pub inline fn createShader(@"type": c.GLenum) c.GLuint { if (IsWasm) { // webgl2 supported types: // GL_VERTEX_SHADER // GL_FRAGMENT_SHADER return jsGlCreateShader(@"type"); } else if (IsWindows) { return winCreateShader(@"type"); } else { return c.glCreateShader(@"type"); } } pub inline fn getShaderInfoLog(shader: c.GLuint, buf_size: c.GLsizei, length: [*c]c.GLsizei, info_log: [*c]c.GLchar) void { if (IsWasm) { length[0] = @intCast(i32, jsGlGetShaderInfoLog(shader, @intCast(u32, buf_size), info_log)); } else if (IsWindows) { winGetShaderInfoLog(shader, buf_size, length, info_log); } else { c.glGetShaderInfoLog(shader, buf_size, length, info_log); } } pub inline fn createProgram() c.GLuint { if (IsWasm) { return jsGlCreateProgram(); } else if (IsWindows) { return winCreateProgram(); } else { return c.glCreateProgram(); } } pub inline fn attachShader(program: c.GLuint, shader: c.GLuint) void { if (IsWasm) { jsGlAttachShader(program, shader); } else if (IsWindows) { winAttachShader(program, shader); } else { c.glAttachShader(program, shader); } } pub inline fn linkProgram(program: c.GLuint) void { if (IsWasm) { jsGlLinkProgram(program); } else if (IsWindows) { winLinkProgram(program); } else { c.glLinkProgram(program); } } pub inline fn getProgramiv(program: c.GLuint, pname: c.GLenum, params: [*c]c.GLint) void { if (IsWasm) { params[0] = jsGlGetProgramParameterInt(program, pname); } else if (IsWindows) { winGetProgramiv(program, pname, params); } else { c.glGetProgramiv(program, pname, params); } } pub inline fn getProgramInfoLog(program: c.GLuint, buf_size: c.GLsizei, length: [*c]c.GLsizei, info_log: [*c]c.GLchar) void { if (IsWasm) { length[0] = @intCast(i32, jsGlGetProgramInfoLog(program, @intCast(u32, buf_size), info_log)); } else if (IsWindows) { winGetProgramInfoLog(program, buf_size, length, info_log); } else { c.glGetProgramInfoLog(program, buf_size, length, info_log); } } pub inline fn deleteProgram(program: c.GLuint) void { if (IsWasm) { jsGlDeleteProgram(program); } else if (IsWindows) { winDeleteProgram(program); } else { c.glDeleteProgram(program); } } pub inline fn deleteShader(shader: c.GLuint) void { if (IsWasm) { jsGlDeleteShader(shader); } else if (IsWindows) { winDeleteShader(shader); } else { c.glDeleteShader(shader); } } pub inline fn genVertexArrays(n: c.GLsizei, arrays: [*c]c.GLuint) void { if (IsWasm) { if (n == 1) { arrays[0] = jsGlCreateVertexArray(); } else { stdx.unsupported(); } } else if (IsWindows) { winGenVertexArrays(n, arrays); } else { c.glGenVertexArrays(n, arrays); } } pub inline fn shaderSource(shader: c.GLuint, count: c.GLsizei, string: [*c]const [*c]const c.GLchar, length: [*c]const c.GLint) void { if (IsWasm) { if (count == 1) { jsGlShaderSource(shader, @ptrCast(*const u8, string[0]), @intCast(usize, length[0])); } else { stdx.unsupported(); } } else if (IsWindows) { winShaderSource(shader, count, string, length); } else { c.glShaderSource(shader, count, string, length); } } pub inline fn compileShader(shader: c.GLuint) void { if (IsWasm) { jsGlCompileShader(shader); } else if (IsWindows) { winCompileShader(shader); } else { c.glCompileShader(shader); } } pub inline fn getShaderiv(shader: c.GLuint, pname: c.GLenum, params: [*c]c.GLint) void { if (IsWasm) { params[0] = jsGlGetShaderParameterInt(shader, pname); } else if (IsWindows) { winGetShaderiv(shader, pname, params); } else { c.glGetShaderiv(shader, pname, params); } } pub inline fn scissor(x: c.GLint, y: c.GLint, width: c.GLsizei, height: c.GLsizei) void { if (IsWasm) { jsGlScissor(x, y, width, height); } else { c.glScissor(x, y, width, height); } } pub inline fn blendFunc(sfactor: c.GLenum, dfactor: c.GLenum) void { if (IsWasm) { jsGlBlendFunc(sfactor, dfactor); } else { c.glBlendFunc(sfactor, dfactor); } } pub inline fn blendEquation(mode: c.GLenum) void { if (IsWasm) { jsGlBlendEquation(mode); } else if (IsWindows) { winBlendEquation(mode); } else { c.glBlendEquation(mode); } } pub inline fn bindVertexArray(array: c.GLuint) void { if (IsWasm) { jsGlBindVertexArray(array); } else if (IsWindows) { winBindVertexArray(array); } else { sdl.glBindVertexArray(array); } } pub inline fn bindBuffer(target: c.GLenum, buffer: c.GLuint) void { if (IsWasm) { // webgl2 supported targets: // GL_ARRAY_BUFFER // GL_ELEMENT_ARRAY_BUFFER // GL_COPY_READ_BUFFER // GL_COPY_WRITE_BUFFER // GL_TRANSFORM_FEEDBACK_BUFFER // GL_UNIFORM_BUFFER // GL_PIXEL_PACK_BUFFER // GL_PIXEL_UNPACK_BUFFER jsGlBindBuffer(target, buffer); } else if (IsWindows) { winBindBuffer(target, buffer); } else { sdl.glBindBuffer(target, buffer); } } pub inline fn bufferData(target: c.GLenum, size: c.GLsizeiptr, data: ?*const anyopaque, usage: c.GLenum) void { if (IsWasm) { jsGlBufferData(target, @ptrCast(?*const u8, data), @intCast(u32, size), usage); } else if (IsWindows) { winBufferData(target, size, data, usage); } else { sdl.glBufferData(target, size, data, usage); } } pub inline fn enableVertexAttribArray(index: c.GLuint) void { if (IsWasm) { jsGlEnableVertexAttribArray(index); } else if (IsWindows) { winEnableVertexAttribArray(index); } else { sdl.glEnableVertexAttribArray(index); } } pub inline fn activeTexture(texture: c.GLenum) void { if (IsWasm) { jsGlActiveTexture(texture); } else if (IsWindows) { winActiveTexture(texture); } else { sdl.glActiveTexture(texture); } } pub inline fn detachShader(program: c.GLuint, shader: c.GLuint) void { if (IsWasm) { jsGlDetachShader(program, shader); } else if (IsWindows) { winDetachShader(program, shader); } else { sdl.glDetachShader(program, shader); } } pub inline fn genRenderbuffers(n: c.GLsizei, renderbuffers: [*c]c.GLuint) void { if (IsWasm) { var i: u32 = 0; while (i < n) : (i += 1) { renderbuffers[i] = jsGlCreateRenderbuffer(); } } else { sdl.glGenRenderbuffers(n, renderbuffers); } } pub inline fn viewport(x: c.GLint, y: c.GLint, width: c.GLsizei, height: c.GLsizei) void { if (IsWasm) { jsGlViewport(x, y, width, height); } else { c.glViewport(x, y, width, height); } } pub inline fn genFramebuffers(n: c.GLsizei, framebuffers: [*c]c.GLuint) void { if (IsWasm) { if (n == 1) { framebuffers[0] = jsGlCreateFramebuffer(); } else { stdx.unsupported(); } } else if (IsWindows) { winGenFramebuffers(n, framebuffers); } else { sdl.glGenFramebuffers(n, framebuffers); } } pub inline fn bindFramebuffer(target: c.GLenum, framebuffer: c.GLuint) void { if (IsWasm) { // webgl2 supports targets: // GL_FRAMEBUFFER // GL_DRAW_FRAMEBUFFER // GL_READ_FRAMEBUFFER jsGlBindFramebuffer(target, framebuffer); } else if (IsWindows) { winBindFramebuffer(target, framebuffer); } else { sdl.glBindFramebuffer(target, framebuffer); } } pub inline fn bindRenderbuffer(target: c.GLenum, renderbuffer: c.GLuint) void { if (IsWasm) { // webgl2 supports targets: // GL_RENDERBUFFER jsGlBindRenderbuffer(target, renderbuffer); } else { c.glBindRenderbuffer(target, renderbuffer); } } pub inline fn texSubImage2D(target: c.GLenum, level: c.GLint, xoffset: c.GLint, yoffset: c.GLint, width: c.GLsizei, height: c.GLsizei, format: c.GLenum, @"type": c.GLenum, pixels: ?*const c.GLvoid) void { if (IsWasm) { jsGlTexSubImage2D(target, level, xoffset, yoffset, width, height, format, @"type", @ptrCast(?*const u8, pixels)); } else { c.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, @"type", pixels); } } pub inline fn texImage2D(target: c.GLenum, level: c.GLint, internal_format: c.GLint, width: c.GLsizei, height: c.GLsizei, border: c.GLint, format: c.GLenum, @"type": c.GLenum, pixels: ?*const c.GLvoid) void { if (IsWasm) { jsGlTexImage2D(target, level, internal_format, width, height, border, format, @"type", @ptrCast(?*const u8, pixels)); } else { c.glTexImage2D(target, level, internal_format, width, height, border, format, @"type", pixels); } } pub fn texImage2DMultisample(target: c.GLenum, samples: c.GLsizei, internalformat: c.GLenum, width: c.GLsizei, height: c.GLsizei, fixedsamplelocations: c.GLboolean) void { if (builtin.os.tag == .windows) { winTexImage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations); } else { sdl.glTexImage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations); } } pub inline fn framebufferRenderbuffer(target: c.GLenum, attachment: c.GLenum, renderbuffertarget: c.GLenum, renderbuffer: c.GLuint) void { if (IsWasm) { jsGlFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); } else { c.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); } } pub inline fn framebufferTexture2D(target: c.GLenum, attachment: c.GLenum, textarget: c.GLenum, texture: c.GLuint, level: c.GLint) void { if (IsWasm) { jsGlFramebufferTexture2D(target, attachment, textarget, texture, level); } else if (IsWindows) { winFramebufferTexture2D(target, attachment, textarget, texture, level); } else { c.glFramebufferTexture2D(target, attachment, textarget, texture, level); } } pub inline fn genBuffers(n: c.GLsizei, buffers: [*c]c.GLuint) void { if (IsWasm) { var i: u32 = 0; while (i < n) : (i += 1) { buffers[i] = jsGlCreateBuffer(); } } else if (IsWindows) { winGenBuffers(n, buffers); } else { sdl.glGenBuffers(n, buffers); } } pub inline fn vertexAttribPointer(index: c.GLuint, size: c.GLint, @"type": c.GLenum, normalized: c.GLboolean, stride: c.GLsizei, pointer: ?*const anyopaque) void { if (IsWasm) { jsGlVertexAttribPointer(index, size, @"type", normalized, stride, pointer); } else if (IsWindows) { winVertexAttribPointer(index, size, @"type", normalized, stride, pointer); } else { sdl.glVertexAttribPointer(index, size, @"type", normalized, stride, pointer); } } pub inline fn deleteVertexArrays(n: c.GLsizei, arrays: [*c]const c.GLuint) void { if (IsWasm) { var i: u32 = 0; while (i < n) : (i += 1) { jsGlDeleteVertexArray(arrays[i]); } } else if (IsWindows) { winDeleteVertexArrays(n, arrays); } else { c.glDeleteVertexArrays(n, arrays); } } pub inline fn deleteBuffers(n: c.GLsizei, buffers: [*c]const c.GLuint) void { if (IsWasm) { var i: u32 = 0; while (i < n) : (i += 1) { jsGlDeleteBuffer(buffers[i]); } } else if (IsWindows) { winDeleteBuffers(n, buffers); } else { c.glDeleteBuffers(n, buffers); } } pub inline fn blitFramebuffer(srcX0: c.GLint, srcY0: c.GLint, srcX1: c.GLint, srcY1: c.GLint, dstX0: c.GLint, dstY0: c.GLint, dstX1: c.GLint, dstY1: c.GLint, mask: c.GLbitfield, filter: c.GLenum) void { if (IsWasm) { jsGlBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); } else if (IsWindows) { winBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); } else { c.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); } } pub inline fn uniformMatrix4fv(location: c.GLint, count: c.GLsizei, transpose: c.GLboolean, value: [*c]const c.GLfloat) void { if (IsWasm) { if (count == 1) { jsGlUniformMatrix4fv(location, transpose, value); } else { stdx.unsupported(); } } else if (IsWindows) { winUniformMatrix4fv(location, count, transpose, value); } else { sdl.glUniformMatrix4fv(location, count, transpose, value); } } pub inline fn uniform2fv(location: c.GLint, count: c.GLsizei, value: [*c]const c.GLfloat) void { if (IsWindows) { winUniform2fv(location, count, value); } else { c.glUniform2fv(location, count, value); } } pub inline fn uniform4fv(location: c.GLint, count: c.GLsizei, value: [*c]const c.GLfloat) void { if (IsWindows) { winUniform4fv(location, count, value); } else { c.glUniform4fv(location, count, value); } } pub inline fn uniform1i(location: c.GLint, v0: c.GLint) void { if (IsWasm) { jsGlUniform1i(location, v0); } else if (IsWindows) { winUniform1i(location, v0); } else { sdl.glUniform1i(location, v0); } } var winUseProgram: fn (program: c.GLuint) void = undefined; var winCreateShader: fn (@"type": c.GLenum) c.GLuint = undefined; var winGetShaderInfoLog: fn (shader: c.GLuint, bufSize: c.GLsizei, length: [*c]c.GLsizei, infoLog: [*c]c.GLchar) void = undefined; var winDeleteShader: fn (shader: c.GLuint) void = undefined; var winCreateProgram: fn () c.GLuint = undefined; var winAttachShader: fn (program: c.GLuint, shader: c.GLuint) void = undefined; var winLinkProgram: fn (program: c.GLuint) void = undefined; var winGetProgramiv: fn (program: c.GLuint, pname: c.GLenum, params: [*c]c.GLint) void = undefined; var winGetProgramInfoLog: fn (program: c.GLuint, bufSize: c.GLsizei, length: [*c]c.GLsizei, infoLog: [*c]c.GLchar) void = undefined; var winDeleteProgram: fn (program: c.GLuint) void = undefined; var winGenVertexArrays: fn (n: c.GLsizei, arrays: [*c]c.GLuint) void = undefined; var winShaderSource: fn (shader: c.GLuint, count: c.GLsizei, string: [*c]const [*c]const c.GLchar, length: [*c]const c.GLint) void = undefined; var winCompileShader: fn (shader: c.GLuint) void = undefined; var winGetShaderiv: fn (shader: c.GLuint, pname: c.GLenum, params: [*c]c.GLint) void = undefined; var winBindBuffer: fn (target: c.GLenum, buffer: c.GLuint) void = undefined; var winBufferData: fn (target: c.GLenum, size: c.GLsizeiptr, data: ?*const anyopaque, usage: c.GLenum) void = undefined; var winUniformMatrix4fv: fn (location: c.GLint, count: c.GLsizei, transpose: c.GLboolean, value: [*c]const c.GLfloat) void = undefined; var winUniform2fv: fn (location: c.GLint, count: c.GLsizei, value: [*c]const c.GLfloat) void = undefined; var winUniform4fv: fn (location: c.GLint, count: c.GLsizei, value: [*c]const c.GLfloat) void = undefined; var winGetUniformLocation: fn (program: c.GLuint, name: [*c]const c.GLchar) c.GLint = undefined; var winUniform1i: fn (location: c.GLint, v0: c.GLint) void = undefined; var winGenBuffers: fn (n: c.GLsizei, buffers: [*c]c.GLuint) void = undefined; var winDeleteBuffers: fn (n: c.GLsizei, buffers: [*c]const c.GLuint) void = undefined; var winBlendEquation: fn (mode: c.GLenum) void = undefined; var winBlitFramebuffer: fn (srcX0: c.GLint, srcY0: c.GLint, srcX1: c.GLint, srcY1: c.GLint, dstX0: c.GLint, dstY0: c.GLint, dstX1: c.GLint, dstY1: c.GLint, mask: c.GLbitfield, filter: c.GLenum) void = undefined; var winDeleteVertexArrays: fn (n: c.GLsizei, arrays: [*c]const c.GLuint) void = undefined; var winVertexAttribPointer: fn (index: c.GLuint, size: c.GLint, @"type": c.GLenum, normalized: c.GLboolean, stride: c.GLsizei, pointer: ?*const anyopaque) void = undefined; var winBindVertexArray: fn (array: c.GLuint) void = undefined; var winDetachShader: fn (program: c.GLuint, shader: c.GLuint) void = undefined; var winFramebufferTexture2D: fn (target: c.GLenum, attachment: c.GLenum, textarget: c.GLenum, texture: c.GLuint, level: c.GLint) void = undefined; var winTexImage2DMultisample: fn (target: c.GLenum, samples: c.GLsizei, internalformat: c.GLenum, width: c.GLsizei, height: c.GLsizei, fixedsamplelocations: c.GLboolean) void = undefined; var winGenFramebuffers: fn (n: c.GLsizei, framebuffers: [*c]c.GLuint) void = undefined; var winEnableVertexAttribArray: fn (index: c.GLuint) void = undefined; var winActiveTexture: fn (texture: c.GLenum) void = undefined; var winBindFramebuffer: fn (target: c.GLenum, framebuffer: c.GLuint) void = undefined; var winCheckFramebufferStatus: fn (target: c.GLenum) c.GLenum = undefined; var initedWinGL = false; // opengl32.dll on Windows only supports 1.1 functions but it knows how to retrieve newer functions // from vendor implementations of OpenGL. This should be called once to load the function pointers we need. // If this becomes hard to maintain we might autogen this like: https://github.com/skaslev/gl3w pub fn initWinGL_Functions() void { if (initedWinGL) { return; } loadGlFunc(&winUseProgram, "glUseProgram"); loadGlFunc(&winCreateShader, "glCreateShader"); loadGlFunc(&winGetShaderInfoLog, "glGetShaderInfoLog"); loadGlFunc(&winDeleteShader, "glDeleteShader"); loadGlFunc(&winCreateProgram, "glCreateProgram"); loadGlFunc(&winAttachShader, "glAttachShader"); loadGlFunc(&winLinkProgram, "glLinkProgram"); loadGlFunc(&winGetProgramiv, "glGetProgramiv"); loadGlFunc(&winGetProgramInfoLog, "glGetProgramInfoLog"); loadGlFunc(&winDeleteProgram, "glDeleteProgram"); loadGlFunc(&winGenVertexArrays, "glGenVertexArrays"); loadGlFunc(&winShaderSource, "glShaderSource"); loadGlFunc(&winCompileShader, "glCompileShader"); loadGlFunc(&winGetShaderiv, "glGetShaderiv"); loadGlFunc(&winBindVertexArray, "glBindVertexArray"); loadGlFunc(&winBindBuffer, "glBindBuffer"); loadGlFunc(&winEnableVertexAttribArray, "glEnableVertexAttribArray"); loadGlFunc(&winActiveTexture, "glActiveTexture"); loadGlFunc(&winDetachShader, "glDetachShader"); loadGlFunc(&winGenFramebuffers, "glGenFramebuffers"); loadGlFunc(&winBindFramebuffer, "glBindFramebuffer"); loadGlFunc(&winTexImage2DMultisample, "glTexImage2DMultisample"); loadGlFunc(&winFramebufferTexture2D, "glFramebufferTexture2D"); loadGlFunc(&winVertexAttribPointer, "glVertexAttribPointer"); loadGlFunc(&winDeleteVertexArrays, "glDeleteVertexArrays"); loadGlFunc(&winGenBuffers, "glGenBuffers"); loadGlFunc(&winDeleteBuffers, "glDeleteBuffers"); loadGlFunc(&winBlitFramebuffer, "glBlitFramebuffer"); loadGlFunc(&winBlendEquation, "glBlendEquation"); loadGlFunc(&winUniformMatrix4fv, "glUniformMatrix4fv"); loadGlFunc(&winUniform2fv, "glUniform2fv"); loadGlFunc(&winUniform4fv, "glUniform4fv"); loadGlFunc(&winGetUniformLocation, "glGetUniformLocation"); loadGlFunc(&winUniform1i, "glUniform1i"); loadGlFunc(&winBufferData, "glBufferData"); loadGlFunc(&winCheckFramebufferStatus, "glCheckFramebufferStatus"); } fn loadGlFunc(ptr_to_local: anytype, name: [:0]const u8) void { if (sdl.SDL_GL_GetProcAddress(name)) |ptr| { ptrCastTo(ptr_to_local, ptr); } else { std.debug.panic("Failed to load: {s}", .{name}); } }
lib/gl/gl.zig
const std = @import("std"); const Diagnostics = @import("diagnostics.zig").Diagnostics; pub const TokenType = enum { const Self = @This(); number_literal, string_literal, character_literal, identifier, comment, whitespace, @"{", @"}", @"(", @")", @"]", @"[", @"var", @"const", @"for", @"while", @"if", @"else", @"function", @"in", @"break", @"continue", @"return", @"and", @"or", @"not", @"+=", @"-=", @"*=", @"/=", @"%=", @"<=", @">=", @"<", @">", @"!=", @"==", @"=", @".", @",", @";", @"+", @"-", @"*", @"/", @"%", /// Returns `true` when the token type is emitted from the tokenizer, /// otherwise `false`. pub fn isEmitted(self: Self) bool { return switch (self) { .comment, .whitespace => false, else => true, }; } }; const keywords = [_][]const u8{ "var", "for", "while", "if", "else", "function", "in", "break", "continue", "return", "and", "or", "not", "const", }; pub const Location = @import("location.zig").Location; /// A single, recognized piece of text in the source file. pub const Token = struct { /// the text that was recognized text: []const u8, /// the position in the source file location: Location, /// the type (and parsed value) of the token type: TokenType, }; pub const Tokenizer = struct { const Self = @This(); /// Result from a tokenization process const Result = union(enum) { token: Token, end_of_file: void, invalid_sequence: []const u8, }; source: []const u8, offset: usize, current_location: Location, pub fn init(chunk_name: []const u8, source: []const u8) Self { return Self{ .source = source, .offset = 0, .current_location = Location{ .line = 1, .column = 1, .chunk = chunk_name, .offset_start = undefined, .offset_end = undefined, }, }; } pub fn next(self: *Self) Result { while (true) { const start = self.offset; if (start >= self.source.len) return .end_of_file; if (nextInternal(self)) |token_type| { const end = self.offset; std.debug.assert(end > start); // tokens may never be empty! var token = Token{ .type = token_type, .location = self.current_location, .text = self.source[start..end], }; // std.debug.print("token: `{}`\n", .{token.text}); if (token.type == .identifier) { inline for (keywords) |kwd| { if (std.mem.eql(u8, token.text, kwd)) { token.type = @field(TokenType, kwd); break; } } } token.location.offset_start = start; token.location.offset_end = end; for (token.text) |c| { if (c == '\n') { self.current_location.line += 1; self.current_location.column = 1; } else { self.current_location.column += 1; } } if (token.type.isEmitted()) return Result{ .token = token }; } else { while (self.accept(invalid_char_class)) {} const end = self.offset; self.current_location.offset_start = start; self.current_location.offset_end = end; return Result{ .invalid_sequence = self.source[start..end] }; } } } const Predicate = fn (u8) bool; fn accept(self: *Self, predicate: fn (u8) bool) bool { if (self.offset >= self.source.len) return false; const c = self.source[self.offset]; const accepted = predicate(c); // std.debug.print("{c} → {}\n", .{ // c, accepted, // }); if (accepted) { self.offset += 1; return true; } else { return false; } } fn any(c: u8) bool { return true; } fn anyOf(comptime chars: []const u8) Predicate { return struct { fn pred(c: u8) bool { return inline for (chars) |o| { if (c == o) break true; } else false; } }.pred; } fn noneOf(comptime chars: []const u8) Predicate { return struct { fn pred(c: u8) bool { return inline for (chars) |o| { if (c == o) break false; } else true; } }.pred; } const invalid_char_class = noneOf(" \r\n\tABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789+-*/%={}()[]<>\"\'.,;!"); const whitespace_class = anyOf(" \r\n\t"); const comment_class = noneOf("\n"); const identifier_class = anyOf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"); const digit_class = anyOf("0123456789"); const hexdigit_class = anyOf("0123456789abcdefABCDEF"); const string_char_class = noneOf("\"\\"); const character_char_class = noneOf("\'\\"); fn nextInternal(self: *Self) ?TokenType { std.debug.assert(self.offset < self.source.len); // copy for shorter code const source = self.source; if (self.accept(whitespace_class)) { while (self.accept(whitespace_class)) {} return .whitespace; } const current_char = source[self.offset]; self.offset += 1; switch (current_char) { '=' => return if (self.accept(anyOf("="))) .@"==" else .@"=", '!' => return if (self.accept(anyOf("="))) .@"!=" else null, '.' => return .@".", ',' => return .@",", ';' => return .@";", '{' => return .@"{", '}' => return .@"}", '(' => return .@"(", ')' => return .@")", ']' => return .@"]", '[' => return .@"[", '+' => return if (self.accept(anyOf("="))) .@"+=" else .@"+", '-' => return if (self.accept(anyOf("="))) .@"-=" else .@"-", '*' => return if (self.accept(anyOf("="))) .@"*=" else .@"*", '/' => { if (self.accept(anyOf("/"))) { while (self.accept(comment_class)) {} return .comment; } else if (self.accept(anyOf("="))) { return .@"/="; } else { return .@"/"; } }, '%' => return if (self.accept(anyOf("="))) .@"%=" else .@"%", '<' => return if (self.accept(anyOf("="))) .@"<=" else .@"<", '>' => return if (self.accept(anyOf("="))) .@">=" else .@">", // parse numbers '0'...'9' => { while (self.accept(digit_class)) {} if (self.accept(anyOf("xX"))) { while (self.accept(hexdigit_class)) {} return .number_literal; } else if (self.accept(anyOf("."))) { while (self.accept(digit_class)) {} return .number_literal; } return .number_literal; }, // parse identifiers 'a'...'z', 'A'...'Z', '_' => { while (self.accept(identifier_class)) {} return .identifier; }, // parse strings '"' => { while (true) { while (self.accept(string_char_class)) {} if (self.accept(anyOf("\""))) { return .string_literal; } else if (self.accept(anyOf("\\"))) { if (self.accept(anyOf("x"))) { // hex literal if (!self.accept(hexdigit_class)) return null; if (!self.accept(hexdigit_class)) return null; } else { if (!self.accept(any)) return null; } } else { return null; } } }, // parse character literals '\'' => { while (true) { while (self.accept(character_char_class)) {} if (self.accept(anyOf("\'"))) { return .character_literal; } else if (self.accept(anyOf("\\"))) { if (self.accept(anyOf("x"))) { // hex literal if (!self.accept(hexdigit_class)) return null; if (!self.accept(hexdigit_class)) return null; } else { if (!self.accept(any)) return null; } } else { return null; } } }, else => return null, } } }; pub fn tokenize(allocator: *std.mem.Allocator, diagnostics: *Diagnostics, chunk_name: []const u8, source: []const u8) ![]Token { var result = std.ArrayList(Token).init(allocator); var tokenizer = Tokenizer.init(chunk_name, source); while (true) { switch (tokenizer.next()) { .end_of_file => return result.toOwnedSlice(), .invalid_sequence => |seq| { try diagnostics.emit(.@"error", tokenizer.current_location, "invalid byte sequence: {X}", .{ seq, }); }, .token => |token| try result.append(token), } } } test "Tokenizer empty string" { var tokenizer = Tokenizer.init("??", ""); std.testing.expectEqual(@TagType(Tokenizer.Result).end_of_file, tokenizer.next()); } test "Tokenizer invalid bytes" { var tokenizer = Tokenizer.init("??", "\\``?`a##§"); { const item = tokenizer.next(); std.testing.expectEqual(@TagType(Tokenizer.Result).invalid_sequence, item); std.testing.expectEqualStrings("\\``?`", item.invalid_sequence); } { const item = tokenizer.next(); std.testing.expectEqual(@TagType(Tokenizer.Result).token, item); std.testing.expectEqualStrings("a", item.token.text); } { const item = tokenizer.next(); std.testing.expectEqual(@TagType(Tokenizer.Result).invalid_sequence, item); std.testing.expectEqualStrings("##§", item.invalid_sequence); } } test "Tokenizer (tokenize compiler test suite)" { var tokenizer = Tokenizer.init("src/test/compiler.lola", @embedFile("../../test/compiler.lola")); while (true) { switch (tokenizer.next()) { .token => { // Use this for manual validation: // std.debug.print("token: {}\n", .{tok}); }, .end_of_file => break, .invalid_sequence => |seq| { std.debug.print("failed to parse test file at `{}`!\n", .{ seq, }); // this test should never reach this state, as the test file // is validated by hand unreachable; }, } } } test "tokenize" { // TODO: Implement meaningful test _ = tokenize; }
src/library/compiler/tokenizer.zig
const std = @import("std"); const c = @import("c.zig"); const types = @import("types.zig"); const Glyph = @import("Glyph.zig"); const Error = @import("error.zig").Error; const intToError = @import("error.zig").intToError; const errorToInt = @import("error.zig").errorToInt; const Outline = @This(); handle: *c.FT_Outline, pub fn init(handle: *c.FT_Outline) Outline { return Outline{ .handle = handle }; } pub fn numPoints(self: Outline) u15 { return @intCast(u15, self.handle.*.n_points); } pub fn numContours(self: Outline) u15 { return @intCast(u15, self.handle.*.n_contours); } pub fn points(self: Outline) []const types.Vector { return @ptrCast([]types.Vector, self.handle.*.points[0..self.numPoints()]); } pub fn tags(self: Outline) []const u8 { return self.handle.tags[0..@intCast(u15, self.handle.n_points)]; } pub fn contours(self: Outline) []const i16 { return self.handle.*.contours[0..self.numContours()]; } pub fn check(self: Outline) Error!void { try intToError(c.FT_Outline_Check(self.handle)); } pub fn transform(self: Outline, matrix: ?types.Matrix) void { var m = matrix orelse std.mem.zeroes(types.Matrix); c.FT_Outline_Transform(self.handle, @ptrCast(*c.FT_Matrix, &m)); } pub fn bbox(self: Outline) Error!types.BBox { var res = std.mem.zeroes(types.BBox); try intToError(c.FT_Outline_Get_BBox(self.handle, @ptrCast(*c.FT_BBox, &res))); return res; } pub fn OutlineFuncs(comptime Context: type) type { return struct { move_to: fn (ctx: Context, to: types.Vector) Error!void, line_to: fn (ctx: Context, to: types.Vector) Error!void, conic_to: fn (ctx: Context, control: types.Vector, to: types.Vector) Error!void, cubic_to: fn (ctx: Context, control_0: types.Vector, control_1: types.Vector, to: types.Vector) Error!void, shift: c_int, delta: isize, }; } pub fn OutlineFuncsWrapper(comptime Context: type) type { return struct { const Self = @This(); ctx: Context, callbacks: OutlineFuncs(Context), fn getSelf(ptr: ?*anyopaque) *Self { return @ptrCast(*Self, @alignCast(@alignOf(Self), ptr)); } fn castVec(vec: [*c]const c.FT_Vector) types.Vector { return @intToPtr(*types.Vector, @ptrToInt(vec)).*; } pub fn move_to(to: [*c]const c.FT_Vector, ctx: ?*anyopaque) callconv(.C) c_int { const self = getSelf(ctx); return if (self.callbacks.move_to(self.ctx, castVec(to))) |_| 0 else |err| errorToInt(err); } pub fn line_to(to: [*c]const c.FT_Vector, ctx: ?*anyopaque) callconv(.C) c_int { const self = getSelf(ctx); return if (self.callbacks.line_to(self.ctx, castVec(to))) |_| 0 else |err| errorToInt(err); } pub fn conic_to( control: [*c]const c.FT_Vector, to: [*c]const c.FT_Vector, ctx: ?*anyopaque, ) callconv(.C) c_int { const self = getSelf(ctx); return if (self.callbacks.conic_to( self.ctx, castVec(control), castVec(to), )) |_| 0 else |err| errorToInt(err); } pub fn cubic_to( control_0: [*c]const c.FT_Vector, control_1: [*c]const c.FT_Vector, to: [*c]const c.FT_Vector, ctx: ?*anyopaque, ) callconv(.C) c_int { const self = getSelf(ctx); return if (self.callbacks.cubic_to( self.ctx, castVec(control_0), castVec(control_1), castVec(to), )) |_| 0 else |err| errorToInt(err); } }; } pub fn decompose(self: Outline, ctx: anytype, callbacks: OutlineFuncs(@TypeOf(ctx))) Error!void { var wrapper = OutlineFuncsWrapper(@TypeOf(ctx)){ .ctx = ctx, .callbacks = callbacks }; try intToError(c.FT_Outline_Decompose( self.handle, &c.FT_Outline_Funcs{ .move_to = @TypeOf(wrapper).move_to, .line_to = @TypeOf(wrapper).line_to, .conic_to = @TypeOf(wrapper).conic_to, .cubic_to = @TypeOf(wrapper).cubic_to, .shift = callbacks.shift, .delta = callbacks.delta, }, &wrapper, )); }
freetype/src/Outline.zig
const std = @import("std"); pub fn atomicFlagTestAndSet(flag: *u1) u1 { return @atomicRmw(u1, flag, .Xchg, 1, .SeqCst); } pub const Semaphore = struct { const Self = @This(); value: std.atomic.Int(i8) = std.atomic.Int(i8).init(0), is_mutated: u1 = 0, pub fn init() void { .value = std.atomic.Int(u8).init(0); .is_mutated = 0; } fn wait(self: *Self) void { while(1 == atomicFlagTestAndSet(&self.is_mutated)) {} while(self.value.get() <= 0) {} const previous_value = self.value.decr(); _ = @atomicRmw(u1, &self.is_mutated, .Xchg, @as(u1, 0), .SeqCst); } pub fn signal(self: *Self) i32 { return self.value.fetchAdd(1); } }; pub fn main() !void { const Context = struct{ const Self = @This(); ping: []const u8 = "ping", pong: []const u8 = "pong", sem: Semaphore = Semaphore{}, fn Ping(self: *Self) void { while (true) { self.sem.wait(); self.critical(self.ping); _ = self.sem.signal(); } } fn Pong(self: *Self) void { while (true) { self.sem.wait(); self.critical(self.pong); _ = self.sem.signal(); } } pub fn critical(self: Self, arg_str: []const u8) void { var str = arg_str; var len: usize = str.len; { var i: usize = 0; for (str) |byte| { const ch = [_]u8{byte}; std.debug.print("{}\n", .{ch}); } } std.debug.print("\n", .{}); } }; var context = Context{}; context.sem.value.set(1); const ping = try std.Thread.spawn(&context, Context.Ping); const pong = try std.Thread.spawn(&context, Context.Pong); ping.wait(); pong.wait(); } var lock_stream: u1 = 0; test "Atomic Test and Set" { var t: u1 = 0; std.debug.print("\ntt was = {}\n", .{t}); var res = atomicFlagTestAndSet(&t); std.debug.print("res is = {}\n", .{res}); std.debug.print("t is now = {}\n", .{t}); res = atomicFlagTestAndSet(&t); std.debug.print("res is now = {}\n", .{res}); const Context = struct{ x: i32 = -1, fn appendNumber(self: *@This()) void { while(1 == atomicFlagTestAndSet(&lock_stream)) {} self.x += 1; std.debug.print("thread {}\n", .{self.x}); lock_stream = 0; } }; var threads = std.ArrayList(*std.Thread).init(std.heap.c_allocator); var thread_index: usize = 0; const thread_count: usize = 11; var context = Context{}; while (thread_index < thread_count) : (thread_index += 1) { try threads.append(try std.Thread.spawn(&context, Context.appendNumber)); } for (threads.items) |thread| { thread.wait(); } threads.deinit(); }
Mutlithreading/semaphore.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const testing = std.testing; const test_suites = @import("test_cases.zig").test_suites; const possibleValues = @import("common.zig").possibleValues; pub fn StringFinder(comptime T: type) type { assert(std.meta.trait.isIndexable(T)); const ElemType = std.meta.Elem(T); assert(@typeInfo(ElemType) == .Int); return struct { allocator: ?*Allocator, pattern: T, bad_char: [possible_values]usize, good_suffix: []usize, const possible_values = possibleValues(ElemType); const Self = @This(); /// An empty pattern, requires no allocations pub const empty = Self{ .allocator = null, .pattern = "", .bad_char = [_]usize{0} ** possible_values, .good_suffix = &[_]usize{}, }; /// Returns the maximum length of suffixes of both strings fn longestCommonSuffix(a: T, b: T) usize { var i: usize = 0; while (i < a.len and i < b.len) : (i += 1) { if (a[(a.len - 1) - i] != b[(b.len - 1) - i]) { break; } } return i; } /// Initializes a StringFinder with a pattern pub fn init(allocator: *Allocator, pattern: T) !Self { if (pattern.len == 0) return Self.empty; var self = Self{ .allocator = allocator, .pattern = pattern, .bad_char = undefined, .good_suffix = try allocator.alloc(usize, pattern.len), }; const last = pattern.len - 1; // Initialize bad character rule table for (self.bad_char) |*x| x.* = pattern.len; for (pattern) |x, i| { if (i == last) break; self.bad_char[x] = last - i; } // Build good suffix rule table var last_prefix = last; // First pass { var i = last + 1; while (i > 0) : (i -= 1) { if (std.mem.startsWith(ElemType, pattern, pattern[i..])) { last_prefix = i; } self.good_suffix[i - 1] = last_prefix + last - (i - 1); } } // Second pass { var i: usize = 0; while (i < last) : (i += 1) { const len_suffix = longestCommonSuffix(pattern, pattern[1 .. i + 1]); if (pattern[i - len_suffix] != pattern[last - len_suffix]) { self.good_suffix[last - len_suffix] = len_suffix + last - i; } } } return self; } /// Frees all memory allocated by this string searcher pub fn deinit(self: *Self) void { if (self.allocator) |allocator| { allocator.free(self.good_suffix); } } /// Returns the index of the first occurence of the pattern in the /// text. Returns null if the pattern wasn't found pub fn next(self: Self, text: T) ?usize { var i: usize = self.pattern.len; while (i <= text.len) { // Try to match starting from the end of the pattern var j: usize = self.pattern.len; while (j > 0 and text[i - 1] == self.pattern[j - 1]) { i -= 1; j -= 1; } // If we matched until the beginning of the pattern, we // have a match if (j == 0) { return i; } // Use the bad character table and the good suffix table // to advance our position i += std.math.max( self.bad_char[text[i - 1]], self.good_suffix[j - 1], ); } return null; } }; } test "boyer moore" { const allocator = testing.allocator; for (test_suites) |suite| { var sf = try StringFinder([]const u8).init(allocator, suite.pattern); defer sf.deinit(); for (suite.cases) |case| { try testing.expectEqual(case.expected, sf.next(case.text)); } } }
src/boyer_moore.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; const BitSet = std.DynamicBitSet; const Str = []const u8; const int = i64; const util = @import("util.zig"); const gpa = util.gpa; const target_min_x = 240; const target_max_x = 292; const target_min_y = -90; const target_max_y = -57; pub fn main() !void { // Maximum initial y velocity is that for which // we barely hit the bottom of the target. // Since speed is symmetric, speed down as we cross // the y axis is equal to speed up when we launched. assert(target_min_y < 0); const max_init_y = -target_min_y - 1; var timer = try std.time.Timer.start(); const part1 = triangle(max_init_y); _ = hitsTarget(9, 3); var part2: int = 0; var y: int = target_min_y; while (y <= max_init_y) : (y += 1) { var x: int = 1; while (x <= target_max_x) : (x += 1) { if (hitsTarget(x, y)) { part2 += 1; } } } const time = timer.read(); print("part1={}, part2={}, time={}\n", .{part1, part2, time}); } fn triangle(i: int) int { return @divExact(i * (i+1), 2); } fn hitsTarget(init_x: int, init_y: int) bool { var dx = init_x; var dy = init_y; var x: int = 0; var y: int = 0; // Take advantage of y being symmetrical // We can fast forward to the point where the ball // falls back down below the y=0 line. if (init_y >= 0) { const steps_to_cross_x_axis = 2 * init_y + 1; if (init_x <= steps_to_cross_x_axis) { dx = 0; x = triangle(init_x); if (x < target_min_x or x > target_max_x) return false; } else { dx = init_x - steps_to_cross_x_axis; x = triangle(init_x) - triangle(dx); if (x > target_max_x) return false; } dy = -init_y - 1; } while (dx > 0) { x += dx; y += dy; dx -= 1; dy -= 1; if (@boolToInt(x > target_max_x) | @boolToInt(y < target_min_y) != 0) { // missed the target, we're under it return false; } if (@boolToInt(x >= target_min_x) & @boolToInt(y <= target_max_y) != 0) { //print("hit! {}, {}\n", .{init_x, init_y}); return true; } } if (x < target_min_x or x > target_max_x) { return false; } while (true) { y += dy; dy -= 1; if (y <= target_max_y) { return y >= target_min_y; } } } // Useful stdlib functions const tokenize = std.mem.tokenize; const split = std.mem.split; const indexOf = std.mem.indexOfScalar; const indexOfAny = std.mem.indexOfAny; const indexOfStr = std.mem.indexOfPosLinear; const lastIndexOf = std.mem.lastIndexOfScalar; const lastIndexOfAny = std.mem.lastIndexOfAny; const lastIndexOfStr = std.mem.lastIndexOfLinear; const trim = std.mem.trim; const sliceMin = std.mem.min; const sliceMax = std.mem.max; const eql = std.mem.eql; const parseEnum = std.meta.stringToEnum; const parseInt = std.fmt.parseInt; const parseFloat = std.fmt.parseFloat; const min = std.math.min; const min3 = std.math.min3; const max = std.math.max; const max3 = std.math.max3; const print = std.debug.print; const assert = std.debug.assert; const sort = std.sort.sort; const asc = std.sort.asc; const desc = std.sort.desc;
src/day17.zig
const std = @import("std"); pub const Version = std.meta.Tuple(&[_]type{ usize, usize }); pub const CompileStep = struct { pub const base_id = .install_dir; const Self = @This(); step: std.build.Step, builder: *std.build.Builder, /// Version of the Java source source_version: Version, /// Version of the target JVM bytecode target_version: Version, /// Name of the jar (name.jar) name: []const u8, /// Bin path output_path: []const u8, /// Classpath classpath: std.ArrayList([]const u8), /// Classes that should be compiled classes: std.ArrayList([]const u8), /// List of classes that should be compiled pub fn init(builder: *std.build.Builder, name_raw: []const u8, version: Version) *Self { const name = builder.dupe(name_raw); const self = builder.allocator.create(Self) catch unreachable; self.* = Self{ .step = std.build.Step.init(base_id, name, builder.allocator, make), .builder = builder, .source_version = version, .target_version = version, .name = name, .output_path = std.fs.path.join(self.builder.allocator, &[_][]const u8{ self.builder.install_prefix, builder.fmt("{s}-bin", .{self.name}) }) catch unreachable, .classpath = std.ArrayList([]const u8).init(builder.allocator), .classes = std.ArrayList([]const u8).init(builder.allocator), }; return self; } pub fn install(self: *Self) void { self.builder.getInstallStep().dependOn(&self.step); } pub fn addClass(self: *Self, path: []const u8) void { self.classes.append(path) catch unreachable; } pub fn jar(self: *Self) *JarStep { return JarStep.init(self.builder, self.name, self.output_path); } fn make(step: *std.build.Step) !void { const self = @fieldParentPtr(CompileStep, "step", step); try self.build(); } fn build(self: *Self) !void { const builder = self.builder; var java_args = std.ArrayList([]const u8).init(builder.allocator); defer java_args.deinit(); try java_args.append("javac"); try java_args.append("-verbose"); try java_args.append("-d"); try java_args.append(self.output_path); try java_args.append("-source"); try java_args.append(builder.fmt("{d}", .{self.source_version[0]})); try java_args.append("-target"); try java_args.append(builder.fmt("{d}", .{self.target_version[0]})); for (self.classes.items) |class| { try java_args.append(class); } const child = std.ChildProcess.init(java_args.items, self.builder.allocator) catch unreachable; defer child.deinit(); child.stderr_behavior = .Pipe; child.env_map = self.builder.env_map; child.spawn() catch |err| { std.log.warn("Unable to spawn {s}: {s}\n", .{ java_args.items[0], @errorName(err) }); return err; }; var progress = std.Progress{}; const root_node = progress.start(self.builder.fmt("{s}", .{self.name}), 0) catch |err| switch (err) { // TODO still run tests in this case error.TimerUnsupported => @panic("timer unsupported"), }; var reader = child.stderr.?.reader(); var buf: [256]u8 = undefined; while (try reader.readUntilDelimiterOrEof(&buf, '\n')) |line| { if (std.mem.startsWith(u8, line, "[")) { var test_node = root_node.start(line, 0); test_node.activate(); progress.refresh(); test_node.end(); // root_node.setEstimatedTotalItems(); // root_node.completeOne(); } else { try std.io.getStdErr().writer().print("{s}\n", .{line}); } } _ = try child.wait(); root_node.end(); } }; pub const JarStep = struct { pub const base_id = .run; const Self = @This(); step: std.build.Step, builder: *std.build.Builder, /// Name of the jar (name.jar) name: []const u8, /// Directory of compiled class files bin_path: []const u8, /// Output path output_path: []const u8, pub fn init(builder: *std.build.Builder, name_raw: []const u8, bin_path_raw: []const u8) *Self { const name = builder.dupe(name_raw); const bin_path = builder.dupe(bin_path_raw); const self = builder.allocator.create(Self) catch unreachable; self.* = Self{ .step = std.build.Step.init(base_id, name, builder.allocator, make), .builder = builder, .name = name, .bin_path = bin_path, .output_path = std.fs.path.join(self.builder.allocator, &[_][]const u8{ self.builder.install_prefix, "jar", builder.fmt("{s}.jar", .{self.name}) }) catch unreachable, }; return self; } fn make(step: *std.build.Step) !void { const self = @fieldParentPtr(JarStep, "step", step); const builder = self.builder; std.fs.cwd().makePath(self.output_path) catch unreachable; var java_args = std.ArrayList([]const u8).init(builder.allocator); defer java_args.deinit(); try java_args.append("jar"); try java_args.append("cf"); try java_args.append(self.output_path); try java_args.append(std.fs.path.join(self.builder.allocator, &[_][]const u8{ self.bin_path, "*" }) catch unreachable); try builder.spawnChild(java_args.items); } };
jbt.zig
const std = @import("std"); const Arena = std.heap.ArenaAllocator; const expectEqual = std.testing.expectEqual; const expectEqualStrings = std.testing.expectEqualStrings; const yeti = @import("yeti"); const initCodebase = yeti.initCodebase; const tokenize = yeti.tokenize; const parse = yeti.parse; const analyzeSemantics = yeti.analyzeSemantics; const codegen = yeti.codegen; const printWasm = yeti.printWasm; const components = yeti.components; const literalOf = yeti.query.literalOf; const typeOf = yeti.query.typeOf; const parentType = yeti.query.parentType; const valueType = yeti.query.valueType; const Entity = yeti.ecs.Entity; const MockFileSystem = yeti.FileSystem; test "analyze semantics of named argument" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); const builtins = codebase.get(components.Builtins); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i64 { \\ id(x=5) \\} \\ \\id(x: i64) i64 { \\ x \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); const top_level = module.get(components.TopLevel); const start = top_level.findString("start").get(components.Overloads).slice()[0]; try expectEqualStrings(literalOf(start.get(components.Module).entity), "foo"); try expectEqualStrings(literalOf(start.get(components.Name).entity), "start"); try expectEqual(start.get(components.Parameters).len(), 0); try expectEqual(start.get(components.ReturnType).entity, builtins.I64); const id = blk: { const body = start.get(components.Body).slice(); try expectEqual(body.len, 1); const call = body[0]; try expectEqual(call.get(components.AstKind), .call); try expectEqual(call.get(components.Arguments).len(), 0); const named_arguments = call.get(components.OrderedNamedArguments).slice(); try expectEqual(named_arguments.len, 1); try expectEqualStrings(literalOf(named_arguments[0]), "5"); try expectEqual(typeOf(call), builtins.I64); break :blk call.get(components.Callable).entity; }; try expectEqualStrings(literalOf(id.get(components.Module).entity), "foo"); try expectEqualStrings(literalOf(id.get(components.Name).entity), "id"); try expectEqual(id.get(components.Parameters).len(), 1); try expectEqual(id.get(components.ReturnType).entity, builtins.I64); const body = id.get(components.Body).slice(); try expectEqual(body.len, 1); const x = body[0]; try expectEqual(x.get(components.AstKind), .local); try expectEqual(typeOf(x), builtins.I64); try expectEqualStrings(literalOf(x), "x"); } test "analyze semantics of positional then named argument" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); const builtins = codebase.get(components.Builtins); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i64 { \\ bar(3, y=5) \\} \\ \\bar(x: i64 y: i64) i64 { \\ x \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); const top_level = module.get(components.TopLevel); const start = top_level.findString("start").get(components.Overloads).slice()[0]; try expectEqualStrings(literalOf(start.get(components.Module).entity), "foo"); try expectEqualStrings(literalOf(start.get(components.Name).entity), "start"); try expectEqual(start.get(components.Parameters).len(), 0); try expectEqual(start.get(components.ReturnType).entity, builtins.I64); const bar = blk: { const body = start.get(components.Body).slice(); try expectEqual(body.len, 1); const call = body[0]; try expectEqual(call.get(components.AstKind), .call); const arguments = call.get(components.Arguments).slice(); try expectEqual(arguments.len, 1); try expectEqualStrings(literalOf(arguments[0]), "3"); const named_arguments = call.get(components.OrderedNamedArguments).slice(); try expectEqual(named_arguments.len, 1); try expectEqualStrings(literalOf(named_arguments[0]), "5"); try expectEqual(typeOf(call), builtins.I64); break :blk call.get(components.Callable).entity; }; try expectEqualStrings(literalOf(bar.get(components.Module).entity), "foo"); try expectEqualStrings(literalOf(bar.get(components.Name).entity), "bar"); try expectEqual(bar.get(components.Parameters).len(), 2); try expectEqual(bar.get(components.ReturnType).entity, builtins.I64); const body = bar.get(components.Body).slice(); try expectEqual(body.len, 1); const x = body[0]; try expectEqual(x.get(components.AstKind), .local); try expectEqual(typeOf(x), builtins.I64); try expectEqualStrings(literalOf(x), "x"); } test "analyze semantics of uniform function call syntax with named argument" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); const builtins = codebase.get(components.Builtins); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i64 { \\ 3.bar(y=5) \\} \\ \\bar(x: i64 y: i64) i64 { \\ x \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); const top_level = module.get(components.TopLevel); const start = top_level.findString("start").get(components.Overloads).slice()[0]; try expectEqualStrings(literalOf(start.get(components.Module).entity), "foo"); try expectEqualStrings(literalOf(start.get(components.Name).entity), "start"); try expectEqual(start.get(components.Parameters).len(), 0); try expectEqual(start.get(components.ReturnType).entity, builtins.I64); const bar = blk: { const body = start.get(components.Body).slice(); try expectEqual(body.len, 1); const call = body[0]; try expectEqual(call.get(components.AstKind), .call); const arguments = call.get(components.Arguments).slice(); try expectEqual(arguments.len, 1); try expectEqualStrings(literalOf(arguments[0]), "3"); const named_arguments = call.get(components.OrderedNamedArguments).slice(); try expectEqual(named_arguments.len, 1); try expectEqualStrings(literalOf(named_arguments[0]), "5"); try expectEqual(typeOf(call), builtins.I64); break :blk call.get(components.Callable).entity; }; try expectEqualStrings(literalOf(bar.get(components.Module).entity), "foo"); try expectEqualStrings(literalOf(bar.get(components.Name).entity), "bar"); try expectEqual(bar.get(components.Parameters).len(), 2); try expectEqual(bar.get(components.ReturnType).entity, builtins.I64); const body = bar.get(components.Body).slice(); try expectEqual(body.len, 1); const x = body[0]; try expectEqual(x.get(components.AstKind), .local); try expectEqual(typeOf(x), builtins.I64); try expectEqualStrings(literalOf(x), "x"); } test "analyze semantics of struct using named arguments" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\struct Rectangle { \\ width: f64 \\ height: f64 \\} \\ \\start() Rectangle { \\ Rectangle(width=10, height=30) \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); const top_level = module.get(components.TopLevel); const start = top_level.findString("start").get(components.Overloads).slice()[0]; try expectEqualStrings(literalOf(start.get(components.Module).entity), "foo"); try expectEqualStrings(literalOf(start.get(components.Name).entity), "start"); try expectEqual(start.get(components.Parameters).len(), 0); const rectangle = start.get(components.ReturnType).entity; try expectEqualStrings(literalOf(rectangle.get(components.Name).entity), "Rectangle"); const body = start.get(components.Body).slice(); try expectEqual(body.len, 1); const construct = body[0]; try expectEqual(construct.get(components.AstKind), .construct); try expectEqual(typeOf(construct), rectangle); try expectEqual(construct.get(components.Arguments).slice().len, 0); const arguments = construct.get(components.OrderedNamedArguments).slice(); try expectEqual(arguments.len, 2); try expectEqualStrings(literalOf(arguments[0]), "10"); try expectEqualStrings(literalOf(arguments[1]), "30"); } test "codegen named arguments" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i32 { \\ id(x=5) \\} \\ \\id(x: i32) i32 { \\ x \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); try codegen(module); const top_level = module.get(components.TopLevel); const start = top_level.findString("start").get(components.Overloads).slice()[0]; const start_instructions = start.get(components.WasmInstructions).slice(); try expectEqual(start_instructions.len, 2); const constant = start_instructions[0]; try expectEqual(constant.get(components.WasmInstructionKind), components.WasmInstructionKind.i32_const); try expectEqualStrings(literalOf(constant.get(components.Constant).entity), "5"); const call = start_instructions[1]; try expectEqual(call.get(components.WasmInstructionKind), .call); const baz = call.get(components.Callable).entity; const baz_instructions = baz.get(components.WasmInstructions).slice(); try expectEqual(baz_instructions.len, 1); } test "print wasm named arguments" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\start() i32 { \\ id(x=5) \\} \\ \\id(x: i32) i32 { \\ x \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); try codegen(module); const wasm = try printWasm(module); try expectEqualStrings(wasm, \\(module \\ \\ (func $foo/start (result i32) \\ (i32.const 5) \\ (call $foo/id..x.i32)) \\ \\ (func $foo/id..x.i32 (param $x i32) (result i32) \\ (local.get $x)) \\ \\ (export "_start" (func $foo/start))) ); } test "codegen struct with named arguments" { var arena = Arena.init(std.heap.page_allocator); defer arena.deinit(); var codebase = try initCodebase(&arena); var fs = try MockFileSystem.init(&arena); _ = try fs.newFile("foo.yeti", \\struct Rectangle { \\ width: f64 \\ height: f64 \\} \\ \\start() { \\ Rectangle(width=5, height=10) \\} ); const module = try analyzeSemantics(codebase, fs, "foo.yeti"); try codegen(module); const top_level = module.get(components.TopLevel); const start = top_level.findString("start").get(components.Overloads).slice()[0]; const start_instructions = start.get(components.WasmInstructions).slice(); try expectEqual(start_instructions.len, 2); { const constant = start_instructions[0]; try expectEqual(constant.get(components.WasmInstructionKind), components.WasmInstructionKind.f64_const); try expectEqualStrings(literalOf(constant.get(components.Constant).entity), "5"); } { const constant = start_instructions[1]; try expectEqual(constant.get(components.WasmInstructionKind), components.WasmInstructionKind.f64_const); try expectEqualStrings(literalOf(constant.get(components.Constant).entity), "10"); } }
src/tests/test_named_arguments.zig
const std = @import("std"); const types = @import("types.zig"); const utils = @import("utils.zig"); var is_inited: bool = false; const cURL = @cImport({ @cInclude("curl/curl.h"); }); fn writeToBoundedArrayCallback(data: *anyopaque, size: c_uint, nmemb: c_uint, user_data: *anyopaque) callconv(.C) c_uint { var buffer = @intToPtr(*std.BoundedArray(u8, 1024*1024), @ptrToInt(user_data)); var typed_data = @intToPtr([*]u8, @ptrToInt(data)); buffer.appendSlice(typed_data[0 .. nmemb * size]) catch return 0; return nmemb * size; } pub fn init() !void { if(is_inited) return error.AlreadyInit; if (cURL.curl_global_init(cURL.CURL_GLOBAL_ALL) != cURL.CURLE_OK) return error.CURLGlobalInitFailed; is_inited = false; } pub fn deinit() void { cURL.curl_global_cleanup(); is_inited = false; } pub const ProcessArgs = struct { ssl_insecure: bool = false, verbose: bool = false, }; /// Primary worker function performing the request and handling the response pub fn processEntry(entry: *types.Entry, args: ProcessArgs, result: *types.EntryResult) !void { if(is_inited) return error.NotInited; ////////////////////////////// // Init / generic setup ////////////////////////////// const handle = cURL.curl_easy_init() orelse return error.CURLHandleInitFailed; defer cURL.curl_easy_cleanup(handle); /////////////////////// // Setup curl options /////////////////////// // Set HTTP method var method = utils.initBoundedArray(u8, 8); try method.appendSlice(entry.method.string()); if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_CUSTOMREQUEST, try utils.boundedArrayAsCstr(method.buffer.len, &method)) != cURL.CURLE_OK) return error.CouldNotSetRequestMethod; // Set URL if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_URL, try utils.boundedArrayAsCstr(entry.url.buffer.len, &entry.url)) != cURL.CURLE_OK) return error.CouldNotSetURL; // Set Payload (if given) if (entry.method == .POST or entry.method == .PUT or entry.payload.slice().len > 0) { if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_POSTFIELDSIZE, entry.payload.slice().len) != cURL.CURLE_OK) return error.CouldNotSetPostDataSize; if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_POSTFIELDS, try utils.boundedArrayAsCstr(entry.payload.buffer.len, &entry.payload)) != cURL.CURLE_OK) return error.CouldNotSetPostData; } // Debug if (args.verbose) { std.debug.print("Payload: {s}\n", .{entry.payload.slice()}); if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_VERBOSE, @intCast(c_long, 1)) != cURL.CURLE_OK) return error.CouldNotSetVerbose; } if (args.ssl_insecure) { if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_SSL_VERIFYPEER, @intCast(c_long, 0)) != cURL.CURLE_OK) return error.CouldNotSetSslVerifyPeer; if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_SSL_VERIFYHOST, @intCast(c_long, 0)) != cURL.CURLE_OK) return error.CouldNotSetSslVerifyHost; } // Pass headers var list: ?*cURL.curl_slist = null; defer cURL.curl_slist_free_all(list); var header_scrap_buf = utils.initBoundedArray(u8, types.HttpHeader.MAX_VALUE_LEN); for (entry.headers.slice()) |*header| { try header_scrap_buf.resize(0); try header.render(header_scrap_buf.buffer.len, &header_scrap_buf); list = cURL.curl_slist_append(list, try utils.boundedArrayAsCstr(header_scrap_buf.buffer.len, &header_scrap_buf)); } if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_HTTPHEADER, list) != cURL.CURLE_OK) return error.CouldNotSetHeaders; ////////////////////// // Execute ////////////////////// try result.response_first_1mb.resize(0); try result.response_headers_first_1mb.resize(0); // set write function callbacks if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_WRITEFUNCTION, writeToBoundedArrayCallback) != cURL.CURLE_OK) return error.CouldNotSetWriteCallback; if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_HEADERDATA, &result.response_headers_first_1mb) != cURL.CURLE_OK) return error.CouldNotSetWriteCallback; if (cURL.curl_easy_setopt(handle, cURL.CURLOPT_WRITEDATA, &result.response_first_1mb) != cURL.CURLE_OK) return error.CouldNotSetWriteCallback; // TODO: This is the critical part to time // Perform // var time_start = std.time.milliTimestamp(); if (cURL.curl_easy_perform(handle) != cURL.CURLE_OK) return error.FailedToPerformRequest; // std.debug.print("inner time: {d}\n", .{std.time.milliTimestamp() - time_start}); //////////////////////// // Handle results //////////////////////// var http_code: u64 = 0; if (cURL.curl_easy_getinfo(handle, cURL.CURLINFO_RESPONSE_CODE, &http_code) != cURL.CURLE_OK) return error.CouldNewGetResponseCode; result.response_http_code = http_code; var content_type_ptr: [*c]u8 = null; if (cURL.curl_easy_getinfo(handle, cURL.CURLINFO_CONTENT_TYPE, &content_type_ptr) != cURL.CURLE_OK) return error.CouldNewGetResponseContentType; // Get Content-Type if (content_type_ptr != null) { var content_type_slice = try std.fmt.bufPrint(&result.response_content_type.buffer, "{s}", .{content_type_ptr}); try result.response_content_type.resize(content_type_slice.len); } } pub fn httpCodeToString(code: u64) []const u8 { return switch (code) { 100 => "Continue", 101 => "Switching protocols", 102 => "Processing", 103 => "Early Hints", 200 => "OK", 201 => "Created", 202 => "Accepted", 203 => "Non-Authoritative Information", 204 => "No Content", 205 => "Reset Content", 206 => "Partial Content", 207 => "Multi-Status", 208 => "Already Reported", 226 => "IM Used", 300 => "Multiple Choices", 301 => "Moved Permanently", 302 => "Found (Previously \"Moved Temporarily\")", 303 => "See Other", 304 => "Not Modified", 305 => "Use Proxy", 306 => "Switch Proxy", 307 => "Temporary Redirect", 308 => "Permanent Redirect", 400 => "Bad Request", 401 => "Unauthorized", 402 => "Payment Required", 403 => "Forbidden", 404 => "Not Found", 405 => "Method Not Allowed", 406 => "Not Acceptable", 407 => "Proxy Authentication Required", 408 => "Request Timeout", 409 => "Conflict", 410 => "Gone", 411 => "Length Required", 412 => "Precondition Failed", 413 => "Payload Too Large", 414 => "URI Too Long", 415 => "Unsupported Media Type", 416 => "Range Not Satisfiable", 417 => "Expectation Failed", 418 => "I'm a Teapot", 421 => "Misdirected Request", 422 => "Unprocessable Entity", 423 => "Locked", 424 => "Failed Dependency", 425 => "Too Early", 426 => "Upgrade Required", 428 => "Precondition Required", 429 => "Too Many Requests", 431 => "Request Header Fields Too Large", 451 => "Unavailable For Legal Reasons", 500 => "Internal Server Error", 501 => "Not Implemented", 502 => "Bad Gateway", 503 => "Service Unavailable", 504 => "Gateway Timeout", 505 => "HTTP Version Not Supported", 506 => "Variant Also Negotiates", 507 => "Insufficient Storage", 508 => "Loop Detected", 510 => "Not Extended", 511 => "Network Authentication Required", else => "", }; }
src/httpclient.zig
const std = @import("std"); const io = std.io; const cursor = @import("cursor.zig"); const Key = union(enum) { // unicode character char: u21, ctrl: u21, alt: u21, fun: u8, // arrow keys up: void, down: void, left: void, right: void, esc: void, delete: void, enter: void, __non_exhaustive: void, pub fn format( value: Key, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype, ) !void { _ = options; if (fmt.len == 1 and fmt[0] == 's') { try writer.writeAll("Key."); switch (value) { .ctrl => |c| try std.fmt.format(writer, "ctrl({u})", .{c}), .alt => |c| try std.fmt.format(writer, "alt({u})", .{c}), .char => |c| try std.fmt.format(writer, "char({u})", .{c}), .fun => |d| try std.fmt.format(writer, "fun({d})", .{d}), // arrow keys .up => try std.fmt.format(writer, "up", .{}), .down => try std.fmt.format(writer, "down", .{}), .left => try std.fmt.format(writer, "left", .{}), .right => try std.fmt.format(writer, "right", .{}), // special keys .esc => try std.fmt.format(writer, "esc", .{}), .enter => try std.fmt.format(writer, "enter", .{}), .delete => try std.fmt.format(writer, "delete", .{}), else => try std.fmt.format(writer, "Not available yet", .{}), } } } }; /// Returns the next event received. /// If raw term is `.blocking` or term is canonical it will block until read at least one event. /// otherwise it will return `.none` if it didnt read any event /// /// `in`: needs to be reader pub fn next(in: anytype) !Event { // TODO: Check buffer size var buf: [20]u8 = undefined; const c = try in.read(&buf); if (c == 0) { return .none; } const view = try std.unicode.Utf8View.init(buf[0..c]); var iter = view.iterator(); var event: Event = .none; // TODO: Find a better way to iterate buffer if (iter.nextCodepoint()) |c0| switch (c0) { '\x1b' => { if (iter.nextCodepoint()) |c1| switch (c1) { // fn (1 - 4) // O - 0x6f - 111 '\x4f' => { return Event{ .key = Key{ .fun = (1 + buf[2] - '\x50') } }; }, // csi '[' => { return try parse_csi(buf[2..c]); }, // alt key else => { return Event{ .key = Key{ .alt = c1 } }; }, } else { return Event{ .key = .esc }; } }, // ctrl keys (avoids ctrl-m) '\x01'...'\x0C', '\x0E'...'\x1A' => return Event{ .key = Key{ .ctrl = c0 + '\x60' } }, // special chars '\x7f' => return Event{ .key = .delete }, '\x0D' => return Event{ .key = .enter }, // chars and shift + chars else => return Event{ .key = Key{ .char = c0 } }, }; return event; } fn parse_csi(buf: []const u8) !Event { switch (buf[0]) { // keys 'A' => return Event{ .key = .up }, 'B' => return Event{ .key = .down }, 'C' => return Event{ .key = .right }, 'D' => return Event{ .key = .left }, '1'...'2' => { switch (buf[1]) { '5' => return Event{ .key = Key{ .fun = 5 } }, '7' => return Event{ .key = Key{ .fun = 6 } }, '8' => return Event{ .key = Key{ .fun = 7 } }, '9' => return Event{ .key = Key{ .fun = 8 } }, '0' => return Event{ .key = Key{ .fun = 9 } }, '1' => return Event{ .key = Key{ .fun = 10 } }, '3' => return Event{ .key = Key{ .fun = 11 } }, '4' => return Event{ .key = Key{ .fun = 12 } }, else => {}, } }, else => {}, } return .not_supported; } pub const Event = union(enum) { key: Key, not_supported, none, }; test "next" { const term = @import("main.zig").term; const stdin = io.getStdIn(); var raw = try term.enableRawMode(stdin.handle, .blocking); defer raw.disableRawMode() catch {}; var i: usize = 0; while (i < 3) : (i += 1) { const key = try next(stdin.reader()); std.debug.print("\n\r{s}\n", .{key}); } }
src/event.zig
const std = @import("std"); const fs = std.fs; const io = std.io; const info = std.log.info; const print = std.debug.print; const fmt = std.fmt; const ArrayList = std.ArrayList; const utils = @import("utils.zig"); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const Op = enum { sum, mul, pub fn apply(self: Op, a: isize, b: isize) isize { return switch (self) { .sum => a + b, .mul => a * b, }; } }; const Token = union(enum) { num: isize, op: Op, lpar, rpar }; const ExprRes = struct { val: isize, ptr: usize, }; fn findMatchingParens(tokens: []Token) usize { var depth: isize = 0; for (tokens) |token, i| { switch (token) { .lpar => depth += 1, .rpar => depth -= 1, else => continue, } if (depth == -1) { return i; } } unreachable; } fn parseTokens(allo: *std.mem.Allocator, line: []const u8) []Token { var output = allo.alloc(Token, 0) catch unreachable; for (line) |char| { const token = switch (char) { ' ' => continue, '(' => .lpar, ')' => .rpar, '+' => Token{ .op = .sum }, '*' => Token{ .op = .mul }, // assume all numbers are single digits (as in examples and input) else => blk: { var chr_as_str: [1]u8 = .{char}; break :blk Token{ .num = std.fmt.parseInt(isize, &chr_as_str, 10) catch unreachable }; }, }; output = allo.realloc(output, output.len + 1) catch unreachable; output[output.len - 1] = token; } return output; } fn calcExpressionP1(tokens: []Token, roll_val: isize, cur_op: ?Op) isize { if (tokens.len == 0) return roll_val; info("tok: {} val: {} curop: {}", .{ tokens[0], roll_val, cur_op }); return switch (tokens[0]) { .lpar => blk: { var val = calcExpressionP1(tokens[1..], 0, null); if (cur_op) |cur_op_val| { val = cur_op_val.apply(roll_val, val); } const closing = findMatchingParens(tokens[1..]); break :blk calcExpressionP1(tokens[closing + 1 + 1 ..], val, null); }, .rpar => return roll_val, .op => |op_op| calcExpressionP1(tokens[1..], roll_val, op_op), .num => |cur_val| if (cur_op) |cur_op_val| calcExpressionP1(tokens[1..], cur_op_val.apply(roll_val, cur_val), null) else calcExpressionP1(tokens[1..], cur_val, null), }; } fn calcExpressionP2(tokens: []Token, roll_val: isize, cur_op: ?Op) isize { if (tokens.len == 0) return roll_val; info("tok: {} val: {} curop: {}", .{ tokens[0], roll_val, cur_op }); return switch (tokens[0]) { .lpar => blk: { var val = calcExpressionP2(tokens[1..], 0, null); if (cur_op) |cur_op_val| { val = cur_op_val.apply(roll_val, val); } const closing = findMatchingParens(tokens[1..]); break :blk calcExpressionP2(tokens[closing + 1 + 1 ..], val, null); }, .rpar => return roll_val, .op => |op_op| switch (op_op) { // NOTE: only change in P2 is this switch .sum => calcExpressionP2(tokens[1..], roll_val, op_op), .mul => op_op.apply(roll_val, calcExpressionP2(tokens[1..], 0, null)), }, .num => |cur_val| if (cur_op) |cur_op_val| calcExpressionP2(tokens[1..], cur_op_val.apply(roll_val, cur_val), null) else calcExpressionP2(tokens[1..], cur_val, null), }; } pub fn main() !void { const begin = @divTrunc(std.time.nanoTimestamp(), 1000); // setup // defer _ = gpa.deinit(); var allo = &gpa.allocator; var lines: std.mem.TokenIterator = try utils.readInputLines(allo, "./input1"); defer allo.free(lines.buffer); var sum_p1: isize = 0; var sum_p2: isize = 0; while (lines.next()) |line| { info("doing expression: {}", .{line}); var tokens = parseTokens(allo, line); defer allo.free(tokens); const res_p1 = calcExpressionP1(tokens, 0, .sum); info("res p1: {}", .{res_p1}); sum_p1 += res_p1; const res_p2 = calcExpressionP2(tokens, 0, .sum); info("res p2: {}", .{res_p2}); sum_p2 += res_p2; } print("p1: {}\n", .{sum_p1}); print("p2: {}\n", .{sum_p2}); // end const delta = @divTrunc(std.time.nanoTimestamp(), 1000) - begin; print("all done in {} microseconds\n", .{delta}); }
day_18/src/main.zig